添加首页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 com.tools.device.devcheck.databinding.ItemCommonTempBinding
|
||||
import com.tools.device.devcheck.databinding.ItemListBinding
|
||||
import com.tools.device.devcheck.dialog.TempDialogFragment
|
||||
|
||||
class TempAdapter: RecyclerView.Adapter<TempAdapter.ListViewHolder>() {
|
||||
private lateinit var context: Context
|
||||
private lateinit var listener: OnTempClickListener
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
@ -22,12 +24,20 @@ class TempAdapter: RecyclerView.Adapter<TempAdapter.ListViewHolder>() {
|
||||
holder: ListViewHolder,
|
||||
position: Int
|
||||
) {
|
||||
|
||||
holder.binding.view.setOnClickListener {
|
||||
listener.onTempClick(position)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return 3
|
||||
}
|
||||
fun setListener(listener: OnTempClickListener){
|
||||
this.listener = listener
|
||||
}
|
||||
|
||||
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.layoutManager= LinearLayoutManager(this)
|
||||
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.recyclerview.widget.LinearLayoutManager
|
||||
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.databinding.ActivityTemperatureBinding
|
||||
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 customPopView: CustomPopView
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -22,7 +24,9 @@ class TemperatureActivity : AppCompatActivity() {
|
||||
binding.imageBack.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
binding.rvTemperature.adapter = TempAdapter()
|
||||
val tempAdapter = TempAdapter()
|
||||
tempAdapter.setListener(this)
|
||||
binding.rvTemperature.adapter = tempAdapter
|
||||
binding.rvTemperature.layoutManager =LinearLayoutManager(this)
|
||||
customPopView =CustomPopView(this,3,callback = {text->
|
||||
|
||||
@ -31,4 +35,9 @@ class TemperatureActivity : AppCompatActivity() {
|
||||
customPopView.show(binding.imageTool)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTempClick(position: Int) {
|
||||
val tempDialog = TempDialogFragment()
|
||||
tempDialog.show(supportFragmentManager, "tempDialog")
|
||||
}
|
||||
}
|
||||
@ -40,14 +40,28 @@ class CustomPopView(context: Context,type: Int,private val callback: (String) ->
|
||||
popupWindow.animationStyle = R.style.PopupAnimation
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
dismiss()
|
||||
}
|
||||
binding.popSleep.setOnClickListener {
|
||||
dismiss()
|
||||
callback.invoke(binding.textSleep.text.toString())
|
||||
if (binding.textSleep.text.toString() == context.getString(R.string.hide_deep_sleep)) {
|
||||
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 {
|
||||
dismiss()
|
||||
callback.invoke(binding.text1.text.toString())
|
||||
@ -57,32 +71,35 @@ class CustomPopView(context: Context,type: Int,private val callback: (String) ->
|
||||
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 -> {
|
||||
binding.popCluster.visibility = View.GONE
|
||||
binding.popSleep.visibility = View.VISIBLE
|
||||
binding.popMore.visibility = View.GONE
|
||||
binding.textSleep.setOnClickListener {
|
||||
dismiss()
|
||||
callback.invoke(binding.textSleep.text.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
2 -> {
|
||||
binding.popCluster.visibility = View.GONE
|
||||
binding.popSleep.visibility = View.GONE
|
||||
binding.popMore.visibility = View.VISIBLE
|
||||
binding.textMore1.setOnClickListener {}
|
||||
binding.textMore2.setOnClickListener {}
|
||||
binding.textMore3.setOnClickListener {}
|
||||
binding.textMore4.setOnClickListener {}
|
||||
binding.textMore5.setOnClickListener {}
|
||||
binding.textMore6.setOnClickListener {}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
binding.popCluster.visibility = View.GONE
|
||||
binding.popSleep.visibility = View.GONE
|
||||
binding.popMore.visibility = View.VISIBLE
|
||||
binding.llHide.visibility = View.GONE
|
||||
}
|
||||
|
||||
4 -> {
|
||||
binding.popCluster.visibility = View.GONE
|
||||
binding.popSleep.visibility = View.GONE
|
||||
|
||||
@ -36,6 +36,15 @@ class TempDialogFragment : DialogFragment() {
|
||||
onPositiveClick()
|
||||
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() {
|
||||
|
||||
@ -41,6 +41,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
SensorsFragment.newInstance()
|
||||
)
|
||||
)
|
||||
offscreenPageLimit = 1
|
||||
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
super.onPageSelected(position)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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_green" android:state_selected="true" tools:ignore="StateListReachable" />
|
||||
</selector>
|
||||
@ -21,6 +21,7 @@
|
||||
android:layout_margin="10dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/back_btn"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:src="@drawable/go_back"
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
android:layout_alignBottom="@id/text_app_name"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingHorizontal="7dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:visibility="visible"
|
||||
android:src="@drawable/more_point"/>
|
||||
<RelativeLayout
|
||||
@ -118,7 +118,8 @@
|
||||
app:tabMode="scrollable"
|
||||
app:tabRippleColor="@null"
|
||||
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>
|
||||
|
||||
@ -22,9 +22,10 @@
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/img_temp1"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:src="@drawable/radius_black"/>
|
||||
android:src="@drawable/radius_sel"/>
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
style="@style/TextContentRight"
|
||||
android:layout_width="wrap_content"
|
||||
@ -40,6 +41,7 @@
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/img_temp2"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:src="@drawable/radius_sel"/>
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background_color"
|
||||
tools:context=".dashboard.CameraFragment">
|
||||
|
||||
tools:context=".dashboard.BatteryFragment">
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
@ -531,4 +530,4 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</LinearLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
@ -8,6 +8,7 @@
|
||||
android:paddingHorizontal="18dp"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:paddingVertical="10dp"
|
||||
android:id="@+id/view"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
|
||||
@ -269,7 +269,9 @@
|
||||
<string name="hight_speed_video">High speed video</string>
|
||||
<string name="video_stabilization">Video stabilization</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="imper_units">Imperial units</string>
|
||||
<string name="reset_">Reset</string>
|
||||
<string name="export">Export</string>
|
||||
<string name="share">Share</string>
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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">
|
||||
<item name="android:textSize">30sp</item>
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- 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. -->
|
||||
<!-- <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 name="Theme.DevCheck" parent="Base.Theme.DevCheck" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user