导航菜单

页面标题

页面副标题

自健身 v3.3.4 - WeightHistoryActivity.java 源代码

正在查看: 自健身 v3.3.4 应用的 WeightHistoryActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mu.gymtrain.Activity.MainPackage;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mu.gymtrain.Adapter.WeightHistoryAdapter;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Bean.WeightBean;
import com.mu.gymtrain.Http.CreatMap;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.Http.ResponseFunc;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.ToastUtil;
import com.mu.gymtrain.Utils.ViewUtils;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import java.util.ArrayList;
import java.util.List;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class WeightHistoryActivity extends BaseActivity implements BaseQuickAdapter.OnItemClickListener {
    private WeightHistoryAdapter adapter;

    @BindView(2131297022)
    RecyclerView recyclerView;

    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;

    @BindView(R.id.title_middle)
    TextView titleMiddle;
    private int page = 0;
    private List<WeightBean> mList = new ArrayList();

    public int getContentLayout() {
        return R.layout.activity_weight_history_layout;
    }

    public void initView() {
        this.refreshLayout.setEnableLoadMore(false);
        this.refreshLayout.setEnableRefresh(false);
        this.titleMiddle.setText("历史记录");
        this.recyclerView.setLayoutManager(new LinearLayoutManager(this));
        WeightHistoryAdapter weightHistoryAdapter = new WeightHistoryAdapter();
        this.adapter = weightHistoryAdapter;
        this.recyclerView.setAdapter(weightHistoryAdapter);
        this.adapter.setOnItemClickListener(this);
    }

    public void initData() {
        ViewUtils.showLoading(this, "加载中...");
        HttpHelper.getInstance().getRetrofitService(this).getUserWeight(new CreatMap.Builder().addParams("pageindex", this.page + "").addParams("pagesize", "30").build().getParam()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).map(new ResponseFunc()).subscribe(new Subscriber<List<WeightBean>>() {
            public void onCompleted() {
            }

            public void onError(Throwable e) {
                ViewUtils.hideLoading();
                ToastUtil.showShort((Context) WeightHistoryActivity.this, (CharSequence) "获取历史数据失败!");
            }

            public void onNext(List<WeightBean> listWeightBean) {
                ViewUtils.hideLoading();
                WeightHistoryActivity.this.mList.clear();
                for (int size = listWeightBean.size(); size > 0; size--) {
                    WeightHistoryActivity.this.mList.add(0, listWeightBean.get(size - 1));
                }
                WeightHistoryActivity.this.adapter.setNewData(WeightHistoryActivity.this.mList);
            }
        });
    }

    @OnClick({R.id.title_left})
    public void onViewClicked() {
        finish();
    }

    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        startActivity(new Intent((Context) this, (Class<?>) WeightHistoryDetailActivity.class));
    }
}