|
|
@@ -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,6 +20,7 @@ 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;
|
|
|
@@ -25,11 +28,14 @@ import android.view.ViewGroup;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bumptech.glide.Glide;
|
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
|
+import com.google.gson.Gson;
|
|
|
import com.kfzs.duanduan.BaseCompatFragment;
|
|
|
import com.kfzs.duanduan.event.BigEvent;
|
|
|
import com.kfzs.duanduan.react.ConfigUtil;
|
|
|
@@ -54,6 +60,7 @@ import com.sheep.gamegroup.model.entity.TaskReleaseEty;
|
|
|
import com.sheep.gamegroup.model.entity.UserEntity;
|
|
|
import com.sheep.gamegroup.model.util.AutoTaskListUtil;
|
|
|
import com.sheep.gamegroup.model.util.EntityUtils;
|
|
|
+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;
|
|
|
@@ -103,9 +110,12 @@ import butterknife.BindView;
|
|
|
import butterknife.ButterKnife;
|
|
|
import butterknife.OnClick;
|
|
|
import butterknife.Unbinder;
|
|
|
+import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.functions.Action1;
|
|
|
+import rx.schedulers.Schedulers;
|
|
|
|
|
|
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 {
|
|
|
|
|
|
@@ -236,6 +246,18 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @return 是否显示红包
|
|
|
+ */
|
|
|
+ public void isShowRedPackage() {
|
|
|
+ if (userEntity == null) {
|
|
|
+ userEntity = DataUtil.getInstance().getUserEntity();
|
|
|
+ }
|
|
|
+ if (((userEntity.getNewbie_task_status() & 16) == 0)&&userEntity.getIs_new()==1) {
|
|
|
+ showRedPackage(getActivity(), LayoutInflater.from(getContext()).inflate(R.layout.homepage_act_layout, null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
|
@Override
|
|
|
protected void initView(Bundle savedInstanceState) {
|
|
|
@@ -253,6 +275,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
//每次进入主页都刷新一下url配置信息
|
|
|
CommonUtil.getInstance().initUrlConfigByNet(null, null);
|
|
|
+ isShowRedPackage();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1158,7 +1181,70 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 邀请成功后在个人资料显示领红包弹窗
|
|
|
+ *
|
|
|
+ * @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();
|
|
|
+ getRedPackage(popupWindow);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ivClose.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 兑换红包
|
|
|
+ *
|
|
|
+ * @param popupWindow
|
|
|
+ */
|
|
|
+ public void getRedPackage(final PopupWindow popupWindow) {
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getNewRedPackage()
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ LogUtil.logI("0------" + new Gson().toJson(baseMessage));
|
|
|
+ G.showToast(baseMessage.getMsg());
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ if (popupWindow.isShowing()){
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
/**
|
|
|
* 新手任务
|
|
|
*/
|