mirror of https://github.com/lizongying/my-tv.git
parent
42b072f5ec
commit
1fd0951f92
@ -0,0 +1,44 @@ |
||||
package com.lizongying.mytv |
||||
|
||||
import android.os.Bundle |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import androidx.fragment.app.DialogFragment |
||||
import com.lizongying.mytv.databinding.DialogBinding |
||||
|
||||
|
||||
class MyDialogFragment(private val versionName: String, private val channelReversal: Boolean) : |
||||
DialogFragment() { |
||||
|
||||
private var _binding: DialogBinding? = null |
||||
private val binding get() = _binding!! |
||||
|
||||
override fun onCreateView( |
||||
inflater: LayoutInflater, |
||||
container: ViewGroup?, |
||||
savedInstanceState: Bundle? |
||||
): View { |
||||
_binding = DialogBinding.inflate(inflater, container, false) |
||||
_binding?.version?.text = |
||||
"当前版本: $versionName\n获取最新: https://github.com/lizongying/my-tv/releases/" |
||||
|
||||
val switchView = _binding?.switchView |
||||
switchView?.isChecked = channelReversal |
||||
switchView?.setOnCheckedChangeListener { _, isChecked -> |
||||
(activity as MainActivity).saveChannelReversal(isChecked) |
||||
} |
||||
|
||||
return binding.root |
||||
} |
||||
|
||||
override fun onDestroyView() { |
||||
super.onDestroyView() |
||||
_binding = null |
||||
} |
||||
|
||||
companion object { |
||||
const val TAG = "MyDialogFragment" |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,44 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:id="@+id/dialog" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
> |
||||
<LinearLayout |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content"> |
||||
<LinearLayout |
||||
android:layout_width="300dp" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical" |
||||
android:paddingTop="20dp" |
||||
android:paddingLeft="7dp" |
||||
android:paddingRight="7dp" |
||||
android:background="#FF263238" |
||||
> |
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:text="@string/app_name" |
||||
android:textSize="16sp" /> |
||||
<TextView |
||||
android:id="@+id/version" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="10dp" |
||||
android:layout_marginBottom="10dp" |
||||
android:text="当前版本: $versionName\n获取最新: https://github.com/lizongying/my-tv/releases/" |
||||
></TextView> |
||||
<Switch |
||||
android:id="@+id/switch_view" |
||||
android:text="@string/title_channel_reversal" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" /> |
||||
</LinearLayout> |
||||
<ImageView |
||||
android:layout_width="300dp" |
||||
android:layout_height="wrap_content" |
||||
android:src="@drawable/appreciate" |
||||
android:background="@color/white" /> |
||||
</LinearLayout> |
||||
</FrameLayout> |
||||
@ -1,4 +1,4 @@ |
||||
<resources> |
||||
<string name="app_name">我的电视</string> |
||||
<string name="logo">logo</string> |
||||
<string name="title_channel_reversal">频道反转</string> |
||||
</resources> |
||||
Loading…
Reference in new issue