package com.uiui.zyappstore.fragment;

import android.os.Bundle;

import android.view.View;


import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.uiui.zyappstore.R;
import com.uiui.zyappstore.adapter.AppAdapter;
import com.uiui.zyappstore.base.LazyLoadFragment;
import com.uiui.zyappstore.base.RefreshManager;
import com.uiui.zyappstore.utils.LogUtils;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;


/**
 * Created by asus on 2017/10/23.
 * 排行的页面
 */

public class RankFragment extends LazyLoadFragment implements RefreshManager.RefreshInterface {
    private RecyclerView mRvResult;
    private SmartRefreshLayout mRefreshLayout;
    private AppAdapter mAppAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.fragment_rank;
    }

    @Override
    public void initViews(View view) {
        mRvResult = view.findViewById(R.id.rank_rv_result);
        mRefreshLayout = view.findViewById(R.id.rank_refresh_layout);
        RefreshManager.getInstance().register(this);
        initView();
    }

    @Override
    public void initDatas() {

    }

    @Override
    public void loadData(Bundle savedInstanceState) {

    }

    @Override
    public void onStart() {
        super.onStart();
//        OKGO.getRankApp(handler);
        LogUtils.e("fht", "RankFragment onStart");
    }

    @Override
    public void onResume() {
        super.onResume();
        LogUtils.e("fht", "RankFragment onResume");

    }

    @Override
    public void onPause() {
        super.onPause();
        LogUtils.e("fht", "RankFragment onPause");

    }

    @Override
    public void onStop() {
        super.onStop();
        LogUtils.e("fht", "RankFragment onStop");

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        LogUtils.e("fht", "RankFragment onDestroy");

    }

    private void initView() {
        mAppAdapter = new AppAdapter(getActivity());
        mRvResult.setLayoutManager(new LinearLayoutManager(getActivity()));
        mRvResult.setAdapter(mAppAdapter);
        mRefreshLayout.setEnableRefresh(true);
        mRefreshLayout.setEnableLoadMore(false);
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
//                OKGO.getRankApp(handler);
            }
        });
    }


    @Override
    public void onRefresh() {
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onLoadBitMap(boolean isLoad) {

    }
}
