Commit 3f728f0a authored by jyx's avatar jyx

代码优化

parent 03b6befb
package com.mints.wisdomclean.ui.adapter package com.mints.helivideo.ui.adapter
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
......
package com.mints.helivideo.ui.fragment.draw
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.mints.helivideo.R
class DrawCashAdapter() : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_draw_cash) {
private var mSelectIndex = 0
init {
mSelectIndex = 0
}
override fun convert(holder: BaseViewHolder, item: String) {
holder.getView<View>(R.id.root_view).setOnClickListener {
setPosition(holder.adapterPosition)
notifyDataSetChanged()
}
holder.setText(R.id.tv_cash, item)
if (getPosition() == holder.adapterPosition) {
//当前选中
holder.getView<View>(R.id.root_view)
.setBackgroundResource(R.drawable.shape_draw_adapter)
} else {
holder.getView<View>(R.id.root_view)
.setBackgroundResource(R.drawable.shape_draw_adapter_none)
}
}
fun getPosition() = mSelectIndex
private fun setPosition(index: Int) {
this.mSelectIndex = index
}
}
\ No newline at end of file
...@@ -2,6 +2,8 @@ package com.mints.helivideo.ui.fragment.draw ...@@ -2,6 +2,8 @@ package com.mints.helivideo.ui.fragment.draw
import android.os.Bundle import android.os.Bundle
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.mints.helivideo.R import com.mints.helivideo.R
import com.mints.helivideo.ui.fragment.base.BaseFragment import com.mints.helivideo.ui.fragment.base.BaseFragment
import com.mints.helivideo.utils.SpanUtils import com.mints.helivideo.utils.SpanUtils
...@@ -27,11 +29,22 @@ class DrawCashFragment : BaseFragment() { ...@@ -27,11 +29,22 @@ class DrawCashFragment : BaseFragment() {
private var drawType = DRAW_TYPE_CASH private var drawType = DRAW_TYPE_CASH
private var mDrawCashData = arrayListOf<String>()
private var mDrawCashAdapter: DrawCashAdapter? = null
override fun initViewsAndEvents() { override fun initViewsAndEvents() {
arguments?.let { arguments?.let {
drawType = it.getInt(DRAW_TYPE, DRAW_TYPE_CASH) drawType = it.getInt(DRAW_TYPE, DRAW_TYPE_CASH)
} }
ry_draw.layoutManager =
LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false)
mDrawCashAdapter = DrawCashAdapter()
ry_draw.adapter = mDrawCashAdapter
mDrawCashData.add("0.3")
mDrawCashData.add("50")
mDrawCashData.add("100")
mDrawCashAdapter?.addData(mDrawCashData)
if (drawType == DRAW_TYPE_CASH) { if (drawType == DRAW_TYPE_CASH) {
tv_title.text = "红包余额(元)" tv_title.text = "红包余额(元)"
......
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<!-- 填充的颜色 --> <!-- 填充的颜色 -->
<stroke android:width="3dp" android:color="@color/red" /> <stroke
<solid android:color="#240a0e" /> android:width="2dp"
android:color="@color/red" />
<solid android:color="@color/white" />
<!-- 设置按钮的四个角为弧形 --> <!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 --> <!-- android:radius 弧形的半径 -->
<corners android:radius="5dip" /> <corners android:radius="5dip" />
......
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<!-- 填充的颜色 --> <!-- 填充的颜色 -->
<stroke
android:width="1dp"
android:color="@color/graya" />
<solid android:color="#282D34" /> <solid android:color="@color/white" />
<!-- 设置按钮的四个角为弧形 --> <!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 --> <!-- android:radius 弧形的半径 -->
<corners android:radius="5dip" /> <corners android:radius="5dip" />
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
android:id="@+id/rg_draw" android:id="@+id/rg_draw"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" android:layout_height="60dp"
android:layout_marginTop="10dp"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="10dp"> android:padding="10dp">
...@@ -53,7 +52,9 @@ ...@@ -53,7 +52,9 @@
android:id="@+id/rb_wechat" android:id="@+id/rb_wechat"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginEnd="@dimen/dp_10"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/shape_draw_adapter_none"
android:button="@null" android:button="@null"
android:gravity="center" android:gravity="center"
android:text="微信" /> android:text="微信" />
...@@ -62,7 +63,9 @@ ...@@ -62,7 +63,9 @@
android:id="@+id/rb_alipay" android:id="@+id/rb_alipay"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="@dimen/dp_10"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/shape_draw_adapter_none"
android:button="@null" android:button="@null"
android:gravity="center" android:gravity="center"
android:text="支付宝" /> android:text="支付宝" />
......
...@@ -16,16 +16,7 @@ ...@@ -16,16 +16,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<TextView <include layout="@layout/layout_draw_header" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:text="剧场"
android:textColor="@color/black"
android:textSize="18sp"
android:textStyle="bold" />
<com.scwang.smartrefresh.layout.SmartRefreshLayout <com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srlMainPage" android:id="@+id/srlMainPage"
......
...@@ -8,4 +8,6 @@ ...@@ -8,4 +8,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<include layout="@layout/layout_draw_header" />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_view"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginEnd="6dp"
android:background="@drawable/shape_draw_adapter_none">
<TextView
android:id="@+id/tv_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_vip_lable"
android:gravity="center"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="@color/white"
android:textSize="10sp" />
<TextView
android:id="@+id/tv_cash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0.3元"
android:textSize="16sp"
android:textStyle="bold" />
</FrameLayout>
\ No newline at end of file
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlVipItemRoot"
android:layout_width="110dp"
android:layout_height="150dp"
android:layout_margin="10dp"
android:background="@drawable/shape_vip_adapter_none"
android:orientation="vertical">
<TextView
android:id="@+id/tvVipItemLable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_vip_lable"
android:gravity="center"
android:paddingLeft="6dp"
android:paddingTop="2dp"
android:paddingRight="6dp"
android:paddingBottom="2dp"
android:textColor="@color/white"
android:textSize="12sp"
tools:text="包年会员" />
<TextView
android:id="@+id/tvVipItemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:textColor="@color/white"
android:textSize="18sp"
tools:text="包年会员" />
<TextView
android:id="@+id/tvVipItemCurMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:gravity="center"
android:textColor="#373737"
android:textSize="24sp"
android:textStyle="bold"
tools:text="$78" />
<TextView
android:id="@+id/tvVipItemMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="16dp"
android:textColor="#939AA3"
android:textSize="14sp"
tools:text="原价:123" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="40dp"
android:paddingBottom="10dp">
<LinearLayout
android:id="@+id/ll_draw_cash"
android:layout_width="140dp"
android:layout_height="40dp"
android:layout_marginStart="20dp"
android:background="@drawable/shape_half_trans"
android:gravity="center_vertical">
<ImageView
android:layout_width="30dp"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_main" />
<TextView
android:id="@+id/tv_cash"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="50元"
android:textColor="@color/white" />
<Button
android:layout_width="60dp"
android:layout_height="28dp"
android:layout_marginEnd="6dp"
android:background="@drawable/shape_green"
android:text="提现"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_draw_gold"
android:layout_width="140dp"
android:layout_height="40dp"
android:layout_gravity="end"
android:layout_marginEnd="20dp"
android:background="@drawable/shape_half_trans"
android:gravity="center_vertical">
<ImageView
android:layout_width="30dp"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_main" />
<TextView
android:id="@+id/tv_gold"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="37个"
android:textColor="@color/white" />
<Button
android:layout_width="60dp"
android:layout_height="28dp"
android:layout_marginEnd="6dp"
android:background="@drawable/shape_green"
android:text="提现"
android:textColor="@color/white" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment