|
|
@@ -7,6 +7,9 @@ import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
+import android.support.v4.widget.SwipeRefreshLayout;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
@@ -22,6 +25,7 @@ import android.widget.ScrollView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bumptech.glide.Glide;
|
|
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|
|
@@ -32,6 +36,7 @@ import com.kfzs.duanduan.react.ReactUtil;
|
|
|
import com.layoutscroll.layoutscrollcontrols.view.EasyLayoutScroll;
|
|
|
import com.sheep.gamegroup.di.components.DaggerSmallSheepComponent;
|
|
|
import com.sheep.gamegroup.di.modules.SmallSheepModule;
|
|
|
+import com.sheep.gamegroup.di.modules.TryMakeMoneyModule;
|
|
|
import com.sheep.gamegroup.event.ImageHeadChange;
|
|
|
import com.sheep.gamegroup.event.MoneyChange;
|
|
|
import com.sheep.gamegroup.event.UserNameChange;
|
|
|
@@ -39,17 +44,26 @@ import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.MoreDataEntity;
|
|
|
import com.sheep.gamegroup.model.entity.NewbieTask;
|
|
|
import com.sheep.gamegroup.model.entity.NewbieTaskRecord;
|
|
|
+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.TaskAcceptedEty;
|
|
|
+import com.sheep.gamegroup.model.entity.TaskReleaseEty;
|
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.presenter.SmallSheepContract;
|
|
|
import com.sheep.gamegroup.presenter.SmallSheepPresenter;
|
|
|
+import com.sheep.gamegroup.presenter.TryMakeMoneyContract;
|
|
|
+import com.sheep.gamegroup.presenter.TryMakeMoneyPresenter;
|
|
|
import com.sheep.gamegroup.util.AppUtil;
|
|
|
import com.sheep.gamegroup.util.BinaryUtil;
|
|
|
+import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.ImageGlarryDrawable;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.gamegroup.util.PreferenceUtils;
|
|
|
import com.sheep.gamegroup.util.UMConfigUtils;
|
|
|
+import com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp;
|
|
|
import com.sheep.gamegroup.view.dialog.DialogNewbieTask1;
|
|
|
import com.sheep.gamegroup.view.dialog.DialogNewbieTaskList;
|
|
|
import com.sheep.gamegroup.view.dialog.DialogNewbieTaskRegistSuccess;
|
|
|
@@ -57,6 +71,7 @@ import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
+import com.sunfusheng.marqueeview.MarqueeView;
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
@@ -66,6 +81,7 @@ import org.xutils.ex.DbException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
|
|
|
@@ -78,10 +94,10 @@ import butterknife.Unbinder;
|
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
-public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContract.View {
|
|
|
+public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContract.View ,TryMakeMoneyContract.View{
|
|
|
|
|
|
@BindView(R.id.upview1)
|
|
|
- EasyLayoutScroll upview1;
|
|
|
+ MarqueeView upview1;
|
|
|
Unbinder unbinder;
|
|
|
|
|
|
@Override
|
|
|
@@ -114,6 +130,8 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
LinearLayout invitationLayout;
|
|
|
@BindView(R.id.lying_layout)
|
|
|
LinearLayout lyingLayout;
|
|
|
+ @BindView(R.id.card_layout)
|
|
|
+ LinearLayout card_layout;
|
|
|
@BindView(R.id.viewpager_banner)
|
|
|
ViewPager viewpager_banner;
|
|
|
@BindView(R.id.group_banner)
|
|
|
@@ -122,18 +140,37 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
ScrollView scrollView;
|
|
|
@BindView(R.id.newbie_task)
|
|
|
View newbie_task;
|
|
|
+ @BindView(R.id.refresh)
|
|
|
+ SwipeRefreshLayout refresh;
|
|
|
+ @BindView(R.id.recyclerview)
|
|
|
+ RecyclerView recyclerview;
|
|
|
|
|
|
@Inject
|
|
|
SmallSheepPresenter pagePresenter;
|
|
|
+ @Inject
|
|
|
+ TryMakeMoneyPresenter tryMakeMoneyPresenter;
|
|
|
private Activity activity;
|
|
|
private UserEntity userEntity;
|
|
|
List<View> views = new ArrayList<>();
|
|
|
|
|
|
+ //recyclerview
|
|
|
+ private TryMakeMoneyAdp tryMakeMoneyAdp;
|
|
|
+ private int position = 0;
|
|
|
+ private List<TaskReleaseEty> releaseEtyLists = new ArrayList<>();
|
|
|
+
|
|
|
Handler mHanderl = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
super.handleMessage(msg);
|
|
|
- refalsh();
|
|
|
+ switch (msg.what){
|
|
|
+ case 0:
|
|
|
+ refalsh();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.RELEASE_TASK, releaseEtyLists),position);
|
|
|
+ tryMakeMoneyAdp.notifyDataSetChanged();
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
};
|
|
|
@@ -145,8 +182,10 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
DaggerSmallSheepComponent.builder()
|
|
|
.netComponent(SheepApp.get(getContext()).getNetComponent())
|
|
|
.smallSheepModule(new SmallSheepModule(this))
|
|
|
+ .tryMakeMoneyModule(new TryMakeMoneyModule(this))
|
|
|
.build()
|
|
|
.inject(this);
|
|
|
+ recyclerInitView();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -178,33 +217,44 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
case MotionEvent.ACTION_DOWN:
|
|
|
if (upview1 != null) {
|
|
|
//开始滚动
|
|
|
- upview1.stopScroll();
|
|
|
+ upview1.stopFlipping();
|
|
|
}
|
|
|
break;
|
|
|
case MotionEvent.ACTION_UP:
|
|
|
if (upview1 != null) {
|
|
|
//开始滚动
|
|
|
- upview1.startScroll();
|
|
|
+ upview1.startFlipping();
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
if (upview1 != null) {
|
|
|
//开始滚动
|
|
|
- upview1.startScroll();
|
|
|
+ upview1.startFlipping();
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
|
+ @Override
|
|
|
+ public void onRefresh() {
|
|
|
+ initData();
|
|
|
+ refresh.setRefreshing(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //recyclerView 禁止滑动
|
|
|
+ recyclerview.setNestedScrollingEnabled(false);
|
|
|
}
|
|
|
|
|
|
public void initData() {
|
|
|
|
|
|
if (upview1 != null) {
|
|
|
//停止滚动
|
|
|
- upview1.stopScroll();
|
|
|
- upview1.startScroll();
|
|
|
+ upview1.stopFlipping();
|
|
|
+ upview1.startFlipping();
|
|
|
}
|
|
|
pagePresenter.getUserInfo();
|
|
|
|
|
|
@@ -213,8 +263,41 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
|
|
|
initWechatIsOpen();
|
|
|
+ recyclerInitData();//任务
|
|
|
+ pagePresenter.bulletin(null);//轮播
|
|
|
+ pagePresenter.slideshow(null);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * recyclerview
|
|
|
+ */
|
|
|
+ private void recyclerInitView(){
|
|
|
+
|
|
|
+ recyclerview.setLayoutManager(new LinearLayoutManager(activity));
|
|
|
+ tryMakeMoneyAdp = new TryMakeMoneyAdp(getActivity());
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
+ tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.NONE, null));
|
|
|
+ }
|
|
|
+ recyclerview.setAdapter(tryMakeMoneyAdp);
|
|
|
+ }
|
|
|
+ private void recyclerInitData(){
|
|
|
+
|
|
|
+
|
|
|
+ position = 0;
|
|
|
+ tryMakeMoneyAdp.clear();
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
+ tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.NONE, null));
|
|
|
+ }
|
|
|
+ tryMakeMoneyAdp.setTaskAcceptedEty(null);
|
|
|
+
|
|
|
+ RequestParameEty parameEty = new RequestParameEty();
|
|
|
+ parameEty.setHashMap(CommonUtil.getInstance().setHashMap(1,100,1,
|
|
|
+ 1,0,0));
|
|
|
|
|
|
+ tryMakeMoneyPresenter.releaseTask(parameEty);
|
|
|
}
|
|
|
+
|
|
|
private Boolean wechatIsOpen = null;
|
|
|
/**
|
|
|
* 获取微信挂机是否开启状态
|
|
|
@@ -264,6 +347,11 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
Jump2View.getInstance().goAskGetMoney(activity, null);
|
|
|
UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_TASK_INVITE);
|
|
|
break;
|
|
|
+ case R.id.card_layout://邀请赚钱
|
|
|
+ Jump2View.getInstance()
|
|
|
+ .goWebview(activity, 3);
|
|
|
+ UMConfigUtils.onEvent(UMConfigUtils.Event.TAB_CREDITCARD);
|
|
|
+ break;
|
|
|
case R.id.lying_layout://躺着赚钱
|
|
|
if(wechatIsOpen == null) {
|
|
|
G.showToast("网络异常,请稍候重试");
|
|
|
@@ -388,6 +476,88 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void acceptedTaskUpdataView(Object o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void failAcceptedTask2View(Object o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void giveUpTaskSuccesView(Object o) {
|
|
|
+ G.showToast("取消任务成功");
|
|
|
+ recyclerInitData();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void giveUpTaskFailView(Object o) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void returnTaskTaskUpdataView(Object o) {
|
|
|
+
|
|
|
+
|
|
|
+ try{
|
|
|
+ BaseMessage baseMessage = (BaseMessage) o;
|
|
|
+ TaskAcceptedEty taskAcceptedEty = JSONObject.parseObject(JSONObject.toJSONString(baseMessage.getData()), TaskAcceptedEty.class);
|
|
|
+ tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.RUN_TASK, taskAcceptedEty),position);
|
|
|
+ tryMakeMoneyAdp.addPresenter(tryMakeMoneyPresenter);
|
|
|
+ tryMakeMoneyAdp.setTaskAcceptedEty(taskAcceptedEty);
|
|
|
+ position ++;
|
|
|
+// mhandler.sendEmptyMessage(0);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ mHanderl.sendEmptyMessage(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void failReturnTask2View(Object o) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ BaseMessage baseMessage = (BaseMessage) o;
|
|
|
+ switch (baseMessage.getCode()){
|
|
|
+ case 300://未查询到正在运行的任务
|
|
|
+// G.showToast(" 未查询到正在运行的任务!");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ G.showToast(" 网络错误!");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ G.showToast(" 网络错误!");
|
|
|
+ }
|
|
|
+ mHanderl.sendEmptyMessage(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void releaseTaskTaskUpdataView(Object o) {
|
|
|
+
|
|
|
+ releaseEtyLists.clear();
|
|
|
+ try{
|
|
|
+ BaseMessage baseMessage = (BaseMessage) o;
|
|
|
+ List<TaskReleaseEty> releaseEtyList = JSONArray.parseArray(JSONArray.toJSONString(baseMessage.getData()), TaskReleaseEty.class);
|
|
|
+ if(releaseEtyList != null){
|
|
|
+ releaseEtyLists.addAll(releaseEtyList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ tryMakeMoneyPresenter.returnTask(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void failReleaseTask2View(Object o) {
|
|
|
+ tryMakeMoneyPresenter.returnTask(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void showMore(final List<MoreDataEntity> loginEty) {
|
|
|
getActivity().runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
@@ -400,6 +570,30 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 公告和轮播
|
|
|
+ * @param baseMessage
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void failSlideshow(BaseMessage baseMessage) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void successSlideshow(BaseMessage baseMessage) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void failbulletin(BaseMessage baseMessage) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void successbulletin(BaseMessage baseMessage) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
|
@@ -414,7 +608,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
super.onPause();
|
|
|
if (upview1 != null) {
|
|
|
//停止滚动
|
|
|
- upview1.stopScroll();
|
|
|
+ upview1.stopFlipping();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -432,6 +626,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
private void invite(final List<MoreDataEntity> loginEty){
|
|
|
views.clear();
|
|
|
+ upview1.removeAllViews();
|
|
|
for (MoreDataEntity entity:loginEty) {
|
|
|
StringBuilder sb=new StringBuilder();
|
|
|
sb.append(TimeStamp2Date(entity.getTime())+" ");
|
|
|
@@ -443,12 +638,12 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
TextView moreView = (TextView) LayoutInflater.from(getActivity()).inflate(R.layout.x_item_view, null);
|
|
|
moreView.setText(sb.toString());
|
|
|
views.add(moreView);
|
|
|
+ upview1.addView(moreView);
|
|
|
}
|
|
|
- upview1.removeAllViews();
|
|
|
- upview1.setEasyViews(views);
|
|
|
+// upview1.setEasyViews(views);
|
|
|
if(!upview1.isAutoStart()){
|
|
|
- upview1.stopScroll();
|
|
|
- upview1.startScroll();
|
|
|
+ upview1.stopFlipping();
|
|
|
+ upview1.startFlipping();
|
|
|
}
|
|
|
|
|
|
|