浏览代码

welfare gift ui tune up

billyyoyo 5 年之前
父节点
当前提交
580b215cfb

+ 10 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/GiftBag.java

@@ -73,6 +73,8 @@ public class GiftBag {
 
     private int UpdatedAt;
 
+    private int IsVip;
+
     private String Icon;
 
     public void setId(int Id){
@@ -168,6 +170,14 @@ public class GiftBag {
         Icon = icon;
     }
 
+    public int getIsVip() {
+        return IsVip;
+    }
+
+    public void setIsVip(int isVip) {
+        IsVip = isVip;
+    }
+
     /**
      * 剩余份数
      * @return

+ 4 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActGiftDetail.java

@@ -51,6 +51,8 @@ public class ActGiftDetail extends BaseActivity {
     TextView item_download_welfare_btn_bottom;
     @BindView(R.id.item_download_welfare_line)
     View item_download_welfare_line;
+    @BindView(R.id.item_download_welfare_vip_flag)
+    View item_download_welfare_vip_flag;
 
     @Override
     protected int getLayoutId() {
@@ -81,6 +83,7 @@ public class ActGiftDetail extends BaseActivity {
         item_download_welfare_money.setVisibility(View.GONE);
         item_download_welfare_num_tv.setVisibility(View.GONE);
         item_download_welfare_btn_bottom.setVisibility(View.GONE);
+        item_download_welfare_vip_flag.setVisibility(View.GONE);
         ViewUtil.setDefaultText(item_download_welfare_name_tv);
         item_download_welfare_btn_center.setVisibility(View.VISIBLE);
 
@@ -98,6 +101,7 @@ public class ActGiftDetail extends BaseActivity {
             ViewUtil.setText(gift_detail_time, data.getGift_bag().getDateText2());
             ViewUtil.setText(gift_detail_content, data.getGift_bag().getGiftContent());
             ViewUtil.setText(gift_detail_tip, data.getGift_bag().getUseMethod());
+            ViewUtil.setVisibility(item_download_welfare_vip_flag, data.getGift_bag().getIsVip() == 1);
             if (TextUtils.isEmpty(data.getCode())) {//没有code,就视为没有领取礼包
                 item_download_welfare_btn_center.setText("领取");
                 item_download_welfare_btn_center.setOnClickListener(new View.OnClickListener() {

+ 59 - 35
app/src/main/java/com/sheep/gamegroup/view/adapter/GiftCenterAdapter.java

@@ -14,6 +14,8 @@ import com.sheep.gamegroup.model.entity.Applications;
 import com.sheep.gamegroup.model.entity.GiftBag;
 import com.sheep.gamegroup.model.entity.GiftBagApp;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.StringUtils;
@@ -44,6 +46,7 @@ import static com.sheep.gamegroup.view.adapter.WelfareAdapter.TO_REFRESH;
 public class GiftCenterAdapter extends AdbCommonRecycler<GiftBagApp> {
 
     private Action1<Integer> action1;
+
     public GiftCenterAdapter(Context context, List<GiftBagApp> list, Action1<Integer> action1) {
         super(context, list);
         this.action1 = action1;
@@ -56,17 +59,18 @@ public class GiftCenterAdapter extends AdbCommonRecycler<GiftBagApp> {
 
     @Override
     public void convert(ViewHolder holder, final GiftBagApp item) {
-        ImageView item_download_welfare_iv = (ImageView)holder.getView(R.id.item_download_welfare_iv);
-        ImageView item_download_welfare_tip_iv = (ImageView)holder.getView(R.id.item_download_welfare_tip_iv);
-        ImageView item_download_welfare_iv2 = (ImageView)holder.getView(R.id.item_download_welfare_iv2);
-        TextView item_download_welfare_name_tv = (TextView)holder.getView(R.id.item_download_welfare_name_tv);
-        TextView item_download_welfare_money = (TextView)holder.getView(R.id.item_download_welfare_money);
-        TextView item_download_welfare_num_tv = (TextView)holder.getView(R.id.item_download_welfare_num_tv);
-        TextView item_download_welfare_num_tv1 = (TextView)holder.getView(R.id.item_download_welfare_num_tv1);
-        TextView item_download_welfare_date_tv = (TextView)holder.getView(R.id.item_download_welfare_date_tv);
-        TextView item_download_welfare_btn_bottom = (TextView)holder.getView(R.id.item_download_welfare_btn_bottom);
-        TextView item_download_welfare_btn_top = (TextView)holder.getView(R.id.item_download_welfare_btn_top);
-        TextView item_download_welfare_btn_center = (TextView)holder.getView(R.id.item_download_welfare_btn_center);
+        ImageView item_download_welfare_vip_flag = (ImageView) holder.getView(R.id.item_download_welfare_vip_flag);
+        ImageView item_download_welfare_iv = (ImageView) holder.getView(R.id.item_download_welfare_iv);
+        ImageView item_download_welfare_tip_iv = (ImageView) holder.getView(R.id.item_download_welfare_tip_iv);
+        ImageView item_download_welfare_iv2 = (ImageView) holder.getView(R.id.item_download_welfare_iv2);
+        TextView item_download_welfare_name_tv = (TextView) holder.getView(R.id.item_download_welfare_name_tv);
+        TextView item_download_welfare_money = (TextView) holder.getView(R.id.item_download_welfare_money);
+        TextView item_download_welfare_num_tv = (TextView) holder.getView(R.id.item_download_welfare_num_tv);
+        TextView item_download_welfare_num_tv1 = (TextView) holder.getView(R.id.item_download_welfare_num_tv1);
+        TextView item_download_welfare_date_tv = (TextView) holder.getView(R.id.item_download_welfare_date_tv);
+        TextView item_download_welfare_btn_bottom = (TextView) holder.getView(R.id.item_download_welfare_btn_bottom);
+        TextView item_download_welfare_btn_top = (TextView) holder.getView(R.id.item_download_welfare_btn_top);
+        TextView item_download_welfare_btn_center = (TextView) holder.getView(R.id.item_download_welfare_btn_center);
         View item_download_welfare_line = holder.getView(R.id.item_download_welfare_line);
         item_download_welfare_line.setVisibility(holder.getAdapterPosition() + 1 == getItemCount() ? View.GONE : View.VISIBLE);
         item_download_welfare_money.setVisibility(View.GONE);
@@ -75,22 +79,23 @@ public class GiftCenterAdapter extends AdbCommonRecycler<GiftBagApp> {
         item_download_welfare_num_tv1.setVisibility(View.GONE);
         item_download_welfare_iv2.setVisibility(View.GONE);
         item_download_welfare_btn_center.setVisibility(View.VISIBLE);
-        if(item == null){
+        if (item == null) {
             ViewUtil.setDefaultText(item_download_welfare_name_tv);
             ViewUtil.setDefaultText(item_download_welfare_num_tv);
             ViewUtil.setDefaultText(item_download_welfare_date_tv);
             item_download_welfare_iv2.setVisibility(View.GONE);
             item_download_welfare_tip_iv.setVisibility(View.GONE);
-        } else if(context instanceof Activity){
+        } else if (context instanceof Activity) {
             final Applications itemApp = item.getApp();
             final GiftBag itemGiftBag = item.getGift_bag();
-            if(itemApp == null || itemGiftBag == null){
+            if (itemApp == null || itemGiftBag == null) {
                 return;
             }
             GlideImageLoader.setGameImage(item_download_welfare_iv, itemApp.getIcon());
             ViewUtil.setText(item_download_welfare_name_tv, itemGiftBag.getGiftName());
             ViewUtil.setText(item_download_welfare_date_tv, itemGiftBag.getDateText());
-            if(TextUtils.isEmpty(item.getCode())){//没有code,就视为没有领取礼包
+            ViewUtil.setVisibility(item_download_welfare_vip_flag, item.getGift_bag().getIsVip() == 1);
+            if (TextUtils.isEmpty(item.getCode())) {//没有code,就视为没有领取礼包
                 item_download_welfare_tip_iv.setVisibility(View.GONE);
                 ViewUtil.setText(item_download_welfare_num_tv, itemGiftBag.getLastNumText());
                 item_download_welfare_btn_center.setText("领取");
@@ -135,34 +140,53 @@ public class GiftCenterAdapter extends AdbCommonRecycler<GiftBagApp> {
 
     /**
      * 领取礼包
+     *
      * @param activity 为空时,不显示领取成功对话框
      * @param item
      * @param action1
      */
     public static void receiveGiftBag(final Activity activity, final GiftBagApp item, final Action1<Integer> action1) {
+        if (item.getGift_bag().getIsVip() == 1) {
+            CommonUtil.getInstance().getUserInfo(true, user -> {
+                if(!user.isVIP()){
+                    ViewUtil.showConfirmDialog(activity, "温馨提示", "该礼包为VIP特权礼包,推荐您成为VIP用户,领取礼包~!",
+                            "放弃", "成为VIP", diag -> {
+                            },
+                            dialog -> Jump2View.getInstance().gotoVip(activity)).show();
+                } else {
+                    obtainGiftBag(activity, item, action1);
+                }
+            });
+
+        } else {
+            obtainGiftBag(activity, item, action1);
+        }
+    }
+
+    private static void obtainGiftBag(final Activity activity, final GiftBagApp item, final Action1<Integer> action1) {
         int gift_bag_id = item.getGift_bag().getId();
         GIFT_BAG_RECEIVE.onEvent("gift_bag_id", gift_bag_id);
         SheepApp.getInstance().getNetComponent().getApiService().receiveGiftBag(gift_bag_id)
-                        .subscribeOn(Schedulers.io())
-                        .observeOn(AndroidSchedulers.mainThread())
-                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                            @Override
-                            public void onNext(BaseMessage baseMessage) {
-                                String code = baseMessage.getData(String.class);
-                                item.setReceived(true);
-                                item.setCode(code);
-                                if(action1 != null)
-                                    action1.call(TO_REFRESH);
-                                if(activity != null)
-                                    ViewUtil.showGetWelfareDialog(activity, item);
-                            }
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        String code = baseMessage.getData(String.class);
+                        item.setReceived(true);
+                        item.setCode(code);
+                        if (action1 != null)
+                            action1.call(TO_REFRESH);
+                        if (activity != null)
+                            ViewUtil.showGetWelfareDialog(activity, item);
+                    }
 
-                            @Override
-                            public void onError(BaseMessage baseMessage) {
-                                if(action1 != null)
-                                    action1.call(RECEIVE_FAILED);
-                                G.showToast(baseMessage);
-                            }
-                        });
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        if (action1 != null)
+                            action1.call(RECEIVE_FAILED);
+                        G.showToast(baseMessage);
+                    }
+                });
     }
 }

+ 7 - 0
app/src/main/res/layout/item_download_welfare.xml

@@ -56,6 +56,13 @@
                     android:padding="5dp"
                     android:src="@mipmap/tip"
                     android:visibility="gone"/>
+                <ImageView
+                    android:id="@+id/item_download_welfare_vip_flag"
+                    android:adjustViewBounds="true"
+                    android:src="@mipmap/gift_vip"
+                    android:layout_width="16dp"
+                    android:visibility="gone"
+                    android:layout_height="wrap_content" />
             </LinearLayout>
 
             <View

二进制
app/src/main/res/mipmap-xxhdpi/gift_vip.png