Procházet zdrojové kódy

主页搜索游戏可以搜索游戏组并进入

zengjiebin před 7 roky
rodič
revize
a93fbbe996

+ 6 - 5
app/src/main/java/com/sheep/gamegroup/absBase/IHomePageSearch.java

@@ -12,13 +12,14 @@ import java.lang.annotation.RetentionPolicy;
  */
 public interface IHomePageSearch {
     //    link_type:	integer ($int64)
-// * 关联类型 1任务(release_task)2游戏(applications)
-    public static final int LINK_TYPE_RELEASE_TASK = 1;
-    public static final int LINK_TYPE_APPLICATIONS = 2;
+// * 关联类型 1任务(release_task)2游戏(applications) 3游戏组(group_game)
+    int LINK_TYPE_RELEASE_TASK = 1;
+    int LINK_TYPE_APPLICATIONS = 2;
+    int LINK_TYPE_GROUP_GAME = 3;
 
-    @IntDef({LINK_TYPE_RELEASE_TASK, LINK_TYPE_APPLICATIONS})
+    @IntDef({LINK_TYPE_RELEASE_TASK, LINK_TYPE_APPLICATIONS, LINK_TYPE_GROUP_GAME})
     @Retention(RetentionPolicy.SOURCE)
-    public @interface LINK_TYPE {
+    @interface LINK_TYPE {
 
     }
     int getLink_id();

+ 5 - 6
app/src/main/java/com/sheep/gamegroup/model/entity/Applications.java

@@ -483,19 +483,18 @@ public class Applications implements IDownload, IGameGroup, Serializable {
     }
 
     public CharSequence getInfo(Action1<SpannableSb> action1) {
-        return new SpannableSb(R.dimen.text_size_12).callAction(action1).append(package_size+"M", "#999999").defaultTextSize()
+        return new SpannableSb("#999999", R.dimen.text_size_12)
+                .callAction(action1)
+                .append(package_size+"M").defaultTcTs()
                 .kgz().append(NumberFormatUtils.retainMost2W(download_count), "#2EBEF2").defaultTextSize()
-                .append("人在玩", "#999999").defaultTextSize()
+                .append("人在玩").defaultTcTs()
                 .getSsb();
     }
     public CharSequence getInfoContainGameFrom() {
-        return getInfoContainGameFrom("#000000");
-    }
-    public CharSequence getInfoContainGameFrom(String textColor) {
         if(TextUtils.isEmpty(getGameFrom())){
             return getInfo();
         }
-        return getInfo(spannableSb -> spannableSb.append("来源:" + getGameFrom(), R.dimen.text_size_11, textColor) .br());
+        return getInfo(spannableSb -> spannableSb.append("来源:", R.dimen.text_size_11, "#8e8e8e").kgy().kgy().append(getGameFrom(), R.dimen.text_size_11, "#6C61D2") .br());
     }
     public CharSequence getSimpleInfo() {
         return new SpannableSb().append(NumberFormatUtils.retainMost2W(download_count), "#2EBEF2").append("人在玩", "#999999").getSsb();

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

@@ -9,7 +9,7 @@ import com.sheep.gamegroup.absBase.IHomePageSearch;
  * <p>
  * content:	string 内容
  * link_id:	integer ($int64) 关联id
- * link_type:	integer ($int64) 关联类型 1任务 2游戏
+ * link_type:	integer ($int64) 关联类型 1任务 2游戏 3游戏组
  * icon:	string 图标
  * title:	string 标题
  * bonus:	string 任务奖金

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/module/game/adapter/AdpGameCenterTypeList.java

@@ -43,7 +43,7 @@ public class AdpGameCenterTypeList extends BaseQuickAdapter<GameEntity, BaseView
             ViewUtil.setImage(item_dm_icon_iv, download.getIcon());
             ViewUtil.setText(item_dm_name_tv, download.getTask_name());
             if(download instanceof Applications){
-                ViewUtil.setText(item_dm_info_tv, ((Applications) download).getInfoContainGameFrom("#8e8e8e"));
+                ViewUtil.setText(item_dm_info_tv, ((Applications) download).getInfoContainGameFrom());
             } else {//似乎这里的else是多余的
                 String info = String.format(Locale.CHINA, "人在玩\u0020%sM\u3000", download.getPackage_size());
                 ViewUtil.setText(item_dm_info_tv, new SpannableSb().append(item.getDownload_count(), "#2EBEF2").append(info, "#8E8E8E")

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/module/game/fragment/FgtGameCenterType.java

@@ -81,6 +81,6 @@ public class FgtGameCenterType extends BaseListFragment6<GameGroup> {
     @Override
     public void initListener() {
         super.initListener();
-        baseQuickAdapter.setOnItemClickListener((adapter, view, position) -> Jump2View.getInstance().goActGameGroupDetail(ListUtil.getItem(apiRefresh.getList(), position)));
+        baseQuickAdapter.setOnItemClickListener((adapter, view, position) -> Jump2View.getInstance().goEntity(ListUtil.getItem(apiRefresh.getList(), position)));
     }
 }

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

@@ -2416,7 +2416,7 @@ public class Jump2View {
     /**
      * 跳转到游戏详情或者任务详情界面
      */
-    public void goTaskOrAppDetail(Context context, IHomePageSearch item) {
+    public void goEntity(Context context, IHomePageSearch item) {
         switch (item.getLink_type()) {
             case IHomePageSearch.LINK_TYPE_RELEASE_TASK:
                 goTaskDetailView(context, item.getLink_id());
@@ -2424,6 +2424,9 @@ public class Jump2View {
             case IHomePageSearch.LINK_TYPE_APPLICATIONS:
                 goPlayGameDetail(item.getLink_id());
                 break;
+            case IHomePageSearch.LINK_TYPE_GROUP_GAME:
+                goActGameGroupDetail(item.getLink_id());
+                break;
         }
     }
 
@@ -2786,7 +2789,7 @@ public class Jump2View {
      */
     public void goSearchResp(SearchResp item) {
         if (item.isGameGroup()) {
-            goActGameGroupDetail(item.getGame_group());
+            goEntity(item.getGame_group());
         } else {
             goEntity(item.getApplications());
         }
@@ -2795,12 +2798,19 @@ public class Jump2View {
     /**
      * 小绵羊3.4.10新增 -- 游戏组详情界面
      */
-    public void goActGameGroupDetail(GameGroup item) {
+    public void goEntity(GameGroup item) {
         if(item == null){
             G.showToast(R.string.please_contact_customer_service);
             return;
         }
-        SheepApp.getInstance().getNetComponent().getApiService().getGameGroupById(item.getId())
+        goActGameGroupDetail(item.getId());
+    }
+
+    /**
+     * 小绵羊3.4.10新增 -- 游戏组详情界面
+     */
+    public void goActGameGroupDetail(int groupGameId) {
+        SheepApp.getInstance().getNetComponent().getApiService().getGameGroupById(groupGameId)
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {

+ 19 - 0
app/src/main/java/com/sheep/gamegroup/util/string/SpannableSb.java

@@ -28,12 +28,20 @@ public class SpannableSb {
     private int start;
     private int end;
     private @DimenRes int defaultTextSize;
+    private String defaultTextColor;
     public SpannableSb(){
 
     }
     public SpannableSb(@DimenRes int defaultTextSize){
         this.defaultTextSize = defaultTextSize;
     }
+    public SpannableSb(String defaultTextColor){
+        this.defaultTextColor = defaultTextColor;
+    }
+    public SpannableSb(String defaultTextColor, @DimenRes int defaultTextSize){
+        this.defaultTextColor = defaultTextColor;
+        this.defaultTextSize = defaultTextSize;
+    }
 
     public SpannableSb append(Object object) {
         String text = object.toString();
@@ -54,6 +62,17 @@ public class SpannableSb {
         }
         return setTextSize(defaultTextSize);
     }
+    //设置了默认颜色的可以直接调用这个来设置颜色
+    public SpannableSb defaultTextColor(){
+        if(TextUtils.isEmpty(defaultTextColor)){
+            return this;
+        }
+        return setTextColor(defaultTextColor);
+    }
+    //设置默认大小和默认颜色
+    public SpannableSb defaultTcTs(){
+        return defaultTextSize().defaultTextColor();
+    }
 
     //前面有内容才换行
     public SpannableSb checkAndBr() {

+ 15 - 32
app/src/main/java/com/sheep/gamegroup/view/activity/ActSearchAppOrTask.java

@@ -99,8 +99,7 @@ public class ActSearchAppOrTask extends BaseActivity {
                                 frame_container.postDelayed(autoSearchRunnable, delay);//1秒后自动搜索
                             }
                         })
-                .setRightBtn(this, "搜索", 0,
-                        v -> toSearchApp());
+                .setRightBtn(this, "搜索", 0, v -> toSearchApp());
 
         recyclerView.setHasFixedSize(true);
         recyclerView.setNestedScrollingEnabled(false);
@@ -109,12 +108,7 @@ public class ActSearchAppOrTask extends BaseActivity {
         adpTitleInfoList.bindToRecyclerView(recyclerView);
     }
 
-    private Runnable autoSearchRunnable = new Runnable() {
-        @Override
-        public void run() {
-            toSearchApp();
-        }
-    };
+    private Runnable autoSearchRunnable = this::toSearchApp;
 
     public static final int MAX_SHOW_SEARCH_RECORD_COUNT = 10;//最多展示的搜索历史的个数
     public static final int SORT_TOP_SEARCH = 1;//热门推荐 的排序
@@ -148,12 +142,7 @@ public class ActSearchAppOrTask extends BaseActivity {
                             List<TopSearchStatistics> newList = baseMessage.getDatas(TopSearchStatistics.class);
                             topSearchStatisticsList.clear();
                             topSearchStatisticsList.addAll(newList);
-                            if (ListUtil.getItem(titleInfoListList, new ListUtil.CallBack<TitleInfoList, Boolean>() {
-                                @Override
-                                public Boolean call(TitleInfoList titleInfoList) {
-                                    return titleInfoList.getSort() == SORT_TOP_SEARCH;
-                                }
-                            }) == null) {
+                            if (ListUtil.getItem(titleInfoListList, titleInfoList -> titleInfoList.getSort() == SORT_TOP_SEARCH) == null) {
                                 addListData("热门推荐", topSearchStatisticsList, SORT_TOP_SEARCH);
                             }
                             notifyDataSetChangedTitleInfoList();
@@ -193,30 +182,24 @@ public class ActSearchAppOrTask extends BaseActivity {
                 ViewUtil.setText(item_search_record_name, item.getInput());
                 if (item instanceof SearchRecord) {
                     //点击一条搜索历史后面的xx
-                    item_search_record_x.setOnClickListener(new View.OnClickListener() {
-                        @Override
-                        public void onClick(View view) {
-                            list.remove(item);
-                            ViewUtil.notifyDataSetChanged(recyclerView);
-                            DDProviderHelper.getInstance().deleteSearchRecord((SearchRecord) item);
-                            if (isTitleInfoListEmpty()) {
-                                frame_container.setVisibility(View.VISIBLE);
-                                recyclerView.setVisibility(View.INVISIBLE);
-                            }
+                    item_search_record_x.setOnClickListener(view12 -> {
+                        list.remove(item);
+                        ViewUtil.notifyDataSetChanged(recyclerView);
+                        DDProviderHelper.getInstance().deleteSearchRecord((SearchRecord) item);
+                        if (isTitleInfoListEmpty()) {
+                            frame_container.setVisibility(View.VISIBLE);
+                            recyclerView.setVisibility(View.INVISIBLE);
                         }
                     });
                 } else {
                     ViewUtil.setVisibility(item_search_record_x, false);
                 }
                 //点击一条搜索历史
-                view.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View view) {
-                        textByClick = true;
-                        TitleBarUtils.getInstance().setSearchText(ActSearchAppOrTask.this, item.getInput());
-                        if (item instanceof IHomePageSearch)
-                            ApiUtil.postTopSearchStatisticsClickTopSearch((IHomePageSearch) item);
-                    }
+                view.setOnClickListener(view1 -> {
+                    textByClick = true;
+                    TitleBarUtils.getInstance().setSearchText(ActSearchAppOrTask.this, item.getInput());
+                    if (item instanceof IHomePageSearch)
+                        ApiUtil.postTopSearchStatisticsClickTopSearch((IHomePageSearch) item);
                 });
             }
         }).setSort(sort));

+ 3 - 3
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtSearchAppOrTask.java

@@ -10,10 +10,8 @@ import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.HomePageSearch;
 import com.sheep.gamegroup.util.ApiUtil;
-import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ListUtil;
-import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.view.adapter.HomePageSearchAdapter;
 
 import java.io.UnsupportedEncodingException;
@@ -25,6 +23,8 @@ import io.reactivex.Observable;
 /**
  * Created by realicing on 2018/9/13.
  * realicing@sina.com
+ *
+ * 小绵羊3.4.10后也可以搜索出游戏组
  */
 public class FgtSearchAppOrTask extends BaseListFragment3<HomePageSearch> implements ISearch, BaseQuickAdapter.OnItemClickListener, IContentContainer<String> {
 
@@ -74,7 +74,7 @@ public class FgtSearchAppOrTask extends BaseListFragment3<HomePageSearch> implem
     public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
         HomePageSearch item = ListUtil.getItem(list, position);
         ApiUtil.postTopSearchStatisticsClickTopSearch(item);
-        Jump2View.getInstance().goTaskOrAppDetail(getContext(), item);
+        Jump2View.getInstance().goEntity(getContext(), item);
     }
 
     @Override