package com.uiui.zyappstore.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

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.BaseActivity;
import com.uiui.zyappstore.base.RefreshManager;
import com.uiui.zyappstore.utils.SPUtils;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;


public class KindDetailActivity extends BaseActivity implements RefreshManager.RefreshInterface {
    private TextView title;
    private String name;
    private int subject, type = 0;
    private String grade;
    private SmartRefreshLayout mRefreshLayout;
    private RecyclerView detail_rv;
    private AppAdapter adapter;
    private ImageView mImageView;

    @Override

    protected int setLayoutResourceID() {
        return R.layout.activity_kind_detail;
    }

    @Override
    protected void initView() {
        title = findViewById(R.id.detail_tv_title);
        detail_rv = findViewById(R.id.detail_rv);
        mRefreshLayout = findViewById(R.id.detail_refresh_layout);
        mImageView = findViewById(R.id.imageView);
    }

    @Override
    protected void initData() {
        subject = getIntent().getIntExtra("kind", 0);
        name = getIntent().getStringExtra("name");
        if (name.equals("娱乐")) {
            type = 1;
        }
        grade = (String) SPUtils.get(this, "sn_grade", "");
        title.setText(name);
        RefreshManager.getInstance().register(this);
        adapter = new AppAdapter(KindDetailActivity.this);
        adapter.setHasStableIds(true);
        detail_rv.setAdapter(adapter);
        detail_rv.setLayoutManager(new LinearLayoutManager(this));
        mRefreshLayout.setEnableLoadMore(false);
        mRefreshLayout.setEnableRefresh(true);
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
//                OKGO.getSortApp(handler, type, grade, subject);
            }
        });
//        OKGO.getSortApp(handler, type, grade, subject);
    }

    @Override
    protected void setListener() {

    }

    public void finish(View view) {
        finish();
    }


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

    @Override
    public void onLoadBitMap(boolean isLoad) {

    }
}
