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

首页红包和个人中心红包领取互斥处理,
首页点击现金任务,跳转到试玩界面去
邀请赚钱弹窗增加动画,方便后面的功能开发,增加的部分代码已注释

(cherry picked from commit 1da7890)

yuanshenglan лет назад: 7
Родитель
Сommit
7cd1f2810a

+ 38 - 9
app/src/main/java/com/kfzs/duanduan/fragment/FgtPersonalCenter.java

@@ -176,7 +176,7 @@ public class FgtPersonalCenter extends BaseCompatFragment {
     @Override
     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
-        isShowRedPackage();
+      getLastUserInfo(null);
     }
 
 
@@ -188,16 +188,13 @@ public class FgtPersonalCenter extends BaseCompatFragment {
         if (userEntity == null) {
             userEntity = DataUtil.getInstance().getUserEntity();
         }
-        if (userEntity.getParent_code() != null) {
+
+        if (!userEntity.getParent_code().equals("") || (userEntity.getCreate_time_line() < 2) || (userEntity.getPackage_cate() == 1)) {
             ivRedpackage.setVisibility(View.GONE);
-            return;
         } else {
-            if (!userEntity.getParent_code().equals("") || (userEntity.getCreate_time_line() < 2) || (userEntity.getPackage_cate() == 1)) {
-                ivRedpackage.setVisibility(View.GONE);
-            } else {
-                ivRedpackage.setVisibility(View.VISIBLE);
-            }
+            ivRedpackage.setVisibility(View.VISIBLE);
         }
+
     }
 
     /**
@@ -305,6 +302,38 @@ public class FgtPersonalCenter extends BaseCompatFragment {
                 });
     }
 
+    public void getLastUserInfo(final Action1<UserEntity> action1) {
+        SheepApp.get(SheepApp.getInstance())
+                .getNetComponent()
+                .getApiService()
+                .getInfo()
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        if (action1 != null)
+                            action1.call(null);
+
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        UserEntity userEntity = baseMessage.getData(UserEntity.class);
+                        if (userEntity != null) {
+                            DataUtil.getInstance().setUserEntity(userEntity);
+                            if (!userEntity.getParent_code().equals("") || (userEntity.getCreate_time_line() < 2) || (userEntity.getPackage_cate() == 1)) {
+                                ivRedpackage.setVisibility(View.GONE);
+                            } else {
+                                ivRedpackage.setVisibility(View.VISIBLE);
+                            }
+                        }
+                     //   initUserInfo();
+                        if (action1 != null)
+                            action1.call(userEntity);
+                    }
+                });
+    }
     @Override
     public void onDestroyView() {
         super.onDestroyView();
@@ -397,7 +426,7 @@ public class FgtPersonalCenter extends BaseCompatFragment {
 
     @Override
     public void onResume() {
-        isShowRedPackage();
+       getLastUserInfo(null);
         super.onResume();
         try {
             initData();

+ 10 - 9
app/src/main/java/com/kfzs/duanduan/fragment/FgtSmallSheep.java

@@ -274,15 +274,13 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
         if (userEntity == null) {
             userEntity = DataUtil.getInstance().getUserEntity();
         }
-        if (userEntity.getParent_code() != null) {
-            return;
-        } else {
-            if (!userEntity.getParent_code().equals("") || (userEntity.getCreate_time_line() < 2) || (userEntity.getPackage_cate() == 1)) {
+//userEntity.getParent_code()获取到的不会存在null,没有时,时"",所以不用判断为null的情况
+        if (!userEntity.getParent_code().equals("") || (userEntity.getCreate_time_line() < 2) || (userEntity.getPackage_cate() == 1)) {
 
-            } else {
-                changeRedPackage(getActivity(), LayoutInflater.from(getContext()).inflate(R.layout.activity_main, null), this);
-            }
+        } else {
+            changeRedPackage(getActivity(), LayoutInflater.from(getContext()).inflate(R.layout.activity_main, null), this);
         }
+
     }
 
     /**
@@ -825,10 +823,13 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
 
     @OnClick({R.id.recharge, R.id.withdrawal, R.id.view_rob_duty,
             R.id.newbie_task, R.id.icon_img_iv, R.id.user_layout,
-            R.id.bottom_line
+            R.id.bottom_line,R.id.homepage_item_money_tv
     })
     public void onViewClicked(View view) {
         switch (view.getId()) {
+            case R.id.homepage_item_money_tv:
+                Jump2View.getInstance().goTryplayView(activity,null);
+                break;
             case R.id.withdrawal://提现
                 Jump2View.getInstance().tryGoWithdrawal(activity, userEntity);
                 break;
@@ -1456,7 +1457,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
     /**
      * popwindow消失监听类,消失恢复window透明度
      */
-      class PopDismissListener implements PopupWindow.OnDismissListener {
+    class PopDismissListener implements PopupWindow.OnDismissListener {
         Activity mActivity;
 
         public PopDismissListener(Activity activity) {

+ 14 - 4
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -268,7 +268,7 @@ public class ViewUtil {
             @Override
             public void onClick(View v) {
                 mRobTask = getTask(ivIcon, tvTitel, tvDutyMoney);
-                LogUtil.logI("抢任务---"+new Gson().toJson(mRobTask));
+                LogUtil.logI("抢任务---" + new Gson().toJson(mRobTask));
 
             }
         });
@@ -300,6 +300,7 @@ public class ViewUtil {
 
     /**
      * 设置默认方块文本
+     *
      * @param textView
      */
     public static void setDefaultText(TextView textView) {
@@ -566,6 +567,7 @@ public class ViewUtil {
         }
 
     }
+
     /**
      * 领取福利成功的对话框
      *
@@ -717,6 +719,7 @@ public class ViewUtil {
                 new StringBuilder("<html><head><meta name=\"viewport\" content=\"width=device-width,height=auto, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes\" /><style>img{max-width:100% !important;height:auto !important;}</style><style>body{max-width:100% !important;}</style></head><body>").append(content).append("</body></html>").toString()
                 , "text/html", "utf-8", null);
     }
+
     public static void loadDataWithBaseURL(WebView webView, String content) {
         webView.loadDataWithBaseURL(null,
                 new StringBuilder("<html><head><meta name=\"viewport\" content=\"width=device-width,height=auto, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes\" /><style>img{max-width:100% !important;height:auto !important;}</style><style>body{max-width:100% !important;}</style></head><body>").append(content).append("</body></html>").toString()
@@ -1315,6 +1318,12 @@ public class ViewUtil {
         final AlertDialog dialog = new AlertDialog.Builder(activity, R.style.AppTheme_Dialog_Alert)
                 .setView(dialog_parent)
                 .create();
+        Window windows = dialog.getWindow();
+        windows.setGravity(Gravity.BOTTOM); //Dialog在屏幕底部弹出来
+        WindowManager.LayoutParams layoutParams = windows.getAttributes();//获得布局属性
+        layoutParams.width = 400; //设置Dialog的宽
+        layoutParams.height = 200; //设置Dialog的高
+        windows.setWindowAnimations(R.style.Rising);//设置动画效果
 //        TextView ask_share_title = dialog_parent.findViewById(R.id.ask_share_title);
         RecyclerView ask_share_list = dialog_parent.findViewById(R.id.ask_share_list);
         GridLayoutManager gridLayoutManager = new GridLayoutManager(activity, 5);
@@ -1402,23 +1411,24 @@ public class ViewUtil {
                 textView.setBackgroundResource(R.drawable.shape_red_stroke_rectangle_no_lb);
                 textView.setTextColor(context.getResources().getColor(R.color.red_FD2D54));
                 textView.setText("现金");
-                textView.setPadding( padding2, padding1,  padding2, padding1);
+                textView.setPadding(padding2, padding1, padding2, padding1);
                 break;
             case 4:
                 textView.setVisibility(View.VISIBLE);
                 textView.setBackgroundResource(R.drawable.shape_red_f07422_stroke_retangle_no_lb);
                 textView.setTextColor(context.getResources().getColor(R.color.red_F07422));
                 textView.setText("活跃");
-                textView.setPadding( padding2, padding1,  padding2, padding1);
+                textView.setPadding(padding2, padding1, padding2, padding1);
                 break;
         }
 
     }
+
     /**
      * 获取状态栏高度
      *
-     * @return , 状态栏高度
      * @param activity
+     * @return , 状态栏高度
      */
     public static int getBarHeight(FragmentActivity activity) {
         int result = 0;

+ 6 - 0
app/src/main/res/drawable/shape_blue_stroke_withe_radius_5.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+<corners android:radius="5dp"/>
+    <solid android:color="@color/blue_2EC2F7"/>
+</shape>

+ 42 - 6
app/src/main/res/layout/ask_to_share.xml

@@ -13,18 +13,54 @@
             android:id="@+id/ask_share_title"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:padding="@dimen/content_padding_15"
             android:text="邀请好友"
             android:textColor="#ff333333"
-            android:textSize="14sp"
-            android:padding="@dimen/content_padding_15"/>
+            android:textSize="14sp" />
+<!--
+        <TextView
+            android:id="@+id/tv_copy"
+            android:layout_width="40dp"
+            android:layout_height="20dp"
+            android:layout_alignParentEnd="true"
+            android:layout_marginEnd="15dp"
+            android:layout_marginTop="20dp"
+            android:gravity="center"
+            android:text="复制"
+            android:background="@drawable/shape_blue_stroke_withe_radius_5"
+            android:textColor="@color/white" />
+
+        <TextView
+            android:id="@+id/tv_invitation_code"
+            android:layout_width="wrap_content"
+            android:layout_height="30dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="15dp"
+            android:layout_toLeftOf="@id/tv_copy"
+            android:textColor="#ff333333"
+            android:gravity="center"
+            android:text="12332" />
+
+        <TextView
+            android:id="@+id/tv_f_invatation"
+            android:layout_width="wrap_content"
+            android:layout_height="30dp"
+            android:layout_marginRight="5dp"
+            android:layout_marginTop="15dp"
+            android:layout_toLeftOf="@id/tv_invitation_code"
+            android:gravity="center"
+            android:textColor="#ff333333"
+            android:text="你的邀请码:" />-->
+
+
         <android.support.v7.widget.RecyclerView
             android:id="@+id/ask_share_list"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
             android:layout_below="@+id/ask_share_title"
-            android:layout_marginTop="20dp"
-            android:layout_marginStart="@dimen/content_padding_15"
             android:layout_marginBottom="35dp"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"/>
+            android:layout_marginStart="@dimen/content_padding_15"
+            android:layout_marginTop="20dp" />
     </RelativeLayout>
 
 </FrameLayout>

+ 1 - 1
app/src/main/res/layout/dialog_redpackage_after_invitation.xml

@@ -18,7 +18,7 @@
             android:layout_height="wrap_content"
             android:layout_centerHorizontal="true"
             android:layout_marginTop="50dp"
-            android:text="@string/congratunation"
+            android:text="    恭喜你!"
             android:textColor="#ffffe0d7"
             android:textSize="24sp" />