package cn.edu.xjau.recyclerviewtest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private List<Cat> catList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initCats();
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);
        CatAdapter adapter = new CatAdapter(catList);
        recyclerView.setAdapter(adapter);
    }

    private void initCats() {
        Cat agl = new Cat("安格拉猫",R.drawable.agl);
        catList.add(agl);
        Cat blm = new Cat("巴厘猫",R.drawable.blm);
        catList.add(blm);
        Cat bmlm = new Cat("波米拉猫",R.drawable.bmlm);
        catList.add(bmlm);
        Cat bo = new Cat("布偶猫",R.drawable.bo);
        catList.add(bo);
        Cat bs = new Cat("波斯猫",R.drawable.bs);
        catList.add(bs);
        Cat dfm = new Cat("东方猫",R.drawable.dfm);
        catList.add(dfm);
        Cat dwm = new Cat("短尾猫",R.drawable.dwm);
        catList.add(dwm);
        Cat fm = new Cat("梵猫",R.drawable.fm);
        catList.add(fm);
        Cat lm = new Cat("蓝猫",R.drawable.lm);
        catList.add(lm);
        Cat my = new Cat("缅因猫1",R.drawable.my);
        catList.add(my);
        Cat slm = new Cat("森林猫",R.drawable.slm);
        catList.add(slm);
        Cat sml = new Cat("索马里猫",R.drawable.sml);
        catList.add(sml);
        Cat xjp = new Cat("新加坡猫",R.drawable.xjp);
        catList.add(xjp);
        Cat xl = new Cat("暹罗猫",R.drawable.xl);
        catList.add(xl);
        Cat zhe = new Cat("折耳猫",R.drawable.zhe);
        catList.add(zhe);
        Cat my1 = new Cat("缅因猫2",R.drawable.my1);
        catList.add(my1);
    }
}
