liujiangyao лет назад: 8
Родитель
Сommit
1aec80b580

+ 9 - 2
app/src/main/java/com/kfzs/duanduan/fragment/FgtSmallSheep.java

@@ -327,8 +327,15 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
         tryMakeMoneyAdp.setTaskAcceptedEty(null);
 
         RequestParameEty parameEty = new RequestParameEty();
-        parameEty.setHashMap(CommonUtil.getInstance().setHashMap(1, 100, 1,
-                1, 0, 0));
+        parameEty.setHashMap(
+                CommonUtil.getInstance()
+                        .setHashMap(1,
+                                100,
+                                1,
+                                1,
+                                0,
+                                0,
+                                -1));
 
         tryMakeMoneyPresenter.releaseTask(parameEty);
     }

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

@@ -129,7 +129,8 @@ public interface ApiService {
     @GET("app/release_task")
     Observable<BaseMessage> releaseTask(@Query("page") int page, @Query("per_page") int per_page,
                                         @Query("platform") int platform, @Query("is_hot") int is_hot,
-                                        @Query("is_recommend") int is_recommend, @Query("about_to_begin") int about_to_begin);
+                                        @Query("is_recommend") int is_recommend, @Query("about_to_begin") int about_to_begin,
+                                        @Query("task_type") int task_type);
 
 
 
@@ -304,4 +305,10 @@ public interface ApiService {
      */
     @GET("app/withdraw_amount_option")
     Observable<BaseMessage> getWithdrawAmountOption();
+
+    /**
+     * 任务类型
+     */
+    @GET("app/release_task/get_child_task")
+    Observable<BaseMessage> getChildTask(@Query("id") int id);
 }

+ 25 - 0
app/src/main/java/com/sheep/gamegroup/model/entity/GridViewEntity.java

@@ -11,12 +11,37 @@ public class GridViewEntity {
         this.value = value;
     }
 
+    public GridViewEntity(boolean selectState, int id, String name) {
+        this.selectState = selectState;
+        this.id = id;
+        this.name = name;
+    }
+
     public GridViewEntity() {
     }
 
     private boolean selectState;
     private String value;
 
+    private int id;// -1:全部
+    private String name;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
     public boolean isSelectState() {
         return selectState;
     }

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/presenter/TryMakeMoneyPresenter.java

@@ -79,7 +79,8 @@ public class TryMakeMoneyPresenter implements TryMakeMoneyContract.Presenter {
 
         apiService.releaseTask(Integer.valueOf(hashMap.get("page")),Integer.valueOf(hashMap.get("per_page")),
                 Integer.valueOf(hashMap.get("platform")),Integer.valueOf(hashMap.get("is_hot")),
-                Integer.valueOf(hashMap.get("is_recommend")),Integer.valueOf(hashMap.get("about_to_begin")))
+                Integer.valueOf(hashMap.get("is_recommend")),Integer.valueOf(hashMap.get("about_to_begin")),
+                Integer.valueOf(hashMap.get("task_type")))
                 .subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {

+ 5 - 1
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -193,7 +193,10 @@ public class CommonUtil {
     /**
      * 任务传送数据组装
      */
-    public HashMap<String, String> setHashMap(int page, int per_page, int platform, int is_hot, int is_recommend, int about_to_begin){
+    public HashMap<String, String> setHashMap(int page, int per_page,
+                                              int platform, int is_hot,
+                                              int is_recommend, int about_to_begin,
+                                              int task_type){
 
         HashMap<String, String> hashMap = new HashMap<>();
         hashMap.put("page", page+"");
@@ -202,6 +205,7 @@ public class CommonUtil {
         hashMap.put("is_hot", is_hot+"");
         hashMap.put("is_recommend", is_recommend+"");
         hashMap.put("about_to_begin", about_to_begin+"");
+        hashMap.put("task_type", task_type+"");
         return hashMap;
     }
     /**

+ 54 - 6
app/src/main/java/com/sheep/gamegroup/view/activity/TryMakeMoneyact.java

@@ -8,23 +8,33 @@ import android.support.v4.view.ViewPager;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 
+import com.alibaba.fastjson.JSONArray;
 import com.kfzs.duanduan.ActDownloadMgr;
 import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.GridViewEntity;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.MyGridview;
 import com.sheep.gamegroup.util.UMConfigUtils;
 import com.sheep.gamegroup.view.adapter.AdpTryMakemoney;
 import com.sheep.gamegroup.view.adapter.AdpTrymakemoneyTabGridview;
 import com.sheep.gamegroup.view.fragment.FgtTryMakeMoney;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
+import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.List;
 
 import butterknife.BindView;
 import butterknife.ButterKnife;
 import butterknife.OnClick;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.schedulers.Schedulers;
 
 /**
  * 试着赚钱页面
@@ -40,6 +50,8 @@ public class TryMakeMoneyact extends BaseActivity {
     MyGridview tabGridview;
     @BindView(R.id.select_tab_iv)
     ImageView selectTabIv;
+    @BindView(R.id.task_gridview_layout)
+    LinearLayout task_gridview_layout;
     private Activity activity;
 
     private AdpTryMakemoney mAdapter;
@@ -49,6 +61,8 @@ public class TryMakeMoneyact extends BaseActivity {
     private ArrayList<Object> gridviewListAll = new ArrayList<>();
     private ArrayList<Object> gridviewList = new ArrayList<>();
     private boolean clickFlag = false;
+    private GridViewEntity gridViewEntity;//选中的
+    private int select;
 
     @Override
     protected int getLayoutId() {
@@ -84,8 +98,11 @@ public class TryMakeMoneyact extends BaseActivity {
         tabGridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-
-//                select = position;
+                if(gridViewEntity == (GridViewEntity) gridviewList.get(position)){
+                    return;
+                }
+                select = position;
+                gridViewEntity = (GridViewEntity) gridviewList.get(position);
                 for(int i=0;i<gridviewList.size();i++){
                     if(position == i){
                         ((GridViewEntity) gridviewList.get(i)).setSelectState(true);
@@ -95,13 +112,44 @@ public class TryMakeMoneyact extends BaseActivity {
                     }
                     tabGridviewAdp.notifyDataSetChanged();
                 }
+                try{
+                    //刷新界面
+                    mAdapter.getItem(position).onResume();
+                }catch (Exception e){
+                    e.printStackTrace();
+                }
             }
         });
     }
 
     @Override
     public void initData() {
-        setValueList();
+        SheepApp.get(activity)
+                .getNetComponent()
+                .getApiService()
+                .getChildTask(1)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(activity) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        G.showToast(baseMessage.getMsg()+"");
+                        task_gridview_layout.setVisibility(View.GONE);
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+
+                        task_gridview_layout.setVisibility(View.VISIBLE);
+                        List<GridViewEntity> entityList = JSONArray.parseArray(JSONArray.toJSONString(baseMessage.getData()), GridViewEntity.class);
+                        if(entityList != null){
+                            gridviewListAll.clear();
+                            gridviewListAll.add(new GridViewEntity(true, -1, "全部" ));
+                            gridviewListAll.addAll(entityList);
+                            setValueList2(clickFlag);
+                        }
+                    }
+                });
     }
 
     @Override
@@ -121,8 +169,8 @@ public class TryMakeMoneyact extends BaseActivity {
     /**
      * 获取tab的值,fragment调用
      */
-    public int getTabValue(){
-        return 0;
+    public GridViewEntity getTabValue(){
+        return gridViewEntity;
     }
 
 
@@ -153,6 +201,6 @@ public class TryMakeMoneyact extends BaseActivity {
                 gridviewList.add(gridviewListAll.get(i));
             }
         }
-
+        tabGridviewAdp.notifyDataSetChanged();
     }
 }

+ 3 - 3
app/src/main/java/com/sheep/gamegroup/view/adapter/AdpTrymakemoneyTabGridview.java

@@ -54,11 +54,11 @@ public class AdpTrymakemoneyTabGridview extends BaseAdapter {
         }
 
         if (getItem(position).isSelectState()){
-            holder.item_tv.setTextColor(context.getResources().getColor(R.color.blue));
+            holder.item_tv.setTextColor(context.getResources().getColor(R.color.blue_end));
         }else{
-            holder.item_tv.setTextColor(context.getResources().getColor(R.color.black));
+            holder.item_tv.setTextColor(context.getResources().getColor(R.color.txt_black_818181));
         }
-        holder.item_tv.setText(getItem(position).getValue()+"");
+        holder.item_tv.setText(getItem(position).getName()+"");
         return convertView;
     }
 

+ 13 - 2
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtTryMakeMoney.java

@@ -16,6 +16,7 @@ import com.kfzs.duanduan.event.BigEvent;
 import com.sheep.gamegroup.di.components.DaggerFgtTryMakeMoneyComponent;
 import com.sheep.gamegroup.di.modules.TryMakeMoneyModule;
 import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.GridViewEntity;
 import com.sheep.gamegroup.model.entity.RecyleObj;
 import com.sheep.gamegroup.model.entity.RecyleType;
 import com.sheep.gamegroup.model.entity.RequestParameEty;
@@ -24,6 +25,7 @@ import com.sheep.gamegroup.model.entity.TaskReleaseEty;
 import com.sheep.gamegroup.presenter.TryMakeMoneyContract;
 import com.sheep.gamegroup.presenter.TryMakeMoneyPresenter;
 import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.view.activity.TryMakeMoneyact;
 import com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -64,6 +66,7 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
     private int position = 0;
     private List<TaskReleaseEty> releaseEtyLists = new ArrayList<>();
     private int type = 0;
+    private GridViewEntity gridViewEntity;//选中的
 
     private void notifyDataSetChanged(){
         tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.RELEASE_TASK, releaseEtyLists),position);
@@ -180,9 +183,17 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
             tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.NONE, null));
         }
         tryMakeMoneyAdp.setTaskAcceptedEty(null);
+        gridViewEntity = ((TryMakeMoneyact)getActivity()).getTabValue();
         RequestParameEty parameEty = new RequestParameEty();
-        parameEty.setHashMap(CommonUtil.getInstance().setHashMap(1,100,1,
-                0,0,type==2 ? 1 : type));
+        parameEty.setHashMap(
+                CommonUtil.getInstance()
+                        .setHashMap(1,
+                                100,
+                                1,
+                                0,
+                                0,
+                                type==2 ? 1 : type,
+                                gridViewEntity == null ? -1 :gridViewEntity.getId()));
         presenter.releaseTask(parameEty);
     }
 

+ 7 - 3
app/src/main/res/layout/try_makemoney_act_layout.xml

@@ -15,7 +15,8 @@
         android:paddingStart="@dimen/content_padding_10"
         android:paddingEnd="@dimen/content_padding_10"
         android:gravity="center_vertical"
-        android:orientation="horizontal">
+        android:orientation="horizontal"
+        android:visibility="gone">
         <TextView
             style="@style/style_ash_tv"
             android:text="接受任务"/>
@@ -66,13 +67,15 @@
             android:text="领取奖励"/>
     </LinearLayout>
     <LinearLayout
+        android:id="@+id/task_gridview_layout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
-        android:paddingLeft="@dimen/content_padding"
+        android:paddingLeft="@dimen/content_padding_3"
         android:paddingRight="@dimen/content_padding"
         android:paddingBottom="@dimen/content_padding_small"
-        android:paddingTop="@dimen/content_padding_small">
+        android:paddingTop="@dimen/content_padding_small"
+        android:background="@color/white">
         <com.sheep.gamegroup.util.MyGridview
             android:id="@+id/tab_gridview"
             android:layout_width="0dp"
@@ -100,6 +103,7 @@
         app:tabGravity="fill"
         app:tabSelectedTextColor="#4bc1fe"
         app:tabTextColor="#444444"
+        android:background="@color/white"
         app:tabMode="fixed" />
 
     <android.support.v4.view.ViewPager

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

@@ -9,6 +9,7 @@
     android:textSize="@dimen/text_size_3"
     android:textColor="@color/txt_black"
     android:padding="@dimen/content_padding_3"
+    android:lines="1"
     android:background="@color/white">
 
 </TextView>