|
|
@@ -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();
|
|
|
}
|
|
|
}
|