diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b710346290..a93d3af35e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -611,6 +611,10 @@
android:name=".energy.EnergyHouseActivity"
android:screenOrientation="portrait" />
+
+
diff --git a/app/src/main/java/com/gh/base/BaseActivity.java b/app/src/main/java/com/gh/base/BaseActivity.java
index 82393324c2..0744ff0ab9 100644
--- a/app/src/main/java/com/gh/base/BaseActivity.java
+++ b/app/src/main/java/com/gh/base/BaseActivity.java
@@ -72,6 +72,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
public final static String DOWNLOAD_HIJACK = "hijack";
public final static String LOGIN_EXCEPTION = "loginException";
public final static String PLUGGABLE = "plugin";
+ public final static int ID_ROOT_INDICATOR = 999;
@NonNull
protected String mEntrance;
@@ -206,6 +207,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
tv.measure(0, 0);
tv.setAlpha(0.15F);
+ tv.setId(ID_ROOT_INDICATOR);
int height = tv.getMeasuredHeight();
int width = tv.getMeasuredWidth();
tv.setPadding(DisplayUtils.dip2px(20), 0, DisplayUtils.dip2px(20), 0);
diff --git a/app/src/main/java/com/gh/gamecenter/personal/NewPersonalActivity.kt b/app/src/main/java/com/gh/gamecenter/personal/NewPersonalActivity.kt
new file mode 100644
index 0000000000..c5dda40b00
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/personal/NewPersonalActivity.kt
@@ -0,0 +1,22 @@
+package com.gh.gamecenter.personal
+
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import com.gh.common.util.DisplayUtils
+import com.gh.gamecenter.NormalActivity
+
+class NewPersonalActivity : NormalActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ hideToolbar(true)
+ DisplayUtils.transparentStatusAndNavigation(this)
+ }
+
+ companion object {
+ fun getIntent(context: Context?): Intent? {
+ return getTargetIntent(context, NewPersonalActivity::class.java, NewPersonalFragment::class.java)
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/gamecenter/personal/NewPersonalFragment.java b/app/src/main/java/com/gh/gamecenter/personal/NewPersonalFragment.java
new file mode 100644
index 0000000000..04e8e1a1ad
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/personal/NewPersonalFragment.java
@@ -0,0 +1,817 @@
+package com.gh.gamecenter.personal;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.database.sqlite.SQLiteException;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewStub;
+import android.widget.ImageView;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
+import androidx.lifecycle.ViewModelProviders;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+
+import com.facebook.drawee.view.SimpleDraweeView;
+import com.gh.base.fragment.BaseLazyFragment;
+import com.gh.common.databind.BindingAdapters;
+import com.gh.common.notifier.Notifier;
+import com.gh.common.util.CheckLoginUtils;
+import com.gh.common.util.DataUtils;
+import com.gh.common.util.DialogUtils;
+import com.gh.common.util.DirectUtils;
+import com.gh.common.util.DisplayUtils;
+import com.gh.common.util.EntranceUtils;
+import com.gh.common.util.ImageUtils;
+import com.gh.common.util.LogUtils;
+import com.gh.common.util.LoginHelper;
+import com.gh.common.util.MtaHelper;
+import com.gh.common.util.NetworkUtils;
+import com.gh.common.util.PackageUtils;
+import com.gh.common.util.SPUtils;
+import com.gh.common.util.StringUtils;
+import com.gh.common.util.TimeUtils;
+import com.gh.common.util.ToastUtils;
+import com.gh.common.view.AvatarBorderView;
+import com.gh.common.view.SpacingItemDecoration;
+import com.gh.gamecenter.GameDetailActivity;
+import com.gh.gamecenter.MainActivity;
+import com.gh.gamecenter.MessageActivity;
+import com.gh.gamecenter.NewsDetailActivity;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.entity.AppEntity;
+import com.gh.gamecenter.entity.Badge;
+import com.gh.gamecenter.entity.BadgeEntity;
+import com.gh.gamecenter.entity.FunctionalGroupEntity;
+import com.gh.gamecenter.entity.FunctionalLinkEntity;
+import com.gh.gamecenter.entity.FunctionalMessageType;
+import com.gh.gamecenter.entity.LinkEntity;
+import com.gh.gamecenter.entity.LoginTokenEntity;
+import com.gh.gamecenter.entity.MessageUnreadEntity;
+import com.gh.gamecenter.entity.SignEntity;
+import com.gh.gamecenter.entity.UserInfoEntity;
+import com.gh.gamecenter.eventbus.EBConcernChanged;
+import com.gh.gamecenter.eventbus.EBNetworkState;
+import com.gh.gamecenter.eventbus.EBReuse;
+import com.gh.gamecenter.eventbus.EBSkip;
+import com.gh.gamecenter.fragment.MainWrapperFragment;
+import com.gh.gamecenter.energy.EnergyCenterActivity;
+import com.gh.gamecenter.energy.EnergyHouseActivity;
+import com.gh.gamecenter.manager.UserManager;
+import com.gh.gamecenter.message.MessageUnreadRepository;
+import com.gh.gamecenter.message.MessageUnreadViewModel;
+import com.gh.gamecenter.personalhome.UserHomeViewModel;
+import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity;
+import com.gh.gamecenter.retrofit.BiResponse;
+import com.gh.gamecenter.retrofit.Response;
+import com.gh.gamecenter.retrofit.RetrofitManager;
+import com.gh.gamecenter.room.AppDatabase;
+import com.gh.gamecenter.subject.SubjectActivity;
+import com.gh.gamecenter.user.UserViewModel;
+import com.google.android.material.appbar.AppBarLayout;
+import com.halo.assistant.HaloApp;
+import com.jakewharton.rxbinding2.view.RxView;
+import com.lightgame.utils.Utils;
+import com.tencent.connect.common.Constants;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+import org.jetbrains.annotations.NotNull;
+import org.json.JSONObject;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.concurrent.TimeUnit;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
+import okhttp3.ResponseBody;
+import retrofit2.HttpException;
+
+public class NewPersonalFragment extends BaseLazyFragment {
+
+ @BindView(R.id.list_refresh)
+ SwipeRefreshLayout mListRefresh;
+ @BindView(R.id.appbar)
+ AppBarLayout appbar;
+ @BindView(R.id.toolbar)
+ Toolbar toolbar;
+ @BindView(R.id.personal_sign)
+ ImageView mPersonalSign;
+ @BindView(R.id.personal_msg)
+ ImageView mPersonalMsg;
+ @BindView(R.id.login_message_hint)
+ TextView mLoginMessageHint;
+ @BindView(R.id.personal_user_icon)
+ AvatarBorderView mUserIcon;
+ @BindView(R.id.personal_user_small_icon)
+ SimpleDraweeView mUserIconSmall;
+ // @BindView(R.id.personal_user_badge)
+// SimpleDraweeView mUserBadge;
+ @BindView(R.id.personal_login)
+ View mPersonalLogin;
+ @BindView(R.id.personal_home)
+ TextView mPersonalHome;
+ @BindView(R.id.personal_user_name)
+ TextView mPersonalUserName;
+ @BindView(R.id.personal_user_name_small)
+ TextView mPersonalUserNameSmall;
+ @BindView(R.id.personal_badge)
+ RelativeLayout mPersonalBadge;
+ @BindView(R.id.personal_badge_tv)
+ TextView mPersonalBadgeTv;
+ @BindView(R.id.personal_badge_icon)
+ SimpleDraweeView mPersonalBadgeIcon;
+ @BindView(R.id.personal_badge_tips)
+ View mPersonalBadgeTips;
+ @BindView(R.id.personal_func)
+ RecyclerView mFuncRecyclerView;
+ @BindView(R.id.personal_new_fans_tips)
+ View personalNewFansTips;
+ @BindView(R.id.personal_energy_tv)
+ TextView mPersonalEnergy;
+
+ public final static String LOGIN_TAG = "login_tag"; //登入标识
+ public final static String LOGOUT_TAG = "logout_tag"; // 登出标识
+ private final static String MESSAGE_READ_OVER = "MESSAGE_READ_OVER";
+ private final static String SP_BADGE_RECORD_SEVEN_DAY = "badgeRecordSevenDay";
+ private final static int REQUEST_MESSAGE = 199;
+
+ private UserInfoEntity mUserInfoEntity;
+
+ private AppDatabase mDatabase;
+
+ private UserViewModel mUserViewModel;
+ private MessageUnreadViewModel mUnreadViewModel;
+ private UserHomeViewModel mUserHomeViewModel;
+ private PersonalViewModel mPersonalViewModel;
+
+ private NewPersonalFunctionGroupAdapter mPersonalFuncGroupAdapter;
+
+ private boolean mIsLogging = false;
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == Constants.REQUEST_LOGIN) { // QQ Login callback
+ LoginHelper.onQQLoginCallback(requestCode, resultCode, data);
+ } else if (requestCode == 32973) {// 32973 WeiBo requestCode
+ LoginHelper.onWeiboLoginCallback(requestCode, resultCode, data);
+ } else if (requestCode == REQUEST_MESSAGE) {
+ if (mUnreadViewModel != null) mUnreadViewModel.retry();
+ }
+ }
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_new_personal_stub;
+ }
+
+ @Override
+ protected boolean useButterKnife() {
+ return false;
+ }
+
+ @SuppressLint("CheckResult")
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mDatabase = AppDatabase.getInstance(getContext());
+ final UserViewModel.Factory factory = new UserViewModel.Factory(getActivity().getApplication());
+ mUserViewModel = ViewModelProviders.of(this, factory).get(UserViewModel.class);
+ mUserHomeViewModel = ViewModelProviders.of(this, new UserHomeViewModel.Factory(HaloApp.getInstance().getApplication(),
+ UserManager.getInstance().getUserId())).get(UserHomeViewModel.class);
+ mUnreadViewModel = ViewModelProviders.of(this,
+ new MessageUnreadViewModel.Factory(HaloApp.getInstance().getApplication())).get(MessageUnreadViewModel.class);
+ mPersonalViewModel = ViewModelProviders.of(this).get(PersonalViewModel.class);
+
+ observeNoneUIRelatedChanges();
+ }
+
+ @Override
+ public void onFragmentFirstVisible() {
+ super.onFragmentFirstVisible();
+
+ inflateRealView();
+ observeUIRelatedChanges();
+ }
+
+ private void inflateRealView() {
+ try {
+ mCachedView = ((ViewStub) (mCachedView.findViewById(R.id.stub))).inflate();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ ButterKnife.bind(this, mCachedView);
+
+ mPersonalFuncGroupAdapter = new NewPersonalFunctionGroupAdapter(requireContext());
+ mFuncRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
+ mFuncRecyclerView.setAdapter(mPersonalFuncGroupAdapter);
+ mFuncRecyclerView.addItemDecoration(new SpacingItemDecoration(true, false, false, false, 0, DisplayUtils.dip2px(32F), 0, 0));
+
+ int statusBarHeight = Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ? 0 : DisplayUtils.getStatusBarHeight(getResources());
+ ViewGroup.LayoutParams params = toolbar.getLayoutParams();
+ params.height = DisplayUtils.dip2px(50) + statusBarHeight;
+ toolbar.setLayoutParams(params);
+
+ appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
+ int absOffset = Math.abs(verticalOffset);
+ int invisibleOffset = DisplayUtils.dip2px(56F + 48F - 50F) - DisplayUtils.getStatusBarHeight(getResources());
+ if (absOffset <= invisibleOffset) {
+ mUserIconSmall.setVisibility(View.GONE);
+ mPersonalUserNameSmall.setVisibility(View.GONE);
+ toolbar.setBackground(null);
+ } else {
+ mUserIconSmall.setVisibility(View.VISIBLE);
+ mPersonalUserNameSmall.setVisibility(View.VISIBLE);
+ toolbar.setBackgroundResource(R.drawable.bg_personal_top);
+ }
+ mListRefresh.setEnabled(absOffset <= 2);
+ });
+ mListRefresh.setColorSchemeColors(ContextCompat.getColor(requireContext(), R.color.theme));
+ mListRefresh.setProgressViewOffset(false, 0, DisplayUtils.dip2px(80) + DisplayUtils.getStatusBarHeight(requireContext().getResources()));
+ mListRefresh.setOnRefreshListener(() -> {
+ mPersonalViewModel.getHaloAddons();
+ if (CheckLoginUtils.isLogin()) {
+ mUnreadViewModel.retry();
+ MessageUnreadRepository.INSTANCE.loadMessageUnreadTotal(false);
+ mUserHomeViewModel.getBadgeList();
+ mUserHomeViewModel.availableBadges();
+ }
+ mBaseHandler.postDelayed(() -> {
+ mListRefresh.setRefreshing(false);
+ }, 2000);
+ MtaHelper.onEvent("我的光环_新", "下拉刷新", "下拉刷新");
+ });
+ MessageUnreadRepository.INSTANCE.loadMessageUnreadTotal(true);
+ }
+
+ private void observeNoneUIRelatedChanges() {
+ mPersonalViewModel.getHaloAddons();
+ mUserViewModel.getLoginObsUserinfo().observe(this, userInfoEntity -> {
+ UserInfoEntity notifyUserInfo;
+ if (userInfoEntity != null) {
+ notifyUserInfo = userInfoEntity.getData();
+ } else {
+ notifyUserInfo = null;
+ }
+
+ if (notifyUserInfo != null && mUserInfoEntity == null) { // 单个用户,首次触发
+ EventBus.getDefault().post(new EBConcernChanged());
+
+ LoginTokenEntity loginTokenEntity = UserManager.getInstance().getLoginTokenEntity();
+ if (mIsLogging && loginTokenEntity != null) {
+ String loginType = loginTokenEntity.getLoginType();
+ LogUtils.login("success", loginType, getLoginEntranceByType(loginType));
+ mIsLogging = false;
+ }
+ }
+
+ mUserInfoEntity = notifyUserInfo;
+ if (notifyUserInfo == null) {
+ mUnreadViewModel.clean();
+ EventBus.getDefault().post(new EBConcernChanged());
+ }
+ });
+
+ mPersonalViewModel.getHaloAddData().observe(this, datas -> {
+ if (!datas.isEmpty()) {
+ MessageUnreadRepository.INSTANCE.loadMessageUnreadTotal(false);
+ }
+ });
+
+ mUnreadViewModel.getLiveData().observe(this
+ , messageUnread -> {
+ if (messageUnread != null && messageUnread.getTotal() > 0) {
+ // 第一次开启应用时检查消息中心看有没有未读消息确定需不需要弹 Notifier 通知
+ showNotifier(messageUnread);
+ }
+ });
+ }
+
+ @SuppressLint("CheckResult")
+ private void observeUIRelatedChanges() {
+ mUserViewModel.getLoginObsUserinfo().observe(this, userInfoEntity -> {
+ if (userInfoEntity != null && userInfoEntity.getData() != null) {
+ changeLoginState(true);
+ } else {
+ changeLoginState(false);
+ }
+ });
+
+ mUserHomeViewModel.getBadges().observe(this, badgeEntities -> {
+ mPersonalBadgeIcon.setImageURI("");
+
+ if (badgeEntities.isEmpty()) {
+ mPersonalBadgeTv.setText("我的徽章");
+ } else {
+ mPersonalBadgeTv.setText(String.format(Locale.CHINA, "%d枚徽章", badgeEntities.size()));
+
+ for (BadgeEntity badgeEntity : badgeEntities) {
+ if (badgeEntity.getWear()) {
+ ImageUtils.display(mPersonalBadgeIcon, badgeEntity.getIcon());
+
+ mPersonalBadgeIcon.setOnClickListener(v -> DialogUtils.showViewBadgeDialog(requireContext(), new Badge(badgeEntity.getName(), badgeEntity.getIcon(), badgeEntity.getActions()),
+ () -> DirectUtils.directToBadgeWall(requireContext(), mUserInfoEntity.getUserId(), mUserInfoEntity.getName(), mUserInfoEntity.getIcon())));
+
+ break;
+ }
+ }
+ }
+ });
+ mUserHomeViewModel.getAvailableBadgeCount().observe(this, count -> mPersonalBadgeTips.setVisibility(count > 0 ? View.VISIBLE : View.GONE));
+
+ mUserHomeViewModel.getAvailableBadge().observe(this, badge -> {
+ // 徽章领取弹窗每隔7天弹出一次,所以要判断现在是否是上一次弹出的第7天或者之后
+ if (badge != null && System.currentTimeMillis() >= SPUtils.getLong(SP_BADGE_RECORD_SEVEN_DAY)) {
+ // 徽章领取弹窗每隔7天弹出一次,所以本次弹出后就记录7天后的时间戳
+ SPUtils.setLong(SP_BADGE_RECORD_SEVEN_DAY, TimeUtils.getStartTimeOfDay(System.currentTimeMillis() + 86400000 * 6));
+
+ DialogUtils.showReceiveBadgeDialog(requireContext(), badge,
+ () -> RetrofitManager.getInstance(requireContext()).getApi()
+ .applyOrReceiveBadge(badge.getId())
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new BiResponse() {
+ @Override
+ public void onSuccess(ResponseBody data) {
+ if ("self".equals(badge.getReceive().getType())) {
+ ToastUtils.INSTANCE.showToast("领取成功");
+ } else {
+ ToastUtils.INSTANCE.showToast("申请成功");
+ }
+ // 跳转到徽章详情
+ DirectUtils.directToBadgeDetail(requireContext(), mUserInfoEntity.getUserId(), badge.getId());
+ }
+
+ @Override
+ public void onFailure(@NotNull Exception exception) {
+ super.onFailure(exception);
+ if ("self".equals(badge.getReceive().getType())) {
+ ToastUtils.INSTANCE.showToast("领取失败");
+ } else {
+ ToastUtils.INSTANCE.showToast("申请失败");
+ }
+ }
+ }));
+ }
+ });
+
+ mUserHomeViewModel.getEnergy().observe(this, energy -> {
+ if (energy > 9999) {
+ mPersonalEnergy.setText("9999+");
+ } else {
+ mPersonalEnergy.setText(energy + "");
+ }
+ });
+
+ mPersonalViewModel.getHaloAddData().observe(this, datas -> {
+ if (!datas.isEmpty()) {
+ mPersonalFuncGroupAdapter.setListData(datas);
+ checkUpdate();
+ }
+ });
+
+ mUnreadViewModel.getLiveData().observe(this
+ , messageUnread -> {
+ if (messageUnread != null && messageUnread.getTotal() > 0) {
+ personalNewFansTips.setVisibility(messageUnread.getFans() > 0 ? View.VISIBLE : View.GONE);
+ mPersonalHome.setText(messageUnread.getFans() > 0 ? ((messageUnread.getFans() < 100 ? messageUnread.getFans() : "99+") + "位新粉丝") : "个人主页");
+ int count = messageUnread.getTotal() - messageUnread.getFans();
+ mLoginMessageHint.setVisibility(count > 0 ? View.VISIBLE : View.GONE);
+ BindingAdapters.setMessageUnread(mLoginMessageHint, count);
+ } else {
+ mLoginMessageHint.setVisibility(View.GONE);
+ mPersonalHome.setText("个人主页");
+ personalNewFansTips.setVisibility(View.GONE);
+ EventBus.getDefault().post(new EBReuse(MESSAGE_READ_OVER));
+ }
+ });
+ mUnreadViewModel.getZixunConcernLiveData().observe(this, hasConcern -> {
+ notifyItemChange("游戏动态", hasConcern ? FunctionalMessageType.NEW_MESSAGE : null);
+ });
+ mUnreadViewModel.getAddonsUnreadLiveData().observe(this, entity -> {
+ notifyItemChange("我的收藏", entity.getFavorite() > 0 ? FunctionalMessageType.NEW_MESSAGE : null);
+ });
+
+ // 微信/签到
+ RxView.clicks(mPersonalSign)
+ .throttleFirst(1, TimeUnit.SECONDS)
+ .subscribe(aVoid -> {
+ if (CheckLoginUtils.isLogin()) {
+ MtaHelper.onEvent("我的光环", "签到");
+ MtaHelper.onEvent("我的光环_新", "签到", "点击签到");
+ sign();
+ } else {
+ MtaHelper.onEvent("我的光环_新", "功能入口-跳转登录", "签到");
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-签到", () -> {
+ });
+ }
+ });
+ }
+
+ @Override
+ public void onFragmentResume() {
+ super.onFragmentResume();
+
+ if (NetworkUtils.isNetworkConnected(requireContext())) {
+ mUnreadViewModel.retry();
+ mUserHomeViewModel.getBadgeList();
+ mUserHomeViewModel.availableBadges();
+ if (CheckLoginUtils.isLogin()) {
+ mUserHomeViewModel.getUserEnergy();
+ }
+ }
+// int currentItem = ((MainWrapperFragment) getParentFragment()).getCurrentItem();
+// if (currentItem == INDEX_PERSONAL) {
+ DisplayUtils.setLightStatusBar(requireActivity(), false);
+// }
+ }
+
+ private void showNotifier(MessageUnreadEntity messageUnread) {
+ if (mUnreadViewModel.isFirstTimeInit()) {
+ mUnreadViewModel.flagFirstTimeInit(false);
+
+ if (messageUnread.getMeta() != null && messageUnread.getMeta().getUser() != null) {
+ if (messageUnread.getMeta() != null) {
+ String displayText = StringUtils.shrinkStringWithDot(messageUnread.getMeta().getUser().getName(), 8);
+ String suffixText;
+ if ("follow_question".equals(messageUnread.getMeta().getType())) {
+ suffixText = "回答了你关注的问题";
+ } else {
+ suffixText = "回答了你的问题";
+ }
+ displayText += suffixText;
+
+ String content = messageUnread.getMeta().getAnswerId() + displayText;
+
+ if (Notifier.shouldShowNotifier(content)) {
+ Notifier.create(getActivity())
+ .setText(displayText)
+ .setDuration(5000)
+ .setIcon(messageUnread.getMeta().getUser().getIcon())
+ .setOnClickListener(view -> {
+ Bundle bundle = new Bundle();
+ bundle.putString(EntranceUtils.KEY_ANSWER_ID, messageUnread.getMeta().getAnswerId());
+ bundle.putString(EntranceUtils.KEY_ENTRANCE, EntranceUtils.ENTRANCE_UMENG);
+ bundle.putString(EntranceUtils.KEY_TO, AnswerDetailActivity.class.getName());
+ EntranceUtils.jumpActivity(getActivity(), bundle);
+
+ MtaHelper.onEvent("消息弹窗", suffixText, "Does not contains any parameter.");
+
+ // 标记已读
+ JSONObject jsonObject = new JSONObject();
+ try {
+ jsonObject.put("type", messageUnread.getMeta().getType());
+ RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
+ RetrofitManager.getInstance(requireContext()).getApi()
+ .postMessageRead(UserManager.getInstance().getUserId(), messageUnread.getMeta().getMessageId(), body)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response() {
+ @Override
+ public void onResponse(@Nullable ResponseBody response) {
+ super.onResponse(response);
+ MessageUnreadRepository.INSTANCE.loadMessageUnreadData();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ Notifier.hide();
+ })
+ .show(true, 500L);
+ Notifier.tagNotifierAsShowed(content);
+ }
+ }
+ }
+ }
+ }
+
+ @OnClick({R.id.toolbar, R.id.collapsingToolbar, R.id.iv_arrow, R.id.personal_info, R.id.personal_login, R.id.personal_user_small_icon, R.id.personal_user_icon, R.id.personal_msg,
+ R.id.personal_user_name_small, R.id.personal_user_name, R.id.personal_badge, R.id.personal_home,
+ R.id.personal_energy, R.id.personal_energy_center, R.id.personal_energy_house, R.id.personal_energy_record})
+ public void onViewClicked(View view) {
+ switch (view.getId()) {
+ case R.id.collapsingToolbar:
+ case R.id.toolbar:
+ case R.id.personal_info:
+ if (mUserInfoEntity == null) {
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-手机登录", null);
+ }
+ break;
+ case R.id.personal_login:
+ MtaHelper.onEvent("我的光环_新", "立即登录", "点击登录");
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-立即登录", null);
+ break;
+ case R.id.personal_msg:
+ if (CheckLoginUtils.isLogin()) {
+ MtaHelper.onEvent("我的光环", "消息");
+ MtaHelper.onEvent("我的光环_新", "消息中心", "点击消息中心");
+ startActivityForResult(MessageActivity.getIntent(getContext(), "(我的光环)+(消息中心)"), REQUEST_MESSAGE);
+ } else {
+ MtaHelper.onEvent("我的光环_新", "功能入口-跳转登录", "消息中心");
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-消息", () -> {
+ });
+ }
+ break;
+ case R.id.personal_user_small_icon:
+ case R.id.personal_user_icon:
+ if (mUserInfoEntity != null) {
+ MtaHelper.onEvent("我的光环", "个人中心");
+ MtaHelper.onEvent("我的光环_新", "头像", "点击头像");
+ DirectUtils.directToHomeActivity(requireContext(), UserManager.getInstance().getUserId(), "", "我的光环");
+ } else {
+ MtaHelper.onEvent("我的光环", "手机登录");
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-手机登录", null);
+ }
+ break;
+ case R.id.personal_user_name_small:
+ case R.id.personal_user_name:
+ if (mUserInfoEntity != null) {
+ MtaHelper.onEvent("我的光环", "个人中心");
+ MtaHelper.onEvent("我的光环_新", "昵称", "点击昵称");
+ DirectUtils.directToHomeActivity(requireContext(), UserManager.getInstance().getUserId(), "", "我的光环");
+ } else {
+ MtaHelper.onEvent("我的光环", "手机登录");
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-手机登录", null);
+ }
+ break;
+ case R.id.iv_arrow:
+ case R.id.personal_home:
+ if (mUserInfoEntity != null) {
+ MtaHelper.onEvent("我的光环", "个人主页");
+ MtaHelper.onEvent("我的光环_新", "个人主页", "进入个人主页");
+ DirectUtils.directToHomeActivity(requireContext(), UserManager.getInstance().getUserId(), "", "我的光环");
+ } else {
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-个人主页", null);
+ }
+ break;
+ case R.id.personal_badge:
+ MtaHelper.onEvent("我的光环_新", "徽章中心", "进入徽章中心");
+ DirectUtils.directToBadgeWall(requireContext(), mUserInfoEntity.getUserId(), mUserInfoEntity.getName(), mUserInfoEntity.getIcon());
+ break;
+ case R.id.personal_energy:
+ if (mUserInfoEntity != null) {
+ MtaHelper.onEvent("我的光环_新", "光能值", "点击光能值");
+ DialogUtils.showEnergyDialog(requireContext(), mUserInfoEntity.getName(), mPersonalEnergy.getText().toString());
+ } else {
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-光能值", null);
+ }
+ break;
+ case R.id.personal_energy_center:
+ MtaHelper.onEvent("我的光环_新", "光能中心", "进入光能中心");
+ requireContext().startActivity(EnergyCenterActivity.Companion.getIntent(requireContext()));
+ break;
+ case R.id.personal_energy_house:
+ MtaHelper.onEvent("我的光环_新", "光能屋", "进入光能屋");
+ requireContext().startActivity(EnergyHouseActivity.Companion.getIntent(requireContext()));
+ break;
+ case R.id.personal_energy_record:
+ if (mUserInfoEntity != null) {
+ MtaHelper.onEvent("我的光环_新", "光能记录", "进入光能记录");
+ DirectUtils.directToEnergyRecord(requireContext());
+ } else {
+ CheckLoginUtils.checkLogin(getContext(), "我的光环-光能记录", null);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ // 连接上网络事件
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onEventMainThread(EBNetworkState busNetworkState) {
+ if (busNetworkState.isNetworkConnected()
+ && UserManager.getInstance().isLoggedIn()
+ && (mUserInfoEntity == null || TextUtils.isEmpty(UserManager.getInstance().getToken()))) {
+ mUserViewModel.retryCheckLogin();
+ }
+ if (busNetworkState.isNetworkConnected()) {
+ mPersonalViewModel.getHaloAddons();
+ }
+ }
+
+// @Subscribe(threadMode = ThreadMode.MAIN)
+// public void onEventMainThread(EBUISwitch busNine) {
+// if (MainWrapperFragment.EB_MAIN_SCROLL_TOP.equals(busNine.getFrom())
+// && INDEX_PERSONAL == busNine.getPosition()) {
+// //mScrollView.fullScroll(ScrollView.FOCUS_UP);
+// }
+// }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onEventMainThread(EBReuse reuse) {
+ if (MESSAGE_READ_OVER.equals(reuse.getType())) { // 消息阅读完成
+ if (mLoginMessageHint != null) {
+ mLoginMessageHint.setVisibility(View.GONE);
+ }
+ }
+ }
+
+ private void sign() {
+ RetrofitManager.getInstance(getContext()).getApi()
+ .postSign(UserManager.getInstance().getUserId())
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response() {
+ @Override
+ public void onResponse(SignEntity signEntity) {
+ mPersonalSign.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.personal_sign_icon_yellow));
+ if (isCanSign(signEntity.getLastTime())) {
+ DialogUtils.showSignDialog(getContext(), "签到成功,获得经验:1"
+ , getString(R.string.sign_dialog_content, signEntity.getSerialSign())
+ , getString(R.string.sign_dialog_content2, signEntity.getExperience())
+ , getSignSkipText(signEntity.getTitle()), () -> {
+ signSkip(signEntity);
+ }
+ );
+ signEntity.setLastTime(System.currentTimeMillis() / 1000);
+ } else {
+ DialogUtils.showSignDialog(getContext(), "今天已签到,明天再来吧~"
+ , getString(R.string.sign_dialog_content, signEntity.getSerialSign())
+ , getString(R.string.sign_dialog_content2, signEntity.getExperience())
+ , getSignSkipText(signEntity.getTitle()), () -> {
+ signSkip(signEntity);
+ }
+ );
+ }
+
+ signEntity.setId(UserManager.getInstance().getUserId());
+ if (mDatabase.signDao().updateSignEntity(signEntity) <= 0) {
+ try {
+ mDatabase.signDao().addSignEntity(signEntity);
+ } catch (SQLiteException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+ if (e == null || e.code() != 401) {
+ toast(R.string.loading_network_error);
+ }
+ }
+ });
+
+ }
+
+ private boolean isCanSign(long time) {
+ SimpleDateFormat formatDay = new SimpleDateFormat("dd", Locale.CHINA);
+
+ long lastSignTime = time * 1000;
+ long curTime = Utils.getTime(getContext()) * 1000;
+ int lastSignDay = Integer.parseInt(formatDay.format(lastSignTime));
+ int curDay = Integer.parseInt(formatDay.format(curTime));
+ return lastSignDay != curDay || curTime - lastSignTime > 24 * 60 * 60 * 1000;
+ }
+
+ private String getSignSkipText(String text) {
+ return TextUtils.isEmpty(text) ? "去首页看看" : text;
+ }
+
+ private void signSkip(SignEntity signEntity) {
+ SignEntity.Data data = signEntity.getData();
+ String entrance = "(我的光环)+(签到)";
+ if (data == null || TextUtils.isEmpty(data.getType())) {
+ EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME));
+ return;
+ }
+ switch (data.getType()) {
+ case "game":
+ DataUtils.onMtaEvent(getActivity(), "我的光环_签到跳转", "游戏", signEntity.getTitle());
+ GameDetailActivity.startGameDetailActivity(getContext(), data.getLink(), entrance);
+ break;
+ case "news":
+ DataUtils.onMtaEvent(getActivity(), "我的光环_签到跳转", "文章", signEntity.getTitle());
+ startActivity(NewsDetailActivity.getIntentById(getContext(), data.getLink(), entrance));
+ break;
+ case "column":
+ DataUtils.onMtaEvent(getActivity(), "我的光环_签到跳转", "专题", signEntity.getTitle());
+ SubjectActivity.startSubjectActivity(getContext(), data.getLink(), null, false, entrance);
+ break;
+
+ default:
+ LinkEntity linkEntity = new LinkEntity();
+ linkEntity.setType(data.getType());
+ linkEntity.setLink(data.getLink());
+ linkEntity.setText(data.getText());
+ linkEntity.setCommunity(data.getCommunity());
+ linkEntity.setDisplay(data.getDisplay());
+ DirectUtils.directToLinkPage(requireContext(), linkEntity, entrance, "");
+ break;
+ }
+ }
+
+ private static String getLoginEntranceByType(String loginTag) {
+ String entrance = "";
+ switch (loginTag) {
+ case "qq":
+ entrance = "我的光环-QQ";
+ break;
+ case "wechat":
+ entrance = "我的光环-微信";
+ break;
+ case "weibo":
+ entrance = "我的光环-新浪微博";
+ break;
+ }
+ return entrance;
+ }
+
+ private void changeLoginState(boolean isLogin) {
+ if (isLogin) {
+ SignEntity signEntity = mDatabase.signDao().getSignEntityById(UserManager.getInstance().getUserId());
+ if (signEntity != null && !isCanSign(signEntity.getLastTime())) {
+ mPersonalSign.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.personal_sign_icon_yellow));
+ } else {
+ mPersonalSign.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.personal_sign_icon_white));
+ }
+ if (mUserInfoEntity != null) {
+ mUserIcon.display(mUserInfoEntity.getIconBorder() == null ? "" : mUserInfoEntity.getIconBorder().getUrl(),
+ mUserInfoEntity.getIcon(), mUserInfoEntity.getAuth() == null ? "" : mUserInfoEntity.getAuth().getIcon());
+ ImageUtils.displayIcon(mUserIconSmall, mUserInfoEntity.getIcon());
+ mPersonalUserName.setVisibility(View.VISIBLE);
+ mPersonalBadge.setVisibility(View.VISIBLE);
+ mPersonalHome.setVisibility(View.VISIBLE);
+ mPersonalLogin.setVisibility(View.GONE);
+ mPersonalUserName.setText(mUserInfoEntity.getName());
+ mPersonalUserNameSmall.setText(mUserInfoEntity.getName());
+ }
+ mUserHomeViewModel.setUserId(UserManager.getInstance().getUserId());
+ mUserHomeViewModel.getBadgeList();
+ mUserHomeViewModel.availableBadges();
+ mUserHomeViewModel.getUserEnergy();
+ MessageUnreadRepository.INSTANCE.loadMessageUnreadTotal(true);
+ } else {
+ mPersonalEnergy.setText("--");
+ mUserIcon.display("", "", "");
+ mUserIconSmall.setImageURI("");
+ mPersonalBadgeTv.setText("我的徽章");
+ mPersonalUserNameSmall.setText("立即登录");
+ mPersonalUserName.setVisibility(View.GONE);
+ mPersonalHome.setVisibility(View.GONE);
+ mPersonalBadge.setVisibility(View.GONE);
+ mPersonalLogin.setVisibility(View.VISIBLE);
+
+ if (mLoginMessageHint.getVisibility() == View.VISIBLE) {
+ mLoginMessageHint.setVisibility(View.GONE);
+ EventBus.getDefault().post(new EBReuse(MESSAGE_READ_OVER));
+ }
+ }
+ }
+
+ private void checkUpdate() {
+ String channel = HaloApp.getInstance().getChannel();
+ RetrofitManager.getInstance(getContext())
+ .getApi()
+ .getUpdate(PackageUtils.getVersionName(), PackageUtils.getVersionCode(), channel)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response() {
+ @Override
+ public void onResponse(AppEntity response) {
+ super.onResponse(response);
+ if (response.getVersionCode() > PackageUtils.getVersionCode()) {
+ notifyItemChange("设置", FunctionalMessageType.NEW_VERSION);
+ } else {
+ notifyItemChange("设置", null);
+ }
+ }
+ });
+ }
+
+ private void notifyItemChange(String funcName, FunctionalMessageType msg) {
+ ArrayList mEntityList = mPersonalFuncGroupAdapter.getMEntityList();
+ for (FunctionalGroupEntity mEntity : mEntityList) {
+ for (FunctionalLinkEntity linkEntity : mEntity.getAddons()) {
+ if (TextUtils.equals(linkEntity.getType(), funcName)) {
+ linkEntity.setMessage(msg);
+ break;
+ }
+ }
+ }
+ mPersonalFuncGroupAdapter.notifyDataSetChanged();
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/personal/NewPersonalFunctionGroupAdapter.kt b/app/src/main/java/com/gh/gamecenter/personal/NewPersonalFunctionGroupAdapter.kt
new file mode 100644
index 0000000000..028c73dc08
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/personal/NewPersonalFunctionGroupAdapter.kt
@@ -0,0 +1,57 @@
+package com.gh.gamecenter.personal
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.ViewGroup
+import android.widget.TextView
+import androidx.recyclerview.widget.GridLayoutManager
+import androidx.recyclerview.widget.RecyclerView
+import com.gh.common.constant.Constants
+import com.gh.common.util.SPUtils
+import com.gh.common.view.GridSpacingItemColorDecoration
+import com.gh.gamecenter.R
+import com.gh.gamecenter.entity.FunctionalGroupEntity
+import com.lightgame.adapter.BaseRecyclerAdapter
+
+class NewPersonalFunctionGroupAdapter(val context: Context) : BaseRecyclerAdapter(context) {
+ val mEntityList = ArrayList()
+
+ fun setListData(datas: ArrayList) {
+ mEntityList.clear()
+ mEntityList.addAll(datas)
+ val haveReadRecord: HashSet = SPUtils.getStringSet(Constants.SP_ADDONS_FUNCS_HAVE_READ) as HashSet
+ mEntityList.forEach loop@{ group ->
+ group.addons.forEach { func ->
+ if (func.remind && haveReadRecord.contains(func.id)) {
+ func.remind = false
+ }
+ }
+ }
+ notifyDataSetChanged()
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
+ return object : RecyclerView.ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_new_personal_fun_group, parent, false)) {}
+ }
+
+ override fun getItemCount(): Int = mEntityList.size
+
+ override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
+ val groupEntity = mEntityList[position]
+ val groupNameTv = holder.itemView.findViewById(R.id.tv_group_name)
+ val funcRv = holder.itemView.findViewById(R.id.funcRv)
+ groupNameTv.text = groupEntity.name
+ funcRv.apply {
+ if (adapter == null) {
+ adapter = PersonalFunctionAdapter(context, groupEntity.name, groupEntity.addons)
+ } else {
+ (adapter as PersonalFunctionAdapter).checkResetData(groupEntity)
+ }
+ layoutManager = GridLayoutManager(context, 4)
+ isNestedScrollingEnabled = false
+ if (itemDecorationCount == 0) {
+ addItemDecoration(GridSpacingItemColorDecoration(context, 0, 32, R.color.white))
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java
index 3f778991ed..9cbafa0251 100644
--- a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java
@@ -13,6 +13,7 @@ import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
@@ -22,6 +23,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.facebook.drawee.view.SimpleDraweeView;
+import com.gh.base.BaseActivity;
import com.gh.base.fragment.BaseLazyFragment;
import com.gh.common.databind.BindingAdapters;
import com.gh.common.notifier.Notifier;
@@ -42,7 +44,8 @@ import com.gh.common.util.StringUtils;
import com.gh.common.util.TimeUtils;
import com.gh.common.util.ToastUtils;
import com.gh.common.view.AvatarBorderView;
-import com.gh.common.view.SpacingItemDecoration;
+import com.gh.common.view.VerticalItemDecoration;
+import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.GameDetailActivity;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.MessageActivity;
@@ -64,8 +67,6 @@ import com.gh.gamecenter.eventbus.EBNetworkState;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBSkip;
import com.gh.gamecenter.fragment.MainWrapperFragment;
-import com.gh.gamecenter.energy.EnergyCenterActivity;
-import com.gh.gamecenter.energy.EnergyHouseActivity;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.message.MessageUnreadRepository;
import com.gh.gamecenter.message.MessageUnreadViewModel;
@@ -146,8 +147,10 @@ public class PersonalFragment extends BaseLazyFragment {
RecyclerView mFuncRecyclerView;
@BindView(R.id.personal_new_fans_tips)
View personalNewFansTips;
- @BindView(R.id.personal_energy_tv)
- TextView mPersonalEnergy;
+ @BindView(R.id.personal_background)
+ SimpleDraweeView mPersonalBackground;
+ @BindView(R.id.personal_background_shadow)
+ View mPersonalBackgroundShadow;
public final static String LOGIN_TAG = "login_tag"; //登入标识
public final static String LOGOUT_TAG = "logout_tag"; // 登出标识
@@ -207,6 +210,17 @@ public class PersonalFragment extends BaseLazyFragment {
observeNoneUIRelatedChanges();
}
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ if (BuildConfig.DEBUG || BuildConfig.BUILD_TIME != 0) {
+ View indicator = getActivity().getWindow().getDecorView().findViewById(android.R.id.content).findViewById(BaseActivity.ID_ROOT_INDICATOR);
+ indicator.setOnClickListener(v ->
+ requireContext().startActivity(NewPersonalActivity.Companion.getIntent(requireContext()))
+ );
+ }
+ }
+
@Override
public void onFragmentFirstVisible() {
super.onFragmentFirstVisible();
@@ -227,7 +241,7 @@ public class PersonalFragment extends BaseLazyFragment {
mPersonalFuncGroupAdapter = new PersonalFunctionGroupAdapter(requireContext());
mFuncRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
mFuncRecyclerView.setAdapter(mPersonalFuncGroupAdapter);
- mFuncRecyclerView.addItemDecoration(new SpacingItemDecoration(true, false, false, false, 0, DisplayUtils.dip2px(32F), 0, 0));
+ mFuncRecyclerView.addItemDecoration(new VerticalItemDecoration(requireContext(), 8f, false));
int statusBarHeight = Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ? 0 : DisplayUtils.getStatusBarHeight(getResources());
ViewGroup.LayoutParams params = toolbar.getLayoutParams();
@@ -236,15 +250,13 @@ public class PersonalFragment extends BaseLazyFragment {
appbar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
int absOffset = Math.abs(verticalOffset);
- int invisibleOffset = DisplayUtils.dip2px(56F + 48F - 50F) - DisplayUtils.getStatusBarHeight(getResources());
+ int invisibleOffset = DisplayUtils.dip2px(40F);
if (absOffset <= invisibleOffset) {
mUserIconSmall.setVisibility(View.GONE);
mPersonalUserNameSmall.setVisibility(View.GONE);
- toolbar.setBackground(null);
} else {
mUserIconSmall.setVisibility(View.VISIBLE);
mPersonalUserNameSmall.setVisibility(View.VISIBLE);
- toolbar.setBackgroundResource(R.drawable.bg_personal_top);
}
mListRefresh.setEnabled(absOffset <= 2);
});
@@ -377,14 +389,6 @@ public class PersonalFragment extends BaseLazyFragment {
}
});
- mUserHomeViewModel.getEnergy().observe(this, energy -> {
- if (energy > 9999) {
- mPersonalEnergy.setText("9999+");
- } else {
- mPersonalEnergy.setText(energy + "");
- }
- });
-
mPersonalViewModel.getHaloAddData().observe(this, datas -> {
if (!datas.isEmpty()) {
mPersonalFuncGroupAdapter.setListData(datas);
@@ -438,9 +442,6 @@ public class PersonalFragment extends BaseLazyFragment {
mUnreadViewModel.retry();
mUserHomeViewModel.getBadgeList();
mUserHomeViewModel.availableBadges();
- if (CheckLoginUtils.isLogin()) {
- mUserHomeViewModel.getUserEnergy();
- }
}
int currentItem = ((MainWrapperFragment) getParentFragment()).getCurrentItem();
if (currentItem == INDEX_PERSONAL) {
@@ -510,8 +511,7 @@ public class PersonalFragment extends BaseLazyFragment {
}
@OnClick({R.id.toolbar, R.id.collapsingToolbar, R.id.iv_arrow, R.id.personal_info, R.id.personal_login, R.id.personal_user_small_icon, R.id.personal_user_icon, R.id.personal_msg,
- R.id.personal_user_name_small, R.id.personal_user_name, R.id.personal_badge, R.id.personal_home,
- R.id.personal_energy, R.id.personal_energy_center, R.id.personal_energy_house, R.id.personal_energy_record})
+ R.id.personal_user_name_small, R.id.personal_user_name, R.id.personal_badge, R.id.personal_home})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.collapsingToolbar:
@@ -572,30 +572,6 @@ public class PersonalFragment extends BaseLazyFragment {
MtaHelper.onEvent("我的光环_新", "徽章中心", "进入徽章中心");
DirectUtils.directToBadgeWall(requireContext(), mUserInfoEntity.getUserId(), mUserInfoEntity.getName(), mUserInfoEntity.getIcon());
break;
- case R.id.personal_energy:
- if (mUserInfoEntity != null) {
- MtaHelper.onEvent("我的光环_新", "光能值", "点击光能值");
- DialogUtils.showEnergyDialog(requireContext(), mUserInfoEntity.getName(), mPersonalEnergy.getText().toString());
- } else {
- CheckLoginUtils.checkLogin(getContext(), "我的光环-光能值", null);
- }
- break;
- case R.id.personal_energy_center:
- MtaHelper.onEvent("我的光环_新", "光能中心", "进入光能中心");
- requireContext().startActivity(EnergyCenterActivity.Companion.getIntent(requireContext()));
- break;
- case R.id.personal_energy_house:
- MtaHelper.onEvent("我的光环_新", "光能屋", "进入光能屋");
- requireContext().startActivity(EnergyHouseActivity.Companion.getIntent(requireContext()));
- break;
- case R.id.personal_energy_record:
- if (mUserInfoEntity != null) {
- MtaHelper.onEvent("我的光环_新", "光能记录", "进入光能记录");
- DirectUtils.directToEnergyRecord(requireContext());
- } else {
- CheckLoginUtils.checkLogin(getContext(), "我的光环-光能记录", null);
- }
- break;
default:
break;
}
@@ -744,6 +720,15 @@ public class PersonalFragment extends BaseLazyFragment {
private void changeLoginState(boolean isLogin) {
if (isLogin) {
+ // 设置背景
+ if (mUserInfoEntity.getBackground() != null) {
+ ImageUtils.display(mPersonalBackground, mUserInfoEntity.getBackground().getUrl());
+ // 自定义背景才需要加阴影
+ if (TextUtils.isEmpty(mUserInfoEntity.getBackground().getId())) {
+ mPersonalBackgroundShadow.setVisibility(View.VISIBLE);
+ }
+ }
+
SignEntity signEntity = mDatabase.signDao().getSignEntityById(UserManager.getInstance().getUserId());
if (signEntity != null && !isCanSign(signEntity.getLastTime())) {
mPersonalSign.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.personal_sign_icon_yellow));
@@ -764,10 +749,10 @@ public class PersonalFragment extends BaseLazyFragment {
mUserHomeViewModel.setUserId(UserManager.getInstance().getUserId());
mUserHomeViewModel.getBadgeList();
mUserHomeViewModel.availableBadges();
- mUserHomeViewModel.getUserEnergy();
MessageUnreadRepository.INSTANCE.loadMessageUnreadTotal(true);
} else {
- mPersonalEnergy.setText("--");
+ ImageUtils.display(mPersonalBackground, R.drawable.personal_top_bg);
+ mPersonalBackgroundShadow.setVisibility(View.GONE);
mUserIcon.display("", "", "");
mUserIconSmall.setImageURI("");
mPersonalBadgeTv.setText("我的徽章");
diff --git a/app/src/main/res/drawable-xhdpi/personal_user_default_icon.png b/app/src/main/res/drawable-xhdpi/personal_user_default_icon.png
index e05defd38a..4361e62ffe 100644
Binary files a/app/src/main/res/drawable-xhdpi/personal_user_default_icon.png and b/app/src/main/res/drawable-xhdpi/personal_user_default_icon.png differ
diff --git a/app/src/main/res/drawable-xhdpi/personal_user_default_icon_new.png b/app/src/main/res/drawable-xhdpi/personal_user_default_icon_new.png
new file mode 100644
index 0000000000..e05defd38a
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/personal_user_default_icon_new.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/personal_top_bg.webp b/app/src/main/res/drawable-xxxhdpi/personal_top_bg.webp
new file mode 100644
index 0000000000..7f6634a9bf
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/personal_top_bg.webp differ
diff --git a/app/src/main/res/layout/fragment_new_personal.xml b/app/src/main/res/layout/fragment_new_personal.xml
new file mode 100644
index 0000000000..f7e79520bc
--- /dev/null
+++ b/app/src/main/res/layout/fragment_new_personal.xml
@@ -0,0 +1,413 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_new_personal_stub.xml b/app/src/main/res/layout/fragment_new_personal_stub.xml
new file mode 100644
index 0000000000..391830aec6
--- /dev/null
+++ b/app/src/main/res/layout/fragment_new_personal_stub.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_personal.xml b/app/src/main/res/layout/fragment_personal.xml
index f7e79520bc..5198672c68 100644
--- a/app/src/main/res/layout/fragment_personal.xml
+++ b/app/src/main/res/layout/fragment_personal.xml
@@ -5,8 +5,7 @@
android:id="@+id/list_refresh"
android:fitsSystemWindows="false"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/white">
+ android:layout_height="match_parent">
+ app:contentScrim="@drawable/personal_top_bg"
+ app:layout_scrollFlags="scroll|exitUntilCollapsed"
+ app:scrimAnimationDuration="200">
-
+ android:layout_height="184dp">
-
+
+
+
+
-
-
+
-
-
-
+
+
+ app:layout_constraintBottom_toBottomOf="@+id/personal_user_icon_container"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/personal_user_icon_container" />
-
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/personal_user_icon_container">
+ android:textSize="16sp"
+ android:textStyle="bold"
+ app:layout_constraintStart_toEndOf="@+id/personal_user_icon_container"
+ app:layout_constraintTop_toTopOf="@+id/personal_user_icon_container"
+ tools:text="姓名" />
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
+ android:paddingTop="15dp"
+ android:paddingLeft="15dp"
+ android:paddingBottom="15dp"
+ android:paddingRight="6dp"
+ android:text="个人主页"
+ android:textColor="@color/white"
+ android:textSize="12sp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/iv_arrow"
+ app:layout_constraintTop_toTopOf="parent" />
-
-
-
+ android:src="@drawable/personal_home_arrow"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
-
-
-
-
-
-
-
-
-
-
-
-
+ android:id="@+id/personal_new_fans_tips"
+ android:layout_width="6dp"
+ android:layout_height="6dp"
+ android:src="@drawable/oval_hint_red_bg"
+ android:visibility="gone"
+ app:layout_constraintStart_toEndOf="@+id/personal_home"
+ app:layout_constraintTop_toTopOf="@+id/personal_home" />
+
+
diff --git a/app/src/main/res/layout/item_new_personal_fun_group.xml b/app/src/main/res/layout/item_new_personal_fun_group.xml
new file mode 100644
index 0000000000..e86f0cea28
--- /dev/null
+++ b/app/src/main/res/layout/item_new_personal_fun_group.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_personal_fun_group.xml b/app/src/main/res/layout/item_personal_fun_group.xml
index e86f0cea28..eeeb97c51d 100644
--- a/app/src/main/res/layout/item_personal_fun_group.xml
+++ b/app/src/main/res/layout/item_personal_fun_group.xml
@@ -3,10 +3,12 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:background="@drawable/bg_personal_card"
android:orientation="vertical"
- android:paddingLeft="16dp"
- android:paddingBottom="32dp"
- android:paddingRight="16dp">
+ android:paddingLeft="18dp"
+ android:paddingTop="16dp"
+ android:paddingRight="16dp"
+ android:paddingBottom="28dp">