弹窗整合

This commit is contained in:
18401019693 2023-12-14 17:28:49 +08:00
parent e353638ec1
commit 280920d5f0
13 changed files with 306 additions and 71 deletions

View File

@ -1,24 +1,72 @@
package com.yunbao.common.dialog; package com.yunbao.common.dialog;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.widget.Button;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.CenterPopupView; import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class ActivateEliteBattleOrderPopupWindow extends CenterPopupView { public class ActivateEliteBattleOrderPopupWindow extends CenterPopupView {
public ActivateEliteBattleOrderPopupWindow(@NonNull Context context) { private boolean elites;//是否精英战令
super(context); private String spendMoney;//花费钱
} private Button buttonWarOrder;
@Override
protected int getImplLayoutId() {
return R.layout.activate_elite_battle_order_popup;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑 public ActivateEliteBattleOrderPopupWindow(@NonNull Context context, String mSpendMoney, boolean elites) {
@Override super(context);
protected void onCreate() { this.elites = elites;
super.onCreate(); spendMoney = mSpendMoney;
} }
@Override
protected int getImplLayoutId() {
return R.layout.activate_elite_battle_order_popup;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑
@Override
protected void onCreate() {
super.onCreate();
buttonWarOrder = findViewById(R.id.button_war_order);
if (elites) {
findViewById(R.id.gift_overvalue).setVisibility(VISIBLE);
findViewById(R.id.gift_overvalue3).setVisibility(GONE);
findViewById(R.id.enjoy_image).setVisibility(GONE);
findViewById(R.id.gift_overvalue).setVisibility(VISIBLE);
} else {
findViewById(R.id.gift_overvalue).setVisibility(GONE);
findViewById(R.id.gift_overvalue3).setVisibility(VISIBLE);
findViewById(R.id.enjoy_image).setVisibility(VISIBLE);
findViewById(R.id.gift_overvalue).setVisibility(GONE);
}
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.war_order_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dialog.dismiss();
}
});
//中文按钮文字
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(spendMoney)
.append("鑽開通");
buttonWarOrder.setText(stringBuffer.toString());
ViewClicksAntiShake.clicksAntiShake(buttonWarOrder, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dialog.dismiss();
new XPopup.Builder(getContext())
.enableDrag(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34))
.asCustom(new LiberalBattlePassPopupWindow(getContext(), spendMoney, elites))
.show();
}
});
}
} }

View File

@ -0,0 +1,59 @@
package com.yunbao.common.dialog;
import android.content.Context;
import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.R;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class LiberalBattlePassPopupWindow extends CenterPopupView {
private String spendMoney;//花费钱
private boolean mElites;//是否精英战令
private TextView liberalBattlePass;
public LiberalBattlePassPopupWindow(@NonNull Context context, String mSpendMoney, boolean elites) {
super(context);
spendMoney = mSpendMoney;
mElites = elites;
}
protected int getImplLayoutId() {
return R.layout.liberal_battle_pass_popup;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑
@Override
protected void onCreate() {
super.onCreate();
liberalBattlePass = findViewById(R.id.liberal_battle_pass);
//中文版
StringBuffer liberalBattlePassHint = new StringBuffer();
liberalBattlePassHint.append("是否花費");
liberalBattlePassHint.append(spendMoney).append(mElites ? "鑽石開通精英戰令!" : "鑽石開通尊享戰令!");
//英文版
//设置样式
String liberalBattlePassStr = liberalBattlePassHint.toString();
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(liberalBattlePassStr);
int spendMoneyIndex = liberalBattlePassStr.indexOf(spendMoney);
int spendMoneySize = spendMoneyIndex + spendMoney.length();
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#CE2BFF")), spendMoneyIndex, spendMoneySize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
liberalBattlePass.setText(builder);
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.cancel), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dialog.dismiss();
}
});
}
}

View File

@ -1,19 +1,29 @@
package com.yunbao.common.dialog; package com.yunbao.common.dialog;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.CenterPopupView; import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
/** /**
* 升級精英/尊享戰令 * 升級精英/尊享戰令
*/ */
public class PromotionElitePopupWindow extends CenterPopupView { public class PromotionElitePopupWindow extends CenterPopupView {
public PromotionElitePopupWindow(@NonNull Context context) { private String enjoySpendMoney,quintessenceSpendMoney;//花费钱
public PromotionElitePopupWindow(@NonNull Context context, String mEnjoySpendMoney, String mQuintessenceSpendMoney) {
super(context); super(context);
enjoySpendMoney = mEnjoySpendMoney;
quintessenceSpendMoney = mQuintessenceSpendMoney;
} }
@Override @Override
protected int getImplLayoutId() { protected int getImplLayoutId() {
return R.layout.promotion_elite_popup; return R.layout.promotion_elite_popup;
@ -23,5 +33,33 @@ public class PromotionElitePopupWindow extends CenterPopupView {
@Override @Override
protected void onCreate() { protected void onCreate() {
super.onCreate(); super.onCreate();
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.close), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dialog.dismiss();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.button_quintessence), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dialog.dismiss();
new XPopup.Builder(getContext())
.enableDrag(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34))
.asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), quintessenceSpendMoney, true))
.show();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.button_enjoy), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dialog.dismiss();
new XPopup.Builder(getContext())
.enableDrag(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34))
.asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), enjoySpendMoney, false))
.show();
}
});
} }
} }

View File

@ -1,18 +1,38 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="300dp" android:layout_height="291dp"
android:layout_marginStart="17dp" android:layout_marginStart="17dp"
android:layout_marginEnd="17dp" android:layout_marginEnd="17dp"
android:background="@drawable/background_order_dialog" android:background="@drawable/background_order_dialog"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/war_order_close"
android:layout_width="19dp"
android:layout_height="19dp"
android:layout_gravity="end"
android:layout_marginTop="14dp"
android:layout_marginEnd="14dp"
android:src="@mipmap/icon_sud_rule_close" />
<ImageView
android:id="@+id/elites_image"
android:layout_width="211dp" android:layout_width="211dp"
android:layout_height="27dp" android:layout_height="27dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="39dp" android:layout_marginTop="3dp"
android:src="@mipmap/icon_activate_the_elite_battle_order" /> android:src="@mipmap/icon_activate_the_elite_battle_order"
android:visibility="gone" />
<ImageView
android:id="@+id/enjoy_image"
android:layout_width="211dp"
android:layout_height="27dp"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:src="@mipmap/icon_enjoy_image"
android:visibility="visible" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -34,12 +54,24 @@
android:src="@mipmap/icon_war_order_diamond" /> android:src="@mipmap/icon_war_order_diamond" />
<TextView <TextView
android:id="@+id/gift_overvalue"
android:layout_width="71dp" android:layout_width="71dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:gravity="center" android:gravity="center"
android:text="@string/gift_overvalue" android:text="@string/gift_overvalue"
android:textColor="#CE2BFF" android:textColor="#CE2BFF"
android:textSize="14sp"
android:visibility="gone" />
<TextView
android:id="@+id/gift_overvalue3"
android:layout_width="71dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:text="@string/gift_overvalue3"
android:textColor="#CE2BFF"
android:textSize="14sp" /> android:textSize="14sp" />
</LinearLayout> </LinearLayout>
@ -97,8 +129,13 @@
android:textSize="13sp" /> android:textSize="13sp" />
<Button <Button
android:layout_width="152dp" android:id="@+id/button_war_order"
android:layout_height="72dp" android:layout_width="150dp"
android:layout_height="48dp"
android:textSize="15sp"
android:textColor="@color/white"
android:textStyle="bold"
android:gravity="center"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:background="@mipmap/button_war_order" /> android:background="@mipmap/button_war_order" />

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="218dp"
android:layout_marginStart="22dp"
android:layout_marginEnd="22dp"
android:background="@drawable/background_order_dialog"
android:orientation="vertical">
<TextView
android:id="@+id/liberal_battle_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="73dp"
android:text="liberal_battle_pass2"
android:textColor="#0D21B2"
android:textSize="16sp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="57dp">
<Button
android:id="@+id/cancel"
android:layout_width="116dp"
android:layout_height="38dp"
android:layout_marginStart="19dp"
android:background="@mipmap/button_liberal_battle_cancel"
android:gravity="center"
android:text="@string/cancel"
android:textColor="#FFFFFF"
android:textSize="14sp" />
<Button
android:layout_width="116dp"
android:layout_height="38dp"
android:layout_gravity="end"
android:layout_marginEnd="19dp"
android:background="@mipmap/button_liberal_battle_sure"
android:gravity="center"
android:text="@string/confirm"
android:textColor="#E03600"
android:textSize="14sp" />
</FrameLayout>
</LinearLayout>

View File

@ -8,6 +8,7 @@
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/close"
android:layout_width="19dp" android:layout_width="19dp"
android:layout_height="19dp" android:layout_height="19dp"
android:layout_gravity="end" android:layout_gravity="end"
@ -40,12 +41,14 @@
android:layout_marginTop="30dp"> android:layout_marginTop="30dp">
<Button <Button
android:id="@+id/button_quintessence"
android:layout_width="116dp" android:layout_width="116dp"
android:layout_height="38dp" android:layout_height="38dp"
android:layout_marginStart="34dp" android:layout_marginStart="34dp"
android:background="@mipmap/button_quintessence" /> android:background="@mipmap/button_quintessence" />
<Button <Button
android:id="@+id/button_enjoy"
android:layout_width="116dp" android:layout_width="116dp"
android:layout_height="38dp" android:layout_height="38dp"
android:layout_gravity="end" android:layout_gravity="end"

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -1406,6 +1406,8 @@ Limited ride And limited avatar frame</string>
<string name="rule_of_war_hint6">6.活動最終解釋權歸PDLIVE所有。</string> <string name="rule_of_war_hint6">6.活動最終解釋權歸PDLIVE所有。</string>
<string name="more_integral">更多積分</string> <string name="more_integral">更多積分</string>
<string name="gift_overvalue">禮物價值超 200%</string> <string name="gift_overvalue">禮物價值超 200%</string>
<string name="gift_overvalue3">禮物價值超 300%</string>
<string name="unlock_more_gifts">解鎖更多禮物 和全套珍稀裝扮</string> <string name="unlock_more_gifts">解鎖更多禮物 和全套珍稀裝扮</string>
<string name="has_reached_level_after_opening">開通后已達到等級的獎勵將會自動解鎖!</string> <string name="has_reached_level_after_opening">開通后已達到等級的獎勵將會自動解鎖!</string>
</resources> </resources>

View File

@ -35,6 +35,7 @@ import com.yunbao.common.Constants;
import com.yunbao.common.HtmlConfig; import com.yunbao.common.HtmlConfig;
import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.dialog.ActivateEliteBattleOrderPopupWindow; import com.yunbao.common.dialog.ActivateEliteBattleOrderPopupWindow;
import com.yunbao.common.dialog.LiberalBattlePassPopupWindow;
import com.yunbao.common.dialog.PromotionElitePopupWindow; import com.yunbao.common.dialog.PromotionElitePopupWindow;
import com.yunbao.common.dialog.RuleOfWarPopupWindow; import com.yunbao.common.dialog.RuleOfWarPopupWindow;
import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.event.JavascriptInterfaceEvent;
@ -388,60 +389,57 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
.setAnchorAvatar(json.getString("avatar")) .setAnchorAvatar(json.getString("avatar"))
.showDialog(); .showDialog();
} else if (TextUtils.equals(event.getMethod(), "postWeakBalance")) { } else if (TextUtils.equals(event.getMethod(), "postWeakBalance")) {
new XPopup.Builder(mContext)
.enableDrag(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
.asCustom(new ActivateEliteBattleOrderPopupWindow(mContext)) .show();
// LiveNetManager.get(mContext).
// getCoolConfig(new com.yunbao.common.http.base.HttpCallback<CoolConfig>() { LiveNetManager.get(mContext).
// @Override getCoolConfig(new com.yunbao.common.http.base.HttpCallback<CoolConfig>() {
// public void onSuccess(CoolConfig data) { @Override
// new XPopup.Builder(mContext) public void onSuccess(CoolConfig data) {
// .enableDrag(false) new XPopup.Builder(mContext)
// .maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34)) .enableDrag(false)
// .asCustom(new CinemaTicketPopupWindow(mContext, data.setTicketCount(event.getCoolConfig().getTicketCount()), new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() { .maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
// @Override .asCustom(new CinemaTicketPopupWindow(mContext, data.setTicketCount(event.getCoolConfig().getTicketCount()), new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() {
// public void onCallBack(String data) { @Override
// if (TextUtils.equals(data, "2")) { public void onCallBack(String data) {
// DialogUitl.showSimpleDialog(mContext, mContext.getString(com.yunbao.live.R.string.live_coin_not_enough), false, if (TextUtils.equals(data, "2")) {
// new DialogUitl.SimpleCallback2() { DialogUitl.showSimpleDialog(mContext, mContext.getString(com.yunbao.live.R.string.live_coin_not_enough), false,
// @Override new DialogUitl.SimpleCallback2() {
// public void onConfirmClick(Dialog dialog, String content) { @Override
// mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1)); public void onConfirmClick(Dialog dialog, String content) {
// } mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
// }
// @Override
// public void onCancelClick() { @Override
// public void onCancelClick() {
// }
// }); }
// } else if (TextUtils.equals(data, "1")) { });
// mWebView.post(new Runnable() { } else if (TextUtils.equals(data, "1")) {
// @Override mWebView.post(new Runnable() {
// public void run() { @Override
// public void run() {
// NativeCallbackModel model = new NativeCallbackModel();
// model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); NativeCallbackModel model = new NativeCallbackModel();
// String nativeJson = new JsonUtil().toJson(model); model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
// mWebView.evaluateJavascript("javascript:nativeCallback('" + nativeJson + "')", new ValueCallback<String>() { String nativeJson = new JsonUtil().toJson(model);
// @Override mWebView.evaluateJavascript("javascript:nativeCallback('" + nativeJson + "')", new ValueCallback<String>() {
// public void onReceiveValue(String value) { @Override
// } public void onReceiveValue(String value) {
// }); }
// });
// }
// }); }
// } });
// }
// }
// })).show(); }
// } })).show();
// }
// @Override
// public void onError (String error){ @Override
// ToastUtil.show(error); public void onError (String error){
// } ToastUtil.show(error);
}
// }); // });
} }