|
|
@@ -1,10 +1,12 @@
|
|
|
package com.kfzs.duanduan.fragment;
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
+import android.app.ActionBar;
|
|
|
import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.graphics.Color;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
@@ -18,12 +20,14 @@ import android.support.v7.app.AlertDialog;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -38,6 +42,7 @@ import com.kfzs.duanduan.view.ViewPagerAutoHeigh;
|
|
|
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.model.api.RedPackageMoney;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.BulletinEnty;
|
|
|
import com.sheep.gamegroup.model.entity.Ext;
|
|
|
@@ -105,6 +110,7 @@ import butterknife.Unbinder;
|
|
|
import rx.functions.Action1;
|
|
|
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.NEWBIE_TASK;
|
|
|
+import static com.sheep.gamegroup.util.ViewUtil.backgroundAlpha;
|
|
|
|
|
|
public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContract.View, TryMakeMoneyContract.View {
|
|
|
|
|
|
@@ -202,10 +208,10 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
break;
|
|
|
case 1:
|
|
|
tryMakeMoneyAdp.clear();
|
|
|
- if(!ListUtil.isEmpty(allTaskAcceptedTaskList)){
|
|
|
+ if (!ListUtil.isEmpty(allTaskAcceptedTaskList)) {
|
|
|
tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.RUN_TASK, allTaskAcceptedTaskList));
|
|
|
}
|
|
|
- if(!ListUtil.isEmpty(releaseEtyLists)) {
|
|
|
+ if (!ListUtil.isEmpty(releaseEtyLists)) {
|
|
|
tryMakeMoneyAdp.add(RecyleObj.make(RecyleType.RELEASE_TASK, releaseEtyLists));
|
|
|
}
|
|
|
tryMakeMoneyAdp.notifyDataSetChanged();
|
|
|
@@ -216,6 +222,18 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @return 是否显示红包
|
|
|
+ */
|
|
|
+ private void isShowRedPackage() {
|
|
|
+ if (userEntity == null) {
|
|
|
+ userEntity = DataUtil.getInstance().getUserEntity();
|
|
|
+ }
|
|
|
+ if (((userEntity.getNewbie_task_status() & (1 << 4)) == 0) && (userEntity.getParent_code().equals("")) && (userEntity.getIs_new() == 1)) {
|
|
|
+ showRedPackage(getActivity(), LayoutInflater.from(getContext()).inflate(R.layout.homepage_act_layout, null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void initView(Bundle savedInstanceState) {
|
|
|
setContentView(R.layout.homepage_act_layout);
|
|
|
@@ -232,6 +250,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
//每次进入主页都刷新一下url配置信息
|
|
|
CommonUtil.getInstance().initUrlConfigByNet(null, null);
|
|
|
+ isShowRedPackage();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -341,7 +360,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
public void run() {
|
|
|
toolBarPositionY = tabLayout.getHeight();
|
|
|
ViewGroup.LayoutParams params = mViewPager.getLayoutParams();
|
|
|
- params.height = G.HEIGHT - toolBarPositionY - tabLayout.getHeight()+1;
|
|
|
+ params.height = G.HEIGHT - toolBarPositionY - tabLayout.getHeight() + 1;
|
|
|
mViewPager.setLayoutParams(params);
|
|
|
}
|
|
|
});
|
|
|
@@ -380,7 +399,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
|
|
|
//用户信息
|
|
|
userEntity = DataUtil.getInstance().getUserEntity();
|
|
|
- if(userEntity != null){
|
|
|
+ if (userEntity != null) {
|
|
|
loadUserInfo();
|
|
|
}
|
|
|
//任务
|
|
|
@@ -393,13 +412,13 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
|
|
|
//实时动态
|
|
|
List<MoreDataEntity> cacheMoreDataEtyList = DataUtil.getInstance().getCacheList(ApiKey.award_detail, MoreDataEntity.class);
|
|
|
- if(!ListUtil.isEmpty(cacheMoreDataEtyList)){
|
|
|
+ if (!ListUtil.isEmpty(cacheMoreDataEtyList)) {
|
|
|
invite(cacheMoreDataEtyList);
|
|
|
}
|
|
|
|
|
|
//公告
|
|
|
List<BulletinEnty> cacheBulletinEtyList = DataUtil.getInstance().getCacheList(ApiKey.bulletin, BulletinEnty.class);
|
|
|
- if(ListUtil.isEmpty(cacheBulletinEtyList)){
|
|
|
+ if (ListUtil.isEmpty(cacheBulletinEtyList)) {
|
|
|
homepageItemNoticeLayout.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
bulletinEntyLists.clear();
|
|
|
@@ -408,7 +427,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
//轮播
|
|
|
List<SlideshowEty> cacheSlideshowEtyList = DataUtil.getInstance().getCacheList(ApiKey.slideshow, SlideshowEty.class);
|
|
|
- if(ListUtil.isEmpty(cacheSlideshowEtyList)){
|
|
|
+ if (ListUtil.isEmpty(cacheSlideshowEtyList)) {
|
|
|
banner.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
for (SlideshowEty slideshowEty : cacheSlideshowEtyList) {
|
|
|
@@ -420,7 +439,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
//首页list
|
|
|
List<HomeListEntity> cacheHomeListEtyList = DataUtil.getInstance().getCacheList(ApiKey.home_list, HomeListEntity.class);
|
|
|
- if(ListUtil.isEmpty(cacheHomeListEtyList)){
|
|
|
+ if (ListUtil.isEmpty(cacheHomeListEtyList)) {
|
|
|
home_list_gridview_layout.setVisibility(View.GONE);
|
|
|
} else {
|
|
|
home_list_gridview_layout.setVisibility(View.VISIBLE);
|
|
|
@@ -452,6 +471,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
|
|
|
int toolBarPositionY;
|
|
|
+
|
|
|
/**
|
|
|
* 刷新数据
|
|
|
*/
|
|
|
@@ -503,7 +523,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
public void run() {
|
|
|
toolBarPositionY = tabLayout.getHeight();
|
|
|
ViewGroup.LayoutParams params = mViewPager.getLayoutParams();
|
|
|
- params.height = G.HEIGHT - toolBarPositionY - tabLayout.getHeight()+1;
|
|
|
+ params.height = G.HEIGHT - toolBarPositionY - tabLayout.getHeight() + 1;
|
|
|
mViewPager.setLayoutParams(params);
|
|
|
}
|
|
|
});
|
|
|
@@ -544,7 +564,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
1,
|
|
|
0,
|
|
|
0,
|
|
|
- "-1",
|
|
|
+ "-1",
|
|
|
3));
|
|
|
// tryMakeMoneyPresenter.releaseTask(parameEty);
|
|
|
}
|
|
|
@@ -584,7 +604,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
BaseMessage baseMessage = (BaseMessage) o;
|
|
|
userEntity = baseMessage.getData(UserEntity.class);
|
|
|
- if(userEntity == null){
|
|
|
+ if (userEntity == null) {
|
|
|
return;
|
|
|
}
|
|
|
DataUtil.getInstance().setUserEntity(userEntity);
|
|
|
@@ -618,12 +638,14 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
public void giveUpTaskFailView(Object o) {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
private int is_succession = 3;//所有
|
|
|
private int show_game_task = 1;//包含游戏任务
|
|
|
+
|
|
|
@Override
|
|
|
public void returnTaskTaskUpdataView(Object object) {
|
|
|
boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.new_run_task(is_succession, show_game_task));
|
|
|
- if(isNewData) {
|
|
|
+ if (isNewData) {
|
|
|
BaseMessage baseMessage = (BaseMessage) object;
|
|
|
allTaskAcceptedTaskList = baseMessage.getDataList(TaskAcceptedEty.class);
|
|
|
AutoTaskListUtil.getInstance().loadList(allTaskAcceptedTaskList);
|
|
|
@@ -657,7 +679,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
@Override
|
|
|
public void releaseTaskTaskUpdataView(Object object) {
|
|
|
boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.release_task);
|
|
|
- if(isNewData && object instanceof BaseMessage) {
|
|
|
+ if (isNewData && object instanceof BaseMessage) {
|
|
|
List<TaskReleaseEty> releaseEtyList = ((BaseMessage) object).getDataList(TaskReleaseEty.class);
|
|
|
if (releaseEtyList != null) {
|
|
|
releaseEtyLists = releaseEtyList;
|
|
|
@@ -695,7 +717,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
@Override
|
|
|
public void successSlideshow(BaseMessage baseMessage) {
|
|
|
boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.slideshow);
|
|
|
- if(isNewData){
|
|
|
+ if (isNewData) {
|
|
|
List<SlideshowEty> slideshowEtyList = baseMessage.getDataList(SlideshowEty.class);
|
|
|
if (ListUtil.isEmpty(slideshowEtyList)) {
|
|
|
banner.setVisibility(View.GONE);
|
|
|
@@ -720,7 +742,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
@Override
|
|
|
public void successbulletin(BaseMessage baseMessage) {
|
|
|
boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.bulletin);
|
|
|
- if(isNewData){
|
|
|
+ if (isNewData) {
|
|
|
List<BulletinEnty> bulletinEntyList = JSONArray.parseArray(JSONArray.toJSONString(baseMessage.getData()), BulletinEnty.class);
|
|
|
if (ListUtil.isEmpty(bulletinEntyList)) {
|
|
|
homepageItemNoticeLayout.setVisibility(View.GONE);
|
|
|
@@ -736,7 +758,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
public void successhomeList(BaseMessage baseMessage) {
|
|
|
checkAndInitView();
|
|
|
boolean isNewData = DataUtil.getInstance().isNewData(ApiKey.home_list);
|
|
|
- if(isNewData){
|
|
|
+ if (isNewData) {
|
|
|
List<HomeListEntity> homeListEntityList = baseMessage.getDataList(HomeListEntity.class);
|
|
|
if (ListUtil.isEmpty(homeListEntityList)) {
|
|
|
home_list_gridview_layout.setVisibility(View.GONE);
|
|
|
@@ -788,16 +810,18 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
home_list_gridview_layout.setVisibility(View.GONE);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
private int onResumeCount = 0;
|
|
|
+
|
|
|
@Override
|
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
|
UserEntity result = DataUtil.getInstance().getUserEntity();
|
|
|
- if(result == null) {
|
|
|
+ if (result == null) {
|
|
|
CommonUtil.getInstance().updateUserInfo(new Action1<UserEntity>() {
|
|
|
@Override
|
|
|
public void call(UserEntity item) {
|
|
|
- if(item != null) {
|
|
|
+ if (item != null) {
|
|
|
userEntity = item;
|
|
|
loadUserInfo();
|
|
|
}
|
|
|
@@ -807,11 +831,11 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
userEntity = result;
|
|
|
loadUserInfo();
|
|
|
}
|
|
|
- if(DataUtil.getInstance().isTaskListChange(getClass()))//数据变化才刷新
|
|
|
+ if (DataUtil.getInstance().isTaskListChange(getClass()))//数据变化才刷新
|
|
|
refreshTaskList();
|
|
|
- if(onResumeCount == 0)//第一次才调用
|
|
|
+ if (onResumeCount == 0)//第一次才调用
|
|
|
// Jump2View.getInstance().tryShowNewbieTask(activity, userEntity, newbie_task);
|
|
|
- onResumeCount++;
|
|
|
+ onResumeCount++;
|
|
|
viewRobDuty.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
@@ -1078,7 +1102,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
* 点击一条公告
|
|
|
*/
|
|
|
private void onClickNotice(BulletinEnty item) {
|
|
|
- switch (item.getJumpType()){// 跳转类型:11,任务 98,内部h5 99,外部h5
|
|
|
+ switch (item.getJumpType()) {// 跳转类型:11,任务 98,内部h5 99,外部h5
|
|
|
case 11:
|
|
|
Jump2View.getInstance().goTaskDetailView(activity, NumberFormatUtils.parseInteger(item.getJumpValue()));
|
|
|
break;
|
|
|
@@ -1121,6 +1145,51 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
});
|
|
|
builder.show();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 邀请成功后在个人资料显示领红包弹窗
|
|
|
+ *
|
|
|
+ * @param mActivity 当前Activity
|
|
|
+ */
|
|
|
+ public void showRedPackage(final Activity mActivity, View viewAnchor) {
|
|
|
+ View view = LayoutInflater.from(mActivity).inflate(R.layout.dialog_redpackage_after_invitation, null, false);
|
|
|
+ TextView tvGetRedPackage = view.findViewById(R.id.tv_get_redpackage);
|
|
|
+ TextView tvMoney = view.findViewById(R.id.tv_money);
|
|
|
+ ImageView ivClose = view.findViewById(R.id.iv_close);
|
|
|
+ TextView tvNew = view.findViewById(R.id.tv_flag1);
|
|
|
+ final PopupWindow popupWindow = new PopupWindow(mActivity);
|
|
|
+ popupWindow.setContentView(view);
|
|
|
+ popupWindow.setAnimationStyle(R.style.Rising);
|
|
|
+ popupWindow.setWidth(ActionBar.LayoutParams.MATCH_PARENT);
|
|
|
+ popupWindow.setHeight(ActionBar.LayoutParams.MATCH_PARENT);
|
|
|
+ popupWindow.setTouchable(true);
|
|
|
+ popupWindow.setFocusable(true);
|
|
|
+ popupWindow.setOutsideTouchable(false);
|
|
|
+ popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ backgroundAlpha(0.7f, mActivity);
|
|
|
+ popupWindow.showAtLocation(viewAnchor, Gravity.CENTER, 0, 0);
|
|
|
+ popupWindow.setOnDismissListener(new ViewUtil.PopDismissListener(mActivity));
|
|
|
+ tvMoney.setText("");
|
|
|
+ tvNew.setText("新人红包");
|
|
|
+ tvGetRedPackage.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ CommonUtil.getInstance().updateUserInfo(null);
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ivClose.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ivClose.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|