jimu-decompiled/sources/com/ubt/jimu/user/view/fragment/InterestFragment.java
2025-05-13 19:24:51 +02:00

210 lines
7.9 KiB
Java

package com.ubt.jimu.user.view.fragment;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import butterknife.ButterKnife;
import com.recyclelib.URecyclerView;
import com.ubt.jimu.R;
import com.ubt.jimu.base.cache.Cache;
import com.ubt.jimu.base.entities.FollowEntities;
import com.ubt.jimu.base.entities.Interest;
import com.ubt.jimu.base.http.ApiObserver;
import com.ubt.jimu.base.http.manager.CommunityManager;
import com.ubt.jimu.user.contract.InterestContract$Presenter;
import com.ubt.jimu.user.contract.InterestContract$View;
import com.ubt.jimu.user.view.LoginActivity;
import com.ubt.jimu.user.view.UserCenterActivity;
import com.ubt.jimu.user.view.adapter.InterestAdapter;
import com.ubt.jimu.utils.NetWorkUtil;
import com.ubt.jimu.widgets.LoadingView;
import com.ubtech.view.fragment.BaseFragment;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes2.dex */
public class InterestFragment extends BaseFragment implements InterestContract$View {
private InterestAdapter b;
private InterestContract$Presenter c;
private long d;
URecyclerView interestRecycleView;
LoadingView loadingView;
private List<Interest> a = new ArrayList();
private Handler e = new Handler();
private void initView() {
if (getArguments() != null) {
this.d = getArguments().getLong("view_user_id");
}
this.b = new InterestAdapter(this.mActivity, this.a);
this.b.a(new InterestAdapter.Callback() { // from class: com.ubt.jimu.user.view.fragment.InterestFragment.1
@Override // com.ubt.jimu.user.view.adapter.InterestAdapter.Callback
public void a(int i) {
UserCenterActivity.a(((BaseFragment) InterestFragment.this).mActivity, ((Interest) InterestFragment.this.a.get(i)).getUserId());
}
@Override // com.ubt.jimu.user.view.adapter.InterestAdapter.Callback
public void b(int i) {
if (Cache.getInstance().getLoginUserIntId() == 0) {
LoginActivity.start(((BaseFragment) InterestFragment.this).mActivity);
} else {
CommunityManager.create().subscriptionAdd(((Interest) InterestFragment.this.a.get(i)).getUserId(), new ApiObserver<FollowEntities>(null) { // from class: com.ubt.jimu.user.view.fragment.InterestFragment.1.1
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void onNext(FollowEntities followEntities) {
super.onNext(followEntities);
InterestFragment.this.c.b(InterestFragment.this.m(), InterestFragment.this.d());
}
});
}
}
});
this.interestRecycleView.setAdapter(this.b);
this.interestRecycleView.setLayoutManager(new LinearLayoutManager(this.mActivity, 1, false));
this.interestRecycleView.setLoadingMoreEnabled(false);
this.interestRecycleView.setLoadingListener(new URecyclerView.LoadingListener() { // from class: com.ubt.jimu.user.view.fragment.InterestFragment.2
@Override // com.recyclelib.URecyclerView.LoadingListener
public void onLoadingMore() {
}
@Override // com.recyclelib.URecyclerView.LoadingListener
public void onRefreshing() {
InterestFragment.this.loadingView.setIsRefresh(true);
InterestFragment.this.c.b(InterestFragment.this.m(), InterestFragment.this.d());
}
});
this.loadingView.setOnRetryListener(new LoadingView.RetryRequest() { // from class: com.ubt.jimu.user.view.fragment.InterestFragment.3
@Override // com.ubt.jimu.widgets.LoadingView.RetryRequest
public void OnRetryListener() {
InterestFragment.this.loadingView.c();
InterestFragment.this.e.postDelayed(new Runnable() { // from class: com.ubt.jimu.user.view.fragment.InterestFragment.3.1
@Override // java.lang.Runnable
public void run() {
InterestFragment.this.c.subscribe();
}
}, 500L);
}
});
this.loadingView.setBackgroundViewColor(getResources().getColor(R.color.bg_F9F9F9));
}
private boolean o() {
return d() == m();
}
private void q() {
if (o()) {
this.loadingView.a(R.string.tips_no_subscription, R.drawable.icon_favourate_empty);
} else {
this.loadingView.a(R.string.others_no_subscription, R.drawable.icon_favourate_empty);
}
}
@Override // com.ubt.jimu.user.contract.InterestContract$View
public int e() {
return 1;
}
@Override // com.ubt.jimu.user.contract.InterestContract$View
public int f() {
return 1000;
}
@Override // com.ubt.jimu.user.contract.InterestContract$View
public long m() {
return Cache.getInstance().getLoginUserIntId();
}
@Override // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
View inflate = layoutInflater.inflate(R.layout.fragment_interest, (ViewGroup) null);
ButterKnife.a(this, inflate);
initView();
return inflate;
}
@Override // androidx.fragment.app.Fragment
public void onDestroy() {
Handler handler = this.e;
if (handler != null) {
handler.removeCallbacksAndMessages(null);
this.e = null;
}
super.onDestroy();
}
@Override // com.ubt.jimu.user.contract.InterestContract$View
public void onError() {
if (NetWorkUtil.b(this.mActivity)) {
this.loadingView.e();
} else {
this.loadingView.d();
}
this.interestRecycleView.A();
}
@Override // androidx.fragment.app.Fragment
public void onPause() {
this.c.unSubscribe();
this.loadingView.b();
super.onPause();
}
@Override // androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
this.c.subscribe();
}
public static InterestFragment a(long j) {
InterestFragment interestFragment = new InterestFragment();
Bundle bundle = new Bundle();
bundle.putLong("view_user_id", j);
interestFragment.setArguments(bundle);
return interestFragment;
}
public /* synthetic */ void b() {
this.loadingView.g();
}
@Override // com.ubt.jimu.user.contract.InterestContract$View
public long d() {
return this.d;
}
@Override // com.ubt.jimu.user.contract.InterestContract$View
public void b(List<Interest> list) {
this.interestRecycleView.A();
if (list != null && list.size() != 0) {
this.loadingView.b();
Log.i("InterestFragment", list.toString());
this.a.clear();
this.a.addAll(list);
this.b.notifyDataSetChanged();
return;
}
q();
}
@Override // com.ubtech.view.BaseView
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void setPresenter(InterestContract$Presenter interestContract$Presenter) {
this.c = interestContract$Presenter;
}
@Override // com.ubt.jimu.user.contract.InterestContract$View
public void a() {
this.loadingView.post(new Runnable() { // from class: com.ubt.jimu.user.view.fragment.a
@Override // java.lang.Runnable
public final void run() {
InterestFragment.this.b();
}
});
}
}