203 lines
7.4 KiB
Java
203 lines
7.4 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 butterknife.Unbinder;
|
|
import com.recyclelib.URecyclerView;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.entities.Fans;
|
|
import com.ubt.jimu.base.entities.FollowEntities;
|
|
import com.ubt.jimu.base.http.ApiObserver;
|
|
import com.ubt.jimu.base.http.manager.CommunityManager;
|
|
import com.ubt.jimu.user.contract.FansContract$Presenter;
|
|
import com.ubt.jimu.user.contract.FansContract$View;
|
|
import com.ubt.jimu.user.view.LoginActivity;
|
|
import com.ubt.jimu.user.view.UserCenterActivity;
|
|
import com.ubt.jimu.user.view.adapter.FansAdapter;
|
|
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 FansFragment extends BaseFragment implements FansContract$View {
|
|
private FansContract$Presenter a;
|
|
private FansAdapter c;
|
|
private long d;
|
|
private Unbinder e;
|
|
URecyclerView fansRecyclerView;
|
|
LoadingView loadingView;
|
|
private List<Fans> b = new ArrayList();
|
|
private Handler f = new Handler();
|
|
|
|
private void initView() {
|
|
if (getArguments() != null) {
|
|
this.d = getArguments().getLong("view_user_id");
|
|
}
|
|
this.c = new FansAdapter(this.mActivity, this.b);
|
|
this.c.a(new FansAdapter.Callback() { // from class: com.ubt.jimu.user.view.fragment.FansFragment.1
|
|
@Override // com.ubt.jimu.user.view.adapter.FansAdapter.Callback
|
|
public void a(int i) {
|
|
UserCenterActivity.a(((BaseFragment) FansFragment.this).mActivity, ((Fans) FansFragment.this.b.get(i)).getUserId());
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.view.adapter.FansAdapter.Callback
|
|
public void a(Fans fans, int i) {
|
|
if (Cache.getInstance().getLoginUserIntId() == 0) {
|
|
LoginActivity.start(((BaseFragment) FansFragment.this).mActivity);
|
|
} else {
|
|
CommunityManager.create().subscriptionAdd((int) fans.getUserId(), new ApiObserver<FollowEntities>(null) { // from class: com.ubt.jimu.user.view.fragment.FansFragment.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);
|
|
FansFragment.this.a.subscribe();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
this.fansRecyclerView.setAdapter(this.c);
|
|
this.fansRecyclerView.setLayoutManager(new LinearLayoutManager(this.mActivity, 1, false));
|
|
this.fansRecyclerView.setLoadingMoreEnabled(false);
|
|
this.fansRecyclerView.setLoadingListener(new URecyclerView.LoadingListener() { // from class: com.ubt.jimu.user.view.fragment.FansFragment.2
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onLoadingMore() {
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onRefreshing() {
|
|
FansFragment.this.loadingView.setIsRefresh(true);
|
|
FansFragment.this.a.d(FansFragment.this.m(), FansFragment.this.d());
|
|
}
|
|
});
|
|
this.loadingView.setOnRetryListener(new LoadingView.RetryRequest() { // from class: com.ubt.jimu.user.view.fragment.FansFragment.3
|
|
@Override // com.ubt.jimu.widgets.LoadingView.RetryRequest
|
|
public void OnRetryListener() {
|
|
FansFragment.this.loadingView.c();
|
|
FansFragment.this.f.postDelayed(new Runnable() { // from class: com.ubt.jimu.user.view.fragment.FansFragment.3.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
FansFragment.this.a.subscribe();
|
|
}
|
|
}, 500L);
|
|
}
|
|
});
|
|
this.loadingView.setBackgroundViewColor(getResources().getColor(R.color.bg_F9F9F9));
|
|
}
|
|
|
|
private void o() {
|
|
if (b()) {
|
|
this.loadingView.a(R.string.tips_no_fans, R.drawable.icon_favourate_empty);
|
|
} else {
|
|
this.loadingView.a(R.string.others_no_fans, R.drawable.icon_favourate_empty);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.FansContract$View
|
|
public int e() {
|
|
return 1;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.FansContract$View
|
|
public int f() {
|
|
return 1000;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.FansContract$View
|
|
public void g(List<Fans> list) {
|
|
this.fansRecyclerView.A();
|
|
if (list == null || list.size() == 0) {
|
|
o();
|
|
return;
|
|
}
|
|
this.loadingView.setVisibility(8);
|
|
Log.i("FansFragment", list.toString());
|
|
this.b.clear();
|
|
this.b.addAll(list);
|
|
this.c.notifyDataSetChanged();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.FansContract$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.recycler_view, (ViewGroup) null);
|
|
this.e = ButterKnife.a(this, inflate);
|
|
initView();
|
|
return inflate;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroyView() {
|
|
this.e.unbind();
|
|
Handler handler = this.f;
|
|
if (handler != null) {
|
|
handler.removeCallbacksAndMessages(null);
|
|
}
|
|
super.onDestroyView();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.FansContract$View
|
|
public void onError() {
|
|
this.loadingView.setVisibility(0);
|
|
if (NetWorkUtil.b(this.mActivity)) {
|
|
this.loadingView.e();
|
|
} else {
|
|
this.loadingView.d();
|
|
}
|
|
this.fansRecyclerView.A();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onPause() {
|
|
super.onPause();
|
|
this.a.unSubscribe();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
super.onResume();
|
|
this.a.subscribe();
|
|
}
|
|
|
|
public static FansFragment a(long j) {
|
|
FansFragment fansFragment = new FansFragment();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putLong("view_user_id", j);
|
|
fansFragment.setArguments(bundle);
|
|
return fansFragment;
|
|
}
|
|
|
|
private boolean b() {
|
|
return d() == m();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.FansContract$View
|
|
public long d() {
|
|
return this.d;
|
|
}
|
|
|
|
@Override // com.ubtech.view.BaseView
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void setPresenter(FansContract$Presenter fansContract$Presenter) {
|
|
this.a = fansContract$Presenter;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.FansContract$View
|
|
public void a() {
|
|
this.loadingView.g();
|
|
}
|
|
}
|