diff --git a/common/src/main/java/com/yunbao/common/bean/PrankGiftBean.java b/common/src/main/java/com/yunbao/common/bean/PrankGiftBean.java index a7e6c95a7..ff79d641e 100644 --- a/common/src/main/java/com/yunbao/common/bean/PrankGiftBean.java +++ b/common/src/main/java/com/yunbao/common/bean/PrankGiftBean.java @@ -56,4 +56,15 @@ public class PrankGiftBean extends BaseModel{ public void setGiftId(String giftId) { this.giftId = giftId; } + + @Override + public String toString() { + return "PrankGiftBean{" + + "title='" + title + '\'' + + ", name='" + name + '\'' + + ", icon='" + icon + '\'' + + ", num=" + num + + ", giftId='" + giftId + '\'' + + '}'; + } } diff --git a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java index f13262a34..bfd4b2b68 100644 --- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java +++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java @@ -16,6 +16,7 @@ import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; import com.yunbao.common.R; +import com.yunbao.common.interfaces.OnItemClickListener; import java.io.File; @@ -226,14 +227,20 @@ public class ImgLoader { .skipMemoryCache(SKIP_MEMORY_CACHE) .into(imageView); } - public static void displayDrawable(Context context, String url, final DrawableCallback callback) { + displayDrawable(context, url, -1, -1, callback); + } + public static void displayDrawable(Context context, String url, int width, int height, final DrawableCallback callback) { if (TextUtils.isEmpty(url) || !contextIsExist(context)) { if (callback != null) callback.onLoadFailed(); } else { - Glide.with(context).asDrawable().load(url).thumbnail(thumbnail).skipMemoryCache(SKIP_MEMORY_CACHE).into(new CustomTarget() { + RequestBuilder builder = Glide.with(context).asDrawable().load(url); + if (width != -1 && height != -1) { + builder = builder.override(width, height); + } + builder.thumbnail(thumbnail).skipMemoryCache(SKIP_MEMORY_CACHE).into(new CustomTarget() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { diff --git a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java index b49247ddd..4efea8234 100644 --- a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java +++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java @@ -96,6 +96,7 @@ public class OpenAdManager { return; } Collections.sort(data, new AdListComparator()); + data.clear(); list = data; if (isShow) { if (showType == 0) { diff --git a/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_add_gift_to.png b/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_add_gift_to.png new file mode 100644 index 000000000..6a4592ca8 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_add_gift_to.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_del.png b/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_del.png new file mode 100644 index 000000000..5608b410d Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_del.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_switch.png b/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_switch.png new file mode 100644 index 000000000..c140e0bc9 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_prank_gift_switch.png differ diff --git a/live/src/main/java/com/yunbao/live/adapter/ItemLivePrankGiftNumberAdapter.java b/live/src/main/java/com/yunbao/live/adapter/ItemLivePrankGiftNumberAdapter.java new file mode 100644 index 000000000..38c3b14fc --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/ItemLivePrankGiftNumberAdapter.java @@ -0,0 +1,79 @@ +package com.yunbao.live.adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.live.R; + +import java.util.ArrayList; +import java.util.List; + +public class ItemLivePrankGiftNumberAdapter extends RecyclerView.Adapter { + List list = new ArrayList<>(); + int selectNumber; + OnSelectNumberListener onSelectNumberListener; + + public void setOnSelectNumberListener(OnSelectNumberListener onSelectNumberListener) { + this.onSelectNumberListener = onSelectNumberListener; + } + + public void setSelectNumber(int selectNumber) { + this.selectNumber = selectNumber; + } + + public int getSelectNumber() { + return selectNumber; + } + + public void setList(List list) { + this.list = list; + notifyDataSetChanged(); + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_prank_dialog_add_gift_number, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + holder.setData(list.get(position), selectNumber); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public interface OnSelectNumberListener { + void onSelectNumber(int number); + } + + public class ViewHolder extends RecyclerView.ViewHolder { + private Button button; + + public ViewHolder(@NonNull View itemView) { + super(itemView); + button = itemView.findViewById(R.id.coin); + } + + public void setData(int number, int selectNumber) { + button.setText(String.valueOf(number)); + if (number == selectNumber) { + button.setBackgroundResource(R.drawable.bg_prank_btn_gift_add_number); + } else { + button.setBackgroundResource(R.drawable.bg_prank_coin); + } + button.setOnClickListener(view -> { + ItemLivePrankGiftNumberAdapter.this.selectNumber = number; + notifyDataSetChanged(); + }); + } + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/GiftPopDialog.java b/live/src/main/java/com/yunbao/live/dialog/GiftPopDialog.java index ac1340c5d..4694205e4 100644 --- a/live/src/main/java/com/yunbao/live/dialog/GiftPopDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/GiftPopDialog.java @@ -217,7 +217,7 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene for (int i = 0; i < list.size(); i++) { JSONObject data = list.getJSONObject(i); GiftTopBean giftTopBean = new GiftTopBean(); - giftTopBean.setName(WordUtil.isNewZh()?data.getString("name"):data.getString("en_name")); + giftTopBean.setName(WordUtil.isNewZh() ? data.getString("name") : data.getString("en_name")); name.add(giftTopBean); } @@ -265,17 +265,17 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene public void onClick(View view) { int id = view.getId(); if (id == R.id.btn_send) { - DialogUitl.showSimpleInputDialog(mContext, WordUtil.isNewZh() ?"輸入數量":"Input quantity", DialogUitl.INPUT_TYPE_NUMBER, new DialogUitl.SimpleCallback() { + DialogUitl.showSimpleInputDialog(mContext, WordUtil.isNewZh() ? "輸入數量" : "Input quantity", DialogUitl.INPUT_TYPE_NUMBER, new DialogUitl.SimpleCallback() { @Override public void onConfirmClick(Dialog dialog, String content) { try { prangNum = Integer.parseInt(content); if (prangNum <= 0) { - ToastUtil.show(WordUtil.isNewZh() ?"數量不能為0或負數":"The quantity cannot be zero or negative"); + ToastUtil.show(WordUtil.isNewZh() ? "數量不能為0或負數" : "The quantity cannot be zero or negative"); return; } if (prangNum > 999) { - ToastUtil.show(WordUtil.isNewZh() ?"數量不能大於999":"The number cannot be greater than 999"); + ToastUtil.show(WordUtil.isNewZh() ? "數量不能大於999" : "The number cannot be greater than 999"); return; } mBtnSend.setText(content); @@ -285,7 +285,7 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene dialog.dismiss(); } catch (Exception e) { e.printStackTrace(); - ToastUtil.show(WordUtil.isNewZh() ? "輸入錯誤":"Input error"); + ToastUtil.show(WordUtil.isNewZh() ? "輸入錯誤" : "Input error"); } } }); @@ -307,29 +307,29 @@ public class GiftPopDialog extends AbsDialogPopupWindow implements ActionListene }); } else if (id == R.id.gift_btn) { if (bean == null) { - ToastUtil.show(WordUtil.isNewZh() ? "整蠱禮物不能為空":"A trick gift can't be empty"); + ToastUtil.show(WordUtil.isNewZh() ? "整蠱禮物不能為空" : "A trick gift can't be empty"); return; } if (StringUtil.isEmpty(prangContext) || prangNum == 0) { - ToastUtil.show(WordUtil.isNewZh() ?"整蠱內容或數量不能為空":"The content or number of pranks cannot be empty"); + ToastUtil.show(WordUtil.isNewZh() ? "整蠱內容或數量不能為空" : "The content or number of pranks cannot be empty"); return; } if (prangNum >= 999) { - ToastUtil.show(WordUtil.isNewZh() ?"整蠱數量不能過大":"The number of pranks should not be too large"); + ToastUtil.show(WordUtil.isNewZh() ? "整蠱數量不能過大" : "The number of pranks should not be too large"); return; } if (WordUtil.isSpecialChar(prangContext)) { - ToastUtil.show(WordUtil.isNewZh() ?"整蠱內容不能包含特殊字符":"The prank content must not contain special characters"); + ToastUtil.show(WordUtil.isNewZh() ? "整蠱內容不能包含特殊字符" : "The prank content must not contain special characters"); return; } if (prangContext.length() > 6) { - ToastUtil.show(WordUtil.isNewZh() ?"整蠱內容過長":"The prank is too long"); + ToastUtil.show(WordUtil.isNewZh() ? "整蠱內容過長" : "The prank is too long"); return; } if (giftBeans != null) { for (PrankGiftBean giftBean : giftBeans) { if (giftBean.getGiftId().equals(bean.getId() + "")) { - ToastUtil.show(WordUtil.isNewZh() ?"整蠱禮物已存在":"Prank gifts already exist"); + ToastUtil.show(WordUtil.isNewZh() ? "整蠱禮物已存在" : "Prank gifts already exist"); return; } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LivePrankAddGiftDialog.java b/live/src/main/java/com/yunbao/live/dialog/LivePrankAddGiftDialog.java new file mode 100644 index 000000000..9c83768cd --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LivePrankAddGiftDialog.java @@ -0,0 +1,136 @@ +package com.yunbao.live.dialog; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.XPopup; +import com.yunbao.common.bean.PrankGiftBean; +import com.yunbao.common.dialog.AbsDialogPopupWindow; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.R; + +import java.util.ArrayList; +import java.util.List; + +public class LivePrankAddGiftDialog extends AbsDialogPopupWindow { + + private TextView prankBtn; + private ImageView backBtn; + private TextView giftText; + private TextView numberText; + private EditText contentText; + + private OnItemClickListener onItemClickListener; + + private List giftBeans = new ArrayList<>(); + + + public LivePrankAddGiftDialog(@NonNull Context context) { + super(context); + } + + @Override + public void buildDialog(XPopup.Builder builder) { + + } + + public LivePrankAddGiftDialog setGiftBeans(List giftBeans) { + this.giftBeans = giftBeans; + return this; + } + + @Override + public int bindLayoutId() { + return R.layout.dialog_live_prank_add_gift; + } + + @Override + protected void onCreate() { + super.onCreate(); + initView(); + } + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + void initView() { + prankBtn = findViewById(R.id.prank_btn); + backBtn = findViewById(R.id.back); + giftText = findViewById(R.id.gift_text); + numberText = findViewById(R.id.number_text); + contentText = findViewById(R.id.content_text); + + ViewClicksAntiShake.clicksAntiShake(giftText, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + GiftPopDialog dialog = new GiftPopDialog(mContext, new GiftPopDialog.ActionListener() { + + @Override + public void onSelectGift(PrankGiftBean bean) { + if (bean != null) { + giftText.setText(bean.getName()); + /*ImgLoader.displayDrawable(mContext, bean.getIcon(), DpUtil.dp2px(16), DpUtil.dp2px(16), new ImgLoader.DrawableCallback() { + @Override + public void onLoadSuccess(Drawable drawable) { + giftText.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); + } + + @Override + public void onLoadFailed() { + } + });*/ + giftText.setTag(bean); + } + } + + @Override + public void onDismiss() { + + } + }); + dialog.setShowNumber(false); + dialog.setList(giftBeans); + dialog.showDialog(); + } + }); + ViewClicksAntiShake.clicksAntiShake(numberText, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + new LivePrankAddGiftNumberDialog(mContext) + .setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(Integer bean, int position) { + numberText.setText(String.valueOf(bean)); + numberText.setTag(bean); + } + }) + .showDialog(); + } + }); + ViewClicksAntiShake.clicksAntiShake(prankBtn, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + PrankGiftBean bean = (PrankGiftBean) giftText.getTag(); + if (bean == null) { + ToastUtil.show(WordUtil.isNewZh() ? "整蠱禮物不能為空" : "A trick gift can't be empty"); + return; + } + if (numberText.getTag()==null){ + ToastUtil.show(WordUtil.isNewZh() ? "整蠱內容或數量不能為空" : "The content or number of pranks cannot be empty"); + return; + } + } + }); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LivePrankAddGiftNumberDialog.java b/live/src/main/java/com/yunbao/live/dialog/LivePrankAddGiftNumberDialog.java new file mode 100644 index 000000000..0ea661e09 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LivePrankAddGiftNumberDialog.java @@ -0,0 +1,137 @@ +package com.yunbao.live.dialog; + +import android.app.Dialog; +import android.content.Context; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.lxj.xpopup.XPopup; +import com.yunbao.common.bean.PrankGiftBean; +import com.yunbao.common.dialog.AbsDialogPopupWindow; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.R; +import com.yunbao.live.adapter.ItemLivePrankGiftNumberAdapter; + +import java.util.ArrayList; +import java.util.List; + +public class LivePrankAddGiftNumberDialog extends AbsDialogPopupWindow { + + private TextView prankBtn; + private ImageView backBtn; + private Button mBtnNumber; + private RecyclerView numberRecycler; + private ItemLivePrankGiftNumberAdapter mAdapter; + + private OnItemClickListener onItemClickListener; + private int giftNumber = -1; + + private List giftBeans = new ArrayList<>(); + + + public LivePrankAddGiftNumberDialog(@NonNull Context context) { + super(context); + } + + public LivePrankAddGiftNumberDialog setOnItemClickListener(OnItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + return this; + } + + @Override + public void buildDialog(XPopup.Builder builder) { + + } + + + @Override + public int bindLayoutId() { + return R.layout.dialog_live_prank_add_gift_number; + } + + @Override + protected void onCreate() { + super.onCreate(); + initView(); + initData(); + } + + @Override + protected void onDismiss() { + super.onDismiss(); + } + + void initView() { + prankBtn = findViewById(R.id.prank_btn); + backBtn = findViewById(R.id.back); + numberRecycler = findViewById(R.id.numberList); + mBtnNumber = findViewById(R.id.btnNumber); + mAdapter = new ItemLivePrankGiftNumberAdapter(); + numberRecycler.setAdapter(mAdapter); + mAdapter.setOnSelectNumberListener(number -> { + if (number > 0) { + giftNumber = number; + mBtnNumber.setText(R.string.live_prank_gift_dialog_number_btn); + } + }); + ViewClicksAntiShake.clicksAntiShake(mBtnNumber, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + DialogUitl.showSimpleInputDialog(mContext, WordUtil.isNewZh() ? "输入数量" : "Input number", DialogUitl.INPUT_TYPE_NUMBER, new DialogUitl.SimpleCallback() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + try { + int number = Integer.parseInt(content); + if (number > 0 && number < 10000) { + mBtnNumber.setText(content); + giftNumber = number; + mAdapter.setSelectNumber(-1); + mAdapter.notifyDataSetChanged(); + dialog.dismiss(); + } + } catch (Exception e) { + e.printStackTrace(); + mBtnNumber.setText(R.string.live_prank_gift_dialog_number_btn); + dialog.dismiss(); + } + } + }); + } + }); + ViewClicksAntiShake.clicksAntiShake(prankBtn, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (onItemClickListener != null) { + if (mAdapter.getSelectNumber() > 0) { + giftNumber = mAdapter.getSelectNumber(); + } + onItemClickListener.onItemClick(giftNumber, 0); + dismiss(); + } + } + }); + } + + List mList = new ArrayList<>(); + + void initData() { + mList.add(9999); + mList.add(3344); + mList.add(1314); + mList.add(520); + mList.add(88); + mList.add(68); + mList.add(10); + mList.add(8); + mList.add(1); + mAdapter.setList(mList); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java index e81a94b2c..5025be9a7 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java @@ -7,6 +7,7 @@ import android.view.Gravity; import android.view.View; import android.view.Window; import android.view.WindowManager; +import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; @@ -27,6 +28,7 @@ import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.ViewUtils; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; @@ -39,7 +41,7 @@ import java.util.Locale; public class LivePrankDialogFragment extends AbsDialogFragment implements View.OnClickListener { private TabLayout mTabLayout; - private View mTurntableConfigLayout; + private View mTurntableConfigLayout, mGiftConfigLayout; private TextView mPrankBtn; private ImageView mTurntableConfigImageView; private TextView mCoinTextView; @@ -48,7 +50,15 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O private LivePrankRecyclerAdapter recyclerAdapter; private String mLiveUid; private PrankHttpTurntableBean bean = new PrankHttpTurntableBean(); - private List giftBeans; + private List giftBeans = new ArrayList<>(); + + private TextView giftSwitch1TitleText; + private TextView giftSwitch1DescText; + private ImageView giftSwitch1Btn; + private TextView giftTypeNowText; + private TextView giftTypeTodoText; + private TextView giftTypeNowSwitchText; + private Button mBtnAddGift; public void setmLiveUid(String mLiveUid) { this.mLiveUid = mLiveUid; @@ -85,11 +95,13 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O initView(); initTab(); initTurntableData(); + initGiftConfigLayoutView(); } private void initView() { mTabLayout = (TabLayout) findViewById(R.id.prank_tabLayout); mTurntableConfigLayout = findViewById(R.id.turntable_layout); + mGiftConfigLayout = findViewById(R.id.gift_layout); mTurntableConfigImageView = (ImageView) findViewById(R.id.switch1_btn); mCoinTextView = (TextView) findViewById(R.id.switch2_btn); mPrankRecyclerView = (RecyclerView) findViewById(R.id.prank_config); @@ -108,6 +120,10 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O recyclerAdapter.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(String bean, int position) { + if (position == -2) { + showGiftDialog(); + return; + } if (recyclerAdapter.getViewTypeOfList()) { switch (position) { case 1: @@ -238,7 +254,9 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O } if ((int) tab.getTag() == 0) { mTurntableConfigLayout.setVisibility(View.VISIBLE); + mGiftConfigLayout.setVisibility(View.GONE); mPrankRecyclerView.setVisibility(View.VISIBLE); + mBtnAddGift.setVisibility(View.GONE); mGiftNotDate.setVisibility(View.GONE); recyclerAdapter.setViewType(LivePrankRecyclerAdapter.TYPE_TURNTABLE); mPrankBtn.setBackgroundResource(R.drawable.bg_live_prank_turntable_save); @@ -253,6 +271,9 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O initTurntableData(); } else { mTurntableConfigLayout.setVisibility(View.GONE); + mGiftConfigLayout.setVisibility(View.VISIBLE); + mBtnAddGift.setVisibility(View.VISIBLE); + recyclerAdapter.setViewType(LivePrankRecyclerAdapter.TYPE_GIFT); mPrankBtn.setBackgroundResource(R.drawable.bg_live_prank_gift_set); if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { @@ -279,6 +300,47 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O }); } + private void showGiftDialog() { + new LivePrankAddGiftDialog(mContext).setGiftBeans(giftBeans).showDialog(); + } + + private void initGiftConfigLayoutView() { + giftSwitch1TitleText = (TextView) findViewById(R.id.gift_switch1_title_text); + giftSwitch1DescText = (TextView) findViewById(R.id.gift_switch1_desc_text); + giftSwitch1Btn = (ImageView) findViewById(R.id.gift_switch1_btn); + giftTypeNowText = (TextView) findViewById(R.id.gift_type_now_text); + giftTypeTodoText = (TextView) findViewById(R.id.gift_type_todo); + giftTypeNowSwitchText = (TextView) findViewById(R.id.gift_type_now_switch); + mBtnAddGift = (Button) findViewById(R.id.gift_add_btn); + + ViewClicksAntiShake.clicksAntiShake(giftSwitch1Btn, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (giftSwitch1Btn.getTag().equals("true")) { + giftSwitch1Btn.setTag("false"); + giftSwitch1Btn.setImageResource(R.mipmap.special_icon_off); + } else { + giftSwitch1Btn.setTag("true"); + giftSwitch1Btn.setImageResource(R.mipmap.special_icon_on); + } + } + }); + ViewClicksAntiShake.clicksAntiShake(giftTypeNowSwitchText, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + CharSequence tmp = giftTypeNowText.getText(); + giftTypeNowText.setText(giftTypeNowSwitchText.getText()); + giftTypeNowSwitchText.setText(tmp); + } + }); + ViewClicksAntiShake.clicksAntiShake(mBtnAddGift, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + showGiftDialog(); + } + }); + } + private void initTurntableData() { LiveNetManager.get(mContext).getAnchorPrankTurntable(mLiveUid, new HttpCallback() { @Override @@ -312,17 +374,23 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O LiveNetManager.get(mContext).getPrankGiftList(mLiveUid, new HttpCallback>() { @Override public void onSuccess(List data) { - if (!data.isEmpty()) { - mGiftNotDate.setVisibility(View.GONE); - mPrankRecyclerView.setVisibility(View.VISIBLE); - recyclerAdapter.setViewType(LivePrankRecyclerAdapter.TYPE_GIFT); - giftBeans = data; - recyclerAdapter.setList(data); - recyclerAdapter.notifyDataSetChanged(); + if (data.size() < 6) { + mBtnAddGift.setVisibility(View.VISIBLE); + } else { + mBtnAddGift.setVisibility(View.GONE); + } + mGiftNotDate.setVisibility(View.GONE); + mPrankRecyclerView.setVisibility(View.VISIBLE); + recyclerAdapter.setViewType(LivePrankRecyclerAdapter.TYPE_GIFT); + giftBeans = data; + recyclerAdapter.setList(data); + recyclerAdapter.notifyDataSetChanged(); + /*if (!data.isEmpty()) { + } else { mPrankRecyclerView.setVisibility(View.GONE); mGiftNotDate.setVisibility(View.VISIBLE); - } + }*/ } @Override diff --git a/live/src/main/res/drawable/bg_prank_btn_gift_add_number.xml b/live/src/main/res/drawable/bg_prank_btn_gift_add_number.xml new file mode 100644 index 000000000..5d55567c7 --- /dev/null +++ b/live/src/main/res/drawable/bg_prank_btn_gift_add_number.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/bg_prank_gift_add_item.xml b/live/src/main/res/drawable/bg_prank_gift_add_item.xml new file mode 100644 index 000000000..abe9f2e32 --- /dev/null +++ b/live/src/main/res/drawable/bg_prank_gift_add_item.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_live_prank_add_gift.xml b/live/src/main/res/layout/dialog_live_prank_add_gift.xml new file mode 100644 index 000000000..07cadbf99 --- /dev/null +++ b/live/src/main/res/layout/dialog_live_prank_add_gift.xml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/dialog_live_prank_add_gift_number.xml b/live/src/main/res/layout/dialog_live_prank_add_gift_number.xml new file mode 100644 index 000000000..46cad6c58 --- /dev/null +++ b/live/src/main/res/layout/dialog_live_prank_add_gift_number.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + +