Przeglądaj źródła

bug 修改。
添加小米游戏模块

liujiangyao 7 lat temu
rodzic
commit
33d5345939

+ 3 - 0
app/src/main/AndroidManifest.xml

@@ -374,6 +374,9 @@
         <activity
             android:name="com.sheep.gamegroup.view.activity.SignRechargeAct"
             android:screenOrientation="portrait" />
+        <activity
+            android:name="com.sheep.gamegroup.view.activity.ActXiaomiGame"
+            android:screenOrientation="portrait" />
 
 
         <!--友盟start-->

+ 3 - 0
app/src/main/java/com/kfzs/duanduan/event/EventTypes.java

@@ -35,4 +35,7 @@ public enum EventTypes {
 
     //幂动科技
     REFRESH_MING_DONG,//刷新界面
+
+    REFRESH_XIAOMI_GAME_LIST,//刷新界面
+    UPDATE_BTN_STATUS,//更新小米游戏按钮状态
 }

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

@@ -698,4 +698,17 @@ public interface ApiService {
      */
     @GET("app/release_task/game_task")
     Observable<BaseMessage> releaseGameTask(@Query("page") int page, @Query("per_page") int per_page,@Query("is_hot") int is_hot, @Query("task_type") String task_type, @Query("name") String name);
+    /**
+     *获取小米游戏列表
+     * platform 1:安卓 2:IOS
+     * download_type  1:非预约下载 2:预约下载
+     */
+    @GET("app/xiaomi/list")
+    Observable<BaseMessage> xiaomiGameList(@Query("page") int page, @Query("per_page") int per_page,@Query("platform") int platform , @Query("download_type") int download_type, @Query("name") String name);
+
+    /**
+     *领取小米游戏账号
+     */
+    @POST("app/xiaomi/Receive")
+    Observable<BaseMessage> receiveXiaomiAccount(@Body JSONObject id);
 }

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

@@ -13,6 +13,16 @@ public class SearchGameRecord {
     private String input;
     @Column(name = "time")
     private long time;
+    @Column(name = "type")//1:小米游戏的数据
+    private int type;
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
 
     public String getInput() {
         return input;

+ 109 - 0
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -1,10 +1,13 @@
 package com.sheep.gamegroup.util;
 
+import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.content.Context;
+import android.content.Intent;
 import android.graphics.Color;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.GradientDrawable;
+import android.net.Uri;
 import android.os.Handler;
 import android.os.Message;
 import android.support.design.widget.TabLayout;
@@ -48,6 +51,7 @@ import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.presenter.TryMakeMoneyPresenter;
 import com.sheep.gamegroup.usage.AppUsageManager;
 import com.sheep.gamegroup.view.activity.GameTaskOrderListAct;
+import com.sheep.gamegroup.view.activity.XiaomiGameEntity;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -81,6 +85,8 @@ import rx.android.schedulers.AndroidSchedulers;
 import rx.functions.Action1;
 import rx.schedulers.Schedulers;
 
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.XIAOMI_GAME_RECEIVE;
+
 /**
  * 一些公用的class
  * Created by ljy on 2018/3/21.
@@ -1299,6 +1305,42 @@ public class CommonUtil {
                 });
     }
     /**
+     * 游戏任务
+     */
+    public void xiaomiGame(final Context context,int page,int per_page, final String name, final Action1<BaseMessage> action1) {
+        ViewUtil.newInstance().showProgress((Activity) context);
+
+        SheepApp.getInstance()
+                .getNetComponent()
+                .getApiService()
+                .xiaomiGameList(
+                        page,
+                        per_page,
+                        0,
+                        1,
+                        name)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        ViewUtil.newInstance().hideProgress((Activity) context);
+                        G.showToast(baseMessage.getMsg());
+                        if (action1 != null)
+                            action1.call(null);
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        ViewUtil.newInstance().hideProgress((Activity) context);
+
+                        if (action1 != null)
+                            action1.call(baseMessage);
+
+                    }
+                });
+    }
+    /**
      * 充值游戏游戏任务
      */
     public void gameTaskList(final Context context, final int task_type,final String name, final Action1<BaseMessage> action1) {
@@ -1444,4 +1486,71 @@ public class CommonUtil {
         }
         return false;
     }
+
+    /**
+     * 小米游戏账号领取
+     */
+    public void xiaomiRevieceAcctoun(TextView find_information_game_task_top, final XiaomiGameEntity items, final Activity activity){
+        XIAOMI_GAME_RECEIVE.onEvent();
+        find_information_game_task_top.setText("取福利号");
+        find_information_game_task_top.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("id", items.getId());
+                ViewUtil.newInstance().showProgress((Activity) activity);
+                SheepApp.getInstance()
+                        .getNetComponent()
+                        .getApiService()
+                        .receiveXiaomiAccount(jsonObject)
+                        .subscribeOn(Schedulers.io())
+                        .observeOn(AndroidSchedulers.mainThread())
+                        .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
+                            @Override
+                            public void onError(BaseMessage baseMessage) {
+                                G.showToast(baseMessage.getMsg());
+                                ViewUtil.newInstance().hideProgress((Activity) activity);
+                            }
+
+                            @SuppressLint({"StringFormatInvalid", "LocalSuppress"})
+                            @Override
+                            public void onNext(BaseMessage baseMessage) {
+                                G.showToast(baseMessage.getMsg());
+                                ViewUtil.newInstance().hideProgress(activity);
+                                String text = String.format(activity.getResources().getString(R.string.get_xiaomi_game_success_dialog),"小米账号","等带服务器开发");
+                                ViewUtil.showMsgDialog(activity,
+                                        text,
+                                        "恭喜你获得福利号",
+                                        "截图保存",
+                                        "我知道了",
+                                        new View.OnClickListener() {
+                                            @Override
+                                            public void onClick(View v) {
+                                                File file = ViewUtil.saveImage((View) v.getParent().getParent(), ClassFileHelper.DIR, System.currentTimeMillis() + ".jpg");
+                                                if (file != null) {
+                                                    Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+                                                    Uri uri = Uri.fromFile(file);
+                                                    intent.setData(uri);
+                                                    activity.sendBroadcast(intent); // 发送广播通知相册
+                                                } else {
+                                                    ViewUtil.sysSaveImage((View) v.getParent().getParent(), "小绵羊-小米", "小绵羊-小米账号");
+                                                }
+                                                G.showToast("已保存");
+                                                EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.REFRESH_MING_DONG));
+                                            }
+                                        },
+                                        new View.OnClickListener() {
+                                            @Override
+                                            public void onClick(View v) {
+
+                                                EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.REFRESH_MING_DONG));
+                                            }
+                                        });
+
+                            }
+                        });
+            }
+        });
+    }
 }

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

@@ -58,6 +58,7 @@ import com.sheep.gamegroup.view.activity.ActSetting;
 import com.sheep.gamegroup.view.activity.ActUnderstandSheep;
 import com.sheep.gamegroup.view.activity.ActUserLabelList;
 import com.sheep.gamegroup.view.activity.ActWeb;
+import com.sheep.gamegroup.view.activity.ActXiaomiGame;
 import com.sheep.gamegroup.view.activity.ActXinwanWeb;
 import com.sheep.gamegroup.view.activity.AskGetMoneyAct;
 import com.sheep.gamegroup.view.activity.BindOrChangeWeixinAct;
@@ -127,6 +128,7 @@ import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_INFO;
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_MY_MONEY;
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_NEW_VERSION;
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_TASK_RECORD;
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.XIAOMI_GAME_LIST;
 
 /**
  * Created by ljy on 2018/3/18.
@@ -1017,6 +1019,9 @@ public class Jump2View {
     }
 
     public void tryShowNewbieTask(final Activity activity, final UserEntity userEntity, final View newbie_task) {
+        if(userEntity == null){
+            return;
+        }
         if (userEntity.getIs_new() == 2){ //1新用户 2老用户
             newbie_task.setVisibility(View.GONE);
         } else {
@@ -1385,6 +1390,8 @@ public class Jump2View {
      */
     public void goGameSearch(Activity activity, Object o){
         Intent intent = new Intent(activity, ActSearchGame.class);
+        if(o instanceof Integer)
+            intent.putExtra("where_come", (Integer) o);
         activity.startActivity(intent);
         SEARCH_GAME.onEvent();
     }
@@ -1411,4 +1418,12 @@ public class Jump2View {
             MI_DONG_VIEW.onEvent();
         }
     }
+    /**
+     * 小米游戏列表
+     */
+    public void goXiaomiGameList(Activity activity, Object o){
+        Intent intent = new Intent(activity,ActXiaomiGame.class);
+        activity.startActivity(intent);
+        XIAOMI_GAME_LIST.onEvent();
+    }
 }

+ 5 - 3
app/src/main/java/com/sheep/gamegroup/util/MyDbManager.java

@@ -30,7 +30,7 @@ public class MyDbManager {
     private MyDbManager() {
         DbManager.DaoConfig daoConfig = new DbManager.DaoConfig()
                 .setDbName("sheep.db")
-                .setDbVersion(1);
+                .setDbVersion(2);
         db = x.getDb(daoConfig);
     }
 
@@ -164,9 +164,11 @@ public class MyDbManager {
         return null;
     }
 
-    public List<SearchGameRecord> getAllSearchGameRecord() {
+    public List<SearchGameRecord> getAllSearchGameRecord(int type) {
         try{
-            return db.selector(SearchGameRecord.class).findAll();
+            return db.selector(SearchGameRecord.class)
+                    .where("type","=", type)
+                    .findAll();
         }catch (Exception e){
             e.printStackTrace();
         }

+ 4 - 1
app/src/main/java/com/sheep/gamegroup/util/TestUtil.java

@@ -284,7 +284,7 @@ public class TestUtil {
      * @param activity
      */
     public static void test(final Activity activity) {
-        final String[] items = {"复制token","复制imsi","复制打点数据","测试可用金额","测试定位信息","测试apk的渠道","幂动科技","游戏搜索","游戏帐号","游戏代充","尝试开启第三方应用使用情况","测试代理页面","第三方应用使用情况",
+        final String[] items = {"小米游戏","复制token","复制imsi","复制打点数据","测试可用金额","测试定位信息","测试apk的渠道","幂动科技","游戏搜索","游戏帐号","游戏代充","尝试开启第三方应用使用情况","测试代理页面","第三方应用使用情况",
                 "开启第三方应用使用情况","h5跳转","新手对话框","md5","空间不足提示框",
                 "显示已经安装应用列表","复制faq地址","复制代理地址","复制世界杯地址","任务游戏列表","世界杯活动","交通银行信用卡测试",
                 "浦发银行信用卡测试", "测试游戏模块","打卡成功提示","定向货币详情","进入绑定身份认证界面时的提示","提交身份认证时的提示", "检查标签",
@@ -295,6 +295,9 @@ public class TestUtil {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
                         switch (items[which]) {
+                            case "小米游戏":
+                                Jump2View.getInstance().goXiaomiGameList(activity, null);
+                                break;
                             case "测试定位信息":
                                 String jsonString = LocationUtils.getInstance().getLocationJSONObject().toJSONString();
                                 G.showToast(jsonString);

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

@@ -152,6 +152,8 @@ public class UMConfigUtils {
         ORDER_MANAGER_PAY("订单管理 -> 立即支付"),//5119
         MI_DONG_VIEW("幂动科技"),//5120
         SETTING("进入设置界面"),
+        XIAOMI_GAME_LIST("小米游戏列表"),
+        XIAOMI_GAME_RECEIVE("小米游戏账号领取"),
         ;
         private String tag;
 

+ 3 - 0
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -303,6 +303,9 @@ public class ViewUtil {
     public static AlertDialog showMsgDialog(final Context context, String msg, String title) {
         return showMsgDialog(context, new DialogConfig().setMsg(msg).setTitle(title).setBtnLeftText("知道了"));
     }
+    public static AlertDialog showMsgDialog(final Context context, String msg, String title, String leftBtn, String rightBtn, View.OnClickListener onClickListener, View.OnClickListener onRightClickListener) {
+        return showMsgDialog(context, new DialogConfig().setMsg(msg).setTitle(title).setBtnLeftText(leftBtn).setBtnRightText(rightBtn).setBtnLeftOnClickListener(onClickListener).setBtnRightOnClickListener(onRightClickListener));
+    }
     public static AlertDialog showMsgDialog(final Context context, String msg, String title,boolean isFinish) {
         return showMsgDialog(context, new DialogConfig().setMsg(msg).setTitle(title).setFinish(isFinish).setBtnLeftText("知道了"));
     }

+ 128 - 63
app/src/main/java/com/sheep/gamegroup/view/activity/ActSearchGame.java

@@ -1,5 +1,9 @@
 package com.sheep.gamegroup.view.activity;
 
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
 import android.support.v7.widget.AppCompatAutoCompleteTextView;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
@@ -17,8 +21,10 @@ import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.arialyy.aria.core.download.DownloadTask;
 import com.kfzs.duanduan.event.BigEvent;
+import com.kfzs.duanduan.event.EventTypes;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.RecyleObj;
@@ -39,12 +45,14 @@ import com.sheep.gamegroup.view.adapter.ArrayAdapter;
 import com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
@@ -56,6 +64,7 @@ import rx.functions.Action1;
 import rx.schedulers.Schedulers;
 
 import static com.sheep.gamegroup.util.UMConfigUtils.Event.SEARCH_GAME_COMMIT;
+import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
 
 /**
  * Created by realicing on 2018/04/.
@@ -76,6 +85,8 @@ public class ActSearchGame extends BaseActivity {
     @BindView(R.id.download_mgr_empty_view)
     View download_mgr_empty_view;
 
+    private int type;//1:小米游戏过来
+
     @Override
     protected int getLayoutId() {
         return R.layout.act_search_game;
@@ -85,6 +96,7 @@ public class ActSearchGame extends BaseActivity {
 
     @Override
     public void initView() {
+        type = getIntent().getIntExtra("where_come", 0);
         EventBus.getDefault().register(this);
         activity = this;
         TitleBarUtils.getInstance()
@@ -115,10 +127,10 @@ public class ActSearchGame extends BaseActivity {
 //        search_game_input.setThreshold(1);
     }
 
-    private AdbCommonRecycler<TaskReleaseEty> adapter;
+    private AdbCommonRecycler<Object> adapter;
     private void initList() {
         search_game_list.setLayoutManager(new LinearLayoutManager(activity));
-        adapter = new AdbCommonRecycler<TaskReleaseEty>(activity, list) {
+        adapter = new AdbCommonRecycler<Object>(activity, list) {
 
             @Override
             public int getViewIdByType(int type) {
@@ -126,12 +138,10 @@ public class ActSearchGame extends BaseActivity {
             }
 
             @Override
-            public void convert(ViewHolder holder, final TaskReleaseEty item) {
+            public void convert(ViewHolder holder, final Object item) {
                 View itemView = holder.itemView;
-                final TaskEty taskEty;
-                if (item == null || (taskEty = item.getTask()) == null) {
+                if(item == null)
                     return;
-                }
                 ImageView find_information_game_icon = (ImageView) itemView.findViewById(R.id.find_information_game_icon);
                 TextView find_information_game_name = (TextView) itemView.findViewById(R.id.find_information_game_name);
                 TextView find_information_game_surplus = (TextView) itemView.findViewById(R.id.find_information_game_surplus);
@@ -139,21 +149,46 @@ public class ActSearchGame extends BaseActivity {
                 TextView find_information_game_yuan = (TextView) itemView.findViewById(R.id.find_information_game_yuan);
                 TextView find_information_game_task_bottom = (TextView) itemView.findViewById(R.id.find_information_game_task_bottom);
                 TextView find_information_game_task_top = (TextView) itemView.findViewById(R.id.find_information_game_task_top);
-                ViewUtil.centerImage(find_information_game_icon, taskEty.getIcon());
-                ViewUtil.setText(find_information_game_name, item.getName());
-                ViewUtil.setText(find_information_game_surplus);
-                ViewUtil.setText(find_information_game_time, taskEty.getDetailShow());
-                find_information_game_yuan.setVisibility(View.INVISIBLE);//这里必须为INVISIBLE,因为要显示两个按钮,下面的按钮位置不动
-                find_information_game_task_top.setVisibility(View.VISIBLE);
-                find_information_game_task_top.setText("立即充值");
-                find_information_game_task_top.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View view) {
-                        ViewUtil.showGamePayAccount(activity, taskEty.getThird_task_id(), item.getName());
+
+                if(item instanceof TaskReleaseEty){
+                    final TaskReleaseEty  items = (TaskReleaseEty) item;
+                    final TaskEty taskEty;
+                    if ((taskEty = items.getTask()) == null) {
+                        return;
                     }
-                });
-                item.getDownloadHelper().updateDownloadTaskView(activity, taskEty, find_information_game_task_bottom);
-                find_information_game_task_bottom.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + taskEty.getDownload_link());
+                    ViewUtil.centerImage(find_information_game_icon, taskEty.getIcon());
+                    ViewUtil.setText(find_information_game_name, items.getName());
+                    ViewUtil.setText(find_information_game_surplus);
+                    ViewUtil.setText(find_information_game_time, taskEty.getDetailShow());
+                    find_information_game_yuan.setVisibility(View.INVISIBLE);//这里必须为INVISIBLE,因为要显示两个按钮,下面的按钮位置不动
+                    find_information_game_task_top.setVisibility(View.VISIBLE);
+                    find_information_game_task_top.setText("立即充值");
+                    find_information_game_task_top.setOnClickListener(new View.OnClickListener() {
+                        @Override
+                        public void onClick(View view) {
+                            ViewUtil.showGamePayAccount(activity, taskEty.getThird_task_id(), items.getName());
+                        }
+                    });
+                    items.getDownloadHelper().updateDownloadTaskView(activity, taskEty, find_information_game_task_bottom);
+                    find_information_game_task_bottom.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + taskEty.getDownload_link());
+                }else if(item instanceof XiaomiGameEntity){
+                    final XiaomiGameEntity  items = (XiaomiGameEntity) item;
+                    ViewUtil.centerImage(find_information_game_icon, items.getIcon());
+                    ViewUtil.setText(find_information_game_name, items.getName());
+                    ViewUtil.setText(find_information_game_surplus);
+                    ViewUtil.setText(find_information_game_time, "");
+                    find_information_game_yuan.setVisibility(View.INVISIBLE);//这里必须为INVISIBLE,因为要显示两个按钮,下面的按钮位置不动
+                    find_information_game_task_top.setVisibility(View.VISIBLE);
+                    if(items.getReceive_account() == 0){//未领取账号
+                        CommonUtil.getInstance()
+                                .xiaomiRevieceAcctoun(find_information_game_task_top, items, activity);
+                    }else {
+                        items.getDownloadHelper().updateDownloadTaskView((Activity) activity, items, find_information_game_task_top);
+                        find_information_game_task_top.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + items.getDownload_url());
+                    }
+                }
+
+
             }
         };
         search_game_list.setAdapter(adapter);
@@ -223,37 +258,42 @@ public class ActSearchGame extends BaseActivity {
 
     List<SearchGameRecord> searchGameRecordList = new ArrayList<>();
     List<TaskReleaseEty> hotList = new ArrayList<>();
-    List<TaskReleaseEty> list = new ArrayList<>();
+    List<Object> list = new ArrayList<>();
 
     @Override
     public void initData() {
         //初始化搜索历史
-        List<SearchGameRecord> newSgrList = MyDbManager.getInstance().getAllSearchGameRecord();
+        List<SearchGameRecord> newSgrList = MyDbManager.getInstance().getAllSearchGameRecord(type);
         ListUtil.addAll(searchGameRecordList, newSgrList);
         inputAdapter.notifyDataSetChanged();
-        //初始化热门列表
-        SheepApp.getInstance().getNetComponent().getApiService()
-                .releaseTask(1, 9,
-                        SheepApp.getInstance().getConnectAddress().getPlatForm(), 1,
-                        0, 0,
-                        "1002,1003,1004", 3)
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
-                    @Override
-                    public void onError(BaseMessage baseMessage) {
-                        CommonUtil.getInstance().updateEmptyView(download_mgr_empty_view, true);
-                        search_game_hot.setVisibility(View.GONE);
-                        search_game_list.setVisibility(View.GONE);
-                    }
+        if(type == 1){
+            search_game_hot.setVisibility(View.GONE);
+        }else {
+            //初始化热门列表
+            SheepApp.getInstance().getNetComponent().getApiService()
+                    .releaseTask(1, 9,
+                            SheepApp.getInstance().getConnectAddress().getPlatForm(), 1,
+                            0, 0,
+                            "1002,1003,1004", 3)
+                    .subscribeOn(Schedulers.io())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
+                        @Override
+                        public void onError(BaseMessage baseMessage) {
+                            CommonUtil.getInstance().updateEmptyView(download_mgr_empty_view, true);
+                            search_game_hot.setVisibility(View.GONE);
+                            search_game_list.setVisibility(View.GONE);
+                        }
+
+                        @Override
+                        public void onNext(BaseMessage baseMessage) {
+                            List<TaskReleaseEty> newList = baseMessage.getDatas(TaskReleaseEty.class);
+                            ListUtil.addAll(hotList, newList);
+                            hotAdapter.notifyDataSetChanged();
+                        }
+                    });
+        }
 
-                    @Override
-                    public void onNext(BaseMessage baseMessage) {
-                        List<TaskReleaseEty> newList = baseMessage.getDatas(TaskReleaseEty.class);
-                        ListUtil.addAll(hotList, newList);
-                        hotAdapter.notifyDataSetChanged();
-                    }
-                });
 
     }
 
@@ -278,6 +318,7 @@ public class ActSearchGame extends BaseActivity {
         SearchGameRecord searchGameRecord = new SearchGameRecord();
         searchGameRecord.setInput(inputText);
         searchGameRecord.setTime(System.currentTimeMillis());
+        searchGameRecord.setType(type);
         MyDbManager.getInstance().saveOrUpdate(searchGameRecord);
         searchGameRecordList.add(searchGameRecord);
 //        initInput();
@@ -287,27 +328,51 @@ public class ActSearchGame extends BaseActivity {
             return;
         }
 
-        CommonUtil.getInstance()
-                .gameTask(activity, "1002,1003,1004", inputText, new Action1<BaseMessage>() {
-                    @Override
-                    public void call(BaseMessage baseMessage) {
-                        try {
-                            if(baseMessage == null){
-
-                                G.showToast("暂无游戏");
-                                list.clear();
-                                notifyDataSetChanged();
-                            }else {
-                                List<TaskReleaseEty> newList = baseMessage.getDatas(TaskReleaseEty.class);
-                                list.clear();
-                                ListUtil.addAll(list, newList);
-                                notifyDataSetChanged();
+        if(type == 1){
+            CommonUtil.getInstance()
+                    .xiaomiGame(activity,1, 100, inputText, new Action1<BaseMessage>() {
+                        @Override
+                        public void call(BaseMessage baseMessage) {
+                            try {
+                                if(baseMessage == null){
+
+                                    G.showToast("暂无游戏");
+                                    list.clear();
+                                    notifyDataSetChanged();
+                                }else {
+                                    List<XiaomiGameEntity> newList = baseMessage.getDatas(XiaomiGameEntity.class);
+                                    list.clear();
+                                    ListUtil.addAll(list, newList);
+                                    notifyDataSetChanged();
+                                }
+                            } catch (Exception e) {
+                                e.printStackTrace();
                             }
-                        } catch (Exception e) {
-                            e.printStackTrace();
                         }
-                    }
-                });
+                    });
+        }else {
+            CommonUtil.getInstance()
+                    .gameTask(activity, "1002,1003,1004", inputText, new Action1<BaseMessage>() {
+                        @Override
+                        public void call(BaseMessage baseMessage) {
+                            try {
+                                if(baseMessage == null){
+
+                                    G.showToast("暂无游戏");
+                                    list.clear();
+                                    notifyDataSetChanged();
+                                }else {
+                                    List<TaskReleaseEty> newList = baseMessage.getDatas(TaskReleaseEty.class);
+                                    list.clear();
+                                    ListUtil.addAll(list, newList);
+                                    notifyDataSetChanged();
+                                }
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    });
+        }
     }
 
     private void notifyDataSetChanged() {

+ 290 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActXiaomiGame.java

@@ -0,0 +1,290 @@
+package com.sheep.gamegroup.view.activity;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.alibaba.fastjson.JSONObject;
+import com.arialyy.aria.core.Aria;
+import com.arialyy.aria.core.download.DownloadTask;
+import com.kfzs.android.view.tag.FlowLayout;
+import com.kfzs.android.view.tag.TagAdapter;
+import com.kfzs.android.view.tag.TagFlowLayout;
+import com.kfzs.duanduan.event.BigEvent;
+import com.kfzs.duanduan.event.EventTypes;
+import com.mdad.sdk.mdsdk.AdManager;
+import com.mdad.sdk.mdsdk.GetAdListListener;
+import com.mdad.sdk.mdsdk.common.AdData;
+import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.model.entity.AdDataSon;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.FindApp;
+import com.sheep.gamegroup.model.entity.FindItem;
+import com.sheep.gamegroup.model.entity.FindTag;
+import com.sheep.gamegroup.model.entity.TaskReleaseEty;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.ListUtil;
+import com.sheep.gamegroup.util.SheepSwipeRefreshLayout;
+import com.sheep.gamegroup.util.SysAppUtil;
+import com.sheep.gamegroup.util.ViewHolder;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
+import com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
+import com.sheep.jiuyan.samllsheep.utils.G;
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+
+import java.io.File;
+import java.util.List;
+import java.util.Locale;
+
+import butterknife.BindView;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Action1;
+import rx.schedulers.Schedulers;
+
+import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
+
+
+/**
+ * Created by ljy on 2018/7/29.
+ */
+
+public class ActXiaomiGame extends BaseActivity {
+
+    @BindView(R.id.title)
+    View title;
+    @BindView(R.id.refresh)
+    SwipeRefreshLayout refresh;
+    @BindView(R.id.empty_view)
+    View empty_view;
+    @BindView(R.id.check_net_ll)
+    View check_net_ll;
+    @BindView(R.id.view_list)
+    RecyclerView view_list;
+
+    private Activity activity;
+    private List<XiaomiGameEntity> list = ListUtil.emptyList();
+    private boolean isRefresh;
+    private int page;
+    private int per_page;
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.net_empty_fresh_list_more;
+    }
+
+    @Override
+    public void initView() {
+        activity = this;
+        EventBus.getDefault().register(this);
+        Aria.download(this).register();
+
+        TitleBarUtils.getInstance()
+                .setTitleFinish(activity)
+                .setTitle(activity, "小米游戏中心")
+                .setRightImgBotton(activity,
+                        R.mipmap.search_black_img,
+                        new View.OnClickListener() {//搜索
+                            @Override
+                            public void onClick(View v) {
+                                Jump2View.getInstance().goGameSearch(activity, 1);
+                            }
+                        });
+        refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+            @Override
+            public void onRefresh() {
+                isRefresh = true;
+                initData();
+                refresh.setRefreshing(false);
+            }
+        });
+
+        view_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
+        view_list.setAdapter(new AdbCommonRecycler<XiaomiGameEntity>(SheepApp.getInstance(), list){
+
+            @Override
+            public int getItemViewType(int position) {
+                return position;
+            }
+            @Override
+            public int getViewIdByType(int type) {//type来源于 getItemViewType 返回的值
+                if(type == -1 + list.size()){
+                    return R.layout.find_item_bottom;
+                }
+                return R.layout.try_makemoney_item_recommend;
+            }
+
+            @Override
+            public void convert(ViewHolder holder, final XiaomiGameEntity item) {
+                if(item == null){
+                    return;
+                }
+                View rootConvertView = holder.itemView;
+                View task_top = rootConvertView.findViewById(R.id.task_top);
+                task_top.setVisibility(View.GONE);
+                TextView item_money = (TextView)rootConvertView.findViewById(R.id.item_money);
+                TextView item_name_tv = (TextView)rootConvertView.findViewById(R.id.item_name_tv);
+                TextView item_num_tv = (TextView)rootConvertView.findViewById(R.id.item_num_tv);
+                TextView item_date_tv = (TextView)rootConvertView.findViewById(R.id.item_date_tv);
+                TextView detail_task_tv_center = (TextView)rootConvertView.findViewById(R.id.detail_task_tv_center);
+                item_money.setVisibility(View.GONE);
+                View line_tv = rootConvertView.findViewById(R.id.line_tv);
+                View detail_task_layout = rootConvertView.findViewById(R.id.detail_task_layout);
+                detail_task_layout.setVisibility(View.GONE);
+
+                GlideImageLoader.setGameImage((ImageView) rootConvertView.findViewById(R.id.item_icon_iv), item.getIcon());
+                item_name_tv.setText(item.getName()+"");
+                item_num_tv.setText("角色扮演");
+                item_date_tv.setText("2万人在玩");
+                detail_task_tv_center.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + item.getDownload_url());
+
+                if(item.getReceive_account() == 0){//未领取账号
+
+                    CommonUtil.getInstance()
+                            .xiaomiRevieceAcctoun(detail_task_tv_center, item, activity);
+                }else {
+                    item.getDownloadHelper().updateDownloadTaskView((Activity) activity, item, detail_task_tv_center);
+                    detail_task_tv_center.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + item.getDownload_url());
+                }
+            }
+        });
+        isRefresh = false;
+    }
+
+    @Override
+    public void initListener() {
+
+        view_list.addOnScrollListener(new RecyclerView.OnScrollListener() {
+            @Override
+            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+                super.onScrollStateChanged(recyclerView, newState);
+                if (newState == RecyclerView.SCROLL_STATE_IDLE) {//滑动到了底部
+                    if (list.size() >= page * per_page) {
+                        loadData(true, false);
+                    } else {
+//                        G.showToast("没有更多数据了");
+                    }
+
+                }
+            }
+        });
+    }
+
+    @Override
+    public void initData() {
+        SysAppUtil.checkNet(new Action1<Integer>() {
+            @Override
+            public void call(Integer result) {
+                if (result != 0) {//无网络
+                    if (check_net_ll != null)
+                        check_net_ll.setVisibility(View.VISIBLE);
+                } else {
+                    if (check_net_ll != null)
+                        check_net_ll.setVisibility(View.GONE);
+                }
+            }
+        });
+
+        try{
+            loadData(false, isRefresh);
+        }catch (Exception e){
+            e.printStackTrace();
+            new Handler().postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    loadData(false, isRefresh);
+                }
+            }, 500);
+        }
+
+
+    }
+
+    private void loadData(boolean isLoadMore, final boolean isRefresh){
+        /**
+         * 异步获取普通任务,回调是在主线程,可以直接更新UI,加载更多的逻辑只需更新pageNo和pageSize即可。
+         */
+        if (isLoadMore)
+            page++;
+        else
+            page = 1;
+
+        CommonUtil.getInstance()
+                .xiaomiGame(activity,page, per_page, "", new Action1<BaseMessage>() {
+                    @Override
+                    public void call(BaseMessage baseMessage) {
+                        try {
+                            if(baseMessage == null){
+
+                                G.showToast("暂无游戏");
+                            }else {
+                                List<XiaomiGameEntity> newList = baseMessage.getDatas(XiaomiGameEntity.class);
+
+                                if (page == 1)
+                                    list.clear();
+                                ListUtil.addAll(list, newList);
+                                view_list.getAdapter().notifyDataSetChanged();
+                            }
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+
+
+    }
+
+    @Subscribe
+    public void onEventMainThread(BigEvent event) {
+        switch (event.getEventTypes()){
+            case REFRESH_XIAOMI_GAME_LIST:
+                initData();
+                break;
+            case UPDATE_BTN_STATUS:
+                if(event.getData() instanceof DownloadTask){
+                    DownloadTask task = (DownloadTask) event.getData();
+                    try {
+                        int p = task.getPercent();    //任务进度百分比
+                        String speed = task.getConvertSpeed();    //转换单位后的下载速度,单位转换需要在配置文件中打开
+                        System.out.println("Aria "+task.getKey()+",p " + p + ", speed = " + speed);
+                        String url = task.getKey();
+                        TextView tvProgress = view_list.findViewWithTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + url);
+                        if (tvProgress == null) {
+                            return;
+                        }
+                        tvProgress.setText(String.format(Locale.CHINA, "%d%%",Math.abs(p)));
+
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+                break;
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        EventBus.getDefault().unregister(this);
+    }
+}

+ 299 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/XiaomiGameEntity.java

@@ -0,0 +1,299 @@
+package com.sheep.gamegroup.view.activity;
+
+import com.sheep.gamegroup.heler.DownloadHelper;
+import com.sheep.gamegroup.model.api.IDownload;
+
+import java.io.Serializable;
+
+/**
+ * 小米游戏
+ * Created by ljy on 2018/7/29.
+ */
+
+public class XiaomiGameEntity implements Serializable,IDownload {
+    private int Id;//integer($int64)
+    private long created_at;//integer($int64)
+    private int download;//integer($int64)1:可下载 其他:不可下载
+
+    private long download_at;//integer($int64)预约下载开放时间
+
+    private int download_count;//integer($int64)下载数量
+
+    private int download_type;//integer($int32)1:非预约下载 2:预约下载
+
+    private String download_url;//string下载地址
+
+    private String icon;//string应用图标
+
+    private String intro;//string应用简介
+
+    private int is_recommend;//integer($int32)是否推荐:0:不推荐 1:推荐
+
+    private String manufacturer;//string厂商
+
+    private String name;//string应用名称
+
+    private String package_id;//stringGameID
+    private String package_name;//string应用包名称
+
+    private float package_sizes;//number($float)包大小(M)
+
+    private int package_type;//integer($int64)出包类型:1:快发出包 2:腾讯出包 3:小米出包 4:其它
+
+    private String pictures;//string宣传图标(分号隔开)
+
+    private int platform;//integer($int32)平台 0:全 1:安卓 2:IOS
+
+    private int receive_account;//integer($int64)0:未领取账号 1:已领取账号
+
+    private int record;//integer($int64)1:可记录 其他:不可记录
+
+    private float score;//number($float)评分
+
+    private int score_count;//integer($int64)评分人数
+
+    private int sort;//integer($int64)排序:越大越靠前
+
+    private int status;//integer($int32)1:开启 2:关闭
+
+    private long updated_at;//integer($int64)
+    private long versions;//string版本号
+
+    public int getId() {
+        return Id;
+    }
+
+    public void setId(int id) {
+        Id = id;
+    }
+
+    public long getCreated_at() {
+        return created_at;
+    }
+
+    public void setCreated_at(long created_at) {
+        this.created_at = created_at;
+    }
+
+    public int getDownload() {
+        return download;
+    }
+
+    public void setDownload(int download) {
+        this.download = download;
+    }
+
+    public long getDownload_at() {
+        return download_at;
+    }
+
+    public void setDownload_at(long download_at) {
+        this.download_at = download_at;
+    }
+
+    public int getDownload_count() {
+        return download_count;
+    }
+
+    public void setDownload_count(int download_count) {
+        this.download_count = download_count;
+    }
+
+    public int getDownload_type() {
+        return download_type;
+    }
+
+    public void setDownload_type(int download_type) {
+        this.download_type = download_type;
+    }
+
+    public String getDownload_url() {
+        return download_url;
+    }
+
+    public void setDownload_url(String download_url) {
+        this.download_url = download_url;
+    }
+
+    @Override
+    public String getPackage_names() {
+        return package_name;
+    }
+
+    @Override
+    public int getTask_type() {
+        return package_type;
+    }
+
+    @Override
+    public String getDownload_link() {
+        return download_url;
+    }
+
+    @Override
+    public String getTask_name() {
+        return name;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public String getIntro() {
+        return intro;
+    }
+
+    public void setIntro(String intro) {
+        this.intro = intro;
+    }
+
+    public int getIs_recommend() {
+        return is_recommend;
+    }
+
+    public void setIs_recommend(int is_recommend) {
+        this.is_recommend = is_recommend;
+    }
+
+    public String getManufacturer() {
+        return manufacturer;
+    }
+
+    public void setManufacturer(String manufacturer) {
+        this.manufacturer = manufacturer;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPackage_id() {
+        return package_id;
+    }
+
+    public void setPackage_id(String package_id) {
+        this.package_id = package_id;
+    }
+
+    public String getPackage_name() {
+        return package_name;
+    }
+
+    public void setPackage_name(String package_name) {
+        this.package_name = package_name;
+    }
+
+    public String getPackage_size() {
+        return "";
+    }
+
+    @Override
+    public int getAcceptedTaskId() {
+        return 0;
+    }
+
+    public void setPackage_size(float package_size) {
+        this.package_sizes = package_size;
+    }
+
+    public int getPackage_type() {
+        return package_type;
+    }
+
+    public void setPackage_type(int package_type) {
+        this.package_type = package_type;
+    }
+
+    public String getPictures() {
+        return pictures;
+    }
+
+    public void setPictures(String pictures) {
+        this.pictures = pictures;
+    }
+
+    public int getPlatform() {
+        return platform;
+    }
+
+    public void setPlatform(int platform) {
+        this.platform = platform;
+    }
+
+    public int getReceive_account() {
+        return receive_account;
+    }
+
+    public void setReceive_account(int receive_account) {
+        this.receive_account = receive_account;
+    }
+
+    public int getRecord() {
+        return record;
+    }
+
+    public void setRecord(int record) {
+        this.record = record;
+    }
+
+    public float getScore() {
+        return score;
+    }
+
+    public void setScore(float score) {
+        this.score = score;
+    }
+
+    public int getScore_count() {
+        return score_count;
+    }
+
+    public void setScore_count(int score_count) {
+        this.score_count = score_count;
+    }
+
+    public int getSort() {
+        return sort;
+    }
+
+    public void setSort(int sort) {
+        this.sort = sort;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public long getUpdated_at() {
+        return updated_at;
+    }
+
+    public void setUpdated_at(long updated_at) {
+        this.updated_at = updated_at;
+    }
+
+    public long getVersions() {
+        return versions;
+    }
+
+    public void setVersions(long versions) {
+        this.versions = versions;
+    }
+    private DownloadHelper downloadHelper = new DownloadHelper();
+
+    public DownloadHelper getDownloadHelper() {
+        return downloadHelper;
+    }
+}

+ 1 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/service/DownloadService.java

@@ -47,6 +47,7 @@ public class DownloadService extends Service{
         LogUtil.println("DownloadService", "running", task.getKey(), task.getTaskName(), task.getPercent());
         mDownloadTaskService.setDownloadTaskPercent(task.getPercent(), task.getCurrentProgress()/1024d/1024d,task.getFileSize()/1024d/1024d,0,task.getKey());
         EventBus.getDefault().post(new BigEvent().setEventTypes(EventTypes.GENERATION_ACCOUNT_REFRESH_ADAPTER).setData(task));
+        EventBus.getDefault().post(new BigEvent().setEventTypes(EventTypes.UPDATE_BTN_STATUS).setData(task));
     }
 
     @Download.onTaskStop void taskStop(DownloadTask task) {

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -54,6 +54,7 @@
     <string name="warm_prompt_content">游戏必须是在小绵羊平台下载的游戏,且游戏账号是新注册的,否者任务奖励无法使用。</string>
     <string name="warm_prompt_content_notice">注意:用户若删除游戏后,系统自动检测让其下载安装游戏。</string>
     <string name="get_game_task_success_dialog">%1$s账号:%2$s \n  密码请在个人中心查看\n  注意:登陆后请及时修改密码哟</string>
+    <string name="get_xiaomi_game_success_dialog">账号:%1$s \n  密码:%2$s \n </string>
 
 
     <string name="accessibility_description">需要权限判断任务是否成功</string>