package com.devbox.ui.Activity;

import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.avos.avoscloud.AVAnalytics;
import com.devbox.R;
import com.devbox.model.CodeLib;
import com.devbox.model.LocalAVObject;
import com.devbox.ui.Adapter.LibListAdapter;

import org.kymjs.kjframe.KJDB;

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


public class CollectionActivity extends BaseActivity {

    private RecyclerView recyclerView;
    private LibListAdapter adapter;
    private ArrayList<CodeLib> codeLibs;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collection);

        this.setToolbarTitle("收藏");
        this.setToolbarDisplayHomeAsUpEnabledAndClickListenner(true, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CollectionActivity.this.finish();
            }
        });


        KJDB kjdb = KJDB.create(this);
        List<LocalAVObject> list = kjdb.findAll(LocalAVObject.class);
        codeLibs = new ArrayList<>();
        for (LocalAVObject la : list) {
            try {
                codeLibs.add((CodeLib) CodeLib.parseAVObject(la.getObjectStr()));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));

        adapter = new LibListAdapter(this, codeLibs);
        recyclerView.setAdapter(adapter);

    }

    @Override
    protected void onResume() {
        super.onResume();
        AVAnalytics.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        AVAnalytics.onPause(this);
    }
}

@@ -494,16 +494,74 @@
 .List;%0A%0A
+import butterknife.Bind;%0Aimport butterknife.ButterKnife;%0A%0A
 %0Apublic 
@@ -613,23 +613,43 @@
  %7B%0A%0A    
-private
+@Bind(R.id.recyclyView)%0A   
  Recycle
@@ -668,16 +668,17 @@
 erView;%0A
+%0A
     priv
@@ -915,16 +915,48 @@
 ection);
+%0A        ButterKnife.bind(this);
 %0A%0A      
@@ -1224,17 +1224,16 @@
    %7D);%0A%0A
-%0A
         
@@ -1750,17 +1750,16 @@
 s, 2));%0A
-%0A
         
@@ -1846,17 +1846,16 @@
 apter);%0A
-%0A
     %7D%0A%0A 

use butterKnife