zengjiebin преди 7 години
родител
ревизия
3f950a3c8b

+ 9 - 0
app/src/main/java/com/sheep/gamegroup/absBase/IContentContainer.java

@@ -0,0 +1,9 @@
+package com.sheep.gamegroup.absBase;
+
+/**
+ * Created by realicing on 2018/11/9.
+ * realicing@sina.com
+ */
+public interface IContentContainer<T> {
+    T getContent();
+}

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

@@ -10,14 +10,15 @@ import com.sheep.gamegroup.absBase.IHomePageSearch;
  * content:	string 内容
  * link_id:	integer ($int64) 关联id
  * link_type:	integer ($int64) 关联类型 1任务 2游戏
- * title:	string
+ * icon:	string 图标
+ * title:	string 标题
  * bonus:	string 任务奖金
- * 标题
  */
 public class HomePageSearch implements IHomePageSearch {
     private String content;
     private String title;
     private String bonus;
+    private String icon;
     private int link_id;
     private int link_type;
 
@@ -60,4 +61,21 @@ public class HomePageSearch implements IHomePageSearch {
     public void setBonus(String bonus) {
         this.bonus = bonus;
     }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    //该类型是否有奖金
+    public boolean hasBonus() {
+        switch (link_type){
+            case IHomePageSearch.LINK_TYPE_RELEASE_TASK://任务有奖金
+                return true;
+        }
+        return false;
+    }
 }

+ 23 - 1
app/src/main/java/com/sheep/gamegroup/view/adapter/HomePageSearchAdapter.java

@@ -1,13 +1,20 @@
 package com.sheep.gamegroup.view.adapter;
 
 import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import android.widget.ImageView;
+import android.widget.TextView;
 
 import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.chad.library.adapter.base.BaseViewHolder;
+import com.kfzs.duanduan.utils.NumberFormatUtils;
+import com.sheep.gamegroup.absBase.IContentContainer;
 import com.sheep.gamegroup.model.entity.HomePageSearch;
+import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.R;
 
 import java.util.List;
+import java.util.Locale;
 
 /**
  * Created by realicing on 2018/11/8.
@@ -16,11 +23,26 @@ import java.util.List;
 public class HomePageSearchAdapter extends BaseQuickAdapter<HomePageSearch, BaseViewHolder> {
 
     public HomePageSearchAdapter(@Nullable List<HomePageSearch> data) {
-        super(R.layout.play_game_vertical_list_item, data);
+        super(R.layout.item_home_page_search, data);
     }
 
     @Override
     protected void convert(BaseViewHolder helper, HomePageSearch item) {
+        ImageView item_home_page_search_iv = helper.itemView.findViewById(R.id.item_home_page_search_iv);
+        TextView item_home_page_search_content_tv = helper.itemView.findViewById(R.id.item_home_page_search_content_tv);
+        TextView item_home_page_search_bonus_tv = helper.itemView.findViewById(R.id.item_home_page_search_bonus_tv);
 
+        ViewUtil.setVisibility(item_home_page_search_bonus_tv, item.hasBonus());
+        ViewUtil.setText(item_home_page_search_bonus_tv, String.format(Locale.CHINA, "+%s元", NumberFormatUtils.retainMost2(NumberFormatUtils.parseFloat(item.getBonus()))));
+        if(contentContainer != null && !TextUtils.isEmpty(contentContainer.getContent()))
+            ViewUtil.setColorMapText(item_home_page_search_content_tv, String.format(Locale.CHINA, "%s/%s", item.getTitle(), item.getContent()), contentContainer.getContent(), "#4889FF");
+        else
+            ViewUtil.setText(item_home_page_search_content_tv, String.format(Locale.CHINA, "%s/%s", item.getTitle(), item.getContent()));
+        ViewUtil.setGameImage(item_home_page_search_iv, item.getIcon());
+    }
+
+    private IContentContainer<String> contentContainer;
+    public void setContentContainer(IContentContainer<String> contentContainer) {
+        this.contentContainer = contentContainer;
     }
 }

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

@@ -4,6 +4,7 @@ import android.support.v7.widget.RecyclerView;
 import android.view.View;
 
 import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.sheep.gamegroup.absBase.IContentContainer;
 import com.sheep.gamegroup.absBase.ISearch;
 import com.sheep.gamegroup.model.api.ApiService;
 import com.sheep.gamegroup.model.entity.BaseMessage;
@@ -21,7 +22,7 @@ import rx.Observable;
  * Created by realicing on 2018/9/13.
  * realicing@sina.com
  */
-public class FgtSearchAppOrTask extends BaseListFragment3<HomePageSearch> implements ISearch, BaseQuickAdapter.OnItemClickListener {
+public class FgtSearchAppOrTask extends BaseListFragment3<HomePageSearch> implements ISearch, BaseQuickAdapter.OnItemClickListener, IContentContainer<String> {
 
     @Override
     public int refreshDataType() {
@@ -33,6 +34,7 @@ public class FgtSearchAppOrTask extends BaseListFragment3<HomePageSearch> implem
     @Override
     protected RecyclerView.Adapter getAdapter() {
         HomePageSearchAdapter adapter = new HomePageSearchAdapter(list);
+        adapter.setContentContainer(this);
         adapter.setOnItemClickListener(this);
         return adapter;
     }
@@ -68,4 +70,9 @@ public class FgtSearchAppOrTask extends BaseListFragment3<HomePageSearch> implem
         ApiUtil.postTopSearchStatisticsClickTopSearch(item);
         Jump2View.getInstance().goTaskOrAppDetail(item);
     }
+
+    @Override
+    public String getContent() {
+        return search_content;
+    }
 }

+ 52 - 0
app/src/main/res/layout/item_home_page_search.xml

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <ImageView
+        android:id="@+id/item_home_page_search_iv"
+        android:layout_width="73dp"
+        android:layout_height="73dp"
+        android:layout_marginStart="7dp"
+        android:padding="20dp"
+        android:src="@drawable/icon_lj"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/item_home_page_search_bonus_tv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:maxLines="1"
+        android:padding="24dp"
+        android:text="+1.5元"
+        android:textColor="#ffff2d4b"
+        android:textSize="15sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/item_home_page_search_content_tv"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="80dp"
+        android:maxLines="2"
+        android:text="试玩赚钱/永恒边界"
+        android:textColor="#ff333333"
+        android:textSize="14sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toStartOf="@id/item_home_page_search_bonus_tv"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1px"
+        android:background="#F2F2F2"
+        app:layout_constraintBottom_toBottomOf="parent" />
+
+
+</android.support.constraint.ConstraintLayout>