Commit 21942a83 authored by jyx's avatar jyx

代码优化

parent 4c8f9b89
......@@ -13,6 +13,7 @@ import android.widget.TextView
import com.mints.helivideo.R
import com.mints.helivideo.common.AppConfig
import com.mints.helivideo.mvp.model.VipBean
import com.mints.helivideo.utils.SpanUtils
class PayYesDialog(
private val context: Context,
......@@ -22,12 +23,10 @@ class PayYesDialog(
context, R.style.dialog
) {
private val lp: WindowManager.LayoutParams
private val fl_dialog_vip_money_root: FrameLayout
private val tv_dialog_vip_next: TextView
private val tv_dialog_vip_money_left: TextView
private val tv_dialog_vip_money_right: TextView
private val tv_dialog_vip_money_center: TextView
private val tv_dialog_vip_count: TextView
private val iv_dialog_vip_quit: ImageView
private val iv_dialog_vip_top: ImageView
private val rl_dialog_vip_bg: RelativeLayout
init {
......@@ -43,35 +42,36 @@ class PayYesDialog(
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { dialogInterface, i, keyEvent ->
if (i == KeyEvent.KEYCODE_BACK) {
true
} else false
i == KeyEvent.KEYCODE_BACK
}
// 查找View
fl_dialog_vip_money_root = findViewById<View>(R.id.fl_dialog_vip_money_root) as FrameLayout
iv_dialog_vip_quit = findViewById<View>(R.id.iv_dialog_vip_quit) as ImageView
iv_dialog_vip_top = findViewById<View>(R.id.iv_dialog_vip_top) as ImageView
tv_dialog_vip_next = findViewById<View>(R.id.tv_dialog_vip_next) as TextView
tv_dialog_vip_money_left = findViewById<View>(R.id.tv_dialog_vip_money_left) as TextView
tv_dialog_vip_money_right = findViewById<View>(R.id.tv_dialog_vip_money_right) as TextView
tv_dialog_vip_money_center = findViewById<View>(R.id.tv_dialog_vip_money_center) as TextView
tv_dialog_vip_count = findViewById<View>(R.id.tv_dialog_vip_count) as TextView
rl_dialog_vip_bg = findViewById<View>(R.id.rl_dialog_vip_bg) as RelativeLayout
iv_dialog_vip_quit.setOnClickListener(listener)
tv_dialog_vip_next.setOnClickListener(listener)
if (vipBean.trial == 0) {
//0-没签约 无0.01
fl_dialog_vip_money_root.visibility = View.VISIBLE
tv_dialog_vip_money_left.text = "¥${vipBean.oldPrice}"
tv_dialog_vip_money_right.text = "¥${vipBean.oldPrice}"
tv_dialog_vip_money_center.text = "¥${vipBean.price}"
tv_dialog_vip_next.text = "立即开通"
rl_dialog_vip_bg.setBackgroundResource(R.mipmap.bg_vip_dialog_one)
tv_dialog_vip_count.text = SpanUtils()
.append("" + vipBean.price)
.setFontSize(30, true)
.append(" 元")
.setFontSize(16, true)
.create()
iv_dialog_vip_top.setImageResource(R.mipmap.ic_vip_pay_top2)
} else {
fl_dialog_vip_money_root.visibility = View.GONE
tv_dialog_vip_next.text = "${0.01}元试用"
rl_dialog_vip_bg.setBackgroundResource(R.mipmap.bg_vip_dialog_zero)
tv_dialog_vip_count.text = SpanUtils()
.append("0.01")
.setFontSize(30, true)
.append(" 元")
.setFontSize(16, true)
.create()
iv_dialog_vip_top.setImageResource(R.mipmap.ic_vip_pay_top1)
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/rl_dialog_vip_bg"
android:layout_width="340dp"
android:layout_height="550dp"
android:layout_centerInParent="true"
android:background="@mipmap/bg_vip_dialog_zero"
android:layout_width="match_parent"
android:layout_height="420dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="36dp"
android:layout_marginTop="-20dp"
android:layout_marginEnd="36dp"
android:background="@mipmap/bg_pay_yes"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_dialog_vip_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="@mipmap/ic_vip_pay_top1" />
<ImageView
android:id="@+id/iv_dialog_vip_quit"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:src="@mipmap/ic_quit_yuan"></ImageView>
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="124dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="20dp"
android:src="@mipmap/ic_vip_back" />
<TextView
android:id="@+id/tv_dialog_vip_next"
android:id="@+id/tv_dialog_vip_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="70dp"
android:background="@mipmap/bg_vip_dialog_btn"
android:gravity="center"
android:text="立即开通"
android:textColor="#6B3D1A"
android:textSize="20sp"></TextView>
android:layout_marginBottom="136dp"
android:textColor="@color/color_FFF0D4" />
<FrameLayout
android:id="@+id/fl_dialog_vip_money_root"
android:layout_width="match_parent"
<TextView
android:id="@+id/tv_dialog_vip_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/tv_dialog_vip_money_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:layout_marginTop="200dp"
android:text="¥123"
android:textColor="@color/red"
android:textSize="22sp"></TextView>
<TextView
android:id="@+id/tv_dialog_vip_money_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="200dp"
android:layout_marginRight="45dp"
android:text="¥123"
android:textColor="@color/red"
android:textSize="22sp"></TextView>
<TextView
android:id="@+id/tv_dialog_vip_money_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="260dp"
android:text="¥123"
android:textColor="@color/red"
android:textSize="22sp"></TextView>
</FrameLayout>
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:background="@mipmap/ic_vip_pay_btn" />
</RelativeLayout>
</RelativeLayout>
</FrameLayout>
......@@ -32,5 +32,6 @@
<color name="color_FD7E0E">#FD7E0E</color>
<color name="color_815136">#815136</color>
<color name="color_FFF0D4">#FFF0D4</color>
</resources>
\ 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