瀏覽代碼

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

weizhengliang 2 年之前
父節點
當前提交
df33c8bb01

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

@@ -42,6 +42,8 @@
         <activity android:screenOrientation="portrait" android:name=".activity.AppUpdateActivity" />
         <activity android:screenOrientation="portrait" android:name=".activity.AppUpdateActivity" />
         <activity android:screenOrientation="portrait" android:name=".activity.NetworkCheckActivity" />
         <activity android:screenOrientation="portrait" android:name=".activity.NetworkCheckActivity" />
         <activity android:screenOrientation="portrait" android:name=".activity.NewEventListActivity"
         <activity android:screenOrientation="portrait" android:name=".activity.NewEventListActivity"
+            android:showOnLockScreen="true"
+            android:showWhenLocked="true"
             android:launchMode="singleTask"/>
             android:launchMode="singleTask"/>
         <activity android:name=".activity.VoiceMsgActivity" android:screenOrientation="portrait"/>
         <activity android:name=".activity.VoiceMsgActivity" android:screenOrientation="portrait"/>
         <activity android:name=".activity.ChannelImActivity" 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.os.Message
 import android.view.KeyEvent
 import android.view.KeyEvent
 import android.view.View
 import android.view.View
+import android.view.WindowManager
 import android.view.inputmethod.InputMethodManager
 import android.view.inputmethod.InputMethodManager
 import com.enation.javashop.android.jrouter.JRouter
 import com.enation.javashop.android.jrouter.JRouter
 import com.enation.javashop.utils.base.tool.BaseToolActivity
 import com.enation.javashop.utils.base.tool.BaseToolActivity
@@ -73,6 +74,11 @@ abstract class BaseActivity<PresenterType : BaseContract.BasePresenter, DataBind
      */
      */
     protected val disposableManager by lazy { DisposableManager() }
     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
      * @author  LDD
      * @From   com.wdkl.ncs.android.component.home.activity.BaseActivity
      * @From   com.wdkl.ncs.android.component.home.activity.BaseActivity
@@ -91,6 +97,9 @@ abstract class BaseActivity<PresenterType : BaseContract.BasePresenter, DataBind
         }
         }
         /**父类初始化*/
         /**父类初始化*/
         super.onCreate(savedInstanceState)
         super.onCreate(savedInstanceState)
+
+        window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
+
         /**执行生命周期监听*/
         /**执行生命周期监听*/
         lifeCycleDo(LIFE_CYCLE_CREATE)
         lifeCycleDo(LIFE_CYCLE_CREATE)
         /**创建根视图*/
         /**创建根视图*/

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

@@ -81,6 +81,13 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
         rv_event_list.adapter = delegateAdapter
         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 bindEvent() {
         adapter.setOnItemClickListener { data, position ->
         adapter.setOnItemClickListener { data, position ->
             if (Constants.assignRole) {
             if (Constants.assignRole) {
@@ -102,6 +109,9 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
 
 
     override fun onResume() {
     override fun onResume() {
         super.onResume()
         super.onResume()
+        if (!Constants.oldEvent) {
+            window.decorView.systemUiVisibility = screen_flags
+        }
         WdKeepAliveService.mNewEventListActive = true
         WdKeepAliveService.mNewEventListActive = true
         renderData(Constants.eventList)
         renderData(Constants.eventList)
         if (!MediaPlayHelper.getInstance().isMediaPlaying) {
         if (!MediaPlayHelper.getInstance().isMediaPlaying) {
@@ -127,7 +137,7 @@ class NewEventListActivity : BaseActivity<NewEventListPresenter, ActivityEventLi
     override fun renderData(data: ArrayList<InteractionVO>) {
     override fun renderData(data: ArrayList<InteractionVO>) {
         Log.e(TAG,"返回的数据 "+data.size)
         Log.e(TAG,"返回的数据 "+data.size)
         //data.sortByDescending { it.id }
         //data.sortByDescending { it.id }
-        srl_event_list.finishRefresh()
+        //srl_event_list.finishRefresh()
         if (data.size > 0) {
         if (data.size > 0) {
             adapter.data.clear()
             adapter.data.clear()
             adapter.data.addAll(data)
             adapter.data.addAll(data)

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

@@ -100,6 +100,11 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
         HomeLaunch.component.inject(this)
         HomeLaunch.component.inject(this)
     }
     }
 
 
+    override fun onWindowFocusChanged(hasFocus: Boolean) {
+        super.onWindowFocusChanged(hasFocus)
+        window.decorView.systemUiVisibility = screen_flags
+    }
+
     //初始化
     //初始化
     override fun init() {
     override fun init() {
 //        DaemonEnv.sendStopWorkBroadcast(this)
 //        DaemonEnv.sendStopWorkBroadcast(this)
@@ -663,6 +668,8 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
 
 
     override fun onResume() {
     override fun onResume() {
         super.onResume()
         super.onResume()
+        window.decorView.systemUiVisibility = screen_flags
+
         //主界面恢复时检查tcp连接状态
         //主界面恢复时检查tcp连接状态
         Log.d(TAG, "Watch home activity resumed...")
         Log.d(TAG, "Watch home activity resumed...")
         if (TcpClientHandler.getConnected()) {
         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"
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
         android:background="#FFBDC3">
         android:background="#FFBDC3">
         <TextView
         <TextView
             android:id="@+id/tv_empty_event"
             android:id="@+id/tv_empty_event"
@@ -20,8 +21,8 @@
             android:layout_height="match_parent"
             android:layout_height="match_parent"
             android:layout_marginLeft="3sp"
             android:layout_marginLeft="3sp"
             android:layout_marginRight="3sp"
             android:layout_marginRight="3sp"
-            bind:srlEnableLoadMore="true"
-            bind:srlEnableRefresh="true">
+            bind:srlEnableLoadMore="false"
+            bind:srlEnableRefresh="false">
             <android.support.v7.widget.RecyclerView
             <android.support.v7.widget.RecyclerView
                 android:id="@+id/rv_event_list"
                 android:id="@+id/rv_event_list"
                 android:layout_width="match_parent"
                 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"
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true">
 
 
         <include
         <include
             android:id="@+id/watch_activity_register_layout"
             android:id="@+id/watch_activity_register_layout"