Skip to content

Commit

Permalink
fix crash when exit to desk
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Apr 16, 2024
1 parent 81a5407 commit 10a71eb
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@

## 更新日志

### v1.0.8

* 点击节目列表/菜单以外区域,自动隐藏节目列表/菜单
* 解决部分情况下崩溃问题

### v1.0.7

* 支持rtsp直播
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/lizongying/mytv0/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ class MainActivity : FragmentActivity() {
}

private val hideMenu = Runnable {
if (!menuFragment.isHidden) {
supportFragmentManager.beginTransaction().hide(menuFragment).commit()
if (!isFinishing && !supportFragmentManager.isStateSaved) {
if (!menuFragment.isHidden) {
supportFragmentManager.beginTransaction().hide(menuFragment).commit()
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/lizongying/mytv0/MenuFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,19 @@ class MenuFragment : Fragment(), GroupAdapter.ItemListener, ListAdapter.ItemList
}
}

binding.menu.setOnClickListener {
hideSelf()
}

return binding.root
}

private fun hideSelf() {
requireActivity().supportFragmentManager.beginTransaction()
.hide(this)
.commit()
}

override fun onItemFocusChange(tvListModel: TVListModel, hasFocus: Boolean) {
if (hasFocus) {
(binding.list.adapter as ListAdapter).update(tvListModel)
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/lizongying/mytv0/SettingFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class SettingFragment : Fragment() {
(activity as MainActivity).settingActive()
}

binding.setting.setOnClickListener {
hideSelf()
}

return binding.root
}

Expand All @@ -100,6 +104,12 @@ class SettingFragment : Fragment() {
binding.versionName.text = versionName
}

private fun hideSelf() {
requireActivity().supportFragmentManager.beginTransaction()
.hide(this)
.commit()
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/layout/menu.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/menu_fragment"
android:id="@+id/menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@android:color/transparent"
android:clickable="true"
android:focusable="false"
>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/group"
Expand All @@ -17,8 +20,8 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list"
android:layout_width="300dp"
android:layout_height="match_parent"
>
android:layout_height="wrap_content"
>
</androidx.recyclerview.widget.RecyclerView>

</LinearLayout>
8 changes: 6 additions & 2 deletions app/src/main/res/layout/setting.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/setting"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:gravity="end"
android:background="@android:color/transparent"
android:clickable="true"
android:focusable="false"
>

<LinearLayout
android:layout_width="300dp"
android:layout_height="match_parent"
Expand Down

0 comments on commit 10a71eb

Please sign in to comment.