Просмотр исходного кода

礼包详情页面添加领取与复制礼包码的功能

zengjiebin лет назад: 7
Родитель
Сommit
ac287bef8a

+ 24 - 13
app/src/main/java/com/sheep/gamegroup/view/activity/ActGiftDetail.java

@@ -1,16 +1,16 @@
 package com.sheep.gamegroup.view.activity;
 
+import android.text.TextUtils;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.sheep.gamegroup.absBase.BaseActivity;
-import com.sheep.gamegroup.model.entity.FriendAndAwardEntity;
 import com.sheep.gamegroup.model.entity.GiftBagApp;
-import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.gamegroup.util.StringUtils;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.view.adapter.GiftCenterAdapter;
 import com.sheep.jiuyan.samllsheep.R;
@@ -18,8 +18,8 @@ import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
 import butterknife.BindView;
-import butterknife.OnClick;
-import rx.functions.Action1;
+
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.GIFT_BAG_COPY_CODE;
 
 /**
  * Created by realicing on 2018/9/14.
@@ -76,7 +76,7 @@ public class ActGiftDetail extends BaseActivity {
         item_download_welfare_btn_bottom.setVisibility(View.GONE);
         ViewUtil.setDefaultText(item_download_welfare_name_tv);
         item_download_welfare_btn_center.setVisibility(View.VISIBLE);
-        item_download_welfare_btn_center.setText("领取");
+
     }
     private GiftBagApp data;
     @Override
@@ -89,6 +89,25 @@ 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());
+            if(TextUtils.isEmpty(data.getCode())){//没有code,就视为没有领取礼包
+                item_download_welfare_btn_center.setText("领取");
+                item_download_welfare_btn_center.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        GiftCenterAdapter.receiveGiftBag(ActGiftDetail.this, data, null);
+                    }
+                });
+            } else {
+                item_download_welfare_btn_center.setText("复制");
+                item_download_welfare_btn_center.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        GIFT_BAG_COPY_CODE.onEvent("gift_bag_id", data.getGift_bag().getId(), "gift_bag_code", data.getCode());
+                        StringUtils.CopyText(data.getCode());
+                        G.showToast("复制成功");
+                    }
+                });
+            }
         } else {
             ViewUtil.setDefaultText(item_download_welfare_name_tv);
             ViewUtil.setDefaultText(gift_detail_time);
@@ -96,13 +115,5 @@ public class ActGiftDetail extends BaseActivity {
             ViewUtil.setDefaultText(gift_detail_tip);
         }
     }
-    @OnClick(R.id.item_download_welfare_btn_center)
-    public void onViewClicked(View view) {
-        switch (view.getId()) {
-            case R.id.item_download_welfare_btn_center:
-                GiftCenterAdapter.receiveGiftBag(ActGiftDetail.this, data, null);
-                break;
-        }
-    }
 
 }

+ 1 - 0
app/src/main/res/layout/act_gift_detail.xml

@@ -2,6 +2,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:background="@color/white"
     android:orientation="vertical">
 
     <include layout="@layout/title" />