Kaynağa Gözat

下载管理界面 添加猜你喜欢列表

zengjiebin 7 yıl önce
ebeveyn
işleme
cfa534f82e

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

@@ -1702,15 +1702,15 @@ public interface ApiService {
     Observable<BaseMessage> getFindPackageTypeList();
     /**
      * 获取游戏排行
-     * 返回 AppForGameCenter 列表
+     * 返回 GameEntity 列表
      */
     @GET("app/find/rank")
     Observable<BaseMessage> getFindRank();
     /**
      * 根据用户喜好推荐
-     * 返回 AppForGameCenter 列表
+     * 返回 GameEntity 列表
      */
-    @GET("app/find/user_like")
+    @GET(ApiKey.getFindUserLike)
     Observable<BaseMessage> getFindUserLike();
 //---------------------------end 小绵羊3.4.10新增 -- app/game_group 游戏组-------------------------------------
 

+ 23 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/UserEntity.java

@@ -57,6 +57,7 @@ public class UserEntity implements Serializable {
     private int bind_flag;//绑定表示 二进制形式 从低到高 第一位手机号 第二位QQ号 第三位微信
     private int level;//用户等级 0:普通用户     1:VIP用户
     private int vip_time;//用户vip期限
+    private int user_type;//用户类型: 1普通用户 2游戏用户
 
     public int getPackage_cate() {
         return package_cate;
@@ -346,6 +347,22 @@ public class UserEntity implements Serializable {
         this.set_password = set_password;
     }
 
+    public int getUser_type() {
+        return user_type;
+    }
+
+    public void setUser_type(int user_type) {
+        this.user_type = user_type;
+    }
+
+
+
+
+
+
+
+
+
     public boolean isNewRegistUser() {//新注册用户
         return TextUtils.equals(create_time, last_login_time);
     }
@@ -423,4 +440,10 @@ public class UserEntity implements Serializable {
         String info = String.format(Locale.CHINA, "\t%s到期", TimeUtil.TimeStamp2Date(vip_time, "yyyy.MM.dd"));
         return new SpannableSb().append("VIP").append(info, R.dimen.text_size_9).getSsb();
     }
+    //用户类型: 1普通用户 2游戏用户
+    public static final int USRE_TYPE_NOR = 1;
+    public static final int USRE_TYPE_GAME = 2;
+    public boolean isGameUser(){
+        return user_type == USRE_TYPE_GAME;
+    }
 }

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/module/game/activity/ActDownloadManager.java

@@ -20,7 +20,7 @@ public class ActDownloadManager extends BaseContainerActivity {
         TitleBarUtils
                 .getInstance()
                 .setShowOrHide(this, true)
-                .setTitle(this, getString(R.string.my_games))
+                .setTitle(this, getString(R.string.label_download_mgr))
                 .setRightBtn(this, "清空记录", 0, view -> {
                     if(fgtDownloadManager != null){
                         fgtDownloadManager.removeAll();

+ 45 - 0
app/src/main/java/com/sheep/gamegroup/module/game/adapter/AdpGameCenter4_0.java

@@ -0,0 +1,45 @@
+package com.sheep.gamegroup.module.game.adapter;
+
+import android.content.Context;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.sheep.gamegroup.model.entity.GameEntity;
+import com.sheep.gamegroup.util.GlideImageLoader;
+import com.sheep.gamegroup.util.ViewUtil;
+import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
+import com.sheep.jiuyan.samllsheep.R;
+
+import java.util.List;
+
+import static com.sheep.gamegroup.view.adapter.PlayGameListAdapter.setOnClickGameEntity;
+
+/**
+ * Created by realicing on 2019/1/21.
+ * realicing@sina.com
+ */
+public class AdpGameCenter4_0 extends AdbCommonRecycler<GameEntity> {
+
+    public AdpGameCenter4_0(Context context, List<GameEntity> list) {
+        super(context, list);
+    }
+
+    @Override
+    public int getViewIdByType(int type) {
+        return R.layout.item_game_center_4_0;
+    }
+
+    @Override
+    public void convert(com.sheep.gamegroup.util.ViewHolder holder, GameEntity item) {
+        ImageView item_hot_welfare_iv = holder.itemView.findViewById(R.id.item_hot_welfare_iv);
+        TextView item_hot_welfare_tv = holder.itemView.findViewById(R.id.item_hot_welfare_tv);
+        if (item == null) {
+            ViewUtil.setDefaultText(item_hot_welfare_tv);
+        } else {
+            // 加载数据
+            ViewUtil.setText(item_hot_welfare_tv, item.getApp().getName());
+            GlideImageLoader.setGameImage(item_hot_welfare_iv, item.getApp().getIcon());
+            setOnClickGameEntity(holder.itemView, item);
+        }
+    }
+}

+ 87 - 11
app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtDownloadManager.java

@@ -2,6 +2,9 @@ package com.sheep.gamegroup.module.game.fragment;
 
 import android.app.Activity;
 import android.content.Intent;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
 import android.widget.ImageView;
 import android.widget.ProgressBar;
 import android.widget.TextView;
@@ -13,9 +16,14 @@ import com.sheep.gamegroup.absBase.AbsDownloadListener;
 import com.sheep.gamegroup.absBase.AbsGetDownloadListener;
 import com.sheep.gamegroup.absBase.AbsObserver;
 import com.sheep.gamegroup.absBase.IApiRefresh;
+import com.sheep.gamegroup.absBase.NetApiRefresh;
 import com.sheep.gamegroup.event.BigEvent;
 import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 import com.sheep.gamegroup.helper.DownloadHelper;
+import com.sheep.gamegroup.model.api.ApiService;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.GameEntity;
+import com.sheep.gamegroup.module.game.adapter.AdpGameCenter4_0;
 import com.sheep.gamegroup.module.game.model.DownloadInfoHelper;
 import com.sheep.gamegroup.util.DownloadUtil;
 import com.sheep.gamegroup.util.ViewUtil;
@@ -27,6 +35,7 @@ import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
 import org.greenrobot.eventbus.Subscribe;
 
 import java.text.DecimalFormat;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -43,7 +52,7 @@ import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX
  * Created by realicing on 2019/1/21.
  * realicing@sina.com
  */
-public class FgtDownloadManager extends BaseListFragment6<DownLoadInfo> {
+public class FgtDownloadManager extends BaseListFragment6<String> {
 
     private DownloadUtil downloadUtil;
     @Override
@@ -53,8 +62,11 @@ public class FgtDownloadManager extends BaseListFragment6<DownLoadInfo> {
     }
 
     private AbsApiRefresh<DownLoadInfo> apiRefresh;
+    private NetApiRefresh<GameEntity> apiRefresh2;
     @Override
     protected void addApiRefresh(List<IApiRefresh> apiRefreshList) {
+        tagList.add("已安装");
+        tagList.add("猜你喜欢");
         apiRefresh = new AbsApiRefresh<DownLoadInfo>(this) {
 
             @Override
@@ -76,11 +88,38 @@ public class FgtDownloadManager extends BaseListFragment6<DownLoadInfo> {
             }
         };
         apiRefreshList.add(apiRefresh);
+
+        apiRefresh2 = new NetApiRefresh<GameEntity>(this) {
+
+            @Override
+            public String getKey(int page, int per_page) {
+                return null;
+            }
+
+            @Override
+            public Observable<BaseMessage> getApi(ApiService apiService) {
+                return apiService.getFindUserLike();
+            }
+
+            @Override
+            public Class<GameEntity> getTClass() {
+                return GameEntity.class;
+            }
+
+            @Override
+            protected boolean hasMore() {
+                return false;
+            }
+        };
+        apiRefreshList.add(apiRefresh2);
     }
+    private BaseQuickAdapter<DownLoadInfo, BaseViewHolder> downLoadInfoAdapter;
+    private RecyclerView.Adapter appFormGameCenterAdapter;
 
+    private List<String> tagList = new ArrayList<>();
     @Override
-    protected BaseQuickAdapter<DownLoadInfo, BaseViewHolder> getAdapter() {
-        return new BaseQuickAdapter<DownLoadInfo, BaseViewHolder>(R.layout.item_download_manager, apiRefresh.getList()){
+    protected BaseQuickAdapter<String, BaseViewHolder> getAdapter() {
+        downLoadInfoAdapter = new BaseQuickAdapter<DownLoadInfo, BaseViewHolder>(R.layout.item_download_manager, apiRefresh.getList()){
             @Override
             protected void convert(BaseViewHolder helper, DownLoadInfo item) {
                 ImageView item_dm_icon_iv = helper.getView(R.id.item_dm_icon_iv);
@@ -92,7 +131,7 @@ public class FgtDownloadManager extends BaseListFragment6<DownLoadInfo> {
 
                 ViewUtil.setImage(item_dm_icon_iv, item.getMIconUrl());
                 ViewUtil.setText(item_dm_name_tv, item.getMGameName());
-                if(item.getMPercent() == 100){
+                if(item.getMPercent() != null && item.getMPercent() == 100){
                     if(item.getMTotalSize() == null){
                         ViewUtil.setText(item_dm_info_tv, "全部下载完成");
                     } else {
@@ -110,21 +149,53 @@ public class FgtDownloadManager extends BaseListFragment6<DownLoadInfo> {
                     Observable.create((ObservableOnSubscribe<Boolean>) emitter -> emitter.onNext(downloadUtil.deleteDownloadTask(item)))
                             .subscribeOn(Schedulers.io())
                             .observeOn(AndroidSchedulers.mainThread()).
-                                    subscribe(new AbsObserver<Boolean>() {
-                                        @Override
-                                        public void onNext(Boolean result) {
-                                            //删除成功
-                                        }
-                                    });
+                            subscribe(new AbsObserver<Boolean>() {
+                                @Override
+                                public void onNext(Boolean result) {
+                                    //删除成功
+                                }
+                            });
                 });
 
                 updateView(getActivity(), item, item_dm_btn_tv);
             }
         };
+        appFormGameCenterAdapter = new AdpGameCenter4_0(SheepApp.getInstance(), apiRefresh2.getList());
+        return new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_play_game_list, tagList) {
+
+            @Override
+            protected void convert(BaseViewHolder holder, String item) {
+                View item_play_game_list_rl = holder.itemView.findViewById(R.id.item_play_game_list_rl);
+                View item_play_game_list_top = holder.itemView.findViewById(R.id.item_play_game_list_top);
+                ViewUtil.setVisibility(item_play_game_list_top, false);
+                TextView item_play_game_list_tv = holder.itemView.findViewById(R.id.item_play_game_list_tv);
+                ViewUtil.setText(item_play_game_list_tv, item);
+                TextView item_play_game_list_more_tv = holder.itemView.findViewById(R.id.item_play_game_list_more_tv);
+                ViewUtil.setVisibility(item_play_game_list_more_tv, false);
+                RecyclerView recyclerView = holder.itemView.findViewById(R.id.item_play_game_list_rv);
+                recyclerView.setHasFixedSize(true);
+                recyclerView.setNestedScrollingEnabled(false);
+                int position = holder.getAdapterPosition();
+                switch (position){
+                    case 0:
+                        ViewUtil.setVisibility(item_play_game_list_rl, !apiRefresh.getList().isEmpty());
+                        recyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
+                        recyclerView.setAdapter(downLoadInfoAdapter);
+                        break;
+                    case 1:
+                        recyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false));
+                        recyclerView.setAdapter(appFormGameCenterAdapter);
+                        break;
+                }
+            }
+        };
     }
 
     //删除所有下载任务与文件
     public void removeAll() {
+        if(apiRefresh == null || apiRefresh.getList().isEmpty()){
+            return;
+        }
         Observable.just(1).map(integer -> {
             try {
                 downloadUtil.deleteAllDownloadTask();
@@ -142,7 +213,12 @@ public class FgtDownloadManager extends BaseListFragment6<DownLoadInfo> {
         .subscribe(new AbsObserver<Integer>() {
             @Override
             public void onNext(Integer integer) {
-                clear();
+                if(apiRefresh != null){
+                    apiRefresh.clear();
+                    if(downLoadInfoAdapter != null){
+                        downLoadInfoAdapter.notifyDataSetChanged();
+                    }
+                }
             }
         });
     }

+ 0 - 89
app/src/main/java/com/sheep/gamegroup/module/game/model/AppForGameCenter.java

@@ -1,89 +0,0 @@
-package com.sheep.gamegroup.module.game.model;
-
-import com.sheep.gamegroup.model.entity.Applications;
-
-/**
- * Created by realicing on 2019/1/18.
- * realicing@sina.com
- *
- * 游戏排行接口返回的数据
- *
- * accepted_task_id:	integer ($int64) 领取福利时使用
- * app:	Applications{...}
- * can_download:	boolean
- * is_reservation:	integer ($int64) 0 不是 1是预约
- * received_voucher:	boolean 是否已经领取了福利
- * release_task_id:	integer ($int64) 发布任务id
- * status:	integer ($int64) 福利任务时使用,和任务记录一样
- */
-public class AppForGameCenter {
-    private int accepted_task_id;
-
-    private Applications app;
-
-    private boolean can_download;
-
-    private int is_reservation;
-
-    private boolean received_voucher;
-
-    private int release_task_id;
-
-    private int status;
-
-    public int getAccepted_task_id() {
-        return accepted_task_id;
-    }
-
-    public void setAccepted_task_id(int accepted_task_id) {
-        this.accepted_task_id = accepted_task_id;
-    }
-
-    public Applications getApp() {
-        return app;
-    }
-
-    public void setApp(Applications app) {
-        this.app = app;
-    }
-
-    public boolean isCan_download() {
-        return can_download;
-    }
-
-    public void setCan_download(boolean can_download) {
-        this.can_download = can_download;
-    }
-
-    public int getIs_reservation() {
-        return is_reservation;
-    }
-
-    public void setIs_reservation(int is_reservation) {
-        this.is_reservation = is_reservation;
-    }
-
-    public boolean isReceived_voucher() {
-        return received_voucher;
-    }
-
-    public void setReceived_voucher(boolean received_voucher) {
-        this.received_voucher = received_voucher;
-    }
-
-    public int getRelease_task_id() {
-        return release_task_id;
-    }
-
-    public void setRelease_task_id(int release_task_id) {
-        this.release_task_id = release_task_id;
-    }
-
-    public int getStatus() {
-        return status;
-    }
-
-    public void setStatus(int status) {
-        this.status = status;
-    }
-}

+ 8 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -22,6 +22,7 @@ import com.sheep.gamegroup.event.BigEvent;
 import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 import com.sheep.gamegroup.helper.DownloadHelper;
 import com.sheep.gamegroup.model.entity.Container;
+import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.ChannelContent;
 import com.sheep.gamegroup.util.CommonUtil;
@@ -165,6 +166,12 @@ public class ActMain extends BaseActYmPermissionCheck {
     private long lastClickTime = 0;
 
     private void initFragments() {
+        //小绵羊3.4.10新增 判断用户是否是游戏用户,是的话默认打开游戏界面
+        UserEntity userEntity = DataUtil.getInstance().getUserEntity();
+        if(userEntity != null && userEntity.isGameUser()){
+            lastPosition = MainTab.FgtGameCenter.ordinal();
+        }
+
         FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
         MainTab[] mainTabs = MainTab.values();
         int index = 0;
@@ -176,7 +183,7 @@ public class ActMain extends BaseActYmPermissionCheck {
             if (!fragment.isAdded()) {
                 transaction.add(R.id.frame_container, fragment, "fragment_" + index);
             }
-            if (index == 0) {
+            if (index == lastPosition) {
                 transaction.show(fragment);
             } else {
                 transaction.hide(fragment);

+ 1 - 2
app/src/main/java/com/sheep/gamegroup/view/adapter/AdpGameCenter3_3List.java

@@ -74,8 +74,7 @@ public class AdpGameCenter3_3List extends RecyclerViewAdapter<ListTypeList<GameE
                     // 加载数据
                     ViewUtil.setText(item_hot_welfare_tv, item.getApp().getName());
                     GlideImageLoader.setGameImage(item_hot_welfare_iv, item.getApp().getIcon());
-                    if (mContext instanceof Activity)
-                        setOnClickGameEntity((Activity) mContext, holder.itemView, item);
+                    setOnClickGameEntity(holder.itemView, item);
                 }
             }
         });

+ 7 - 10
app/src/main/java/com/sheep/gamegroup/view/adapter/PlayGameListAdapter.java

@@ -5,7 +5,6 @@ import android.content.Context;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.View;
-import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
@@ -18,6 +17,7 @@ import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ViewHolder;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.service.DownloadService;
 
 import java.util.List;
@@ -49,7 +49,7 @@ public class PlayGameListAdapter extends AdbCommonRecycler<ListTypeList<GameEnti
 
             @Override
             public void convert(ViewHolder holder, final GameEntity gameEntity) {
-                setOnClickGameEntity((Activity) context, holder.itemView, gameEntity);
+                setOnClickGameEntity(holder.itemView, gameEntity);
 
                 View item_download_welfare_line = holder.itemView.findViewById(R.id.line_tv);
                 TextView detail_task_tv_center = holder.itemView.findViewById(R.id.detail_task_tv_center);
@@ -59,7 +59,7 @@ public class PlayGameListAdapter extends AdbCommonRecycler<ListTypeList<GameEnti
 
                 ViewUtil.setText(item_name_tv, gameEntity.getApp().getName());
                 ViewUtil.setText(item_date_tv, gameEntity.getApp().getPackage_size()+"M");
-                GlideImageLoader.setGameImage((ImageView) holder.itemView.findViewById(R.id.item_icon_iv), gameEntity.getApp().getIcon());
+                GlideImageLoader.setGameImage(holder.itemView.findViewById(R.id.item_icon_iv), gameEntity.getApp().getIcon());
                 CommonUtil.getInstance().palyGameDetailBtnValue(context,gameEntity,detail_task_tv_center, 1);
 
                 item_download_welfare_line.setVisibility(holder.getAdapterPosition() + 1 == getItemCount() ? View.GONE : View.VISIBLE);
@@ -75,18 +75,15 @@ public class PlayGameListAdapter extends AdbCommonRecycler<ListTypeList<GameEnti
 
     /**
      * 设置游戏中心中游戏的点击与长按
-     * @param activity
      * @param view
      * @param item
      */
-    public static void setOnClickGameEntity(final Activity activity, View view, final GameEntity item){
+    public static void setOnClickGameEntity(View view, final GameEntity item){
         if(item.getApp() != null){
             DownloadService.setDownLoadLongClick(view, item.getApp());
-            view.setOnClickListener(new View.OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    Jump2View.getInstance().goPlayGameDetail(activity, item.getApp().getId());
-                }
+            view.setOnClickListener(v -> {
+                Activity activity = SheepApp.getInstance().getCurrentActivity();
+                Jump2View.getInstance().goPlayGameDetail(activity, item.getApp().getId());
             });
         } else if(item.getRelease_task() != null) {
             DownloadService.setDownLoadLongClick(view, item.getRelease_task().getTask());

+ 2 - 0
app/src/main/java/org/afinal/simplecache/ApiKey.java

@@ -82,6 +82,8 @@ public class ApiKey {
     public static final String system_notification = "app/message/system_notification/";
     //获取我安装的游戏列表 3.4.9新增
     public static final String getMyGmeList = "app/game_consumption/my_games_v2";
+    //获取下载管理界面中的猜你喜欢 3.4.10新增
+    public static final String getFindUserLike = "app/find/user_like";
 
     public static final String getPackageVersion(String package_name, String type, int version){
         return String.format(Locale.CHINA, "%s?package_name=%s&type=%s&version=%d", getPackageVersion, package_name, type, version);

+ 30 - 0
app/src/main/res/layout/item_game_center_4_0.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_gravity="center"
+    android:orientation="vertical"
+    android:layout_marginStart="10dp"
+    android:paddingTop="20dp"
+    android:paddingBottom="20dp">
+
+    <ImageView
+        android:id="@+id/item_hot_welfare_iv"
+        android:layout_width="73dp"
+        android:layout_height="73dp"
+        android:layout_marginStart="6dp"
+        android:layout_marginEnd="6dp"
+        android:layout_gravity="center"
+        android:src="@drawable/icon_lj" />
+
+    <TextView
+        android:id="@+id/item_hot_welfare_tv"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="18dp"
+        android:ellipsize="end"
+        android:gravity="center"
+        android:singleLine="true"
+        android:textColor="#333333"
+        android:textSize="15sp" />
+</LinearLayout>

+ 3 - 1
app/src/main/res/layout/item_play_game_list.xml

@@ -10,7 +10,9 @@
         android:layout_height="10dp"
         android:background="#fff5f5f5" />
 
-    <RelativeLayout style="@style/style_wc_rl">
+    <RelativeLayout
+        android:id="@+id/item_play_game_list_rl"
+        style="@style/style_wc_rl">
 
         <TextView
             android:id="@+id/item_play_game_list_tv"