Parcourir la source

修改几个界面隐藏导航栏

weizhengliang il y a 2 ans
Parent
commit
fd724ef645

+ 2 - 0
home/src/main/AndroidManifest.xml

@@ -40,6 +40,8 @@
         <activity android:screenOrientation="portrait" android:name=".activity.TakeoverActivity" />
         <activity android:screenOrientation="portrait" android:name=".activity.AppUpdateActivity" />
         <activity android:screenOrientation="portrait" android:name=".activity.NewEventListActivity"
+            android:showOnLockScreen="true"
+            android:showWhenLocked="true"
             android:launchMode="singleTask"/>
         <activity android:name=".activity.VoiceMsgActivity" android:screenOrientation="portrait"/>
         <activity android:name=".activity.ChannelImActivity" android:screenOrientation="portrait"/>

+ 17 - 2
home/src/main/code/com/wdkl/ncs/android/component/home/activity/BaseActivity.kt

@@ -1,9 +1,14 @@
 package com.wdkl.ncs.android.component.home.activity
 
+import android.annotation.TargetApi
+import android.app.Activity
 import android.content.Context
 import android.content.Intent
+import android.graphics.Color
+import android.os.Build
 import android.os.Bundle
 import android.view.View
+import android.view.WindowManager
 import android.view.inputmethod.InputMethodManager
 import androidx.databinding.DataBindingUtil
 import androidx.databinding.ViewDataBinding
@@ -62,6 +67,11 @@ abstract class BaseActivity<PresenterType : BaseContract.BasePresenter, DataBind
      */
     protected val disposableManager by lazy { DisposableManager() }
 
+    protected val screen_flags = (
+            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+                    or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                    or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
+
     /**
      * @author  LDD
      * @From   com.wdkl.ncs.android.component.home.activity.BaseActivity
@@ -76,6 +86,9 @@ abstract class BaseActivity<PresenterType : BaseContract.BasePresenter, DataBind
         }
         /**父类初始化*/
         super.onCreate(savedInstanceState)
+
+        window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
+
         /**执行生命周期监听*/
         lifeCycleDo(LIFE_CYCLE_CREATE)
         /**创建根视图*/
@@ -154,8 +167,10 @@ abstract class BaseActivity<PresenterType : BaseContract.BasePresenter, DataBind
         lifeCycleDo(LIFE_CYCLE_DESTORY)
         /**清除声明周期监听引用*/
         removeAllCallBack()
-        /**处理android4.4.2 底层内存泄漏*/
-        fixInputMethodManagerLeak(activity)
+        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
+            /**处理android4.4.2 底层内存泄漏*/
+            fixInputMethodManagerLeak(activity)
+        }
         errorLog("PageDestory","页面销毁======>$localClassName")
     }
 

+ 13 - 2
home/src/main/code/com/wdkl/ncs/android/component/home/activity/NewEventListActivity.kt

@@ -17,6 +17,7 @@ import com.wdkl.ncs.android.component.home.util.ImPlayDialogHelper
 import com.wdkl.ncs.android.component.home.util.MediaPlayHelper
 import com.wdkl.ncs.android.component.home.util.RingPlayHelper
 import com.wdkl.ncs.android.component.home.util.SpeechUtil
+import com.wdkl.ncs.android.lib.base.LIFE_CYCLE_RESUME
 import com.wdkl.ncs.android.middleware.common.Constants
 import com.wdkl.ncs.android.lib.utils.AppTool
 import com.wdkl.ncs.android.lib.utils.showMessage
@@ -75,12 +76,22 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
         rv_event_list.adapter = delegateAdapter
     }
 
+    override fun onWindowFocusChanged(hasFocus: Boolean) {
+        super.onWindowFocusChanged(hasFocus)
+        if (!Constants.oldEvent) {
+            window.decorView.systemUiVisibility = screen_flags
+        }
+    }
+
     override fun bindEvent() {
 
     }
 
     override fun onResume() {
         super.onResume()
+        if (!Constants.oldEvent) {
+            window.decorView.systemUiVisibility = screen_flags
+        }
         WdKeepAliveService.mNewEventListActive = true
         renderData(Constants.eventList)
         if (!MediaPlayHelper.getInstance().isMediaPlaying) {
@@ -107,7 +118,7 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
     override fun renderData(data: ArrayList<InteractionVO>) {
         Log.e(TAG,"返回的数据 "+data.size)
         //data.sortByDescending { it.id }
-        srl_event_list.finishRefresh()
+        //srl_event_list.finishRefresh()
         if (data.size > 0) {
             adapter.data.clear()
             adapter.data.addAll(data)
@@ -165,7 +176,7 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
                 if (resTcpModel.data != null) {
                     dismissDialog()
                     if (mVibrator!=null) mVibrator.cancel()
-                    val responseInteractionVO = Gson().fromJson<InteractionVO>(resTcpModel.data.toString(), InteractionVO::class.java)
+                    val responseInteractionVO = Gson().fromJson(resTcpModel.data.toString(), InteractionVO::class.java)
                     showMessage("已响应"+responseInteractionVO.fromFrameFullName + " " + responseInteractionVO.data)
 
                     var doFinish = false

+ 1 - 1
home/src/main/code/com/wdkl/ncs/android/component/home/activity/VoiceMsgActivity.kt

@@ -68,7 +68,7 @@ class VoiceMsgActivity:BaseActivity<VoiceMsgPresenter,ActivityVoiceMsgBinding>()
         // 获取WakeLock对象
         val powerManager= getSystemService(Context.POWER_SERVICE) as PowerManager
         wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP or PowerManager.SCREEN_DIM_WAKE_LOCK, "voice_msg_on")
-}
+    }
 
     override fun enableHeadsetVoiceMsg(): Boolean {
         return false

+ 7 - 6
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchHome2Activity.kt

@@ -105,20 +105,19 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
         HomeLaunch.component.inject(this)
     }
 
+    override fun onWindowFocusChanged(hasFocus: Boolean) {
+        super.onWindowFocusChanged(hasFocus)
+        window.decorView.systemUiVisibility = screen_flags
+    }
+
     //初始化
     override fun init() {
-//        DaemonEnv.sendStopWorkBroadcast(this)
         AnrFcExceptionUtil.getInstance(application).initFCException()
         //注册广播
         regReceiver()
 
         tv_register_version.text = "v" + CommonUtils.getAppVersionName(activity)
 
-        //TTS初始化
-//        SpeechUtil.getInstance().init(BaseApplication.appContext)
-//        SpeechUtil.getInstance().startSpeechThread()
-        //DaemonEnv.initContext(this);
-
         initCountDownTimer()
 
         //网络强度监听
@@ -680,6 +679,8 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
 
     override fun onResume() {
         super.onResume()
+        window.decorView.systemUiVisibility = screen_flags
+
         //主界面恢复时检查tcp连接状态
         Log.d(TAG, "Watch home activity resumed...")
         if (TcpClientHandler.getConnected()) {

+ 3 - 2
home/src/main/res/layout/activity_event_list.xml

@@ -3,6 +3,7 @@
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
         android:background="#FFBDC3">
         <TextView
             android:id="@+id/tv_empty_event"
@@ -20,8 +21,8 @@
             android:layout_height="match_parent"
             android:layout_marginLeft="3sp"
             android:layout_marginRight="3sp"
-            bind:srlEnableLoadMore="true"
-            bind:srlEnableRefresh="true">
+            bind:srlEnableLoadMore="false"
+            bind:srlEnableRefresh="false">
             <androidx.recyclerview.widget.RecyclerView
                 android:id="@+id/rv_event_list"
                 android:layout_width="match_parent"