添加首页style和temp的dialog
This commit is contained in:
parent
658640c875
commit
008fe8d2e5
@ -6,9 +6,11 @@ import android.view.ViewGroup
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.tools.device.devcheck.databinding.ItemCommonTempBinding
|
import com.tools.device.devcheck.databinding.ItemCommonTempBinding
|
||||||
import com.tools.device.devcheck.databinding.ItemListBinding
|
import com.tools.device.devcheck.databinding.ItemListBinding
|
||||||
|
import com.tools.device.devcheck.dialog.TempDialogFragment
|
||||||
|
|
||||||
class TempAdapter: RecyclerView.Adapter<TempAdapter.ListViewHolder>() {
|
class TempAdapter: RecyclerView.Adapter<TempAdapter.ListViewHolder>() {
|
||||||
private lateinit var context: Context
|
private lateinit var context: Context
|
||||||
|
private lateinit var listener: OnTempClickListener
|
||||||
override fun onCreateViewHolder(
|
override fun onCreateViewHolder(
|
||||||
parent: ViewGroup,
|
parent: ViewGroup,
|
||||||
viewType: Int
|
viewType: Int
|
||||||
@ -22,12 +24,20 @@ class TempAdapter: RecyclerView.Adapter<TempAdapter.ListViewHolder>() {
|
|||||||
holder: ListViewHolder,
|
holder: ListViewHolder,
|
||||||
position: Int
|
position: Int
|
||||||
) {
|
) {
|
||||||
|
holder.binding.view.setOnClickListener {
|
||||||
|
listener.onTempClick(position)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return 3
|
return 3
|
||||||
}
|
}
|
||||||
|
fun setListener(listener: OnTempClickListener){
|
||||||
|
this.listener = listener
|
||||||
|
}
|
||||||
|
|
||||||
class ListViewHolder(val binding: ItemCommonTempBinding): RecyclerView.ViewHolder(binding.root)
|
class ListViewHolder(val binding: ItemCommonTempBinding): RecyclerView.ViewHolder(binding.root)
|
||||||
}
|
}
|
||||||
|
interface OnTempClickListener {
|
||||||
|
fun onTempClick(position: Int)
|
||||||
|
}
|
||||||
@ -22,5 +22,6 @@ class BlueToothActivity : AppCompatActivity() {
|
|||||||
binding.recyclerView.adapter= ListAdapter()
|
binding.recyclerView.adapter= ListAdapter()
|
||||||
binding.recyclerView.layoutManager= LinearLayoutManager(this)
|
binding.recyclerView.layoutManager= LinearLayoutManager(this)
|
||||||
binding.titleText.text=intent.getStringExtra(TITLE_KEY)
|
binding.titleText.text=intent.getStringExtra(TITLE_KEY)
|
||||||
|
binding.backBtn.setOnClickListener { finish() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,11 +8,13 @@ import androidx.core.view.ViewCompat
|
|||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.tools.device.devcheck.R
|
import com.tools.device.devcheck.R
|
||||||
|
import com.tools.device.devcheck.adapter.OnTempClickListener
|
||||||
import com.tools.device.devcheck.adapter.TempAdapter
|
import com.tools.device.devcheck.adapter.TempAdapter
|
||||||
import com.tools.device.devcheck.databinding.ActivityTemperatureBinding
|
import com.tools.device.devcheck.databinding.ActivityTemperatureBinding
|
||||||
import com.tools.device.devcheck.dialog.CustomPopView
|
import com.tools.device.devcheck.dialog.CustomPopView
|
||||||
|
import com.tools.device.devcheck.dialog.TempDialogFragment
|
||||||
|
|
||||||
class TemperatureActivity : AppCompatActivity() {
|
class TemperatureActivity : AppCompatActivity(),OnTempClickListener {
|
||||||
private lateinit var binding: ActivityTemperatureBinding
|
private lateinit var binding: ActivityTemperatureBinding
|
||||||
private lateinit var customPopView: CustomPopView
|
private lateinit var customPopView: CustomPopView
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -22,7 +24,9 @@ class TemperatureActivity : AppCompatActivity() {
|
|||||||
binding.imageBack.setOnClickListener {
|
binding.imageBack.setOnClickListener {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
binding.rvTemperature.adapter = TempAdapter()
|
val tempAdapter = TempAdapter()
|
||||||
|
tempAdapter.setListener(this)
|
||||||
|
binding.rvTemperature.adapter = tempAdapter
|
||||||
binding.rvTemperature.layoutManager =LinearLayoutManager(this)
|
binding.rvTemperature.layoutManager =LinearLayoutManager(this)
|
||||||
customPopView =CustomPopView(this,3,callback = {text->
|
customPopView =CustomPopView(this,3,callback = {text->
|
||||||
|
|
||||||
@ -31,4 +35,9 @@ class TemperatureActivity : AppCompatActivity() {
|
|||||||
customPopView.show(binding.imageTool)
|
customPopView.show(binding.imageTool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onTempClick(position: Int) {
|
||||||
|
val tempDialog = TempDialogFragment()
|
||||||
|
tempDialog.show(supportFragmentManager, "tempDialog")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -11,7 +11,7 @@ import com.tools.device.devcheck.R
|
|||||||
import com.tools.device.devcheck.databinding.PopupLayoutBinding
|
import com.tools.device.devcheck.databinding.PopupLayoutBinding
|
||||||
import androidx.core.graphics.drawable.toDrawable
|
import androidx.core.graphics.drawable.toDrawable
|
||||||
|
|
||||||
class CustomPopView(context: Context,type: Int,private val callback: (String) -> Unit) {
|
class CustomPopView(context: Context, type: Int, private val callback: (String) -> Unit) {
|
||||||
private val context: Context = context
|
private val context: Context = context
|
||||||
private val type: Int = type
|
private val type: Int = type
|
||||||
private lateinit var popupWindow: PopupWindow
|
private lateinit var popupWindow: PopupWindow
|
||||||
@ -40,14 +40,28 @@ class CustomPopView(context: Context,type: Int,private val callback: (String) ->
|
|||||||
popupWindow.animationStyle = R.style.PopupAnimation
|
popupWindow.animationStyle = R.style.PopupAnimation
|
||||||
|
|
||||||
setType()
|
setType()
|
||||||
|
binding.llMore1.setOnClickListener {
|
||||||
|
if (binding.textMore1.text.toString() == context.getString(R.string.metric_units)) {
|
||||||
|
binding.textMore1.text = context.getString(R.string.imper_units)
|
||||||
|
} else {
|
||||||
|
binding.textMore1.text = context.getString(R.string.metric_units)
|
||||||
}
|
}
|
||||||
|
dismiss()
|
||||||
private fun setType() {//0:簇1或簇2 1:隐藏深度休眠 2:主页更多 3:公制单位和重置 4:公制单位
|
}
|
||||||
when (type) {
|
binding.popSleep.setOnClickListener {
|
||||||
0 -> {
|
dismiss()
|
||||||
binding.popCluster.visibility = View.VISIBLE
|
callback.invoke(binding.textSleep.text.toString())
|
||||||
binding.popSleep.visibility = View.GONE
|
if (binding.textSleep.text.toString() == context.getString(R.string.hide_deep_sleep)) {
|
||||||
binding.popMore.visibility = View.GONE
|
binding.textSleep.text = context.getString(R.string.show_deep_sleep)
|
||||||
|
} else {
|
||||||
|
binding.textSleep.text = context.getString(R.string.hide_deep_sleep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.textMore2.setOnClickListener {}
|
||||||
|
binding.textMore3.setOnClickListener {}
|
||||||
|
binding.textMore4.setOnClickListener {}
|
||||||
|
binding.textMore5.setOnClickListener {}
|
||||||
|
binding.textMore6.setOnClickListener {}
|
||||||
binding.text1.setOnClickListener {
|
binding.text1.setOnClickListener {
|
||||||
dismiss()
|
dismiss()
|
||||||
callback.invoke(binding.text1.text.toString())
|
callback.invoke(binding.text1.text.toString())
|
||||||
@ -57,33 +71,36 @@ class CustomPopView(context: Context,type: Int,private val callback: (String) ->
|
|||||||
callback.invoke(binding.text2.text.toString())
|
callback.invoke(binding.text2.text.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setType() {//0:簇1或簇2 1:隐藏深度休眠 2:主页更多 3:公制单位和重置 4:公制单位
|
||||||
|
when (type) {
|
||||||
|
0 -> {
|
||||||
|
binding.popCluster.visibility = View.VISIBLE
|
||||||
|
binding.popSleep.visibility = View.GONE
|
||||||
|
binding.popMore.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
1 -> {
|
1 -> {
|
||||||
binding.popCluster.visibility = View.GONE
|
binding.popCluster.visibility = View.GONE
|
||||||
binding.popSleep.visibility = View.VISIBLE
|
binding.popSleep.visibility = View.VISIBLE
|
||||||
binding.popMore.visibility = View.GONE
|
binding.popMore.visibility = View.GONE
|
||||||
binding.textSleep.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
callback.invoke(binding.textSleep.text.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
2 -> {
|
2 -> {
|
||||||
binding.popCluster.visibility = View.GONE
|
binding.popCluster.visibility = View.GONE
|
||||||
binding.popSleep.visibility = View.GONE
|
binding.popSleep.visibility = View.GONE
|
||||||
binding.popMore.visibility = View.VISIBLE
|
binding.popMore.visibility = View.VISIBLE
|
||||||
binding.textMore1.setOnClickListener {}
|
|
||||||
binding.textMore2.setOnClickListener {}
|
|
||||||
binding.textMore3.setOnClickListener {}
|
|
||||||
binding.textMore4.setOnClickListener {}
|
|
||||||
binding.textMore5.setOnClickListener {}
|
|
||||||
binding.textMore6.setOnClickListener {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
3 -> {
|
3 -> {
|
||||||
binding.popCluster.visibility = View.GONE
|
binding.popCluster.visibility = View.GONE
|
||||||
binding.popSleep.visibility = View.GONE
|
binding.popSleep.visibility = View.GONE
|
||||||
binding.popMore.visibility = View.VISIBLE
|
binding.popMore.visibility = View.VISIBLE
|
||||||
binding.llHide.visibility = View.GONE
|
binding.llHide.visibility = View.GONE
|
||||||
}
|
}
|
||||||
4->{
|
|
||||||
|
4 -> {
|
||||||
binding.popCluster.visibility = View.GONE
|
binding.popCluster.visibility = View.GONE
|
||||||
binding.popSleep.visibility = View.GONE
|
binding.popSleep.visibility = View.GONE
|
||||||
binding.popMore.visibility = View.VISIBLE
|
binding.popMore.visibility = View.VISIBLE
|
||||||
|
|||||||
@ -36,6 +36,15 @@ class TempDialogFragment : DialogFragment() {
|
|||||||
onPositiveClick()
|
onPositiveClick()
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
baseBinding.imgTemp1.isSelected = true
|
||||||
|
baseBinding.imgTemp1.setOnClickListener {
|
||||||
|
baseBinding.imgTemp1.isSelected = true
|
||||||
|
baseBinding.imgTemp2.isSelected = false
|
||||||
|
}
|
||||||
|
baseBinding.imgTemp2.setOnClickListener {
|
||||||
|
baseBinding.imgTemp2.isSelected = true
|
||||||
|
baseBinding.imgTemp1.isSelected = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
SensorsFragment.newInstance()
|
SensorsFragment.newInstance()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
offscreenPageLimit = 1
|
||||||
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
super.onPageSelected(position)
|
super.onPageSelected(position)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/radius_green" android:state_selected="true"/>
|
||||||
<item android:drawable="@drawable/radius_black" />
|
<item android:drawable="@drawable/radius_black" />
|
||||||
<item android:drawable="@drawable/radius_green" android:state_selected="true" tools:ignore="StateListReachable" />
|
|
||||||
</selector>
|
</selector>
|
||||||
@ -21,6 +21,7 @@
|
|||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/back_btn"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:src="@drawable/go_back"
|
android:src="@drawable/go_back"
|
||||||
|
|||||||
@ -58,7 +58,7 @@
|
|||||||
android:layout_alignBottom="@id/text_app_name"
|
android:layout_alignBottom="@id/text_app_name"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:paddingHorizontal="7dp"
|
android:paddingHorizontal="7dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="20dp"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
android:src="@drawable/more_point"/>
|
android:src="@drawable/more_point"/>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@ -118,7 +118,8 @@
|
|||||||
app:tabMode="scrollable"
|
app:tabMode="scrollable"
|
||||||
app:tabRippleColor="@null"
|
app:tabRippleColor="@null"
|
||||||
app:tabSelectedTextColor="@color/module_title_color"
|
app:tabSelectedTextColor="@color/module_title_color"
|
||||||
app:tabTextColor="@color/main_tab_unselected" />
|
app:tabTextColor="@color/main_tab_unselected"
|
||||||
|
app:tabTextAppearance="@style/NoCapsTabTextAppearance"/>
|
||||||
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|||||||
@ -22,9 +22,10 @@
|
|||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/img_temp1"
|
||||||
android:layout_width="23dp"
|
android:layout_width="23dp"
|
||||||
android:layout_height="23dp"
|
android:layout_height="23dp"
|
||||||
android:src="@drawable/radius_black"/>
|
android:src="@drawable/radius_sel"/>
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
style="@style/TextContentRight"
|
style="@style/TextContentRight"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -40,6 +41,7 @@
|
|||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/img_temp2"
|
||||||
android:layout_width="23dp"
|
android:layout_width="23dp"
|
||||||
android:layout_height="23dp"
|
android:layout_height="23dp"
|
||||||
android:src="@drawable/radius_sel"/>
|
android:src="@drawable/radius_sel"/>
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/background_color"
|
android:background="@color/background_color"
|
||||||
tools:context=".dashboard.CameraFragment">
|
tools:context=".dashboard.BatteryFragment">
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
@ -531,4 +530,4 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
</LinearLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
@ -8,6 +8,7 @@
|
|||||||
android:paddingHorizontal="18dp"
|
android:paddingHorizontal="18dp"
|
||||||
android:layout_marginHorizontal="8dp"
|
android:layout_marginHorizontal="8dp"
|
||||||
android:paddingVertical="10dp"
|
android:paddingVertical="10dp"
|
||||||
|
android:id="@+id/view"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
|||||||
@ -269,7 +269,9 @@
|
|||||||
<string name="hight_speed_video">High speed video</string>
|
<string name="hight_speed_video">High speed video</string>
|
||||||
<string name="video_stabilization">Video stabilization</string>
|
<string name="video_stabilization">Video stabilization</string>
|
||||||
<string name="hide_deep_sleep">Hide deep sleep</string>
|
<string name="hide_deep_sleep">Hide deep sleep</string>
|
||||||
|
<string name="show_deep_sleep">Show deep sleep</string>
|
||||||
<string name="metric_units">Metric units</string>
|
<string name="metric_units">Metric units</string>
|
||||||
|
<string name="imper_units">Imperial units</string>
|
||||||
<string name="reset_">Reset</string>
|
<string name="reset_">Reset</string>
|
||||||
<string name="export">Export</string>
|
<string name="export">Export</string>
|
||||||
<string name="share">Share</string>
|
<string name="share">Share</string>
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<!-- tab的样式禁止大写-->
|
||||||
|
<style name="NoCapsTabTextAppearance" parent="TextAppearance.Design.Tab">
|
||||||
|
<item name="textAllCaps">false</item>
|
||||||
|
<item name="android:textAllCaps">false</item>
|
||||||
|
<item name="android:textSize">14sp</item>
|
||||||
|
</style>
|
||||||
<!-- 超大字号-->
|
<!-- 超大字号-->
|
||||||
<style name="TextTitleBig">
|
<style name="TextTitleBig">
|
||||||
<item name="android:textSize">30sp</item>
|
<item name="android:textSize">30sp</item>
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Base.Theme.DevCheck" parent="Theme.Material3.DayNight.NoActionBar">
|
<style name="Base.Theme.DevCheck" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||||
<!-- Customize your light theme here. -->
|
<!-- Customize your light theme here. -->
|
||||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||||
|
<item name="android:statusBarColor" >@color/white</item>
|
||||||
|
<item name="backgroundColor">@color/white</item>
|
||||||
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.DevCheck" parent="Base.Theme.DevCheck" />
|
<style name="Theme.DevCheck" parent="Base.Theme.DevCheck" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user