|
@@ -1,11 +1,14 @@
|
|
|
package com.edufound.reader.presenter;
|
|
|
|
|
|
import android.graphics.Color;
|
|
|
+import android.graphics.drawable.ColorDrawable;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.FrameLayout;
|
|
|
+import android.widget.HorizontalScrollView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
import android.widget.RadioButton;
|
|
|
import android.widget.RadioGroup;
|
|
|
import android.widget.TextView;
|
|
@@ -26,6 +29,7 @@ import com.edufound.reader.bean.UserEventEnum;
|
|
|
import com.edufound.reader.contract.MainContract;
|
|
|
import com.edufound.reader.cusview.CusToast;
|
|
|
import com.edufound.reader.fragment.CharacterFragment;
|
|
|
+import com.edufound.reader.fragment.EventFragment;
|
|
|
import com.edufound.reader.fragment.MyTabFragment;
|
|
|
import com.edufound.reader.fragment.RecommendFragment;
|
|
|
import com.edufound.reader.listener.PopUtilClickListener;
|
|
@@ -37,7 +41,6 @@ import com.edufound.reader.util.EfunboxUtil;
|
|
|
import com.edufound.reader.util.MMKVEncodeKey;
|
|
|
import com.edufound.reader.util.MMKVUtil;
|
|
|
import com.edufound.reader.util.SizeUtils;
|
|
|
-import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
import com.okhttplib.HttpInfo;
|
|
|
import com.okhttplib.callback.Callback;
|
|
@@ -60,6 +63,7 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
OrderApiServerImpl mOrderApi;
|
|
|
ActivityEventServerImpl mEventApi;
|
|
|
MyTabFragment mUserFragment;
|
|
|
+ EventFragment mEventFragment;
|
|
|
RecommendFragment mRecommendFragment;
|
|
|
FragmentManager mFragmentManager;
|
|
|
RecommendFragment mFollowFragment;
|
|
@@ -83,9 +87,11 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
switch (id) {
|
|
|
case R.id.main_left_tab_layout_myinfo:
|
|
|
//我的
|
|
|
+ Logger.e("我的");
|
|
|
if (EfunboxUtil.checkLogin(mView.getActivity(), mView.getRootView())) {
|
|
|
mRadioCheckIndex = 0;
|
|
|
mRecommendFragment = null;
|
|
|
+ mEventFragment = null;
|
|
|
mFollowFragment = null;
|
|
|
mCharacterFragment = null;
|
|
|
if (mUserFragment == null) {
|
|
@@ -94,15 +100,32 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
changeFragmentLayout(mUserFragment);
|
|
|
mUserApi.postUserEvent(mView.getActivity(), UserEventEnum.EVENT_MY.getEvent());
|
|
|
} else {
|
|
|
- ((RadioButton) radioGroup.getChildAt(mRadioCheckIndex)).setChecked(true);
|
|
|
+ Logger.e("");
|
|
|
+// ((RadioButton) radioGroup.getChildAt(mRadioCheckIndex)).setChecked(true);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case R.id.main_left_tab_layout_event:
|
|
|
+ //活动
|
|
|
+ mRadioCheckIndex = 1;
|
|
|
+ mRecommendFragment = null;
|
|
|
+ mUserFragment = null;
|
|
|
+ mFollowFragment = null;
|
|
|
+ mCharacterFragment = null;
|
|
|
+ if (mEventFragment == null) {
|
|
|
+ mEventFragment = new EventFragment();
|
|
|
}
|
|
|
+ changeFragmentLayout(mEventFragment);
|
|
|
+// mUserApi.postUserEvent(mView.getActivity(), UserEventEnum.EVENT_MY.getEvent());
|
|
|
break;
|
|
|
case R.id.main_left_tab_layout_recommend:
|
|
|
//推荐
|
|
|
- mRadioCheckIndex = 1;
|
|
|
- ((RadioButton) radioGroup.getChildAt(mRadioCheckIndex)).setChecked(true);
|
|
|
+ Logger.e("推荐");
|
|
|
+ mRadioCheckIndex = 2;
|
|
|
+// ((RadioButton) radioGroup.getChildAt(mRadioCheckIndex)).setChecked(true);
|
|
|
mUserFragment = null;
|
|
|
mFollowFragment = null;
|
|
|
+ mEventFragment = null;
|
|
|
mCharacterFragment = null;
|
|
|
if (mRecommendFragment == null) {
|
|
|
mRecommendFragment = new RecommendFragment(0);
|
|
@@ -112,10 +135,12 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
break;
|
|
|
case R.id.main_left_tab_layout_follow:
|
|
|
//关注
|
|
|
+ Logger.e("关注");
|
|
|
if (EfunboxUtil.checkLogin(mView.getActivity(), mView.getRootView())) {
|
|
|
- mRadioCheckIndex = 2;
|
|
|
+ mRadioCheckIndex = 3;
|
|
|
mUserFragment = null;
|
|
|
mCharacterFragment = null;
|
|
|
+ mEventFragment = null;
|
|
|
mRecommendFragment = null;
|
|
|
if (mFollowFragment == null) {
|
|
|
mFollowFragment = new RecommendFragment(1);
|
|
@@ -128,11 +153,13 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
break;
|
|
|
case R.id.main_left_tab_layout_character:
|
|
|
//任务
|
|
|
- mRadioCheckIndex = 3;
|
|
|
+ Logger.e("任务");
|
|
|
+ mRadioCheckIndex = 4;
|
|
|
((RadioButton) radioGroup.getChildAt(mRadioCheckIndex)).setChecked(true);
|
|
|
mUserFragment = null;
|
|
|
mFollowFragment = null;
|
|
|
mRecommendFragment = null;
|
|
|
+ mEventFragment = null;
|
|
|
if (mCharacterFragment == null) {
|
|
|
mCharacterFragment = new CharacterFragment();
|
|
|
}
|
|
@@ -168,7 +195,21 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
|
|
|
@Override
|
|
|
public void checkModelIsDebug() {
|
|
|
+
|
|
|
if (Consts.isIsDebug()) {
|
|
|
+// {
|
|
|
+ HorizontalScrollView scrollView = new HorizontalScrollView(mView.getActivity());
|
|
|
+ ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
+ scrollView.setLayoutParams(params);
|
|
|
+ LinearLayout testlayout = new LinearLayout(mView.getActivity());
|
|
|
+ testlayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
|
|
|
+ testlayout.setDividerDrawable(new ColorDrawable() {
|
|
|
+ @Override
|
|
|
+ public int getIntrinsicWidth() {
|
|
|
+ return SizeUtils.dp2px(mView.getActivity(), 50);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ testlayout.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
TextView tv = new TextView(mView.getActivity());
|
|
|
tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
|
|
tv.setTextSize(SizeUtils.px2dp(mView.getActivity(), 30));
|
|
@@ -179,9 +220,79 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
// MMKVUtil.getInstance().clearAll();
|
|
|
+ EfunboxUtil.toWebFlowerActivity(mView.getActivity(), "http://activity.ai160.com/index.html",null);
|
|
|
}
|
|
|
});
|
|
|
- mView.getRootView().addView(tv);
|
|
|
+ testlayout.addView(tv);
|
|
|
+//
|
|
|
+//
|
|
|
+// ModelViewA modelViewA = new ModelViewA(mView.getActivity());
|
|
|
+// modelViewA.initView("http://reader-apk.ai160.com/reader-apk/res/character_image.png", new View.OnClickListener() {
|
|
|
+// @Override
|
|
|
+// public void onClick(View v) {
|
|
|
+// CusToast.getInstance(mView.getActivity()).show("test model view A right", 1000);
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+//
|
|
|
+// ModelViewB modelViewB = new ModelViewB(mView.getActivity());
|
|
|
+// modelViewB.initView("http://reader-apk.ai160.com/reader-apk/res/character_image.png", new ModelViewB.OnClickBtnListener() {
|
|
|
+// @Override
|
|
|
+// public void clickLeft() {
|
|
|
+// CusToast.getInstance(mView.getActivity()).show("test model view B left", 1000);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void clickRight() {
|
|
|
+// CusToast.getInstance(mView.getActivity()).show("test model view B right", 1000);
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+//
|
|
|
+// ModelViewC modelViewC = new ModelViewC(mView.getActivity());
|
|
|
+// modelViewC.initView("http://reader-apk.ai160.com/reader-apk/res/character_image.png");
|
|
|
+// modelViewC.setItemClickListener(new ModelViewC.onItemClickListener() {
|
|
|
+// @Override
|
|
|
+// public void clickItem(View view, int position) {
|
|
|
+// CusToast.getInstance(mView.getActivity()).show("test model view C position:" + position, 1000);
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+//
|
|
|
+// ModelViewD modelViewD = new ModelViewD(mView.getActivity());
|
|
|
+// List<String> list = new ArrayList<>();
|
|
|
+// for (int i = 0; i < 4; i++) {
|
|
|
+// list.add(i + "");
|
|
|
+// }
|
|
|
+// modelViewD.initView("http://reader-apk.ai160.com/reader-apk/res/character_image.png", list, new ModelViewD.OnClickBtnListener() {
|
|
|
+// @Override
|
|
|
+// public void clickLeft(Object object) {
|
|
|
+// CusToast.getInstance(mView.getActivity()).show("test model view D 查看规则", 1000);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void clickRight(Object object) {
|
|
|
+// CusToast.getInstance(mView.getActivity()).show("test model view D 排行榜", 1000);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void clickItem(Object object) {
|
|
|
+// CusToast.getInstance(mView.getActivity()).show("test model view D item:" + String.valueOf(object), 1000);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// });
|
|
|
+//
|
|
|
+// testlayout.addView(modelViewA);
|
|
|
+// testlayout.addView(modelViewB);
|
|
|
+// testlayout.addView(modelViewC);
|
|
|
+// testlayout.addView(modelViewD);
|
|
|
+ scrollView.addView(testlayout);
|
|
|
+//
|
|
|
+ mView.getRootView().addView(scrollView);
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -198,6 +309,7 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
public void clickSubmit(Object object) {
|
|
|
// Toast.makeText(mView.getActivity(), "选择了:" + EfunboxUtil.getEnumByCNGrade(object.toString()), Toast.LENGTH_SHORT).show();
|
|
|
MMKVUtil.getInstance().encode(MMKVEncodeKey.USER_GRADE, EfunboxUtil.getEnumByCNGrade(object.toString()));
|
|
|
+ getLoginEvent();
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -209,7 +321,6 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
mUserApi.isLogin(mView.getActivity(), DeviceUuidFactory.getUuid(), new Callback() {
|
|
|
@Override
|
|
|
public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- Gson gson = new Gson();
|
|
|
try {
|
|
|
JSONObject object = new JSONObject(info.getRetDetail());
|
|
|
if (object.getString("code").equals("300") || object.getInt("code") == 300) {
|
|
@@ -224,25 +335,26 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
}
|
|
|
// registerMobile("18655365222");
|
|
|
getYFVip();
|
|
|
- mView.setCheckIndex();
|
|
|
} else {
|
|
|
HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
|
|
|
}.getType());
|
|
|
- Logger.e("info.get:" + info.getRetDetail());
|
|
|
Consts.setUID(bean.getData().getUid());
|
|
|
//用户是否登录,登录了,创建Consts的userbean
|
|
|
Consts.setmConstsUserBean(bean.getData());
|
|
|
- mView.setCheckIndex();
|
|
|
mUserApi.loginSign(mView.getActivity(), new Callback() {
|
|
|
@Override
|
|
|
public void onSuccess(HttpInfo info) throws IOException {
|
|
|
try {
|
|
|
HttpResultBean<SignBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<SignBean>>() {
|
|
|
}.getType());
|
|
|
- if (bean.getData().getIsSign()) {
|
|
|
- CusToast.getInstance(mView.getActivity()).show("恭喜签到成功\n奖励" + bean.getData().getCount() + "朵小红花", 2000);
|
|
|
+ if (bean.getData() != null) {
|
|
|
+ if (bean.getData().getIsSign()) {
|
|
|
+ CusToast.getInstance(mView.getActivity()).show("恭喜签到成功\n奖励" + bean.getData().getCount() + "朵小红花", 2000);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Logger.e("签到参数 isSign是空的");
|
|
|
}
|
|
|
- Logger.e("loginSign:-----loginSign---loginSign---loginSign");
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
@@ -260,48 +372,11 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
- //检查有没有用户信息
|
|
|
- if (Consts.getmConstsUserBean() == null && Consts.getmConstsBaiDuUserBean() == null) {
|
|
|
- //百度跟自己的都没有用户信息,请求有没有注册活动,有活动显示活动,没活动不显示
|
|
|
- //请求接口
|
|
|
- mEventApi.getEventByType(ActivityEventServerImpl.EVENT_TYPE_LOGIN, new Callback() {
|
|
|
- @Override
|
|
|
- public void onSuccess(HttpInfo info) throws IOException {
|
|
|
- Logger.e("获取活动成功:" + info.getRetDetail());
|
|
|
- HttpResultBean<ActivityEventBean> activityBean = info.getRetDetail(new TypeToken<HttpResultBean<ActivityEventBean>>() {
|
|
|
- }.getType());
|
|
|
- if (Boolean.valueOf(activityBean.getSuccess())) {
|
|
|
- //接口返回成功
|
|
|
- if (activityBean.getData() != null) {
|
|
|
- //有活动
|
|
|
- PopWindowUtil.RegistrationEventsWindow(mView.getActivity(), mView.getRootView(), new PopUtilClickListener() {
|
|
|
- @Override
|
|
|
- public void clickCancel() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void clickSubmit(Object object) {
|
|
|
- //点击进行登录逻辑
|
|
|
- EfunboxUtil.checkLogin(mView.getActivity(), mView.getRootView());
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- //没活动
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ //有没有用户都先检查活动
|
|
|
+ EfunboxUtil.checkEvents(mView.getActivity());
|
|
|
+ getLoginEvent();
|
|
|
|
|
|
- @Override
|
|
|
- public void onFailure(HttpInfo info) throws IOException {
|
|
|
- Logger.e("获取活动失败:" + info.getRetDetail());
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- } else {
|
|
|
- EfunboxUtil.checkEvents(mView.getActivity(), mView.getRootView(), true);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -315,11 +390,56 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
} else {
|
|
|
//选择过年纪。无处理
|
|
|
}
|
|
|
- mView.setCheckIndex();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void getLoginEvent() {
|
|
|
+ //检查有没有用户信息
|
|
|
+ if (Consts.getmConstsUserBean() == null && Consts.getmConstsBaiDuUserBean() == null) {
|
|
|
+ //百度跟自己的都没有用户信息,请求有没有注册活动,有活动显示活动,没活动不显示
|
|
|
+ //请求接口
|
|
|
+ mEventApi.getEventByType(ActivityEventServerImpl.EVENT_TYPE_LOGIN, new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("获取活动成功:" + info.getRetDetail());
|
|
|
+ HttpResultBean<ActivityEventBean> activityBean = info.getRetDetail(new TypeToken<HttpResultBean<ActivityEventBean>>() {
|
|
|
+ }.getType());
|
|
|
+ if (Boolean.valueOf(activityBean.getSuccess())) {
|
|
|
+ //接口返回成功
|
|
|
+ if (activityBean.getData() != null) {
|
|
|
+ //有活动
|
|
|
+ PopWindowUtil.RegistrationEventsWindow(mView.getActivity(), mView.getRootView(), new PopUtilClickListener() {
|
|
|
+ @Override
|
|
|
+ public void clickCancel() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void clickSubmit(Object object) {
|
|
|
+ //点击进行登录逻辑
|
|
|
+ EfunboxUtil.checkLogin(mView.getActivity(), mView.getRootView());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ //没活动
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("获取活动失败:" + info.getRetDetail());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void getYFVip() {
|
|
|
|
|
|
if (!Consts.getUmengChannel().equals(ChannelCodeEnum.BAIDU.getChannelCode())) {
|
|
@@ -330,8 +450,6 @@ public class MainPresenter extends BasePresenter<MainContract.View> implements M
|
|
|
public void onSuccess(HttpInfo info) throws IOException {
|
|
|
HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
}.getType());
|
|
|
- Logger.e("info.getRetDetail():" + info.getRetDetail());
|
|
|
- Logger.e("bean.getData():" + bean.getData());
|
|
|
if (!TextUtils.isEmpty(bean.getData())) {
|
|
|
Consts.setIsYFVip(true);
|
|
|
}
|