소스 검색

发表成功的对话框3秒后自动消失;
签到与引导页面的跳转添加

zengjiebin 7 년 전
부모
커밋
99f9e6c265

+ 14 - 0
app/src/main/java/com/sheep/gamegroup/absBase/IJump.java

@@ -0,0 +1,14 @@
+package com.sheep.gamegroup.absBase;
+
+/**
+ * Created by realicing on 2018/11/8.
+ * realicing@sina.com
+ */
+public interface IJump {
+
+    String getJump();
+
+    String getUrl();
+
+    String getTitle();
+}

+ 9 - 0
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -3,7 +3,9 @@ package com.sheep.gamegroup.model.api;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.jiuyan.samllsheep.bean.UserCenterModule;
 
+import java.util.List;
 import java.util.Map;
 
 import retrofit2.Call;
@@ -1293,8 +1295,15 @@ public interface ApiService {
      */
     @POST("app/mobile_point/recharge")
     Observable<BaseMessage> rechargeCMCC(@Body JSONObject jsonObject);
+//---------------------------start 个人中心-------------------------------------
+    /**
+     * 用户中心模块获取
+     */
+    @GET("/v1/app/user_module/")
+    Observable<BaseMessage> userModule();
 
 
+//---------------------------end 个人中心-------------------------------------
 //---------------------------start 游戏sdk相关接口-------------------------------------
 
     /**

+ 3 - 1
app/src/main/java/com/sheep/gamegroup/model/entity/HomeListEntity.java

@@ -2,12 +2,14 @@ package com.sheep.gamegroup.model.entity;
 
 import android.text.TextUtils;
 
+import com.sheep.gamegroup.absBase.IJump;
+
 /**
  * 首页list
  * Created by ljy on 2018/5/10.
  */
 
-public class HomeListEntity {
+public class HomeListEntity implements IJump {
     private String CreateTime;//	integer ($int64)创建时间,时间戳
     private String Desc;//	string描述
     private String Icon;//	string图标地址

+ 26 - 19
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -33,6 +33,7 @@ import com.kfzs.duanduan.utils.ApkUtils;
 import com.mdad.sdk.mdsdk.AdManager;
 import com.mdad.sdk.mdsdk.common.AdData;
 import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.absBase.IJump;
 import com.sheep.gamegroup.alipay.PayResult;
 import com.sheep.gamegroup.event.BigEvent;
 import com.sheep.gamegroup.event.EventTypes;
@@ -465,13 +466,13 @@ public class CommonUtil {
     public static final int JUMP_FIND_GMAE = 21;//发现中的游戏
 
     /**
-     * 点击主页HomeList跳转
+     * 点击jump跳转
      */
-    public void goNative(Context context, HomeListEntity entity, String from) {
-
-        switch (Integer.valueOf(entity.getJump())) {
+    public void goNative(Context context, IJump jump, String from) {
+        Activity activity = (Activity) context;
+        switch (Integer.valueOf(jump.getJump())) {
             case JUMP_NEW_USER_TASK://新手任务
-                DialogNewbieTaskList.tryShowDialog((Activity) context);
+                DialogNewbieTaskList.tryShowDialog(activity);
                 NEWBIE_TASK.onEvent();
                 break;
             case JUMP_TRY_PLAY://试玩赚钱
@@ -493,7 +494,7 @@ public class CommonUtil {
                 Jump2View.getInstance().goRechargeQAct(context, from);
                 break;
             case JUMP_WX_ASSIST://微信辅助
-                Jump2View.getInstance().goWeb(context, entity.getUrl(), "微信二维码辅助好友注册任务");
+                Jump2View.getInstance().goWeb(context, jump.getUrl(), "微信二维码辅助好友注册任务");
                 break;
             case JUMP_SUCCESSION_TASK://连续任务
                 Jump2View.getInstance().goSequentialTaskView(context);
@@ -502,12 +503,12 @@ public class CommonUtil {
                 Jump2View.getInstance().goSignCardAct(context, null);
                 break;
             case JUMP_H5_INNER://内部WebView加载H5
-                if (checkLongMao((Activity) context, entity))
-                    Jump2View.getInstance().goWeb(context, entity.getUrl(), entity.getTitle());
+                if (checkLongMao(activity, jump))
+                    Jump2View.getInstance().goWeb(context, jump.getUrl(), jump.getTitle());
                 break;
             case JUMP_H5_OUTER://外部浏览器加载H5
-                if (checkLongMao((Activity) context, entity))
-                    Jump2View.getInstance().goWeb(context, entity.getUrl());
+                if (checkLongMao(activity, jump))
+                    Jump2View.getInstance().goWeb(context, jump.getUrl());
                 break;
             case JUMP_GAME_TASK://游戏任务
                 Jump2View.getInstance().goGameMakeMoney(context, 0);
@@ -516,26 +517,32 @@ public class CommonUtil {
                 Jump2View.getInstance().goXianwanWeb(context, null, null);
                 break;
             case JUMP_GAME_RECHARGE://游戏代充(游戏充值)
-                Jump2View.getInstance().goGameRecharge((Activity) context, null);
+                Jump2View.getInstance().goGameRecharge(activity, null);
                 break;
             case JUMP_MI_DONG://幂动科技(简单任务)
-                Jump2View.getInstance().goMiDong((Activity) context, null);
+                Jump2View.getInstance().goMiDong(activity, null);
                 break;
             case JUMP_XIAO_MI://小米游戏列表
-                Jump2View.getInstance().goXiaomiGameList((Activity) context, null);
+                Jump2View.getInstance().goXiaomiGameList(activity, null);
                 break;
             case JUMP_EXCHANGE_CMCC://移动积分兑换
                 Jump2View.getInstance().goActExchangeCMCC(context);
                 break;
             case JUMP_YM://有米积分
-                Jump2View.getInstance().goYm((Activity) context);
+                Jump2View.getInstance().goYm(activity);
+                break;
+            case IDConstant.JUMP_SIGN_SHEEP://签到小绵羊
+                Jump2View.getInstance().goActSignSheep(activity);
+                break;
+            case IDConstant.JUMP_GUIDE_NEW_USER://新手引导图文或视频
+                Jump2View.getInstance().goActGuideNewUser(activity);
                 break;
             default:
-                String url = entity.getUrl();
+                String url = jump.getUrl();
                 if (TextUtils.isEmpty(url))
                     G.showToast(R.string.coming_soon);
                 else//有链接直接跳转内部h5
-                    Jump2View.getInstance().goWeb(context, entity.getUrl(), entity.getTitle());
+                    Jump2View.getInstance().goWeb(context, jump.getUrl(), jump.getTitle());
                 break;
 
         }
@@ -550,11 +557,11 @@ public class CommonUtil {
      * 尝试跳转到龙猫竞猜
      *
      * @param activity
-     * @param entity
+     * @param jump
      * @return 判断到已经安装,返回false
      */
-    private boolean checkLongMao(Activity activity, HomeListEntity entity) {
-        if (entity.getTitle() != null && entity.getTitle().startsWith(LONG_MAO_APP_NAME) && PackageUtil.isAppInstalled(SheepApp.getInstance(), LONG_MAO_APP_PACKAGE_NAME)) {
+    private boolean checkLongMao(Activity activity, IJump jump) {
+        if (jump.getTitle() != null && jump.getTitle().startsWith(LONG_MAO_APP_NAME) && PackageUtil.isAppInstalled(SheepApp.getInstance(), LONG_MAO_APP_PACKAGE_NAME)) {
             try {
                 PackageUtil.startApp(SheepApp.getInstance(), LONG_MAO_APP_PACKAGE_NAME);
             } catch (Exception ignore) {

+ 2 - 0
app/src/main/java/com/sheep/gamegroup/util/IDConstant.java

@@ -41,6 +41,8 @@ public class IDConstant {
     public static final int JUMP_CREDIT_CARD_WEB = 133;//跳转到信用卡web申请界面; id 信用卡信息的id
     public static final int JUMP_AUDIT_TASK_LIST = 113;//任务记录
     public static final int JUMP_TASK_DETAIL = 112;//任务详情: 任务的id
+    public static final int JUMP_SIGN_SHEEP = 301;//301:签到
+    public static final int JUMP_GUIDE_NEW_USER = 302;//302:新手引导
     //TODO 这里移动积分兑换的id需要替换
     public static final int JUMP_EXCHANGE_CMCC = 1000025;//移动积分兑换
     public static final int JUMP_YM = 1000026;//有米积分

+ 17 - 0
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -125,6 +125,8 @@ import com.sheep.jiuyan.samllsheep.service.DownloadService;
 import com.sheep.jiuyan.samllsheep.service.FloatShotScreenService;
 import com.sheep.jiuyan.samllsheep.service.ListenerShotNewService;
 import com.sheep.jiuyan.samllsheep.service.ListenerShotService;
+import com.sheep.jiuyan.samllsheep.ui.activity.SignActivity;
+import com.sheep.jiuyan.samllsheep.ui.activity.UserNavActivity;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.youmi.android.offer.BaseActYmPermissionCheck;
@@ -2145,4 +2147,19 @@ public class Jump2View {
     public void goActFindInformationComment(Activity activity, int article_id) {
         activity.startActivity(DataUtil.putObject(new Intent(activity, ActArticleComment.class), article_id));
     }
+
+    /**
+     * 签到 小绵羊
+     * @param activity
+     */
+    public void goActSignSheep(Activity activity) {
+        activity.startActivity(new Intent(activity, SignActivity.class));
+    }
+    /**
+     * 新手引导图文或视频
+     * @param activity
+     */
+    public void goActGuideNewUser(Activity activity) {
+        activity.startActivity(new Intent(activity, UserNavActivity.class));
+    }
 }

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/util/ResImageGetter.java

@@ -7,6 +7,7 @@ import android.widget.TextView;
 
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
 
 /**
  * Created by realicing on 2018/11/7.
@@ -17,7 +18,7 @@ public class ResImageGetter implements Html.ImageGetter {
     private int textSize;
 
     public ResImageGetter(TextView textView) {
-        textSize = (int) textView.getTextSize() * 3;
+        textSize = G.getRealPix(60);
     }
 
     @Override

+ 25 - 1
app/src/main/java/com/sheep/gamegroup/view/dialog/DialogSuccessUtil.java

@@ -9,6 +9,13 @@ import com.sheep.gamegroup.util.ActivityManager;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 
+import java.util.concurrent.TimeUnit;
+
+import rx.Observable;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Action1;
+import rx.schedulers.Schedulers;
+
 /**
  * Created by realicing on 2018/11/7.
  * realicing@sina.com
@@ -20,7 +27,8 @@ public class DialogSuccessUtil {
                 .setView(dialog_parent)
                 .create();
         TextView dialog_title = dialog_parent.findViewById(R.id.dialog_title);
-        dialog_parent.findViewById(R.id.dialog_close).setOnClickListener(new View.OnClickListener() {
+        final View close = dialog_parent.findViewById(R.id.dialog_close);
+        close.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 try {
@@ -37,5 +45,21 @@ public class DialogSuccessUtil {
         } catch (Exception e) {
             e.printStackTrace();
         }
+
+        //3秒后自动消失
+        Observable.just(1).delay(3, TimeUnit.SECONDS)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new Action1<Integer>() {
+                    @Override
+                    public void call(Integer integer) {
+                        try {
+                            if(dialog.isShowing())
+                                close.performClick();
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
     }
 }

+ 26 - 35
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPersonalCenter.java

@@ -31,6 +31,7 @@ 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.ListUtil;
 import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.TestUtil;
@@ -50,6 +51,7 @@ import com.trello.rxlifecycle2.android.FragmentEvent;
 
 import org.afinal.simplecache.ACache;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
@@ -218,40 +220,31 @@ public class FgtPersonalCenter extends BaseFragment {
      * 初始化用户中心模块列表
      */
     private void initUserModuleItem() {
-        Network.api().userModule()
-                .compose(Scheduler.apply(this.<List<UserCenterModule>>bindUntilEvent(FragmentEvent.DESTROY)))
-                .subscribe(new Observer<List<UserCenterModule>>() {
-                    @Override
-                    public void onSubscribe(Disposable d) {
-
-                    }
-
-                    @Override
-                    public void onNext(List<UserCenterModule> userCenterModules) {
-                        if (userCenterModules != null) {
-                            moduleLayout.setVisibility(View.VISIBLE);
-                            GridLayoutManager manager = new GridLayoutManager(getContext(), 4);
-                            BaseQuickAdapter<UserCenterModule, BaseViewHolder> adapter = new BaseQuickAdapter<UserCenterModule, BaseViewHolder>(R.layout.item_my_list_but, userCenterModules) {
-                                @Override
-                                protected void convert(BaseViewHolder helper, UserCenterModule item) {
-                                    bindUserCenterModule(helper, item);
+        SheepApp.getInstance().getNetComponent().getApiService().userModule()
+                        .subscribeOn(Schedulers.io())
+                        .observeOn(AndroidSchedulers.mainThread())
+                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                            @Override
+                            public void onNext(BaseMessage baseMessage) {
+                                ArrayList<UserCenterModule> newList = baseMessage.getDataList(UserCenterModule.class);
+                                if (!ListUtil.isEmpty(newList)) {
+                                    moduleLayout.setVisibility(View.VISIBLE);
+                                    GridLayoutManager manager = new GridLayoutManager(getContext(), 4);
+                                    BaseQuickAdapter<UserCenterModule, BaseViewHolder> adapter = new BaseQuickAdapter<UserCenterModule, BaseViewHolder>(R.layout.item_my_list_but, newList) {
+                                        @Override
+                                        protected void convert(BaseViewHolder helper, UserCenterModule item) {
+                                            bindUserCenterModule(helper, item);
+                                        }
+                                    };
+                                    moduleList.setLayoutManager(manager);
+                                    moduleList.setAdapter(adapter);
                                 }
-                            };
-                            moduleList.setLayoutManager(manager);
-                            moduleList.setAdapter(adapter);
-                        }
-                    }
+                            }
 
-                    @Override
-                    public void onError(Throwable e) {
-
-                    }
-
-                    @Override
-                    public void onComplete() {
-
-                    }
-                });
+                            @Override
+                            public void onError(BaseMessage baseMessage) {
+                            }
+                        });
     }
 
     /**
@@ -267,9 +260,7 @@ public class FgtPersonalCenter extends BaseFragment {
             helper.getView(R.id.my_item_but).setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View v) {
-                    startActivity(new Intent(getContext(), SignActivity.class));
-                    G.showToast("点击测试");
-                    // TODO: 2018/11/1 zhoujuncai: Item点击事件,跳转处理,显示隐藏等
+                    CommonUtil.getInstance().goNative(activity, item, "个人中心");
                 }
             });
         }

+ 3 - 1
app/src/main/java/com/sheep/jiuyan/samllsheep/bean/UserCenterModule.java

@@ -1,11 +1,13 @@
 package com.sheep.jiuyan.samllsheep.bean;
 
+import com.sheep.gamegroup.absBase.IJump;
+
 /**
  * Created by: zhoujuncai.
  * Created date: 2018/11/1.
  * Description: 用户中心item数据对象
  */
-public class UserCenterModule {
+public class UserCenterModule implements IJump {
 
     /**
      * display:	integer ($int64)

+ 0 - 6
app/src/main/java/com/sheep/jiuyan/samllsheep/net/map/ApiService.java

@@ -24,12 +24,6 @@ public interface ApiService {
     int TIME_OUT = 15;
 
     /**
-     * 用户中心模块获取
-     */
-    @GET("/v1/app/user_module/")
-    Observable<List<UserCenterModule>> userModule();
-
-    /**
      * 新手引导
      */
     @GET("/v1/app/user/novice_guidance")

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

@@ -36,6 +36,7 @@
                 android:layout_height="wrap_content"
                 tools:layoutManager="android.support.v7.widget.GridLayoutManager"
                 tools:listitem="@layout/item_my_list_but"
+                android:background="@color/white"
                 tools:spanCount="4" />
 
         </LinearLayout>

+ 28 - 26
app/src/main/res/layout/item_my_list_but.xml

@@ -1,46 +1,48 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/my_item_but"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:background="#ffffff"
-    android:gravity="center"
-    android:orientation="vertical"
-    android:paddingLeft="20dp"
-    android:paddingTop="10dp"
-    android:paddingRight="20dp"
-    android:paddingBottom="10dp">
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal"
+    android:paddingTop="@dimen/content_padding_10"
+    android:paddingBottom="@dimen/content_padding_10">
 
     <LinearLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:id="@+id/my_item_img_text"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="@dimen/content_padding_4"
         android:gravity="center"
         android:orientation="vertical">
 
         <ImageView
             android:id="@+id/my_item_img"
-            android:layout_width="56dp"
-            android:layout_height="56dp"
-            android:layout_marginBottom="12dp"
-            android:adjustViewBounds="true"
-            android:contentDescription="@string/image_des"
-            android:src="@drawable/ic_but_sign" />
+            android:layout_width="match_parent"
+            android:paddingStart="16dp"
+            android:paddingEnd="16dp"
+            android:layout_height="wrap_content"
+            android:scaleType="fitXY"
+            android:adjustViewBounds="true" />
 
         <TextView
             android:id="@+id/my_item_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="签到"
-            android:textColor="#333333"
+            android:layout_marginTop="15dp"
+            android:text="试玩赚钱"
+            android:textColor="@color/black_6_3"
             android:textSize="14sp" />
     </LinearLayout>
 
-    <ImageView
+    <TextView
         android:id="@+id/my_item_tag"
-        android:layout_width="wrap_content"
+        android:layout_width="35dp"
         android:layout_height="wrap_content"
-        android:layout_alignParentTop="true"
-        android:layout_alignParentEnd="true"
-        android:contentDescription="@string/image_des"
-        android:visibility="gone" />
-</RelativeLayout>
+        android:layout_toEndOf="@+id/my_item_img_text"
+        android:gravity="center"
+        android:padding="2dp"
+        android:text="试玩"
+        android:textColor="@color/black_6_3"
+        android:textSize="7sp" />
+</RelativeLayout>