Просмотр исходного кода

主界面和事件界面隐藏虚拟导航栏

weizhengliang 2 лет назад
Родитель
Сommit
78a5abb789

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

@@ -56,6 +56,8 @@
 <!--        <activity android:name="com.wdkl.ncs.android.component.home.activity.WatchRegisterActivity">-->
 <!--        <activity android:name="com.starrtc.demo.demo.SplashActivity">-->
         <activity android:name="com.wdkl.ncs.android.component.home.activity.WatchHome2Activity"
+            android:showOnLockScreen="true"
+            android:showWhenLocked="true"
             android:launchMode="singleInstance"
             android:screenOrientation="portrait">
             <intent-filter>

+ 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"/>

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

@@ -10,6 +10,7 @@ import android.os.Looper
 import android.os.Message
 import android.view.KeyEvent
 import android.view.View
+import android.view.WindowManager
 import android.view.inputmethod.InputMethodManager
 import com.enation.javashop.android.jrouter.JRouter
 import com.enation.javashop.utils.base.tool.BaseToolActivity
@@ -71,6 +72,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
@@ -85,6 +91,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)
         /**创建根视图*/

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

@@ -74,12 +74,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) {
@@ -106,7 +116,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)

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

@@ -105,6 +105,11 @@ 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)
@@ -679,6 +684,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">
             <android.support.v7.widget.RecyclerView
                 android:id="@+id/rv_event_list"
                 android:layout_width="match_parent"

+ 2 - 1
home/src/main/res/layout/watch_activity_home2.xml

@@ -3,7 +3,8 @@
 
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true">
 
         <include
             android:id="@+id/watch_activity_register_layout"