133 lines
5.3 KiB
Java
133 lines
5.3 KiB
Java
package com.ubt.jimu.community.view.fragment;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import androidx.recyclerview.widget.GridLayoutManager;
|
|
import com.recyclelib.URecyclerView;
|
|
import com.ubt.jimu.BaseActivity;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.entities.MyPostListEntities;
|
|
import com.ubt.jimu.base.http.ApiObserver;
|
|
import com.ubt.jimu.base.http.manager.CommunityManager;
|
|
import com.ubt.jimu.community.view.adapter.IssueNewsAdapter;
|
|
import com.ubt.jimu.course.view.GridItemDecoration;
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
import io.reactivex.disposables.Disposable;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class IssueFragment extends IssueCommonFragment {
|
|
private List<MyPostListEntities.RecordsBean> b;
|
|
private IssueNewsAdapter c;
|
|
private ApiObserver<MyPostListEntities> d;
|
|
private CompositeDisposable e = new CompositeDisposable();
|
|
private int f = 1;
|
|
private String g;
|
|
|
|
static /* synthetic */ int c(IssueFragment issueFragment) {
|
|
int i = issueFragment.f;
|
|
issueFragment.f = i + 1;
|
|
return i;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void requestData() {
|
|
CommunityManager.create().myReportList(this.g, this.f, 12, this.d);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.community.view.fragment.IssueCommonFragment
|
|
public void initData() {
|
|
this.g = getArguments().getString("userId");
|
|
this.b = new ArrayList();
|
|
this.c = new IssueNewsAdapter(this.mActivity, this.b, 2, this.g);
|
|
this.rvIssue.setLayoutManager(new GridLayoutManager((Context) this.mActivity, 4, 1, false));
|
|
int dimensionPixelOffset = getResources().getDimensionPixelOffset(R.dimen.user_center_collection_item_margin);
|
|
this.rvIssue.a(new GridItemDecoration(getResources().getDimensionPixelOffset(R.dimen.user_center_collection_item_margin_top), dimensionPixelOffset, 1));
|
|
this.rvIssue.setAdapter(this.c);
|
|
this.rvIssue.setLoadingMoreEnabled(true);
|
|
b();
|
|
requestData();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.community.view.fragment.IssueCommonFragment, androidx.fragment.app.Fragment
|
|
public void onDestroyView() {
|
|
this.e.dispose();
|
|
this.e.a();
|
|
if (this.d != null) {
|
|
this.d = null;
|
|
}
|
|
super.onDestroyView();
|
|
}
|
|
|
|
private void b() {
|
|
this.d = new ApiObserver<MyPostListEntities>(this.lvLoading) { // from class: com.ubt.jimu.community.view.fragment.IssueFragment.1
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(MyPostListEntities myPostListEntities) {
|
|
if (myPostListEntities.getRecords() != null && myPostListEntities.getRecords().size() != 0) {
|
|
IssueFragment.this.a(myPostListEntities);
|
|
return;
|
|
}
|
|
IssueFragment.this.lvLoading.setServiceLoadingError(R.drawable.ic_try_reload);
|
|
IssueFragment.this.lvLoading.setServiceTextError(R.string.loading_service_error);
|
|
IssueFragment.this.lvLoading.f();
|
|
if (IssueFragment.this.b.size() == myPostListEntities.getTotal()) {
|
|
IssueFragment.this.rvIssue.setNoMore(true);
|
|
} else {
|
|
IssueFragment.this.rvIssue.setNoMore(false);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
IssueFragment.this.e.b(disposable);
|
|
}
|
|
};
|
|
this.rvIssue.setLoadingListener(new URecyclerView.LoadingListener() { // from class: com.ubt.jimu.community.view.fragment.IssueFragment.2
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onLoadingMore() {
|
|
IssueFragment.c(IssueFragment.this);
|
|
IssueFragment.this.requestData();
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onRefreshing() {
|
|
IssueFragment.this.f = 1;
|
|
IssueFragment.this.lvLoading.setIsRefresh(true);
|
|
IssueFragment.this.rvIssue.setNoMore(false);
|
|
IssueFragment.this.requestData();
|
|
}
|
|
});
|
|
((BaseActivity) getActivity()).loadComplete(this.rvIssue, this.d);
|
|
}
|
|
|
|
public static IssueFragment c(String str) {
|
|
IssueFragment issueFragment = new IssueFragment();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("userId", str);
|
|
issueFragment.setArguments(bundle);
|
|
return issueFragment;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(MyPostListEntities myPostListEntities) {
|
|
if (myPostListEntities != null) {
|
|
if (this.f == 1) {
|
|
this.b.clear();
|
|
}
|
|
this.b.addAll(myPostListEntities.getRecords());
|
|
if (this.b.size() == myPostListEntities.getTotal()) {
|
|
this.rvIssue.setNoMore(true);
|
|
}
|
|
}
|
|
this.c.notifyDataSetChanged();
|
|
}
|
|
}
|