241 lines
7.7 KiB
Java
241 lines
7.7 KiB
Java
package com.ubt.jimu.user.setting.view;
|
|
|
|
import android.content.Intent;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.RequestBuilder;
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.db.user.UserDbHandler;
|
|
import com.ubt.jimu.base.entities.User;
|
|
import com.ubt.jimu.base.event.MessageEvent;
|
|
import com.ubt.jimu.base.mvp.BaseMvpFragment;
|
|
import com.ubt.jimu.base.mvp.SingleClickListener;
|
|
import com.ubt.jimu.base.util.FileUtil;
|
|
import com.ubt.jimu.user.setting.presenter.MyAccountPresenter;
|
|
import com.ubt.jimu.user.view.LoginActivity;
|
|
import com.ubt.jimu.user.view.UserDetailInfoActivity;
|
|
import com.ubt.jimu.user.view.setting.ThePolicyActivity;
|
|
import com.ubt.jimu.utils.LogUtils;
|
|
import com.ubt.jimu.utils.ShortcutHelper;
|
|
import com.ubt.jimu.widgets.RoundedImageView;
|
|
import com.ubtech.view.widget.UButton;
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class MyAccountFragment extends BaseMvpFragment<MyAccountPresenter> implements MyAccountPresenter.MyAccountView, SingleClickListener {
|
|
private LinearLayout a;
|
|
private FrameLayout b;
|
|
private UButton c;
|
|
private RoundedImageView d;
|
|
private TextView e;
|
|
private TextView f;
|
|
private long g;
|
|
private long h;
|
|
private boolean i;
|
|
private boolean j;
|
|
private User k;
|
|
private RelativeLayout l;
|
|
private RelativeLayout m;
|
|
private RelativeLayout n;
|
|
|
|
private void a(User user) {
|
|
boolean z = this.i;
|
|
if (!z || (z && !this.j)) {
|
|
return;
|
|
}
|
|
this.e.setText(user.getNickName());
|
|
this.f.setText("UID:" + user.getUserId());
|
|
this.d.setBackgroundResource(R.drawable.user_center_protrait_bg);
|
|
RequestBuilder<Drawable> a = Glide.a(this).a(user.getUserImage());
|
|
a.a(RequestOptions.N().b(R.drawable.community_img_official).a(R.drawable.community_img_official));
|
|
a.a((ImageView) this.d);
|
|
}
|
|
|
|
private void b() {
|
|
this.c.setOnClickListener(this);
|
|
this.l.setOnClickListener(this);
|
|
this.m.setOnClickListener(this);
|
|
this.n.setOnClickListener(this);
|
|
}
|
|
|
|
private void initView(View view) {
|
|
this.l = (RelativeLayout) view.findViewById(R.id.btn_edit_pmsg);
|
|
this.m = (RelativeLayout) view.findViewById(R.id.btn_write_off);
|
|
this.n = (RelativeLayout) view.findViewById(R.id.btn_logout);
|
|
this.a = (LinearLayout) view.findViewById(R.id.ll_account);
|
|
this.b = (FrameLayout) view.findViewById(R.id.unLoginLayout);
|
|
this.c = (UButton) view.findViewById(R.id.btnLogin);
|
|
this.d = (RoundedImageView) view.findViewById(R.id.iv_setting_portrait);
|
|
this.e = (TextView) view.findViewById(R.id.tv_setting_name);
|
|
this.f = (TextView) view.findViewById(R.id.tv_setting_uid);
|
|
}
|
|
|
|
private void o() {
|
|
this.g = getArguments().getLong("view_user_id", 0L);
|
|
this.k = UserDbHandler.getUser();
|
|
User user = this.k;
|
|
if (user != null) {
|
|
this.h = user.getUserId();
|
|
} else {
|
|
this.h = 0L;
|
|
}
|
|
boolean z = true;
|
|
this.i = this.h > 0;
|
|
long j = this.h;
|
|
if ((j <= 0 || j != this.g) && this.g > 0) {
|
|
z = false;
|
|
}
|
|
this.j = z;
|
|
User user2 = this.k;
|
|
if (user2 != null) {
|
|
a(user2);
|
|
}
|
|
}
|
|
|
|
private void q() {
|
|
boolean z = this.i || this.g > 0;
|
|
this.b.setVisibility(z ? 8 : 0);
|
|
this.a.setVisibility(z ? 0 : 8);
|
|
}
|
|
|
|
public void c(String str) {
|
|
LogUtils.c("退出登录:" + str);
|
|
((MyAccountPresenter) this.mPresenter).a(str);
|
|
this.b.setVisibility(0);
|
|
this.a.setVisibility(8);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public int getLayoutID() {
|
|
return R.layout.fragment_setting_myaccount;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public boolean isRegistEventBus() {
|
|
return true;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.setting.presenter.MyAccountPresenter.MyAccountView
|
|
public void l() {
|
|
Cache.getInstance().clearCacheUser();
|
|
UserDbHandler.clearUser();
|
|
ShortcutHelper.a(JimuApplication.l());
|
|
EventBus.b().b(new MessageEvent(1));
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onActivityResult(int i, int i2, Intent intent) {
|
|
super.onActivityResult(i, i2, intent);
|
|
if (i == 4096) {
|
|
if (intent == null) {
|
|
getActivity().finish();
|
|
return;
|
|
}
|
|
User user = (User) intent.getSerializableExtra("user");
|
|
if (user != null) {
|
|
b(user);
|
|
} else {
|
|
getActivity().finish();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener, android.view.View.OnClickListener
|
|
public /* synthetic */ void onClick(View view) {
|
|
com.ubt.jimu.base.mvp.b.$default$onClick(this, view);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onDetach() {
|
|
super.onDetach();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public void onReceiveMessage(MessageEvent messageEvent) {
|
|
super.onReceiveMessage(messageEvent);
|
|
if (messageEvent.getType() == 5) {
|
|
this.b.setVisibility(0);
|
|
this.a.setVisibility(8);
|
|
return;
|
|
}
|
|
if (messageEvent.getType() == 6) {
|
|
a(UserDbHandler.getUser());
|
|
return;
|
|
}
|
|
if (messageEvent.getType() == 1) {
|
|
this.b.setVisibility(0);
|
|
this.a.setVisibility(8);
|
|
} else if (messageEvent.getType() == 0) {
|
|
b(UserDbHandler.getUser());
|
|
} else if (messageEvent.getType() == 7) {
|
|
b(UserDbHandler.getUser());
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener
|
|
public void onSingleClick(View view) {
|
|
int id = view.getId();
|
|
if (id == R.id.btnLogin) {
|
|
LoginActivity.start(getActivity(), FileUtil.ZIP_BUFFER_SIZE);
|
|
return;
|
|
}
|
|
if (id == R.id.btn_edit_pmsg) {
|
|
if (this.h > 0) {
|
|
UserDetailInfoActivity.start(getActivity());
|
|
return;
|
|
} else {
|
|
LoginActivity.start(getActivity(), FileUtil.ZIP_BUFFER_SIZE);
|
|
return;
|
|
}
|
|
}
|
|
if (id == R.id.btn_write_off) {
|
|
ThePolicyActivity.a(getActivity(), 10);
|
|
} else if (id == R.id.btn_logout) {
|
|
c(Cache.getInstance().getUserToken());
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onStart() {
|
|
super.onStart();
|
|
o();
|
|
q();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onViewCreated(View view, Bundle bundle) {
|
|
super.onViewCreated(view, bundle);
|
|
initView(view);
|
|
b();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public MyAccountPresenter createPresenter() {
|
|
return new MyAccountPresenter();
|
|
}
|
|
|
|
private void b(User user) {
|
|
if (user != null) {
|
|
this.h = user.getUserId();
|
|
o();
|
|
q();
|
|
a(user);
|
|
}
|
|
}
|
|
}
|