Commit 478c7a21 authored by mengcuiguang's avatar mengcuiguang

代码优化

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