|
|
@@ -14,7 +14,6 @@ import android.support.v7.app.AlertDialog;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
|
-import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
@@ -23,9 +22,7 @@ import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
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.request.RequestOptions;
|
|
|
import com.kfzs.duanduan.BaseCompatFragment;
|
|
|
@@ -33,7 +30,6 @@ import com.kfzs.duanduan.event.BigEvent;
|
|
|
import com.kfzs.duanduan.react.ReactUtil;
|
|
|
import com.kfzs.duanduan.react.SharedPreferences;
|
|
|
import com.kfzs.duanduan.utils.NumberFormatUtils;
|
|
|
-import com.mdad.sdk.mdsdk.AdManager;
|
|
|
import com.sheep.gamegroup.di.components.DaggerSmallSheepComponent;
|
|
|
import com.sheep.gamegroup.di.modules.SmallSheepModule;
|
|
|
import com.sheep.gamegroup.di.modules.TryMakeMoneyModule;
|
|
|
@@ -59,18 +55,16 @@ import com.sheep.gamegroup.presenter.SmallSheepPresenter;
|
|
|
import com.sheep.gamegroup.presenter.TryMakeMoneyContract;
|
|
|
import com.sheep.gamegroup.presenter.TryMakeMoneyPresenter;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
+import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
-import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.gamegroup.util.MyGridview;
|
|
|
import com.sheep.gamegroup.util.MyListview;
|
|
|
-import com.sheep.gamegroup.util.PreferenceUtils;
|
|
|
import com.sheep.gamegroup.util.SysAppUtil;
|
|
|
import com.sheep.gamegroup.util.TestUtil;
|
|
|
import com.sheep.gamegroup.util.UMConfigUtils;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
-import com.sheep.gamegroup.util.glide.GlideCircleTransformWithBorder;
|
|
|
import com.sheep.gamegroup.view.activity.NotificationsUtils;
|
|
|
import com.sheep.gamegroup.view.adapter.AdpHomeListGrideview;
|
|
|
import com.sheep.gamegroup.view.adapter.AdpHomeListListview;
|
|
|
@@ -328,14 +322,14 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
|
|
|
//用户信息
|
|
|
- userEntity = CommonUtil.getInstance().getCacheResult(ApiKey.get_info, UserEntity.class);
|
|
|
+ userEntity = DataUtil.getInstance().getUserEntity();
|
|
|
if(userEntity == null){//onResume中从网络获取
|
|
|
} else {
|
|
|
loadUserInfo();
|
|
|
}
|
|
|
|
|
|
//实时动态
|
|
|
- List<MoreDataEntity> cacheMoreDataEtyList = CommonUtil.getInstance().getCacheList(ApiKey.award_detail, MoreDataEntity.class);
|
|
|
+ List<MoreDataEntity> cacheMoreDataEtyList = DataUtil.getInstance().getCacheList(ApiKey.award_detail, MoreDataEntity.class);
|
|
|
if(ListUtil.isEmpty(cacheMoreDataEtyList)){
|
|
|
pagePresenter.getAwardDetail();
|
|
|
} else {
|
|
|
@@ -349,15 +343,16 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.NONE, null));
|
|
|
}
|
|
|
- List<TaskAcceptedEty> cacheTaskAcceptedEtyList = CommonUtil.getInstance().getCacheList(ApiKey.new_run_task(3), TaskAcceptedEty.class);
|
|
|
+ List<TaskAcceptedEty> cacheTaskAcceptedEtyList = DataUtil.getInstance().getCacheList(ApiKey.new_run_task(3), TaskAcceptedEty.class);
|
|
|
if (ListUtil.isEmpty(cacheTaskAcceptedEtyList)) {//onResume中从网络获取
|
|
|
|
|
|
} else {
|
|
|
+ AutoTaskListUtil.getInstance().loadList(cacheTaskAcceptedEtyList);
|
|
|
tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.RUN_TASK, cacheTaskAcceptedEtyList), position);
|
|
|
tryMakeMoneyAdp.addPresenter(tryMakeMoneyPresenter);
|
|
|
position++;
|
|
|
}
|
|
|
- List<TaskReleaseEty> cacheTaskReleaseEtyList = CommonUtil.getInstance().getCacheList(ApiKey.release_task, TaskReleaseEty.class);
|
|
|
+ List<TaskReleaseEty> cacheTaskReleaseEtyList = DataUtil.getInstance().getCacheList(ApiKey.release_task, TaskReleaseEty.class);
|
|
|
if (ListUtil.isEmpty(cacheTaskReleaseEtyList)) {//onResume中从网络获取
|
|
|
|
|
|
} else {
|
|
|
@@ -369,7 +364,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
tryMakeMoneyAdp.notifyDataSetChanged();
|
|
|
|
|
|
//公告
|
|
|
- List<BulletinEnty> cacheBulletinEtyList = CommonUtil.getInstance().getCacheList(ApiKey.bulletin, BulletinEnty.class);
|
|
|
+ List<BulletinEnty> cacheBulletinEtyList = DataUtil.getInstance().getCacheList(ApiKey.bulletin, BulletinEnty.class);
|
|
|
if(ListUtil.isEmpty(cacheBulletinEtyList)){
|
|
|
homepageItemNoticeLayout.setVisibility(View.GONE);
|
|
|
pagePresenter.bulletin(null);
|
|
|
@@ -379,7 +374,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
inviteNotice(bulletinEntyLists);
|
|
|
}
|
|
|
//轮播
|
|
|
- List<SlideshowEty> cacheSlideshowEtyList = CommonUtil.getInstance().getCacheList(ApiKey.slideshow, SlideshowEty.class);
|
|
|
+ List<SlideshowEty> cacheSlideshowEtyList = DataUtil.getInstance().getCacheList(ApiKey.slideshow, SlideshowEty.class);
|
|
|
if(ListUtil.isEmpty(cacheSlideshowEtyList)){
|
|
|
banner.setVisibility(View.GONE);
|
|
|
pagePresenter.slideshow(null);
|
|
|
@@ -392,7 +387,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
bindBanner();
|
|
|
}
|
|
|
//首页list
|
|
|
- List<HomeListEntity> cacheHomeListEtyList = CommonUtil.getInstance().getCacheList(ApiKey.home_list, HomeListEntity.class);
|
|
|
+ List<HomeListEntity> cacheHomeListEtyList = DataUtil.getInstance().getCacheList(ApiKey.home_list, HomeListEntity.class);
|
|
|
if(ListUtil.isEmpty(cacheHomeListEtyList)){
|
|
|
home_list_gridview_layout.setVisibility(View.GONE);
|
|
|
pagePresenter.homeList();//首页list
|
|
|
@@ -436,9 +431,6 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- mInitData();
|
|
|
- }
|
|
|
- private void mInitData() {
|
|
|
if (upview1 != null) {
|
|
|
//停止滚动
|
|
|
upview1.stopFlipping();
|
|
|
@@ -545,29 +537,11 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
return;
|
|
|
}
|
|
|
BaseMessage baseMessage = (BaseMessage) o;
|
|
|
- userEntity = JSON.parseObject(JSONObject.toJSONString(baseMessage.getData()), UserEntity.class);
|
|
|
+ userEntity = baseMessage.getData(UserEntity.class);
|
|
|
if(userEntity == null){
|
|
|
return;
|
|
|
}
|
|
|
- new Handler().postDelayed(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- //幂动科技
|
|
|
- CommonUtil.getInstance().initMiDong(activity, userEntity.getId());
|
|
|
- }
|
|
|
- }, 500);
|
|
|
- //保存用户id信息
|
|
|
- PreferenceUtils.setPrefString(SheepApp.mContext, UMConfigUtils.LOGIN_OPENID, userEntity.getOpen_id());
|
|
|
- //保存用户邀请人邀请码
|
|
|
- PreferenceUtils.setPrefString(SheepApp.mContext, "invitation_code", userEntity.getParent_code());
|
|
|
- try {
|
|
|
- MyDbManager.getInstance().saveOrUpdateUser(userEntity);
|
|
|
-
|
|
|
-// userEntity = MyDbManager.getInstance().dbFindUser();
|
|
|
- Log.e("------userEntity", userEntity.getNickname() + "|" + userEntity.getMobile() + "");
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ DataUtil.getInstance().setUserEntity(userEntity);
|
|
|
mHanderl.sendEmptyMessage(0);
|
|
|
Jump2View.getInstance().tryShowNewbieTask(activity, userEntity, newbie_task);
|
|
|
}
|
|
|
@@ -675,7 +649,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- setViews(loginEty);
|
|
|
+ invite(loginEty);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -797,10 +771,29 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
@Override
|
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
|
- if(pagePresenter != null) {
|
|
|
- pagePresenter.getUserInfo();
|
|
|
- recyclerInitData();//任务
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ //幂动科技
|
|
|
+ CommonUtil.getInstance().initMiDong(activity, userEntity.getId());
|
|
|
+ }
|
|
|
+ }, 500);
|
|
|
+ UserEntity result = DataUtil.getInstance().getUserEntity();
|
|
|
+ if(result == null) {
|
|
|
+ CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
|
|
|
+ @Override
|
|
|
+ public void call(UserEntity item) {
|
|
|
+ if(item != null) {
|
|
|
+ userEntity = item;
|
|
|
+ loadUserInfo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ userEntity = result;
|
|
|
+ loadUserInfo();
|
|
|
}
|
|
|
+ recyclerInitData();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -816,29 +809,14 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void setViews(final List<MoreDataEntity> loginEty) {
|
|
|
-
|
|
|
- invite(loginEty);
|
|
|
-// new Handler().postDelayed(new Runnable(){
|
|
|
-// public void run() {
|
|
|
-//
|
|
|
-// }
|
|
|
-// },60000*2);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void invite(final List<MoreDataEntity> loginEty) {
|
|
|
+ private void invite(final List<MoreDataEntity> moreDataEntityList) {
|
|
|
views.clear();
|
|
|
upview1.removeAllViews();
|
|
|
- for (MoreDataEntity entity : loginEty) {
|
|
|
+ for (MoreDataEntity entity : moreDataEntityList) {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.append(TimeStamp2Date(entity.getTime())).append(" ");
|
|
|
sb.append(entity.getName()).append(" ");
|
|
|
sb.append(entity.getDesc());
|
|
|
-// LinearLayout moreView = (LinearLayout) LayoutInflater.from(activity).inflate(R.layout.x_item_view, null);
|
|
|
-// TextView tv_desc = moreView.findViewById(R.id.tv_desc);
|
|
|
-// tv_desc.setText(sb.toString());
|
|
|
TextView moreView = (TextView) LayoutInflater.from(activity).inflate(R.layout.x_item_view, null);
|
|
|
moreView.setText(sb.toString());
|
|
|
views.add(moreView);
|
|
|
@@ -923,13 +901,9 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
@Override
|
|
|
public void onAttach(Context context) {
|
|
|
super.onAttach(context);
|
|
|
- try {
|
|
|
- userEntity = MyDbManager.getInstance().dbFindUser();
|
|
|
- if (userEntity != null) {
|
|
|
- loadUserInfo();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ userEntity = DataUtil.getInstance().getUserEntity();
|
|
|
+ if (userEntity != null) {
|
|
|
+ loadUserInfo();
|
|
|
}
|
|
|
}
|
|
|
|