feat:初步完成房间红包入口组件UI
feat:完善网络调试工具Stetho的配置
This commit is contained in:
@@ -17,6 +17,7 @@ import androidx.multidex.MultiDex;
|
||||
|
||||
import com.bumptech.glide.request.target.ViewTarget;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.facebook.stetho.Stetho;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.mob.MobSDK;
|
||||
import com.mob.moblink.MobLink;
|
||||
@@ -252,6 +253,7 @@ public class XChatApplication extends BaseApp {
|
||||
//fixed: Glide Exception:"You must not call setTag() on a view Glide is targeting"
|
||||
ViewTarget.setTagId(R.id.tag_glide);
|
||||
|
||||
initStetho(context);
|
||||
init(channel);
|
||||
|
||||
//生命周期监听
|
||||
@@ -543,4 +545,18 @@ public class XChatApplication extends BaseApp {
|
||||
unregisterActivityLifecycleCallbacks(lifeCycleHelper);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化Stetho(网络调试)
|
||||
*/
|
||||
private static void initStetho(Context context) {
|
||||
if (Env.isDebug()) {
|
||||
Stetho.initialize(
|
||||
Stetho.newInitializerBuilder(context)
|
||||
.enableDumpapp(Stetho.defaultDumperPluginsProvider(context))
|
||||
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -125,6 +125,9 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
microView = mView.findViewById(R.id.micro_view);
|
||||
pkBoardView = mView.findViewById(R.id.layout_pk_board);
|
||||
pkBoardView.setOnActionListener(this);
|
||||
|
||||
//TODO 临时测试
|
||||
gameBinding.redPackageWidget.loadData(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -808,7 +811,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
} else {
|
||||
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
|
||||
gameBinding.ivTreasureBox.setVisibility(View.VISIBLE);
|
||||
|
||||
GlideApp.with(BasicConfig.INSTANCE.getAppContext())
|
||||
.load(GoldBoxHelper.getBoxIcon())
|
||||
.error(R.drawable.icon_room_treasure_box)
|
||||
|
@@ -261,5 +261,4 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
event.firstChargeRewardList
|
||||
).openDialog()
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.functions.Predicate
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.TimeZone
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/24 16:37
|
||||
* Desc:房间内的红包入口
|
||||
**/
|
||||
class RedPackageWidget : ConstraintLayout {
|
||||
private var textView: TextView? = null
|
||||
private var countDownDisposable: Disposable? = null
|
||||
|
||||
// 倒计时格式(分:秒)
|
||||
private val mmssFormat by lazy(LazyThreadSafetyMode.NONE) {
|
||||
SimpleDateFormat("mm:ss").apply {
|
||||
timeZone = TimeZone.getTimeZone("GMT+00:00")
|
||||
}
|
||||
}
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context)
|
||||
.inflate(R.layout.red_package_widget, this, true)
|
||||
textView = findViewById(R.id.tv_text)
|
||||
}
|
||||
|
||||
fun loadData(data: RedPackageNotifyInfo?) {
|
||||
this.isVisible = true
|
||||
switchUI(true)
|
||||
val time = System.currentTimeMillis() + Random.nextLong(1000, 1000 * 100)
|
||||
val count = time - System.currentTimeMillis()
|
||||
countDownDisposable = Observable.intervalRange(0, count, 0, 500L, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext {
|
||||
val gap = time - System.currentTimeMillis()
|
||||
if (gap >= 0) {
|
||||
textView?.text = mmssFormat.format(gap)
|
||||
}
|
||||
}
|
||||
.doOnComplete {
|
||||
switchUI(false)
|
||||
}
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换UI
|
||||
* @param isCountDown 是否倒计时模式?否则为可抢红包模式
|
||||
*/
|
||||
private fun switchUI(isCountDown: Boolean) {
|
||||
if (isCountDown) {
|
||||
textView?.setBackgroundResource(R.drawable.shape_99292929_8)
|
||||
textView?.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10f)
|
||||
} else {
|
||||
textView?.setBackgroundResource(R.drawable.red_package_widget_bg_text)
|
||||
textView?.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9f)
|
||||
}
|
||||
}
|
||||
|
||||
fun onStop() {
|
||||
if (countDownDisposable?.isDisposed == false) {
|
||||
countDownDisposable?.dispose()
|
||||
}
|
||||
}
|
||||
}
|
@@ -116,6 +116,9 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
}
|
||||
|
||||
private void subMsg() {
|
||||
if (isInEditMode()) {
|
||||
return;
|
||||
}
|
||||
subscribe = IMNetEaseManager.get()
|
||||
.getChatRoomEventObservable().subscribe(
|
||||
roomEvent -> onReceiveRoomEvent(roomEvent),
|
||||
|
BIN
app/src/main/res/drawable-xxhdpi/red_package_widget_bg.webp
Normal file
BIN
app/src/main/res/drawable-xxhdpi/red_package_widget_bg.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/red_package_widget_bg_text.webp
Normal file
BIN
app/src/main/res/drawable-xxhdpi/red_package_widget_bg_text.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
7
app/src/main/res/drawable/shape_99292929_8.xml
Normal file
7
app/src/main/res/drawable/shape_99292929_8.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="8dp"/>
|
||||
<solid android:color="#99292929"/>
|
||||
</shape>
|
26
app/src/main/res/layout/red_package_widget.xml
Normal file
26
app/src/main/res/layout/red_package_widget.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge 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:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout_width="58dp"
|
||||
tools:layout_height="58dp"
|
||||
android:background="@drawable/red_package_widget_bg"
|
||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_text"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@drawable/red_package_widget_bg_text"
|
||||
android:gravity="center"
|
||||
android:text="@string/red_package_widget_get"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="9dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</merge>
|
@@ -5169,5 +5169,5 @@
|
||||
<string name="red_package_open_btn_msg">發彈幕\n搶紅包</string>
|
||||
<string name="red_package_opened_money_tips">已存入錢包,請到我的收益確認</string>
|
||||
<string name="red_package_opened_count_format">已領取%s/%s個</string>
|
||||
|
||||
<string name="red_package_widget_get">抢红包</string>
|
||||
</resources>
|
@@ -229,20 +229,33 @@
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/ic_first_charge_enter"
|
||||
android:visibility="gone"
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_02" />
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_02"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_radish_entrance"
|
||||
android:layout_width="65dp"
|
||||
android:layout_height="65dp"
|
||||
android:layout_above="@id/iv_treasure_box"
|
||||
android:layout_above="@id/red_package_widget"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/ic_radish_entrance"
|
||||
android:visibility="gone"
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_03" />
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_03"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
android:id="@+id/red_package_widget"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="58dp"
|
||||
android:layout_above="@id/iv_treasure_box"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="18.5dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_treasure_box"
|
||||
@@ -255,7 +268,8 @@
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/icon_room_treasure_box"
|
||||
android:visibility="gone"
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_04" />
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_04"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_queuing_micro"
|
||||
@@ -269,7 +283,8 @@
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/ic_dating_queuing_micro"
|
||||
android:visibility="gone"
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_05" />
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_05"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@@ -100,24 +100,25 @@
|
||||
android:id="@+id/contribute_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="85dp"
|
||||
android:background="@drawable/bg_single_room_rank_entrance"
|
||||
android:drawablePadding="@dimen/dp_2"
|
||||
android:gravity="center"
|
||||
android:onClick="@{click}"
|
||||
android:paddingStart="@dimen/dp_8"
|
||||
android:paddingEnd="@dimen/dp_4"
|
||||
android:layout_marginTop="85dp"
|
||||
android:text="@string/room_host_list"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:drawableStartCompat="@drawable/ic_sing_room_contribute_list"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:drawableStartCompat="@drawable/ic_sing_room_contribute_list" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_hour_rank"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:background="@drawable/bg_single_room_rank_entrance"
|
||||
android:drawablePadding="@dimen/dp_2"
|
||||
android:gravity="center"
|
||||
@@ -126,7 +127,6 @@
|
||||
android:text="@string/room_list_hour"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
app:drawableStartCompat="@drawable/ic_single_room_rank"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/contribute_list" />
|
||||
@@ -201,10 +201,20 @@
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/ic_radish_entrance"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/iv_treasure_box"
|
||||
tools:visibility="visible"
|
||||
app:layout_constraintBottom_toTopOf="@id/red_package_widget"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:contentDescription="@string/layout_fragment_single_room_06" />
|
||||
|
||||
<com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
android:id="@+id/red_package_widget"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="58dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/iv_treasure_box"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_treasure_box"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_treasure_box" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_treasure_box"
|
||||
android:layout_width="65dp"
|
||||
@@ -216,7 +226,8 @@
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/fl_speedy_message"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:contentDescription="@string/layout_fragment_single_room_07" />
|
||||
tools:contentDescription="@string/layout_fragment_single_room_07"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.yizhuan.erban.avroom.widget.MessageView
|
||||
android:id="@+id/message_view"
|
||||
|
@@ -147,8 +147,8 @@ dependencies {
|
||||
api 'com.facebook.android:facebook-login:16.2.0'
|
||||
|
||||
// 网络请求chrome数据调试
|
||||
implementation 'com.facebook.stetho:stetho:1.5.1'
|
||||
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
|
||||
api 'com.facebook.stetho:stetho:1.5.1'
|
||||
api 'com.facebook.stetho:stetho-okhttp3:1.5.1'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
Reference in New Issue
Block a user