精灵夺宝:赠送精灵后隐藏点击查看
This commit is contained in:
@@ -20,6 +20,7 @@ class MyFairySendDialog : BaseDialog<TreasureFairyDialogMyFairySendBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var gravity = Gravity.CENTER
|
||||
private var onSendListener: (() -> Unit)? = null
|
||||
|
||||
companion object {
|
||||
fun newInstance(bundle: Bundle, userInfo: SimpleUserInfo): MyFairySendDialog {
|
||||
@@ -63,8 +64,16 @@ class MyFairySendDialog : BaseDialog<TreasureFairyDialogMyFairySendBinding>() {
|
||||
}
|
||||
|
||||
viewModel.sendFairyLiveData.observe(viewLifecycleOwner) {
|
||||
if (it.getContentIfNotHandled() == true) dismissAllowingStateLoss()
|
||||
if (it.getContentIfNotHandled() == true) {
|
||||
dismissAllowingStateLoss()
|
||||
onSendListener?.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setOnSendListener(onSendListener: () -> Nothing) {
|
||||
this.onSendListener = onSendListener
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -10,6 +10,7 @@ import com.mango.core.auth.AuthModel;
|
||||
import com.mango.core.gift.bean.SimpleUserInfo;
|
||||
import com.mango.core.im.custom.bean.CustomAttachment;
|
||||
import com.mango.core.im.custom.bean.FairySendAttachment;
|
||||
import com.mango.core.manager.IMNetEaseManager;
|
||||
import com.mango.core.treasurefairy.FairyInfo;
|
||||
import com.mango.moshen.R;
|
||||
import com.mango.moshen.treasurefairy.dialog.MyFairySendDialog;
|
||||
@@ -17,11 +18,15 @@ import com.mango.moshen.ui.utils.ImageLoadUtils;
|
||||
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by chenran on 2018/1/2.
|
||||
*/
|
||||
|
||||
public class MsgViewHolderFairy extends MsgViewHolderBase implements View.OnClickListener {
|
||||
private final static String IS_SEND = "afafagag";
|
||||
private TextView tvContent;
|
||||
private ImageView ivFairyIcon;
|
||||
private View flIconBg;
|
||||
@@ -55,10 +60,14 @@ public class MsgViewHolderFairy extends MsgViewHolderBase implements View.OnClic
|
||||
} else {
|
||||
flIconBg.setBackgroundResource(R.drawable.shape_f5f4fa_8dp_round);
|
||||
}
|
||||
|
||||
Map<String, Object> localExtension = message.getLocalExtension();
|
||||
boolean isSend = false;
|
||||
if (localExtension != null && localExtension.containsKey(IS_SEND)) {
|
||||
isSend = (boolean) localExtension.get(IS_SEND);
|
||||
}
|
||||
boolean isAskFor = attachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_FAIRY_ASK_FOR;
|
||||
|
||||
if (isAskFor && attachment.getUid() != AuthModel.get().getCurrentUid()) {
|
||||
if (!isSend && isAskFor && attachment.getUid() != AuthModel.get().getCurrentUid()) {
|
||||
tvView.setVisibility(View.VISIBLE);
|
||||
contentContainer.setOnClickListener(this);
|
||||
} else {
|
||||
@@ -77,6 +86,15 @@ public class MsgViewHolderFairy extends MsgViewHolderBase implements View.OnClic
|
||||
bundle.putSerializable("userInfo", userInfo);
|
||||
bundle.putSerializable("fairyInfo", fairyInfo);
|
||||
bundle.putBoolean("isSend", true);
|
||||
MyFairySendDialog.Companion.newInstance(bundle, userInfo).show(context);
|
||||
MyFairySendDialog sendDialog = MyFairySendDialog.Companion.newInstance(bundle, userInfo);
|
||||
sendDialog.setOnSendListener(() -> {
|
||||
Map<String, Object> localExtension = message.getLocalExtension();
|
||||
if (localExtension == null) localExtension = new HashMap<>();
|
||||
localExtension.put(IS_SEND, true);
|
||||
message.setLocalExtension(localExtension);
|
||||
IMNetEaseManager.get().updateMessageToLocal(message);
|
||||
return null;
|
||||
});
|
||||
sendDialog.show(context);
|
||||
}
|
||||
}
|
||||
|
9
app/src/main/res/drawable/shape_007983_4dp_round.xml
Normal file
9
app/src/main/res/drawable/shape_007983_4dp_round.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#007983" />
|
||||
|
||||
<corners android:radius="4dp" />
|
||||
|
||||
</shape>
|
@@ -2,11 +2,8 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#007983" />
|
||||
<solid android:color="#00A69D" />
|
||||
|
||||
<corners android:radius="8dp" />
|
||||
|
||||
<stroke
|
||||
android:width="1px"
|
||||
android:color="#FFE8AA" />
|
||||
</shape>
|
@@ -71,7 +71,7 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/ll_resource"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -82,30 +82,36 @@
|
||||
<ImageView
|
||||
android:id="@+id/iv_resource_0"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_resource_0" />
|
||||
android:layout_height="0dp"
|
||||
android:src="@drawable/ic_resource_0"
|
||||
app:layout_constraintDimensionRatio="222:148"
|
||||
app:layout_constraintEnd_toStartOf="@id/iv_resource_1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_resource_1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_resource_1" />
|
||||
android:src="@drawable/ic_resource_1"
|
||||
app:layout_constraintDimensionRatio="222:148"
|
||||
app:layout_constraintEnd_toStartOf="@id/iv_resource_2"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_resource_0"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_resource_2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_resource_2" />
|
||||
android:src="@drawable/ic_resource_2"
|
||||
app:layout_constraintDimensionRatio="222:148"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/iv_resource_1"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -2,8 +2,8 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/layout_container"
|
||||
android:layout_width="235dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
@@ -11,7 +11,6 @@
|
||||
android:layout_width="62dp"
|
||||
android:layout_height="62dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="@drawable/shape_white_8dp_round">
|
||||
|
||||
<ImageView
|
||||
@@ -28,7 +27,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
@@ -24,16 +24,24 @@
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:background="@drawable/shape_00a69d_8dp_round">
|
||||
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/iv_fairy_icon"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:src="@drawable/default_cover"
|
||||
app:riv_border_color="#FFE8AA"
|
||||
app:riv_border_width="1px"
|
||||
app:riv_corner_radius="4dp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
|
Reference in New Issue
Block a user