Merge branch 'dev_guard_new_ui'
@ -46,6 +46,7 @@ public class Constants {
|
|||||||
public static final String LIVE_NEAR = "liveNear";
|
public static final String LIVE_NEAR = "liveNear";
|
||||||
public static final String LIVE_CLASS_PREFIX = "liveClass_";
|
public static final String LIVE_CLASS_PREFIX = "liveClass_";
|
||||||
public static final String LIVE_ADMIN_ROOM = "liveAdminRoom";
|
public static final String LIVE_ADMIN_ROOM = "liveAdminRoom";
|
||||||
|
public static final String LIVE_ANCHER_NAME = "ancherName";//主播名
|
||||||
public static final String HAS_GAME = "hasGame";
|
public static final String HAS_GAME = "hasGame";
|
||||||
public static final String OPEN_FLASH = "openFlash";
|
public static final String OPEN_FLASH = "openFlash";
|
||||||
public static final String SHARE_QR_CODE_FILE = "shareQrCodeFile.png";
|
public static final String SHARE_QR_CODE_FILE = "shareQrCodeFile.png";
|
||||||
|
@ -55,6 +55,7 @@ import com.yunbao.live.dialog.LiveGuardBuyDialogFragment;
|
|||||||
import com.yunbao.live.dialog.LiveGuardDialogFragment;
|
import com.yunbao.live.dialog.LiveGuardDialogFragment;
|
||||||
import com.yunbao.live.dialog.LiveInputDialogFragment;
|
import com.yunbao.live.dialog.LiveInputDialogFragment;
|
||||||
import com.yunbao.live.dialog.LiveMoreDialogFragment;
|
import com.yunbao.live.dialog.LiveMoreDialogFragment;
|
||||||
|
import com.yunbao.live.dialog.LiveNewGuardBuyDialogFragment;
|
||||||
import com.yunbao.live.dialog.LiveRedPackListDialogFragment;
|
import com.yunbao.live.dialog.LiveRedPackListDialogFragment;
|
||||||
import com.yunbao.live.dialog.LiveRedPackSendDialogFragment;
|
import com.yunbao.live.dialog.LiveRedPackSendDialogFragment;
|
||||||
import com.yunbao.live.dialog.LiveShareDialogFragment;
|
import com.yunbao.live.dialog.LiveShareDialogFragment;
|
||||||
@ -1299,6 +1300,23 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
|
|||||||
fragment.show(getSupportFragmentManager(), "LiveHotDialogFragment");
|
fragment.show(getSupportFragmentManager(), "LiveHotDialogFragment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开购买新版守护的弹窗
|
||||||
|
*/
|
||||||
|
public void openNewBuyGuardWindow() {
|
||||||
|
if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream) || mLiveGuardInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LiveNewGuardBuyDialogFragment fragment = new LiveNewGuardBuyDialogFragment();
|
||||||
|
fragment.setLiveGuardInfo(mLiveGuardInfo);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(Constants.COIN_NAME, mCoinName);
|
||||||
|
bundle.putString(Constants.LIVE_UID, mLiveUid);
|
||||||
|
bundle.putString(Constants.LIVE_ANCHER_NAME, mAncherName);
|
||||||
|
bundle.putString(Constants.STREAM, mStream);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
fragment.show(getSupportFragmentManager(), "LiveGuardBuyDialogFragment");
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 打开购买守护的弹窗
|
* 打开购买守护的弹窗
|
||||||
*/
|
*/
|
||||||
|
@ -36,6 +36,9 @@ public class GuardRightAdapter extends RecyclerView.Adapter<GuardRightAdapter.Vh
|
|||||||
// mColor2 = ContextCompat.getColor(context, R.color.gray3);
|
// mColor2 = ContextCompat.getColor(context, R.color.gray3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setList(List<GuardRightBean> mList) {
|
||||||
|
this.mList = mList;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,109 @@
|
|||||||
|
package com.yunbao.live.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.yunbao.common.utils.WordUtil;
|
||||||
|
import com.yunbao.live.R;
|
||||||
|
import com.yunbao.live.bean.GuardBuyBean;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 守护购买列表适配器
|
||||||
|
*/
|
||||||
|
public class LiveNewGuardBuyItemsAdapter extends RecyclerView.Adapter<LiveNewGuardBuyItemsAdapter.Vh> {
|
||||||
|
|
||||||
|
List<GuardBuyBean> items = new ArrayList<>();
|
||||||
|
private final Context context;
|
||||||
|
private int selectId = 1;
|
||||||
|
private OnItemSelectListener itemSelect;
|
||||||
|
|
||||||
|
public LiveNewGuardBuyItemsAdapter(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(List<GuardBuyBean> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
public void setOnItemSelectListener(OnItemSelectListener listener){
|
||||||
|
this.itemSelect=listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new Vh(LayoutInflater.from(context).inflate(R.layout.item_dialog_guard_buy, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull Vh holder, int position) {
|
||||||
|
GuardBuyBean bean = items.get(position);
|
||||||
|
holder.setData(bean, bean.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeItem(int id) {
|
||||||
|
this.selectId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class Vh extends RecyclerView.ViewHolder {
|
||||||
|
private LinearLayout buyButton;
|
||||||
|
private TextView title;
|
||||||
|
private TextView msg;
|
||||||
|
private TextView coin;
|
||||||
|
|
||||||
|
public Vh(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
buyButton = itemView.findViewById(R.id.guard_buy_button);
|
||||||
|
title = itemView.findViewById(R.id.guard_buy_title);
|
||||||
|
msg = itemView.findViewById(R.id.guard_buy_goback);
|
||||||
|
coin = itemView.findViewById(R.id.guard_buy_money);
|
||||||
|
|
||||||
|
buyButton.setOnClickListener(view -> {
|
||||||
|
buyButton.setBackgroundResource(R.drawable.img_k_selected);
|
||||||
|
changeItem((int)title.getTag());
|
||||||
|
notifyDataSetChanged();
|
||||||
|
if(itemSelect!=null){
|
||||||
|
itemSelect.onSelectId((int)title.getTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setData(GuardBuyBean bean, int id) {
|
||||||
|
String coin = bean.getCoin() + "";
|
||||||
|
title.setText(bean.getName());
|
||||||
|
title.setTag(id);
|
||||||
|
String msgText = WordUtil.getString(R.string.buy_guard_back_coin);
|
||||||
|
msg.setText(msgText + coin);
|
||||||
|
this.coin.setText(coin);
|
||||||
|
if(id==selectId){
|
||||||
|
buyButton.setBackgroundResource(R.drawable.img_k_selected);
|
||||||
|
}else {
|
||||||
|
buyButton.setBackgroundResource(R.drawable.img_k_uncheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于回调通知当前选择id
|
||||||
|
*/
|
||||||
|
public interface OnItemSelectListener {
|
||||||
|
void onSelectId(int id);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ package com.yunbao.live.bean;
|
|||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.live.R;
|
import com.yunbao.live.R;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cxf on 2018/11/6.
|
* Created by cxf on 2018/11/6.
|
||||||
* 守护商品类型
|
* 守护商品类型
|
||||||
@ -67,4 +69,15 @@ public class GuardBuyBean {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GuardBuyBean{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", type=" + type +
|
||||||
|
", coin=" + coin +
|
||||||
|
", privilege=" + Arrays.toString(privilege) +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,12 @@ public class LiveGuardDialogFragment extends AbsDialogFragment implements View.O
|
|||||||
mTip = (TextView) mRootView.findViewById(R.id.tip);
|
mTip = (TextView) mRootView.findViewById(R.id.tip);
|
||||||
mBtnBuy = (TextView) mRootView.findViewById(R.id.btn_buy);
|
mBtnBuy = (TextView) mRootView.findViewById(R.id.btn_buy);
|
||||||
mBtnBuy.setOnClickListener(this);
|
mBtnBuy.setOnClickListener(this);
|
||||||
|
/* mBtnBuy.setOnLongClickListener(view -> {
|
||||||
|
//长按调用老版购买守护页面,调试用
|
||||||
|
dismiss();
|
||||||
|
((LiveActivity) mContext).openBuyGuardWindow();
|
||||||
|
return false;
|
||||||
|
});*/
|
||||||
if (mLiveGuardInfo != null) {
|
if (mLiveGuardInfo != null) {
|
||||||
mGuardNum.setText(WordUtil.getString(R.string.guard_guard) + "(" + mLiveGuardInfo.getGuardNum() + ")");
|
mGuardNum.setText(WordUtil.getString(R.string.guard_guard) + "(" + mLiveGuardInfo.getGuardNum() + ")");
|
||||||
int guardType = mLiveGuardInfo.getMyGuardType();
|
int guardType = mLiveGuardInfo.getMyGuardType();
|
||||||
@ -158,7 +164,7 @@ public class LiveGuardDialogFragment extends AbsDialogFragment implements View.O
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
dismiss();
|
dismiss();
|
||||||
((LiveActivity) mContext).openBuyGuardWindow();
|
((LiveActivity) mContext).openNewBuyGuardWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,316 @@
|
|||||||
|
package com.yunbao.live.dialog;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.yunbao.common.CommonAppConfig;
|
||||||
|
import com.yunbao.common.Constants;
|
||||||
|
import com.yunbao.common.bean.UserBean;
|
||||||
|
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||||
|
import com.yunbao.common.http.HttpCallback;
|
||||||
|
import com.yunbao.common.utils.DialogUitl;
|
||||||
|
import com.yunbao.common.utils.RouteUtil;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
import com.yunbao.common.utils.WordUtil;
|
||||||
|
import com.yunbao.live.R;
|
||||||
|
import com.yunbao.live.activity.LiveActivity;
|
||||||
|
import com.yunbao.live.adapter.GuardRightAdapter;
|
||||||
|
import com.yunbao.live.adapter.LiveNewGuardBuyItemsAdapter;
|
||||||
|
import com.yunbao.live.bean.GuardBuyBean;
|
||||||
|
import com.yunbao.live.bean.GuardRightBean;
|
||||||
|
import com.yunbao.live.bean.LiveGuardInfo;
|
||||||
|
import com.yunbao.live.http.LiveHttpConsts;
|
||||||
|
import com.yunbao.live.http.LiveHttpUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cxf on 2018/11/6.
|
||||||
|
* 直播间购买守护弹窗
|
||||||
|
* 改版后效果
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LiveNewGuardBuyDialogFragment extends AbsDialogFragment implements View.OnClickListener {
|
||||||
|
|
||||||
|
private RecyclerView mRights;//权益列表
|
||||||
|
private RecyclerView mBuys;//购买列表
|
||||||
|
private TextView anchorName;
|
||||||
|
private TextView mCoin;
|
||||||
|
private String mCoinName;
|
||||||
|
private TextView mCoinNameTextView;
|
||||||
|
private View mBtnBuy;
|
||||||
|
private List<GuardRightBean> mRightList=new ArrayList<>();//权限列表
|
||||||
|
private List<GuardBuyBean> mBuyList;//商品列表
|
||||||
|
private long mCoinVal;//余额
|
||||||
|
private String mLiveUid;
|
||||||
|
private String mStream;
|
||||||
|
private String mAncherName;
|
||||||
|
private LiveGuardInfo mLiveGuardInfo;
|
||||||
|
private GuardBuyBean mTargetBuyBean;
|
||||||
|
|
||||||
|
private LiveNewGuardBuyItemsAdapter buyItemsAdapter;
|
||||||
|
private GuardRightAdapter mGuardRightAdapter;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId() {
|
||||||
|
return R.layout.dialog_new_guard_buy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDialogStyle() {
|
||||||
|
return R.style.dialog2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canCancel() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setWindowAttributes(Window window) {
|
||||||
|
window.setWindowAnimations(R.style.bottomToTopAnim);
|
||||||
|
WindowManager.LayoutParams params = window.getAttributes();
|
||||||
|
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||||
|
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||||
|
params.gravity = Gravity.BOTTOM;
|
||||||
|
window.setAttributes(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLiveGuardInfo(LiveGuardInfo info) {
|
||||||
|
mLiveGuardInfo = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
mCoinNameTextView = mRootView.findViewById(R.id.guard_coin_name);
|
||||||
|
mCoin = mRootView.findViewById(R.id.guard_coin);
|
||||||
|
mBtnBuy = mRootView.findViewById(R.id.guard_btn_buy);
|
||||||
|
mRights = mRootView.findViewById(R.id.guard_rights);
|
||||||
|
mBuys = mRootView.findViewById(R.id.guard_buys);
|
||||||
|
anchorName = mRootView.findViewById(R.id.guard_anchor_name);
|
||||||
|
mBtnBuy.setOnClickListener(this);
|
||||||
|
mRights.setHasFixedSize(true);
|
||||||
|
mRights.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||||
|
mBuys.setHasFixedSize(true);
|
||||||
|
mBuys.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false){
|
||||||
|
@Override
|
||||||
|
public boolean canScrollHorizontally() {//购买列表禁止滑动
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mBuys.setItemViewCacheSize(3);
|
||||||
|
|
||||||
|
buyItemsAdapter = new LiveNewGuardBuyItemsAdapter(mContext);
|
||||||
|
mGuardRightAdapter = new GuardRightAdapter(mContext, mRightList);
|
||||||
|
mRights.setAdapter(mGuardRightAdapter);
|
||||||
|
mBuys.setAdapter(buyItemsAdapter);
|
||||||
|
buyItemsAdapter.setOnItemSelectListener(this::refreshList);
|
||||||
|
|
||||||
|
Bundle bundle = getArguments();
|
||||||
|
if (bundle != null) {
|
||||||
|
mLiveUid = bundle.getString(Constants.LIVE_UID);
|
||||||
|
mStream = bundle.getString(Constants.STREAM);
|
||||||
|
mAncherName=bundle.getString(Constants.LIVE_ANCHER_NAME);
|
||||||
|
String coinName = WordUtil.getString(R.string.diamond);
|
||||||
|
mCoinName = coinName;
|
||||||
|
mCoinNameTextView.setText(WordUtil.getString(R.string.guard_my) + coinName + ":");
|
||||||
|
anchorName.setText(String.format("成爲%s的守護", mAncherName));
|
||||||
|
}
|
||||||
|
LiveHttpUtil.getGuardBuyList(new HttpCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
|
if (code == 0 && info.length > 0) {
|
||||||
|
JSONObject obj = JSON.parseObject(info[0]);
|
||||||
|
mRightList = JSON.parseArray(obj.getString("privilege"), GuardRightBean.class);
|
||||||
|
mBuyList = JSON.parseArray(obj.getString("list"), GuardBuyBean.class);
|
||||||
|
try {
|
||||||
|
mCoinVal = obj.getLongValue("coin");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
mCoin.setText(String.valueOf(mCoinVal));
|
||||||
|
buyItemsAdapter.setItems(mBuyList);
|
||||||
|
mGuardRightAdapter.setList(mRightList);
|
||||||
|
buyItemsAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
refreshList(1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ToastUtil.show(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void refreshList(int index) {
|
||||||
|
if (!mRightList.isEmpty()) {
|
||||||
|
GuardBuyBean guardBuyBean = mBuyList.get(index - 1);
|
||||||
|
mTargetBuyBean=guardBuyBean;
|
||||||
|
for (GuardRightBean bean : mRightList) {
|
||||||
|
bean.setChecked(false);
|
||||||
|
}
|
||||||
|
for (int i : guardBuyBean.getPrivilege()) {
|
||||||
|
mRightList.get(i).setChecked(true);
|
||||||
|
}
|
||||||
|
mGuardRightAdapter.notifyDataSetChanged();
|
||||||
|
mBtnBuy.setEnabled(mCoinVal >= guardBuyBean.getCoin());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
int i = view.getId();
|
||||||
|
if (i == R.id.guard_btn_buy) {
|
||||||
|
clickBuyGuard();
|
||||||
|
|
||||||
|
}
|
||||||
|
// else if (i == R.id.coin) {
|
||||||
|
// forwardMyCoin();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到我的钻石
|
||||||
|
*/
|
||||||
|
private void forwardMyCoin() {
|
||||||
|
dismiss();
|
||||||
|
RouteUtil.forwardMyCoin(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击购买守护按钮
|
||||||
|
*/
|
||||||
|
private void clickBuyGuard() {
|
||||||
|
if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream) || mLiveGuardInfo == null || mTargetBuyBean == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.d("ffffff", "" + mLiveGuardInfo.getMyGuardType() + " " + mTargetBuyBean.getType());
|
||||||
|
if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_MONTH && mTargetBuyBean.getType() == Constants.GUARD_TYPE_DAY) {
|
||||||
|
DialogUitl.showSimpleTipDialog(mContext, WordUtil.getString(R.string.guard_buy_tip));
|
||||||
|
return;
|
||||||
|
} else if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_YEAR && mTargetBuyBean.getType() == Constants.GUARD_TYPE_DAY) {
|
||||||
|
DialogUitl.showSimpleTipDialog(mContext, "您為當前主播的年守護無法開通周守護");
|
||||||
|
return;
|
||||||
|
} else if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_YEAR && mTargetBuyBean.getType() == Constants.GUARD_TYPE_MONTH) {
|
||||||
|
DialogUitl.showSimpleTipDialog(mContext, "您為當前主播的年守護無法開通月守護");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_MONTH
|
||||||
|
&& mTargetBuyBean.getType() == Constants.GUARD_TYPE_YEAR) {
|
||||||
|
DialogUitl.showSimpleDialog(mContext, WordUtil.getString(R.string.guard_buy_tip_2), new DialogUitl.SimpleCallback() {
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick(Dialog dialog, String content) {
|
||||||
|
doBuyGuard();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_DAY
|
||||||
|
&& mTargetBuyBean.getType() == Constants.GUARD_TYPE_MONTH) {
|
||||||
|
DialogUitl.showSimpleDialog(mContext, "您為當前主播的周守護,開通月守護將覆蓋您的周守護時長,是否開通?", new DialogUitl.SimpleCallback() {
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick(Dialog dialog, String content) {
|
||||||
|
doBuyGuard();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else if (mLiveGuardInfo.getMyGuardType() == Constants.GUARD_TYPE_DAY
|
||||||
|
&& mTargetBuyBean.getType() == Constants.GUARD_TYPE_YEAR) {
|
||||||
|
DialogUitl.showSimpleDialog(mContext, "您為當前主播的周守護,開通年守護將覆蓋您的周守護時長,是否開通?", new DialogUitl.SimpleCallback() {
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick(Dialog dialog, String content) {
|
||||||
|
doBuyGuard();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
buyGuard();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购买守护
|
||||||
|
*/
|
||||||
|
private void buyGuard() {
|
||||||
|
if (mTargetBuyBean == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DialogUitl.showSimpleDialog(mContext,
|
||||||
|
String.format(WordUtil.getString(R.string.guard_buy_tip_3), mTargetBuyBean.getCoin(), mCoinName, mTargetBuyBean.getShopName()),
|
||||||
|
new DialogUitl.SimpleCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick(Dialog dialog, String content) {
|
||||||
|
doBuyGuard();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购买守护
|
||||||
|
*/
|
||||||
|
private void doBuyGuard() {
|
||||||
|
if (mTargetBuyBean == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LiveHttpUtil.buyGuard(mLiveUid, mStream, mTargetBuyBean.getId(), new HttpCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
|
if (code == 0 && info.length > 0) {
|
||||||
|
JSONObject obj = JSON.parseObject(info[0]);
|
||||||
|
String votes = obj.getString("votestotal");//主播当前的映票数
|
||||||
|
int guardNum = obj.getIntValue("guard_nums");//主播当前的守护人数
|
||||||
|
int guardType = obj.getIntValue("type");
|
||||||
|
String ancherName = obj.getString("ancherName");
|
||||||
|
String liveuid = obj.getString("liveuid");
|
||||||
|
if (mLiveGuardInfo != null) {
|
||||||
|
mLiveGuardInfo.setMyGuardType(guardType);
|
||||||
|
mLiveGuardInfo.setMyGuardEndTime(obj.getString("endtime"));
|
||||||
|
mLiveGuardInfo.setGuardNum(guardNum);
|
||||||
|
}
|
||||||
|
mCoinVal = obj.getLongValue("coin");
|
||||||
|
String coinString = String.valueOf(mCoinVal);
|
||||||
|
mCoin.setText(coinString);
|
||||||
|
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||||||
|
if (u != null) {
|
||||||
|
u.setCoin(coinString);
|
||||||
|
u.setLevel(obj.getIntValue("level"));
|
||||||
|
}
|
||||||
|
((LiveActivity) mContext).sendBuyGuardMessage2(votes, guardNum, guardType, ancherName, liveuid);
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
ToastUtil.show(msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
mLiveGuardInfo = null;
|
||||||
|
LiveHttpUtil.cancel(LiveHttpConsts.GET_GUARD_BUY_LIST);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
}
|
9
live/src/main/res/drawable/bg_guard_info.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:width="365dp" android:height="333dp">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="#ffffffff" />
|
||||||
|
<corners android:radius="16dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
9
live/src/main/res/drawable/bg_guard_up_title.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:width="182dp" android:height="32dp">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="#ff9e7afd" />
|
||||||
|
<corners android:radius="16dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
BIN
live/src/main/res/drawable/guardian_img_bg.png
Normal file
After Width: | Height: | Size: 656 KiB |
BIN
live/src/main/res/drawable/guardian_img_wings.png
Normal file
After Width: | Height: | Size: 251 KiB |
BIN
live/src/main/res/drawable/img_diamond.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
live/src/main/res/drawable/img_guard_bottom.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
live/src/main/res/drawable/img_k_selected.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
live/src/main/res/drawable/img_k_uncheck.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
live/src/main/res/drawable/img_venosa.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
live/src/main/res/drawable/sh_img_title.png
Normal file
After Width: | Height: | Size: 17 KiB |
@ -48,8 +48,7 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/guard_buy_2"
|
android:text="@string/guard_buy_2"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp" />
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tip"
|
android:id="@+id/tip"
|
||||||
|
184
live/src/main/res/layout/dialog_new_guard_buy.xml
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout 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="wrap_content"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:clipChildren="false">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/guard_rootView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="52dp"
|
||||||
|
android:background="@drawable/guardian_img_bg"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/guard_linearLayout"
|
||||||
|
android:layout_width="182dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:layout_marginTop="52dp"
|
||||||
|
android:layout_marginBottom="21dp"
|
||||||
|
android:background="@drawable/bg_guard_up_title"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/guard_constraintLayout"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/guard_anchor_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text=""
|
||||||
|
android:textColor="#F6F7FB"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/guard_constraintLayout"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginTop="11dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:background="@drawable/bg_guard_info"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/guard_linearLayout">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/guard_textView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/buy_guard_info"
|
||||||
|
android:textColor="#020202"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/guard_buys_layout"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="110dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/guard_textView2">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/guard_buys"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/guard_imageView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/guard_buys_layout"
|
||||||
|
app:srcCompat="@drawable/sh_img_title" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/guard_rights"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/guard_imageView2">
|
||||||
|
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/guard_relativeLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="77dp"
|
||||||
|
android:layout_marginTop="-20dp"
|
||||||
|
android:background="@drawable/img_guard_bottom"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/guard_constraintLayout">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/guard_coin_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:textColor="@color/textColor2"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/guard_coin"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_toRightOf="@id/guard_coin_name"
|
||||||
|
android:drawablePadding="4dp"
|
||||||
|
android:textColor="@color/global"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/guard_btn_buy"
|
||||||
|
android:layout_width="90dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
android:background="@drawable/bg_guard_btn_buy"
|
||||||
|
android:enabled="false"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/guard_buy"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/guard_imageView"
|
||||||
|
android:layout_width="243dp"
|
||||||
|
android:layout_height="117dp"
|
||||||
|
android:layout_above="@id/guard_rootView"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginBottom="-102dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/guardian_img_wings" />
|
||||||
|
</RelativeLayout>
|
71
live/src/main/res/layout/item_dialog_guard_buy.xml
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="107dp"
|
||||||
|
android:layout_height="109dp"
|
||||||
|
android:id="@+id/guard_buy_button"
|
||||||
|
android:background="@drawable/img_k_selected"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/guard_buy_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:text="TextView"
|
||||||
|
android:textColor="#020202"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/guard_buy_goback"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="17dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="right"
|
||||||
|
android:text="TextView"
|
||||||
|
android:textColor="#979797"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="10dp"
|
||||||
|
android:layout_height="11dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
app:srcCompat="@drawable/img_venosa" />
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_marginTop="14dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/guard_buy_money"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="17dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="right"
|
||||||
|
android:text="TextView"
|
||||||
|
android:textColor="#7C4FF9"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="17dp"
|
||||||
|
android:layout_height="13dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_weight="1"
|
||||||
|
app:srcCompat="@drawable/img_diamond" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
@ -1 +1,4 @@
|
|||||||
<resources></resources>
|
<resources>
|
||||||
|
<string name="buy_guard_info" translatable="false">成爲TA的守護,爲TA保駕護航!</string>
|
||||||
|
<string name="buy_guard_back_coin" translatable="false">返還</string>
|
||||||
|
</resources>
|
||||||
|