96 lines
4.3 KiB
Java
96 lines
4.3 KiB
Java
package com.ubt.jimu.community.view.fragment;
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import com.recyclelib.URecyclerView;
|
|
import com.ubt.jimu.BaseActivity;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.entities.SearchContentBean;
|
|
import com.ubt.jimu.base.http.ApiObserver;
|
|
import com.ubt.jimu.base.http.manager.CommunityManager;
|
|
import com.ubt.jimu.community.view.SearchActivity;
|
|
import com.ubt.jimu.community.view.adapter.search.ContentAdapter;
|
|
import com.ubtech.view.fragment.BaseFragment;
|
|
import com.ubtrobot.log.ALog;
|
|
import java.util.ArrayList;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ContentFragment extends CommonFragment {
|
|
private ArrayList<SearchContentBean.RecordsBean> c;
|
|
private ContentAdapter d;
|
|
private ApiObserver<SearchContentBean> e;
|
|
private int f = 1;
|
|
|
|
static /* synthetic */ int b(ContentFragment contentFragment) {
|
|
int i = contentFragment.f;
|
|
contentFragment.f = i + 1;
|
|
return i;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void requestData() {
|
|
CommunityManager.create().userSearchResult(this.a, "post", Cache.getInstance().getUserId(), this.f, 12, this.e);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.community.view.fragment.CommonFragment
|
|
protected void initData() {
|
|
this.c = new ArrayList<>();
|
|
this.e = new ApiObserver<SearchContentBean>(((SearchActivity) this.mActivity).viewLoading) { // from class: com.ubt.jimu.community.view.fragment.ContentFragment.1
|
|
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(SearchContentBean searchContentBean) {
|
|
ALog.a(ContentFragment.this.TAG).d("searchModel==" + searchContentBean.getPages());
|
|
if (searchContentBean.getRecords() == null || searchContentBean.getRecords().size() <= 0) {
|
|
ContentFragment.this.ryContent.setNoMore(true);
|
|
} else {
|
|
if (ContentFragment.this.f == 1) {
|
|
ContentFragment.this.c.clear();
|
|
}
|
|
ContentFragment.this.c.addAll(searchContentBean.getRecords());
|
|
if (ContentFragment.this.f == searchContentBean.getTotal()) {
|
|
ContentFragment.this.ryContent.setNoMore(true);
|
|
} else {
|
|
ContentFragment.this.ryContent.setNoMore(false);
|
|
}
|
|
}
|
|
ContentFragment.this.d.notifyDataSetChanged();
|
|
ContentFragment contentFragment = ContentFragment.this;
|
|
contentFragment.d(contentFragment.c.size());
|
|
}
|
|
};
|
|
this.d = new ContentAdapter(this.mActivity, this.c);
|
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.mActivity, 1, false);
|
|
this.ryContent.setAdapter(this.d);
|
|
this.ryContent.setLayoutManager(linearLayoutManager);
|
|
this.ryContent.setLoadingListener(new URecyclerView.LoadingListener() { // from class: com.ubt.jimu.community.view.fragment.ContentFragment.2
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onLoadingMore() {
|
|
ContentFragment.b(ContentFragment.this);
|
|
ContentFragment.this.requestData();
|
|
((SearchActivity) ((BaseFragment) ContentFragment.this).mActivity).viewLoading.setVisibility(8);
|
|
}
|
|
|
|
@Override // com.recyclelib.URecyclerView.LoadingListener
|
|
public void onRefreshing() {
|
|
ContentFragment.this.f = 1;
|
|
ContentFragment.this.requestData();
|
|
((SearchActivity) ((BaseFragment) ContentFragment.this).mActivity).viewLoading.setVisibility(8);
|
|
}
|
|
});
|
|
((BaseActivity) getActivity()).loadComplete(this.ryContent, this.e);
|
|
}
|
|
|
|
public static ContentFragment b() {
|
|
ContentFragment contentFragment = new ContentFragment();
|
|
ALog.a("ContentFragment").d(contentFragment.toString());
|
|
return contentFragment;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.community.view.fragment.CommonFragment
|
|
public void c(String str) {
|
|
this.a = str;
|
|
this.f = 1;
|
|
this.d.a(this.a);
|
|
requestData();
|
|
}
|
|
}
|