Commit 478c7a21 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 4984fd26
package com.duben.dayplaylet.utils package com.duben.dayplaylet.utils
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.os.Handler import android.os.Handler
import android.view.Gravity import android.view.Gravity
...@@ -11,6 +12,7 @@ import android.widget.Toast ...@@ -11,6 +12,7 @@ import android.widget.Toast
import com.duben.dayplaylet.R import com.duben.dayplaylet.R
object ConsumerToastUtil { object ConsumerToastUtil {
@SuppressLint("MissingInflatedId")
@JvmStatic @JvmStatic
fun showAwardText(context: Context?, redPkgInt: Int, yuanbaoInt: Int) { fun showAwardText(context: Context?, redPkgInt: Int, yuanbaoInt: Int) {
SoundPoolUtil.getInstance().getGoldVoice() SoundPoolUtil.getInstance().getGoldVoice()
...@@ -23,6 +25,7 @@ object ConsumerToastUtil { ...@@ -23,6 +25,7 @@ object ConsumerToastUtil {
try { try {
val toastview = LayoutInflater.from(context).inflate(R.layout.toast_text_layout, null) val toastview = LayoutInflater.from(context).inflate(R.layout.toast_text_layout, null)
val ll_toast_redpkg = toastview.findViewById<View>(R.id.ll_toast_redpkg) as LinearLayout val ll_toast_redpkg = toastview.findViewById<View>(R.id.ll_toast_redpkg) as LinearLayout
val ll_toast_yuanbao = toastview.findViewById<View>(R.id.ll_toast_yuanbao) as LinearLayout
val redPkg = toastview.findViewById<View>(R.id.tv_toast_redpkg) as TextView val redPkg = toastview.findViewById<View>(R.id.tv_toast_redpkg) as TextView
val yuanbao = toastview.findViewById<View>(R.id.tv_toast_yuanbao) as TextView val yuanbao = toastview.findViewById<View>(R.id.tv_toast_yuanbao) as TextView
...@@ -34,9 +37,9 @@ object ConsumerToastUtil { ...@@ -34,9 +37,9 @@ object ConsumerToastUtil {
} }
if (yuanbaoInt > 0) { if (yuanbaoInt > 0) {
yuanbao.text = "+${yuanbaoInt}" yuanbao.text = "+${yuanbaoInt}"
yuanbao.visibility = View.VISIBLE ll_toast_yuanbao.visibility = View.VISIBLE
} else { } else {
yuanbao.visibility = View.GONE ll_toast_yuanbao.visibility = View.GONE
} }
val toast = Toast(context) val toast = Toast(context)
toast.setGravity(Gravity.CENTER, 0, 0) toast.setGravity(Gravity.CENTER, 0, 0)
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
android:id="@+id/ll_toast_redpkg" android:id="@+id/ll_toast_redpkg"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="20dp" android:layout_margin="30dp"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:layout_width="60dp" android:layout_width="120dp"
android:layout_height="60dp" android:layout_height="120dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_redpkg" /> android:src="@mipmap/ic_redpkg" />
...@@ -27,22 +27,35 @@ ...@@ -27,22 +27,35 @@
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="18sp" android:textSize="28sp"
android:textStyle="bold" android:textStyle="bold"
tools:text="+10" /> tools:text="+10" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/ll_toast_yuanbao"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:orientation="vertical">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_yuanbao" />
<TextView <TextView
android:id="@+id/tv_toast_yuanbao" android:id="@+id/tv_toast_yuanbao"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="30dp" android:layout_gravity="center_horizontal"
android:drawableTop="@mipmap/ic_yuanbao" android:layout_marginTop="4dp"
android:drawablePadding="14dp"
android:gravity="center_horizontal"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="18sp" android:textSize="28sp"
android:textStyle="bold" android:textStyle="bold"
tools:text="+10" /> tools:text="+10" />
</LinearLayout>
</LinearLayout> </LinearLayout>
\ 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