480 lines
21 KiB
Java
480 lines
21 KiB
Java
package com.ubt.jimu.message.view.fragment;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewStub;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import android.widget.Toast;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import butterknife.ButterKnife;
|
|
import butterknife.Unbinder;
|
|
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
|
import com.recyclelib.URecyclerView;
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.entities.ApiRecord;
|
|
import com.ubt.jimu.base.http.ApiObserver;
|
|
import com.ubt.jimu.base.http.ApiResultException;
|
|
import com.ubt.jimu.base.http.manager.MsgCenterManager;
|
|
import com.ubt.jimu.message.JimuMessage;
|
|
import com.ubt.jimu.message.view.adapter.UserMessageAdapter;
|
|
import com.ubt.jimu.widgets.LoadingView;
|
|
import com.ubtech.view.fragment.LazyLoadFragment;
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
import io.reactivex.disposables.Disposable;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class UserMessageFragment extends LazyLoadFragment implements URecyclerView.LoadingListener, UserMessageAdapter.OnMessageInteractionListener, LoadingView.RetryRequest {
|
|
private static final String ARG_PARAM1 = "msgType";
|
|
private static final String ARG_PARAM2 = "param2";
|
|
private UserMessageAdapter adapter;
|
|
protected ImageView imgNoMessage;
|
|
protected LoadingView loadingView;
|
|
private Unbinder mBind;
|
|
private OnMsgFragmentInteractionListener mListener;
|
|
private String mParam2;
|
|
private String msgType;
|
|
protected URecyclerView recyclerView;
|
|
protected View stubView;
|
|
protected TextView tvTips;
|
|
protected ViewStub viewStub;
|
|
private CompositeDisposable disposable = new CompositeDisposable();
|
|
private List<JimuMessage> messages = new ArrayList();
|
|
private final int PAGE_SIZE = 20;
|
|
private int pageNum = 1;
|
|
|
|
public interface OnMsgFragmentInteractionListener {
|
|
void onNoNewMsg(String str);
|
|
}
|
|
|
|
static /* synthetic */ int access$108(UserMessageFragment userMessageFragment) {
|
|
int i = userMessageFragment.pageNum;
|
|
userMessageFragment.pageNum = i + 1;
|
|
return i;
|
|
}
|
|
|
|
private void initView() {
|
|
this.adapter = new UserMessageAdapter(getContext(), this.messages);
|
|
this.adapter.setInteractionListener(this);
|
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
|
linearLayoutManager.k(1);
|
|
this.recyclerView.setLayoutManager(linearLayoutManager);
|
|
this.recyclerView.setAdapter(this.adapter);
|
|
this.recyclerView.setLoadingListener(this);
|
|
this.recyclerView.setLoadingMoreEnabled(true);
|
|
this.loadingView.setOnRetryListener(this);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* JADX WARN: Removed duplicated region for block: B:23:0x0074 */
|
|
/* JADX WARN: Removed duplicated region for block: B:37:0x00ae A[Catch: Exception -> 0x00bf, TryCatch #0 {Exception -> 0x00bf, blocks: (B:13:0x003a, B:27:0x0079, B:29:0x007c, B:32:0x009d, B:34:0x00a0, B:37:0x00ae, B:39:0x00b1, B:42:0x0052, B:45:0x005c, B:48:0x0066), top: B:12:0x003a }] */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
public void jump(com.ubt.jimu.message.JimuMessage r6, int r7) {
|
|
/*
|
|
r5 = this;
|
|
if (r6 == 0) goto Lc3
|
|
java.lang.String r7 = r6.getLink()
|
|
boolean r7 = android.text.TextUtils.isEmpty(r7)
|
|
if (r7 == 0) goto Le
|
|
goto Lc3
|
|
Le:
|
|
java.lang.String r7 = r6.getLink()
|
|
java.lang.String r0 = "http"
|
|
boolean r7 = r7.startsWith(r0)
|
|
if (r7 == 0) goto L2b
|
|
androidx.fragment.app.FragmentActivity r7 = r5.getActivity()
|
|
java.lang.String r6 = r6.getLink()
|
|
r0 = 2131099967(0x7f06013f, float:1.7812302E38)
|
|
java.lang.String r1 = ""
|
|
com.ubt.jimu.base.HelpActivity.start(r7, r6, r1, r0)
|
|
return
|
|
L2b:
|
|
java.lang.String r6 = r6.getLink()
|
|
java.lang.String r7 = "/"
|
|
java.lang.String[] r6 = r6.split(r7)
|
|
int r7 = r6.length
|
|
r0 = 1
|
|
if (r7 != r0) goto L3a
|
|
return
|
|
L3a:
|
|
r7 = r6[r0] // Catch: java.lang.Exception -> Lbf
|
|
r1 = -1
|
|
int r2 = r7.hashCode() // Catch: java.lang.Exception -> Lbf
|
|
r3 = -1655966961(0xffffffff9d4bf30f, float:-2.6992485E-21)
|
|
r4 = 2
|
|
if (r2 == r3) goto L66
|
|
r3 = 3135424(0x2fd7c0, float:4.393665E-39)
|
|
if (r2 == r3) goto L5c
|
|
r3 = 3446944(0x3498a0, float:4.830197E-39)
|
|
if (r2 == r3) goto L52
|
|
goto L70
|
|
L52:
|
|
java.lang.String r2 = "post"
|
|
boolean r7 = r7.equals(r2) // Catch: java.lang.Exception -> Lbf
|
|
if (r7 == 0) goto L70
|
|
r7 = 1
|
|
goto L71
|
|
L5c:
|
|
java.lang.String r2 = "fans"
|
|
boolean r7 = r7.equals(r2) // Catch: java.lang.Exception -> Lbf
|
|
if (r7 == 0) goto L70
|
|
r7 = 2
|
|
goto L71
|
|
L66:
|
|
java.lang.String r2 = "activity"
|
|
boolean r7 = r7.equals(r2) // Catch: java.lang.Exception -> Lbf
|
|
if (r7 == 0) goto L70
|
|
r7 = 0
|
|
goto L71
|
|
L70:
|
|
r7 = -1
|
|
L71:
|
|
r1 = 3
|
|
if (r7 == 0) goto Lae
|
|
if (r7 == r0) goto L9d
|
|
if (r7 == r4) goto L79
|
|
goto Lc3
|
|
L79:
|
|
int r6 = r6.length // Catch: java.lang.Exception -> Lbf
|
|
if (r6 < r1) goto Lc3
|
|
android.os.Bundle r6 = new android.os.Bundle // Catch: java.lang.Exception -> Lbf
|
|
r6.<init>() // Catch: java.lang.Exception -> Lbf
|
|
java.lang.String r7 = "view_user_id"
|
|
com.ubt.jimu.base.cache.Cache r1 = com.ubt.jimu.base.cache.Cache.getInstance() // Catch: java.lang.Exception -> Lbf
|
|
long r1 = r1.getLoginUserIntId() // Catch: java.lang.Exception -> Lbf
|
|
r6.putLong(r7, r1) // Catch: java.lang.Exception -> Lbf
|
|
java.lang.String r7 = "page_index"
|
|
r6.putInt(r7, r0) // Catch: java.lang.Exception -> Lbf
|
|
androidx.fragment.app.FragmentActivity r7 = r5.getActivity() // Catch: java.lang.Exception -> Lbf
|
|
com.ubt.jimu.BaseActivity r7 = (com.ubt.jimu.BaseActivity) r7 // Catch: java.lang.Exception -> Lbf
|
|
com.ubt.jimu.user.view.InterestFansActivity.a(r7, r6) // Catch: java.lang.Exception -> Lbf
|
|
goto Lc3
|
|
L9d:
|
|
int r7 = r6.length // Catch: java.lang.Exception -> Lbf
|
|
if (r7 < r1) goto Lc3
|
|
androidx.fragment.app.FragmentActivity r7 = r5.getActivity() // Catch: java.lang.Exception -> Lbf
|
|
r6 = r6[r4] // Catch: java.lang.Exception -> Lbf
|
|
int r6 = java.lang.Integer.parseInt(r6) // Catch: java.lang.Exception -> Lbf
|
|
com.ubt.jimu.community.view.PublishDetailActivity.start(r7, r6) // Catch: java.lang.Exception -> Lbf
|
|
goto Lc3
|
|
Lae:
|
|
int r7 = r6.length // Catch: java.lang.Exception -> Lbf
|
|
if (r7 < r1) goto Lc3
|
|
androidx.fragment.app.FragmentActivity r7 = r5.getActivity() // Catch: java.lang.Exception -> Lbf
|
|
r6 = r6[r4] // Catch: java.lang.Exception -> Lbf
|
|
int r6 = java.lang.Integer.parseInt(r6) // Catch: java.lang.Exception -> Lbf
|
|
com.ubt.jimu.community.activity.JimuActActivity.start(r7, r6) // Catch: java.lang.Exception -> Lbf
|
|
goto Lc3
|
|
Lbf:
|
|
r6 = move-exception
|
|
r6.printStackTrace()
|
|
Lc3:
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.message.view.fragment.UserMessageFragment.jump(com.ubt.jimu.message.JimuMessage, int):void");
|
|
}
|
|
|
|
private void loadMessage(int i) {
|
|
if ("3".equals(TextUtils.isEmpty(this.msgType) ? "1" : this.msgType)) {
|
|
loadNews(i);
|
|
} else if (Cache.getInstance().getUser() == null) {
|
|
showNoMsgTips();
|
|
} else {
|
|
loadUserMsg(i);
|
|
}
|
|
}
|
|
|
|
private void loadNews(final int i) {
|
|
ApiObserver<ApiRecord<JimuMessage>> apiObserver = new ApiObserver<ApiRecord<JimuMessage>>(this.loadingView) { // from class: com.ubt.jimu.message.view.fragment.UserMessageFragment.3
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onComplete() {
|
|
super.onComplete();
|
|
UserMessageFragment.this.recyclerView.y();
|
|
UserMessageFragment.this.recyclerView.z();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
UserMessageFragment.this.disposable.b(disposable);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onNext(ApiRecord<JimuMessage> apiRecord) {
|
|
if (apiRecord == null || apiRecord.getRecords() == null) {
|
|
if (UserMessageFragment.this.pageNum == 1) {
|
|
UserMessageFragment.this.showNoMsgTips();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (apiRecord.getRecords().size() == 0) {
|
|
if (i == 1) {
|
|
UserMessageFragment.this.showNoMsgTips();
|
|
} else {
|
|
UserMessageFragment.this.recyclerView.setNoMore(true);
|
|
}
|
|
}
|
|
if (UserMessageFragment.this.pageNum == 1) {
|
|
UserMessageFragment.this.messages.clear();
|
|
}
|
|
UserMessageFragment.this.messages.addAll(apiRecord.getRecords());
|
|
UserMessageFragment.this.adapter.notifyDataSetChanged();
|
|
UserMessageFragment.access$108(UserMessageFragment.this);
|
|
}
|
|
};
|
|
apiObserver.setApiErrorListener(new ApiObserver.ApiErrorListener() { // from class: com.ubt.jimu.message.view.fragment.UserMessageFragment.4
|
|
@Override // com.ubt.jimu.base.http.ApiObserver.ApiErrorListener
|
|
public void onError(ApiResultException apiResultException) {
|
|
UserMessageFragment.this.recyclerView.y();
|
|
UserMessageFragment.this.recyclerView.z();
|
|
if (apiResultException.getCode() > 399) {
|
|
UserMessageFragment.this.showNoMsgTips();
|
|
}
|
|
}
|
|
});
|
|
MsgCenterManager.getInstance().news(i, 20, JimuApplication.l().g(), apiObserver);
|
|
}
|
|
|
|
private void loadUserMsg(int i) {
|
|
ApiObserver<ApiRecord<JimuMessage>> apiObserver = new ApiObserver<ApiRecord<JimuMessage>>(this.loadingView) { // from class: com.ubt.jimu.message.view.fragment.UserMessageFragment.1
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onComplete() {
|
|
super.onComplete();
|
|
UserMessageFragment.this.recyclerView.y();
|
|
UserMessageFragment.this.recyclerView.z();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
UserMessageFragment.this.disposable.b(disposable);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onNext(ApiRecord<JimuMessage> apiRecord) {
|
|
if (apiRecord == null || apiRecord.getRecords() == null) {
|
|
if (UserMessageFragment.this.pageNum == 1) {
|
|
UserMessageFragment.this.showNoMsgTips();
|
|
}
|
|
} else {
|
|
if (apiRecord.getRecords().size() == 0) {
|
|
if (UserMessageFragment.this.pageNum == 1) {
|
|
UserMessageFragment.this.showNoMsgTips();
|
|
return;
|
|
} else {
|
|
UserMessageFragment.this.recyclerView.setNoMore(true);
|
|
return;
|
|
}
|
|
}
|
|
if (UserMessageFragment.this.pageNum == 1) {
|
|
UserMessageFragment.this.messages.clear();
|
|
}
|
|
UserMessageFragment.this.messages.addAll(apiRecord.getRecords());
|
|
UserMessageFragment.this.adapter.notifyDataSetChanged();
|
|
UserMessageFragment.access$108(UserMessageFragment.this);
|
|
}
|
|
}
|
|
};
|
|
apiObserver.setApiErrorListener(new ApiObserver.ApiErrorListener() { // from class: com.ubt.jimu.message.view.fragment.UserMessageFragment.2
|
|
@Override // com.ubt.jimu.base.http.ApiObserver.ApiErrorListener
|
|
public void onError(ApiResultException apiResultException) {
|
|
UserMessageFragment.this.recyclerView.y();
|
|
UserMessageFragment.this.recyclerView.z();
|
|
if (apiResultException.getCode() > 399) {
|
|
UserMessageFragment.this.showNoMsgTips();
|
|
}
|
|
}
|
|
});
|
|
MsgCenterManager.getInstance().list(i, 20, this.msgType, apiObserver);
|
|
}
|
|
|
|
public static UserMessageFragment newInstance(String str, String str2) {
|
|
UserMessageFragment userMessageFragment = new UserMessageFragment();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(ARG_PARAM1, str);
|
|
bundle.putString(ARG_PARAM2, str2);
|
|
userMessageFragment.setArguments(bundle);
|
|
return userMessageFragment;
|
|
}
|
|
|
|
private void setMsgRead(final JimuMessage jimuMessage, final int i) {
|
|
if (1 == jimuMessage.getIsRead()) {
|
|
jump(jimuMessage, i);
|
|
} else {
|
|
MsgCenterManager.getInstance().setMsgState(jimuMessage.getId(), new ApiObserver<Map<String, Boolean>>(null) { // from class: com.ubt.jimu.message.view.fragment.UserMessageFragment.5
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onComplete() {
|
|
super.onComplete();
|
|
UserMessageFragment.this.adapter.notifyDataSetChanged();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
super.onError(th);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
UserMessageFragment.this.disposable.b(disposable);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onNext(Map<String, Boolean> map) {
|
|
super.onNext((AnonymousClass5) map);
|
|
if (map == null) {
|
|
return;
|
|
}
|
|
if (map.containsKey(FileDownloadModel.STATUS) && map.get(FileDownloadModel.STATUS).booleanValue()) {
|
|
jimuMessage.setIsRead(1);
|
|
UserMessageFragment.this.adapter.notifyDataSetChanged();
|
|
int i2 = 0;
|
|
Iterator it = UserMessageFragment.this.messages.iterator();
|
|
while (it.hasNext() && ((JimuMessage) it.next()).getIsRead() != 0) {
|
|
i2++;
|
|
}
|
|
if (i2 == UserMessageFragment.this.messages.size() && UserMessageFragment.this.mListener != null) {
|
|
UserMessageFragment.this.mListener.onNoNewMsg(UserMessageFragment.this.msgType);
|
|
}
|
|
}
|
|
UserMessageFragment.this.jump(jimuMessage, i);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void showNoMsgTips() {
|
|
String str;
|
|
if (isDetached() || isRemoving()) {
|
|
return;
|
|
}
|
|
this.loadingView.setVisibility(8);
|
|
this.recyclerView.setVisibility(8);
|
|
if (this.stubView == null) {
|
|
this.stubView = this.viewStub.inflate();
|
|
this.viewStub.setVisibility(0);
|
|
this.imgNoMessage = (ImageView) this.stubView.findViewById(R.id.imgNoMessage);
|
|
this.tvTips = (TextView) this.stubView.findViewById(R.id.tvTips);
|
|
}
|
|
if (Cache.getInstance().getUser() != null) {
|
|
this.imgNoMessage.setImageResource(R.mipmap.no_message);
|
|
} else if ("3".equals(this.msgType)) {
|
|
this.imgNoMessage.setImageResource(R.mipmap.no_message);
|
|
} else {
|
|
this.imgNoMessage.setImageResource(R.drawable.icon_no_login);
|
|
}
|
|
if (this.tvTips != null) {
|
|
String userId = Cache.getInstance().getUserId();
|
|
if (this.mActivity != null) {
|
|
str = "local".equals(userId) ? this.mActivity.getString(R.string.favourite_no_login) : this.mActivity.getString(R.string.msg_center_no_message);
|
|
if ("3".equals(this.msgType)) {
|
|
str = this.mActivity.getString(R.string.msg_center_no_message);
|
|
}
|
|
} else {
|
|
str = "";
|
|
}
|
|
this.tvTips.setText(str);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.widgets.LoadingView.RetryRequest
|
|
public void OnRetryListener() {
|
|
loadData();
|
|
}
|
|
|
|
@Override // com.ubtech.view.fragment.LazyLoadFragment
|
|
protected void loadData() {
|
|
loadMessage(1);
|
|
}
|
|
|
|
@Override // com.ubtech.view.fragment.LazyLoadFragment, androidx.fragment.app.Fragment
|
|
public void onAttach(Context context) {
|
|
super.onAttach(context);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
if (getArguments() != null) {
|
|
this.msgType = getArguments().getString(ARG_PARAM1);
|
|
this.mParam2 = getArguments().getString(ARG_PARAM2);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
|
View inflate = layoutInflater.inflate(R.layout.fragment_user_message, viewGroup, false);
|
|
this.mBind = ButterKnife.a(this, inflate);
|
|
initView();
|
|
return inflate;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.message.view.adapter.UserMessageAdapter.OnMessageInteractionListener
|
|
public void onDeleteMsgClick(JimuMessage jimuMessage, int i) {
|
|
Toast.makeText(getContext(), "删除:" + i, 0).show();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
this.disposable.dispose();
|
|
this.disposable.a();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroyView() {
|
|
this.mBind.unbind();
|
|
super.onDestroyView();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDetach() {
|
|
super.onDetach();
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onLoadingMore() {
|
|
if (isDetached() || isRemoving()) {
|
|
return;
|
|
}
|
|
this.loadingView.setIsRefresh(true);
|
|
loadMessage(this.pageNum + 1);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.message.view.adapter.UserMessageAdapter.OnMessageInteractionListener
|
|
public void onMessageClick(JimuMessage jimuMessage, int i) {
|
|
setMsgRead(jimuMessage, i);
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onRefreshing() {
|
|
if (isDetached() || isRemoving()) {
|
|
return;
|
|
}
|
|
this.loadingView.setVisibility(0);
|
|
this.recyclerView.setNoMore(false);
|
|
this.loadingView.setIsRefresh(true);
|
|
this.pageNum = 1;
|
|
loadMessage(this.pageNum);
|
|
}
|
|
|
|
public void setListener(OnMsgFragmentInteractionListener onMsgFragmentInteractionListener) {
|
|
this.mListener = onMsgFragmentInteractionListener;
|
|
}
|
|
}
|