diff --git a/common/src/main/java/com/yunbao/common/bean/CoolConfig.java b/common/src/main/java/com/yunbao/common/bean/CoolConfig.java new file mode 100644 index 000000000..e0b7552a5 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/CoolConfig.java @@ -0,0 +1,14 @@ +package com.yunbao.common.bean; + +public class CoolConfig extends BaseModel { + private int rate; + + public int getRate() { + return rate; + } + + public CoolConfig setRate(int rate) { + this.rate = rate; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/NativeCallbackModel.java b/common/src/main/java/com/yunbao/common/bean/NativeCallbackModel.java new file mode 100644 index 000000000..742409245 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/NativeCallbackModel.java @@ -0,0 +1,14 @@ +package com.yunbao.common.bean; + +public class NativeCallbackModel extends BaseModel{ + private String uid ; + + public String getUid() { + return uid; + } + + public NativeCallbackModel setUid(String uid) { + this.uid = uid; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/dialog/CinemaTicketPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/CinemaTicketPopupWindow.java new file mode 100644 index 000000000..41ac75ff8 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/CinemaTicketPopupWindow.java @@ -0,0 +1,99 @@ +package com.yunbao.common.dialog; + +import android.content.Context; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.R; +import com.yunbao.common.bean.CoolConfig; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import java.math.BigDecimal; + +public class CinemaTicketPopupWindow extends CenterPopupView { + private CoolConfig mCoolConfig; + private TextView cinemaTicket, ticketsPlusMinus, quantityNeed; + private int ticket = 1; + private CinemaTicketPopupWindowCallBack mCinemaTicketPopupWindowCallBack; + + public CinemaTicketPopupWindow(@NonNull Context context, CoolConfig coolConfig, CinemaTicketPopupWindowCallBack cinemaTicketPopupWindowCallBack) { + super(context); + mCoolConfig = coolConfig; + mCinemaTicketPopupWindowCallBack = cinemaTicketPopupWindowCallBack; + } + + @Override + protected int getImplLayoutId() { + return R.layout.cinema_ticket_popup; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + + cinemaTicket = findViewById(R.id.cinema_ticket); + ticketsPlusMinus = findViewById(R.id.tickets_plus_minus); + quantityNeed = findViewById(R.id.quantity_need); + cinemaTicket.setText(String.valueOf(ticket)); + ticketsPlusMinus.setText(String.valueOf(ticket)); + quantityNeed.setText(new BigDecimal(ticket).multiply(new BigDecimal(mCoolConfig.getRate())).toString()); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.cinema_ticket_close), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + dialog.dismiss(); + } + }); + findViewById(R.id.sub).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + if (ticket > 1) { + ticket = ticket - 1; + cinemaTicket.setText(String.valueOf(ticket)); + ticketsPlusMinus.setText(String.valueOf(ticket)); + quantityNeed.setText(new BigDecimal(ticket).multiply(new BigDecimal(mCoolConfig.getRate())).toString()); + } + } + }); + findViewById(R.id.add).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + ticket = ticket + 1; + cinemaTicket.setText(String.valueOf(ticket)); + ticketsPlusMinus.setText(String.valueOf(ticket)); + quantityNeed.setText(new BigDecimal(ticket).multiply(new BigDecimal(mCoolConfig.getRate())).toString()); + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.cinema_ticket_exchange), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + LiveNetManager.get(getContext()) + .buyTicket(String.valueOf(ticket), new HttpCallback() { + @Override + public void onSuccess(Object data) { + + if (mCinemaTicketPopupWindowCallBack != null) { + mCinemaTicketPopupWindowCallBack.onCallBack(); + } + dialog.dismiss(); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + }); + } + + public interface CinemaTicketPopupWindowCallBack { + void onCallBack(); + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index fdcf3ad76..b0f7ca437 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -9,6 +9,7 @@ import com.yunbao.common.bean.BlindBoxInfoModel; import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.ContributeModel; +import com.yunbao.common.bean.CoolConfig; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; @@ -1081,4 +1082,13 @@ public interface PDLiveApi { Observable> viewingDurationGetGift( @Query("liveuid") String liveUid ); + + @GET("/api/public/?service=cool.config") + Observable> getCoolConfig(); + + @FormUrlEncoded + @POST("/api/public/?service=cool.buy_ticket") + Observable> buyTicket( + @Field("quantity") String quantity + ); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index b7bf69d11..e12e6c590 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -11,6 +11,7 @@ import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BlindBoxInfoModel; import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CheckRemainingBalance; +import com.yunbao.common.bean.CoolConfig; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; @@ -2407,6 +2408,51 @@ public class LiveNetManager { }).isDisposed(); } + public void getCoolConfig(HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getCoolConfig() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel coolConfigResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(coolConfigResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + + } + + public void buyTicket(String quantity, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .buyTicket(quantity) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel objectResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(null); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void quickGiftSendGift(String quickGiftNumber, String liveUid, String stream, HttpCallback callback) { API.get().pdLiveApi(mContext) .quickGiftSendGift(quickGiftNumber, liveUid, stream) diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfacePlayLetUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfacePlayLetUtils.java index 69627c998..1f7bfb453 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfacePlayLetUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfacePlayLetUtils.java @@ -6,6 +6,8 @@ import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebView; +import com.yunbao.common.event.JavascriptInterfaceEvent; + public class JavascriptInterfacePlayLetUtils { private Activity mContext; private WebView mWebView; @@ -40,6 +42,11 @@ public class JavascriptInterfacePlayLetUtils { @JavascriptInterface public void postWeakBalance(String data) { + Log.e("TAG", "postWeakBalance data==" + data); + Bus.get().post(new JavascriptInterfaceEvent() + .setMethod("postWeakBalance")); + + } } diff --git a/common/src/main/res/drawable/background_cinema_ticket_hint.xml b/common/src/main/res/drawable/background_cinema_ticket_hint.xml new file mode 100644 index 000000000..bf1eaf96a --- /dev/null +++ b/common/src/main/res/drawable/background_cinema_ticket_hint.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/common/src/main/res/layout/cinema_ticket_popup.xml b/common/src/main/res/layout/cinema_ticket_popup.xml new file mode 100644 index 000000000..58778fa45 --- /dev/null +++ b/common/src/main/res/layout/cinema_ticket_popup.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-b+en+us/backgroundn_cinema_ticket_exchange.png b/common/src/main/res/mipmap-b+en+us/backgroundn_cinema_ticket_exchange.png new file mode 100644 index 000000000..da90a6622 Binary files /dev/null and b/common/src/main/res/mipmap-b+en+us/backgroundn_cinema_ticket_exchange.png differ diff --git a/common/src/main/res/mipmap-b+en+us/icon_cinema_ticket_title.png b/common/src/main/res/mipmap-b+en+us/icon_cinema_ticket_title.png new file mode 100644 index 000000000..6520c65c5 Binary files /dev/null and b/common/src/main/res/mipmap-b+en+us/icon_cinema_ticket_title.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/backgroud_tickets_plus_minus.png b/common/src/main/res/mipmap-xxxhdpi/backgroud_tickets_plus_minus.png new file mode 100644 index 000000000..8bcf9b285 Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/backgroud_tickets_plus_minus.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/background_cinema_ticket.png b/common/src/main/res/mipmap-xxxhdpi/background_cinema_ticket.png new file mode 100644 index 000000000..c2fa2bf91 Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/background_cinema_ticket.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/backgroundn_cinema_ticket_exchange.png b/common/src/main/res/mipmap-xxxhdpi/backgroundn_cinema_ticket_exchange.png new file mode 100644 index 000000000..110da07a0 Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/backgroundn_cinema_ticket_exchange.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket.png b/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket.png new file mode 100644 index 000000000..bcb7554da Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket_close.png b/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket_close.png new file mode 100644 index 000000000..f2f8c448d Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket_close.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket_title.png b/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket_title.png new file mode 100644 index 000000000..c465bfc4d Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/icon_cinema_ticket_title.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/icon_collectibles2.png b/common/src/main/res/mipmap-xxxhdpi/icon_collectibles2.png new file mode 100644 index 000000000..977fe087d Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/icon_collectibles2.png differ diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index 4d8c78578..ea8c51a54 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -1387,5 +1387,11 @@ Limited ride And limited avatar frame 100-500 coins Above 500 coins combo X + Exchange quantity: + Need %s + Exchange&Usage Rules: + ·One star coin can be exchanged for one ticket. You can customize the exchange quantity according to your needs. Once the ticket is exchanged, it cannot be revoked. Please confirm in advance; + ·One ticket can be used to watch one episode of a short drama. After successful redemption, you can return to the viewing page and use the ticket to continue watching the movie; + ·Ticket prohibit illegal activities such as offline trading and acquisitions, and PDLIVE will crack down severely on various profit-making trading activities; diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index fda612880..6e3e7cfa5 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1384,4 +1384,10 @@ 100-500星幣 500以上星幣 連擊× + 兌換數量: + 需要 %s + 兌換&使用規則: + ·星幣兌換1張觀影券,您可以根據需求自定義兌換數量,觀影券一經兌換不可撤銷,請提前確認; + ·張觀影券可觀看一集短劇,兌換成功後即可返回觀影頁面,使用觀影券繼續觀看影片; + ·觀影券禁止線下交易、收購等不正當行為,PDLIVE將對各類以盈利為目的的交易行為進行嚴厲 打擊; diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index a29fd4693..23f344a09 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1383,4 +1383,10 @@ 100-500星幣 500以上星幣 連擊× + 兌換數量: + 需要 %s + 兌換&使用規則: + ·星幣兌換1張觀影券,您可以根據需求自定義兌換數量,觀影券一經兌換不可撤銷,請提前確認; + ·張觀影券可觀看一集短劇,兌換成功後即可返回觀影頁面,使用觀影券繼續觀看影片; + ·觀影券禁止線下交易、收購等不正當行為,PDLIVE將對各類以盈利為目的的交易行為進行嚴厲 打擊; diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index d38df75c0..15d0d1d1b 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1383,5 +1383,11 @@ 100-500星幣 500以上星幣 連擊× + 兌換數量: + 需要 %s + 兌換&使用規則: + ·星幣兌換1張觀影券,您可以根據需求自定義兌換數量,觀影券一經兌換不可撤銷,請提前確認; + ·張觀影券可觀看一集短劇,兌換成功後即可返回觀影頁面,使用觀影券繼續觀看影片; + ·觀影券禁止線下交易、收購等不正當行為,PDLIVE將對各類以盈利為目的的交易行為進行嚴厲打擊; diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 984589395..40ddae421 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1390,4 +1390,10 @@ Limited ride And limited avatar frame 100-500 coins Above 500 coins combo X + Exchange quantity: + Need %s + Exchange&Usage Rules: + ·One star coin can be exchanged for one ticket. You can customize the exchange quantity according to your needs. Once the ticket is exchanged, it cannot be revoked. Please confirm in advance; + ·One ticket can be used to watch one episode of a short drama. After successful redemption, you can return to the viewing page and use the ticket to continue watching the movie; + ·Ticket prohibit illegal activities such as offline trading and acquisitions, and PDLIVE will crack down severely on various profit-making trading activities; diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java index 505688619..d0cb74102 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java @@ -2,6 +2,7 @@ package com.yunbao.main.views; import static android.content.Context.CLIPBOARD_SERVICE; +import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -28,16 +29,23 @@ import androidx.annotation.RequiresApi; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.lxj.xpopup.XPopup; +import com.momo.mcamera.util.JsonUtil; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.HtmlConfig; +import com.yunbao.common.bean.CoolConfig; import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.NativeCallbackModel; +import com.yunbao.common.dialog.CinemaTicketPopupWindow; import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.LiveHttpUtil; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.JavascriptInterfacePlayLetUtils; import com.yunbao.common.utils.JavascriptInterfaceUtils; @@ -90,6 +98,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl Bus.getOn(this); String url = HtmlConfig.ENCOURAGE + "?t=" + Math.random() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"); +// String url = "https://coolshi.feioou.com/testAndroid.html"; final LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView); mProgressBar = (ProgressBar) findViewById(R.id.progressbar); mWebView = new WebView(mContext); @@ -214,6 +223,26 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } mWebView.loadUrl(url); + findViewById(R.id.native_callback).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mWebView.post(new Runnable() { + @Override + public void run() { + + NativeCallbackModel model = new NativeCallbackModel(); + model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); + String nativeJson = new JsonUtil().toJson(model); + mWebView.evaluateJavascript("javascript:nativeCallback('" +nativeJson + "')", new ValueCallback() { + @Override + public void onReceiveValue(String value) { + } + }); + + } + }); + } + }); } public void loadNewUrl() { @@ -360,7 +389,44 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl .setShareLink(CommonAppConfig.HOST + json.getString("link")) .setAnchorAvatar(json.getString("avatar")) .showDialog(); + } else if (TextUtils.equals(event.getMethod(), "postWeakBalance")) { + LiveNetManager.get(mContext). + getCoolConfig(new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(CoolConfig data) { + new XPopup.Builder(mContext) + .enableDrag(false) + .maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34)) + .asCustom(new CinemaTicketPopupWindow(mContext, data, new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() { + @Override + public void onCallBack() { + mWebView.post(new Runnable() { + @Override + public void run() { + + NativeCallbackModel model = new NativeCallbackModel(); + model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); + String nativeJson = new JsonUtil().toJson(model); + mWebView.evaluateJavascript("javascript:nativeCallback('" +nativeJson + "')", new ValueCallback() { + @Override + public void onReceiveValue(String value) { + } + }); + + } + }); + } + })).show(); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } } } + } diff --git a/main/src/main/res/layout/view_main_encourage.xml b/main/src/main/res/layout/view_main_encourage.xml index 770c5b814..aeda3309b 100644 --- a/main/src/main/res/layout/view_main_encourage.xml +++ b/main/src/main/res/layout/view_main_encourage.xml @@ -18,4 +18,11 @@ android:layout_height="3dp" android:progressDrawable="@drawable/bg_horizontal_progressbar" /> +