|
|
@@ -9,7 +9,9 @@ import android.text.TextUtils;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
+import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
|
|
import com.kfzs.duanduan.event.BigEvent;
|
|
|
import com.kfzs.duanduan.event.EventTypes;
|
|
|
import com.sheep.gamegroup.di.components.DaggerFgtTryMakeMoneyComponent;
|
|
|
@@ -17,7 +19,7 @@ import com.sheep.gamegroup.di.modules.TryMakeMoneyModule;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.RecyleObj;
|
|
|
import com.sheep.gamegroup.model.entity.RecyleType;
|
|
|
-import com.sheep.gamegroup.model.entity.RequestParameEty;
|
|
|
+import com.sheep.gamegroup.model.entity.RequestParamEty;
|
|
|
import com.sheep.gamegroup.model.entity.TaskAcceptedEty;
|
|
|
import com.sheep.gamegroup.model.entity.TaskReleaseEty;
|
|
|
import com.sheep.gamegroup.presenter.TryMakeMoneyContract;
|
|
|
@@ -25,6 +27,7 @@ import com.sheep.gamegroup.presenter.TryMakeMoneyPresenter;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
+import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.activity.GamemakeMoneyAct;
|
|
|
import com.sheep.gamegroup.view.activity.TryMakeMoneyact;
|
|
|
import com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp;
|
|
|
@@ -51,11 +54,9 @@ import butterknife.Unbinder;
|
|
|
* Created by ljy on 2018/4/26.
|
|
|
*/
|
|
|
|
|
|
-public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContract.View{
|
|
|
+public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContract.View {
|
|
|
@BindView(R.id.recyclerview)
|
|
|
- RecyclerView recyclerview;
|
|
|
- @BindView(R.id.refresh)
|
|
|
- SwipeRefreshLayout refresh;
|
|
|
+ XRecyclerView recyclerview;
|
|
|
@BindView(R.id.empty_view)
|
|
|
View empty_view;
|
|
|
Unbinder unbinder;
|
|
|
@@ -67,42 +68,69 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
private List<TaskAcceptedEty> acceptedEtyList = new ArrayList<>();
|
|
|
private List<TaskReleaseEty> releaseEtyLists = new ArrayList<>();
|
|
|
private List<TaskReleaseEty> releaseEtyListsBegin = new ArrayList<>();
|
|
|
- private int type = 0;
|
|
|
- private String show_type;
|
|
|
+ private int about_to_begin = 0;
|
|
|
+ private String show_type;//有值代表来自主页
|
|
|
private int is_succession;//0:一般任务 1:连续任务
|
|
|
|
|
|
private void checkAndInitView() {
|
|
|
- if(refresh == null)
|
|
|
- refresh = findViewById(R.id.refresh);
|
|
|
- if(empty_view == null)
|
|
|
+ if (empty_view == null)
|
|
|
empty_view = findViewById(R.id.empty_view);
|
|
|
}
|
|
|
+
|
|
|
private static final int LIST_COUNT = 3;//tryMakeMoneyAdp 总共有3条数据
|
|
|
private static final RecyleObj NULL = RecyleObj.make(RecyleType.NONE, null);//空数据
|
|
|
- private void notifyDataSetChanged(){
|
|
|
+
|
|
|
+ private void notifyDataSetChanged() {
|
|
|
checkAndInitView();
|
|
|
tryMakeMoneyAdp.clear();
|
|
|
- if(!ListUtil.isEmpty(acceptedEtyList))
|
|
|
+ if (!ListUtil.isEmpty(acceptedEtyList))
|
|
|
tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.RUN_TASK, acceptedEtyList));
|
|
|
- if(!ListUtil.isEmpty(releaseEtyLists))
|
|
|
+ if (!ListUtil.isEmpty(releaseEtyLists))
|
|
|
tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.RELEASE_TASK, releaseEtyLists));
|
|
|
- if(!ListUtil.isEmpty(releaseEtyListsBegin))
|
|
|
+ if (!ListUtil.isEmpty(releaseEtyListsBegin))
|
|
|
tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.BEGIN_TASK, releaseEtyListsBegin));
|
|
|
tryMakeMoneyAdp.refreshAdapter();
|
|
|
boolean showEmpty = acceptedEtyList.isEmpty() && releaseEtyLists.isEmpty() && releaseEtyListsBegin.isEmpty();
|
|
|
CommonUtil.getInstance().updateEmptyView(empty_view, showEmpty);
|
|
|
- refresh.setRefreshing(false);
|
|
|
- if(!TextUtils.isEmpty(show_type))
|
|
|
+ recyclerview.refreshComplete();
|
|
|
+ recyclerview.loadMoreComplete();
|
|
|
+ notifyBottomLine(false);
|
|
|
+ if (!TextUtils.isEmpty(show_type))
|
|
|
EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.FGT_SHEEP_REFRESH_H));
|
|
|
}
|
|
|
- public static FgtTryMakeMoney newInstance(int type){
|
|
|
+
|
|
|
+ private void notifyBottomLine(boolean noMore) {
|
|
|
+ if(bottomLine != null) {
|
|
|
+ if (!TextUtils.isEmpty(show_type)){
|
|
|
+ bottomLine.setVisibility(View.GONE);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int count = getDataCount();
|
|
|
+ bottomLine.setVisibility(count == 0 ? View.INVISIBLE : View.VISIBLE);
|
|
|
+ if(noMore) {
|
|
|
+ final boolean isCanScrollToPosition = count > 10;//页数大于一页才显示点击回到顶部
|
|
|
+ TextView bottom_line_text = bottomLine.findViewById(R.id.bottom_line_text);
|
|
|
+ bottom_line_text.setText(isCanScrollToPosition ? "我是有底线的,点击我回到顶部" : "我是有底线的");
|
|
|
+ bottomLine.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ if (isCanScrollToPosition)
|
|
|
+ recyclerview.scrollToPosition(0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static FgtTryMakeMoney newInstance(int type) {
|
|
|
FgtTryMakeMoney fgtTryMakeMoney = new FgtTryMakeMoney();
|
|
|
Bundle bundle = new Bundle();
|
|
|
bundle.putInt("type", type);
|
|
|
fgtTryMakeMoney.setArguments(bundle);
|
|
|
return fgtTryMakeMoney;
|
|
|
}
|
|
|
- public static FgtTryMakeMoney newInstance(int type,String show_type){
|
|
|
+
|
|
|
+ public static FgtTryMakeMoney newInstance(int type, String show_type) {
|
|
|
FgtTryMakeMoney fgtTryMakeMoney = new FgtTryMakeMoney();
|
|
|
Bundle bundle = new Bundle();
|
|
|
bundle.putInt("type", type);
|
|
|
@@ -116,13 +144,24 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
- // TODO: inflate a fragment view
|
|
|
View rootView = super.onCreateView(inflater, container, savedInstanceState);
|
|
|
unbinder = ButterKnife.bind(this, rootView);
|
|
|
Bundle bundle = getArguments();
|
|
|
- if(bundle != null){
|
|
|
- type = bundle.getInt("type", 0);
|
|
|
+ if (bundle != null) {
|
|
|
+ about_to_begin = bundle.getInt("type", 0);
|
|
|
show_type = bundle.getString("show_type", "");
|
|
|
+ switch (show_type){
|
|
|
+ case "is_hot":
|
|
|
+ isGetRelease = true;
|
|
|
+ break;
|
|
|
+ case "about_to_begin":
|
|
|
+ isGetReleaseBegin = true;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ isGetRelease = true;
|
|
|
+ isGetReleaseBegin = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
return rootView;
|
|
|
}
|
|
|
@@ -137,18 +176,21 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
activity = getActivity();
|
|
|
initView();
|
|
|
initData();
|
|
|
+ initListener();
|
|
|
}
|
|
|
+
|
|
|
private String task_type = "-1";
|
|
|
private boolean isGameTask = false;
|
|
|
+
|
|
|
public void initView() {
|
|
|
- if(activity == null){
|
|
|
+ if (activity == null) {
|
|
|
return;
|
|
|
}
|
|
|
- if(activity instanceof TryMakeMoneyact) {//试玩任务、连续任务
|
|
|
+ if (activity instanceof TryMakeMoneyact) {//试玩任务、连续任务
|
|
|
is_succession = ((TryMakeMoneyact) activity).getIsSuccession();
|
|
|
task_type = "-1";
|
|
|
isGameTask = false;
|
|
|
- } else if(activity instanceof GamemakeMoneyAct) {//游戏任务
|
|
|
+ } else if (activity instanceof GamemakeMoneyAct) {//游戏任务
|
|
|
is_succession = ((GamemakeMoneyAct) activity).getIsSuccession();
|
|
|
task_type = "1002,1003,1004";
|
|
|
isGameTask = true;
|
|
|
@@ -160,102 +202,134 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
.inject(FgtTryMakeMoney.this);
|
|
|
recyclerview.setLayoutManager(new LinearLayoutManager(activity));
|
|
|
tryMakeMoneyAdp = new TryMakeMoneyAdp(activity);
|
|
|
- tryMakeMoneyAdp.addType(type);
|
|
|
+ tryMakeMoneyAdp.addType(about_to_begin);
|
|
|
tryMakeMoneyAdp.addShowType(show_type);
|
|
|
- tryMakeMoneyAdp.setIs_succession(TextUtils.isEmpty(show_type)?is_succession:3);
|
|
|
+ tryMakeMoneyAdp.setIs_succession(TextUtils.isEmpty(show_type) ? is_succession : 3);
|
|
|
tryMakeMoneyAdp.addPresenter(presenter);
|
|
|
for (int i = 0; i < LIST_COUNT; i++) {
|
|
|
tryMakeMoneyAdp.add(NULL);
|
|
|
}
|
|
|
recyclerview.setAdapter(tryMakeMoneyAdp);
|
|
|
|
|
|
- initListener();
|
|
|
+ bottomLine = ViewUtil.setBottomLine(recyclerview);
|
|
|
|
|
|
}
|
|
|
+ private View bottomLine;
|
|
|
|
|
|
public void initListener() {
|
|
|
- refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
|
+ recyclerview.setLoadingListener(new XRecyclerView.LoadingListener() {
|
|
|
@Override
|
|
|
public void onRefresh() {
|
|
|
refreshData();
|
|
|
}
|
|
|
- });
|
|
|
- recyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
|
- @Override
|
|
|
- public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
|
- super.onScrollStateChanged(recyclerView, newState);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
- public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
|
-
|
|
|
- int topRowVerticalPosition =
|
|
|
- (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
|
|
|
-
|
|
|
- refresh.setEnabled(topRowVerticalPosition >= 0);
|
|
|
+ public void onLoadMore() {
|
|
|
+ boolean noMoreRelease = true;
|
|
|
+ boolean noMoreReleaseBegin = true;
|
|
|
+
|
|
|
+ if(isGetRelease) {
|
|
|
+ if (ListUtil.size(releaseEtyLists) >= per_page * releasePage) {
|
|
|
+ releasePage += 1;
|
|
|
+ noMoreRelease = false;
|
|
|
+ //先加载缓存
|
|
|
+ getReleaseFromACache(0);
|
|
|
+ //再加载网络数据
|
|
|
+ getReleaseFromNetWork(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isGetReleaseBegin) {
|
|
|
+ if (ListUtil.size(releaseEtyListsBegin) >= per_page * releaseBeginPage) {
|
|
|
+ releaseBeginPage += 1;
|
|
|
+ noMoreReleaseBegin = false;
|
|
|
+ //先加载缓存
|
|
|
+ getReleaseFromACache(1);
|
|
|
+ //再加载网络数据
|
|
|
+ getReleaseFromNetWork(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(noMoreRelease && noMoreReleaseBegin){
|
|
|
+ recyclerview.setNoMore(true);
|
|
|
+ notifyBottomLine(true);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
private boolean isFirstCache = false;//是否首先尝试缓存
|
|
|
+
|
|
|
//先尝试缓存数据,无缓存数据时,再尝试获取网络数据
|
|
|
- public void initData(){
|
|
|
+ public void initData() {
|
|
|
isFirstCache = true;
|
|
|
mInitData();
|
|
|
}
|
|
|
+
|
|
|
//强制刷新数据
|
|
|
- public void refreshData(){
|
|
|
+ public void refreshData() {
|
|
|
isFirstCache = false;
|
|
|
- if(TextUtils.isEmpty(show_type))
|
|
|
- if(refresh != null)
|
|
|
- refresh.setRefreshing(true);
|
|
|
+ releasePage = 1;
|
|
|
+ releaseBeginPage = 1;
|
|
|
mInitData();
|
|
|
}
|
|
|
+
|
|
|
+ private int releasePage = 1;
|
|
|
+ private int releaseBeginPage = 1;
|
|
|
+ private int per_page = 10;
|
|
|
+ //是否获取发布的任务列表
|
|
|
+ private boolean isGetRelease = false;
|
|
|
+ //是否获取即将开始的列表
|
|
|
+ private boolean isGetReleaseBegin = false;
|
|
|
+
|
|
|
public void mInitData() {
|
|
|
- if(!acceptedEtyList.isEmpty()) {
|
|
|
+ if (!acceptedEtyList.isEmpty()) {
|
|
|
acceptedEtyList.clear();
|
|
|
notifyDataSetChanged();
|
|
|
}
|
|
|
CommonUtil.getInstance().resetEmptyView(empty_view);
|
|
|
- //加载缓存
|
|
|
- if(TextUtils.isEmpty(show_type))
|
|
|
- type = 0;
|
|
|
- if(isFirstCache){
|
|
|
+ if (isFirstCache) {
|
|
|
//注释掉获取缓存的正在进行的任务
|
|
|
List<TaskAcceptedEty> cacheTaskAcceptedEtyList;
|
|
|
- if(isGameTask) {
|
|
|
+ if (isGameTask) {
|
|
|
cacheTaskAcceptedEtyList = DataUtil.getInstance().getCacheList(ApiKey.run_game_task, TaskAcceptedEty.class);
|
|
|
} else {
|
|
|
- cacheTaskAcceptedEtyList = DataUtil.getInstance().getCacheList(ApiKey.new_run_task(TextUtils.isEmpty(show_type)?is_succession:3, 0), TaskAcceptedEty.class);
|
|
|
+ cacheTaskAcceptedEtyList = DataUtil.getInstance().getCacheList(ApiKey.new_run_task(TextUtils.isEmpty(show_type) ? is_succession : 3, 0), TaskAcceptedEty.class);
|
|
|
}
|
|
|
if (ListUtil.isEmpty(cacheTaskAcceptedEtyList)) {
|
|
|
acceptedEtyList.clear();
|
|
|
} else {
|
|
|
acceptedEtyList = cacheTaskAcceptedEtyList;
|
|
|
- if(!ListUtil.isEmpty(acceptedEtyList)){//清除时间数据,缓存数据不显示时间
|
|
|
+ if (!ListUtil.isEmpty(acceptedEtyList)) {//清除时间数据,缓存数据不显示时间
|
|
|
for (TaskAcceptedEty taskAcceptedEty : acceptedEtyList) {
|
|
|
taskAcceptedEty.setEnd_time(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- getFromACache(type);
|
|
|
}
|
|
|
- //加载网络数据
|
|
|
- if(TextUtils.isEmpty(show_type))//这里为
|
|
|
- type = 0;
|
|
|
- getFromNetWork(type);
|
|
|
+ initAcceptedTaskList();
|
|
|
+ if(isGetRelease) {
|
|
|
+ //先加载缓存
|
|
|
+ getReleaseFromACache(0);
|
|
|
+ //再加载网络数据
|
|
|
+ getReleaseFromNetWork(0);
|
|
|
+ }
|
|
|
+ if(isGetReleaseBegin) {
|
|
|
+ //先加载缓存
|
|
|
+ getReleaseFromACache(1);
|
|
|
+ //再加载网络数据
|
|
|
+ getReleaseFromNetWork(1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取正在运行的任务
|
|
|
*/
|
|
|
private void initAcceptedTaskList() {
|
|
|
- if(isGameTask){
|
|
|
+ if (isGameTask) {
|
|
|
presenter.runGameTask();
|
|
|
- } else if(!TextUtils.isEmpty(show_type)){
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- presenter.returnTask(TextUtils.isEmpty(show_type)?is_succession:3, 0);
|
|
|
+ } else if (TextUtils.isEmpty(show_type)) {
|
|
|
+ presenter.returnTask(is_succession, 0);
|
|
|
+ } else {//主页不加载数据
|
|
|
+// presenter.returnTask(3, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -284,7 +358,7 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
public void failAcceptedTask2View(Object o) {
|
|
|
try {
|
|
|
BaseMessage baseMessage = (BaseMessage) o;
|
|
|
- switch (baseMessage.getCode()){
|
|
|
+ switch (baseMessage.getCode()) {
|
|
|
case 300://未查询到数据
|
|
|
G.showToast(" 未查询到数据!");
|
|
|
break;
|
|
|
@@ -292,7 +366,7 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
G.showToast(" 网络错误!");
|
|
|
break;
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
G.showToast(" 网络错误!");
|
|
|
}
|
|
|
@@ -309,16 +383,16 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
public void giveUpTaskFailView(Object o) {
|
|
|
try {
|
|
|
BaseMessage baseMessage = (BaseMessage) o;
|
|
|
- G.showToast(baseMessage.getMsg()+"");
|
|
|
- }catch (Exception e){
|
|
|
+ G.showToast(baseMessage.getMsg() + "");
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void returnTaskTaskUpdataView(Object object) {
|
|
|
- boolean isNewData = DataUtil.getInstance().isNewData(isGameTask ? ApiKey.run_game_task : ApiKey.new_run_task(TextUtils.isEmpty(show_type)?is_succession:3, 0));
|
|
|
- if(isNewData) {
|
|
|
+ public void returnTaskTaskUpdateView(Object object) {
|
|
|
+ boolean isNewData = DataUtil.getInstance().isNewData(isGameTask ? ApiKey.run_game_task : ApiKey.new_run_task(TextUtils.isEmpty(show_type) ? is_succession : 3, 0));
|
|
|
+ if (isNewData) {
|
|
|
if (object instanceof BaseMessage) {
|
|
|
List<TaskAcceptedEty> taskAcceptedEty = ((BaseMessage) object).getDataList(TaskAcceptedEty.class);
|
|
|
if (ListUtil.isEmpty(taskAcceptedEty)) {
|
|
|
@@ -327,64 +401,52 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
acceptedEtyList.clear();
|
|
|
acceptedEtyList.addAll(taskAcceptedEty);
|
|
|
}
|
|
|
- notifyDataSetChanged();
|
|
|
}
|
|
|
}
|
|
|
- refresh.setRefreshing(false);
|
|
|
+ notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void failReturnTask2View(Object object) {
|
|
|
- if(!acceptedEtyList.isEmpty()) {
|
|
|
+ if (!acceptedEtyList.isEmpty()) {
|
|
|
acceptedEtyList.clear();
|
|
|
- notifyDataSetChanged();
|
|
|
}
|
|
|
- refresh.setRefreshing(false);
|
|
|
+ notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取已经发布任务
|
|
|
- * @param object
|
|
|
+ * 获取已经发布任务
|
|
|
+ *
|
|
|
+ * @param baseMessage
|
|
|
*/
|
|
|
@Override
|
|
|
- public void releaseTaskTaskUpdataView(Object object) {
|
|
|
- boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.release_task(type, task_type, TextUtils.isEmpty(show_type)?is_succession:3));
|
|
|
- if(isNewData && object instanceof BaseMessage) {
|
|
|
- List<TaskReleaseEty> releaseEtyList = ((BaseMessage) object).getDataList(TaskReleaseEty.class);
|
|
|
- switch (type) {
|
|
|
+ public void releaseTaskTaskUpdateView(BaseMessage baseMessage, int about_to_begin) {
|
|
|
+ boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.release_task(about_to_begin == 0 ? releasePage : releaseBeginPage, per_page, about_to_begin, task_type, TextUtils.isEmpty(show_type) ? is_succession : 3));
|
|
|
+ if (isNewData) {
|
|
|
+ List<TaskReleaseEty> releaseEtyList = baseMessage.getDataList(TaskReleaseEty.class);
|
|
|
+ switch (about_to_begin) {
|
|
|
case 0:
|
|
|
- releaseEtyLists.clear();
|
|
|
- releaseEtyLists.addAll(releaseEtyList);
|
|
|
+ ListUtil.addAll(releaseEtyLists, releaseEtyList);
|
|
|
break;
|
|
|
case 1:
|
|
|
- releaseEtyListsBegin.clear();
|
|
|
- releaseEtyListsBegin.addAll(releaseEtyList);
|
|
|
+ ListUtil.addAll(releaseEtyListsBegin, releaseEtyList);
|
|
|
break;
|
|
|
}
|
|
|
- notifyDataSetChanged();
|
|
|
}
|
|
|
- getFromNetWorkFirst(type);
|
|
|
+ notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void failReleaseTask2View(Object object) {
|
|
|
- switch (type){
|
|
|
- case 0:
|
|
|
- releaseEtyLists.clear();
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- releaseEtyListsBegin.clear();
|
|
|
- break;
|
|
|
- }
|
|
|
+ public void failReleaseTask2View(BaseMessage baseMessage, int about_to_begin) {
|
|
|
notifyDataSetChanged();
|
|
|
- getFromNetWorkFirst(type);
|
|
|
}
|
|
|
|
|
|
private int onResumeCount = 0;
|
|
|
+
|
|
|
@Override
|
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
|
- if (onResumeCount > 0 && presenter != null){//直接全部刷新
|
|
|
+ if (onResumeCount > 0 && presenter != null) {//直接全部刷新
|
|
|
refreshData();
|
|
|
}
|
|
|
onResumeCount++;
|
|
|
@@ -393,79 +455,43 @@ public class FgtTryMakeMoney extends BaseFragment implements TryMakeMoneyContrac
|
|
|
@Override
|
|
|
public void onPause() {
|
|
|
super.onPause();
|
|
|
- if(tryMakeMoneyAdp != null){
|
|
|
+ if (tryMakeMoneyAdp != null) {
|
|
|
tryMakeMoneyAdp.cancelAllTimers();
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * 发布的任务
|
|
|
- * type: 0 1
|
|
|
- */
|
|
|
- private void getFromACacheFirst(int type){
|
|
|
- if(TextUtils.isEmpty(show_type)){
|
|
|
- this.type = ++type;
|
|
|
- getFromACache(this.type);
|
|
|
- }
|
|
|
- }
|
|
|
- private void getFromACache(int type){
|
|
|
+
|
|
|
+ //从ACache获取发布的任务列表
|
|
|
+ private void getReleaseFromACache(int about_to_begin) {
|
|
|
try {
|
|
|
- if(type > 1){
|
|
|
- return;
|
|
|
- }
|
|
|
- List<TaskReleaseEty> cacheTaskReleaseEtyList = DataUtil.getInstance().getCacheList(ApiKey.release_task(type, task_type, TextUtils.isEmpty(show_type)?is_succession:3), TaskReleaseEty.class);
|
|
|
- switch (type){
|
|
|
+ List<TaskReleaseEty> cacheTaskReleaseEtyList = DataUtil.getInstance().getCacheList(ApiKey.release_task(about_to_begin == 0 ? releasePage : releaseBeginPage, per_page, about_to_begin, task_type, TextUtils.isEmpty(show_type) ? is_succession : 3), TaskReleaseEty.class);
|
|
|
+ switch (about_to_begin) {
|
|
|
case 0:
|
|
|
- if(cacheTaskReleaseEtyList == null) {
|
|
|
- releaseEtyLists.clear();
|
|
|
- } else {
|
|
|
- releaseEtyLists.clear();
|
|
|
- releaseEtyLists.addAll(cacheTaskReleaseEtyList);
|
|
|
- notifyDataSetChanged();
|
|
|
- getFromACacheFirst(type);
|
|
|
- }
|
|
|
+ ListUtil.addAll(releaseEtyLists, cacheTaskReleaseEtyList);
|
|
|
break;
|
|
|
case 1:
|
|
|
- if(cacheTaskReleaseEtyList == null) {
|
|
|
- releaseEtyListsBegin.clear();
|
|
|
- } else {
|
|
|
- releaseEtyListsBegin.clear();
|
|
|
- releaseEtyListsBegin.addAll(cacheTaskReleaseEtyList);
|
|
|
- notifyDataSetChanged();
|
|
|
- getFromACacheFirst(type);
|
|
|
- }
|
|
|
+ ListUtil.addAll(releaseEtyListsBegin, cacheTaskReleaseEtyList);
|
|
|
break;
|
|
|
}
|
|
|
+ notifyDataSetChanged();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * 发布的任务
|
|
|
- * type: 0 1
|
|
|
- */
|
|
|
- private void getFromNetWorkFirst(int type){
|
|
|
- if(TextUtils.isEmpty(show_type)){
|
|
|
- this.type = ++type;
|
|
|
- getFromNetWork(this.type);
|
|
|
- }
|
|
|
- }
|
|
|
- private void getFromNetWork(int type){
|
|
|
- if(type > 1){
|
|
|
- initAcceptedTaskList();
|
|
|
- return;
|
|
|
- }
|
|
|
- RequestParameEty parameEty = new RequestParameEty();
|
|
|
- parameEty.setHashMap(
|
|
|
+
|
|
|
+ //从网络获取发布的任务列表
|
|
|
+ private void getReleaseFromNetWork(int about_to_begin) {
|
|
|
+ RequestParamEty paramEty = new RequestParamEty();
|
|
|
+ paramEty.setHashMap(
|
|
|
CommonUtil.getInstance()
|
|
|
- .setHashMap(1,
|
|
|
- 100,
|
|
|
+ .setHashMap(about_to_begin == 0 ? releasePage : releaseBeginPage,
|
|
|
+ per_page,
|
|
|
SheepApp.getInstance().getConnectAddress().getPlatForm(),
|
|
|
- TextUtils.isEmpty(show_type)?0:show_type.equals("is_hot")?1:0,
|
|
|
+ TextUtils.isEmpty(show_type) ? 0 : show_type.equals("is_hot") ? 1 : 0,
|
|
|
0,
|
|
|
- type,
|
|
|
+ about_to_begin,
|
|
|
task_type,
|
|
|
- TextUtils.isEmpty(show_type)?is_succession:3));
|
|
|
- presenter.releaseTask(parameEty);
|
|
|
+ TextUtils.isEmpty(show_type) ? is_succession : 3));
|
|
|
+ presenter.releaseTask(paramEty);
|
|
|
}
|
|
|
|
|
|
public int getDataCount() {
|