正在查看: 自健身 v3.3.4 应用的 ArticleFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 ArticleFragment.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Fragment;
import android.content.Intent;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.hjq.http.EasyHttp;
import com.hjq.http.listener.OnHttpListener;
import com.hjq.http.request.GetRequest;
import com.mu.gymtrain.Activity.ArticleDetailActivity;
import com.mu.gymtrain.Adapter.ArticleAdapter;
import com.mu.gymtrain.Base.BaseFragment;
import com.mu.gymtrain.Bean.ArticleListBean;
import com.mu.gymtrain.Http.api.ArticleListAPI;
import com.mu.gymtrain.R;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import okhttp3.Call;
public class ArticleFragment extends BaseFragment implements BaseQuickAdapter.OnItemClickListener, OnRefreshLoadMoreListener {
private ArticleAdapter adapter;
private int page = 1;
private RecyclerView recyclerView;
private SmartRefreshLayout refreshLayout;
protected int getLayout() {
return R.layout.fragment_article_layout;
}
protected void lazyLoad() {
}
public void onClick(View v) {
}
protected void initView() {
this.recyclerView = getRootView().findViewById(2131297022);
this.refreshLayout = getRootView().findViewById(R.id.refreshLayout);
this.recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
ArticleAdapter articleAdapter = new ArticleAdapter();
this.adapter = articleAdapter;
this.recyclerView.setAdapter(articleAdapter);
this.adapter.setOnItemClickListener(this);
this.refreshLayout.setOnRefreshLoadMoreListener(this);
this.refreshLayout.setEnableRefresh(false);
}
protected void initData() {
((GetRequest) EasyHttp.get(this).api(new ArticleListAPI(this.page))).request(new OnHttpListener<ArticleListBean>() {
@Override
public void onEnd(Call call) {
OnHttpListener.CC.$default$onEnd(this, call);
}
@Override
public void onStart(Call call) {
OnHttpListener.CC.$default$onStart(this, call);
}
@Override
public void onSucceed(ArticleListBean articleListBean, boolean z) {
onSucceed((AnonymousClass1) articleListBean);
}
@Override
public void onSucceed(ArticleListBean result) {
if (ArticleFragment.this.page > 1) {
ArticleFragment.this.adapter.addData(result.getList());
} else {
ArticleFragment.this.adapter.setNewData(result.getList());
}
ArticleFragment.this.refreshLayout.finishRefresh();
ArticleFragment.this.refreshLayout.finishLoadMore();
}
@Override
public void onFail(Exception e) {
ArticleFragment.this.showToast(e.getMessage());
ArticleFragment.this.refreshLayout.finishRefresh();
ArticleFragment.this.refreshLayout.finishLoadMore();
}
});
}
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
ArticleListBean.ListBean listBean = (ArticleListBean.ListBean) adapter.getItem(position);
int id = listBean.getId();
Intent intent = new Intent(getContext(), (Class<?>) ArticleDetailActivity.class);
intent.putExtra("html", "http://36.112.61.98:8888" + listBean.getContentUrl());
intent.putExtra("id", id);
startActivity(intent);
}
public void onLoadMore(RefreshLayout refreshLayout) {
this.page++;
initData();
}
public void onRefresh(RefreshLayout refreshLayout) {
this.page = 1;
initData();
}
}