package agersant.polaris.activity.browse;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ProgressBar;

import com.android.volley.Response;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;

import agersant.polaris.CollectionItem;
import agersant.polaris.R;
import agersant.polaris.activity.PolarisActivity;
import agersant.polaris.api.ServerAPI;

public class BrowseActivity extends PolarisActivity {

    public static final String PATH = "PATH";
    private ExplorerAdapter adapter;
    private ProgressBar progressBar;

    public BrowseActivity() {
        super(R.string.collection, R.id.nav_collection);
    }

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

        progressBar = (ProgressBar) findViewById(R.id.progress_bar);

        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.browse_recycler_view);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(linearLayoutManager);

        adapter = new ExplorerAdapter();
        recyclerView.setAdapter(adapter);

        Intent intent = getIntent();
        String path = intent.getStringExtra(BrowseActivity.PATH);
        if (path == null) {
            path = "";
        }
        loadPath(path);
    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(0, 0);
    }

    private void loadPath(String path) {
        Response.Listener<JSONArray> success = new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                setContent(response);
            }
        };
        ServerAPI server = ServerAPI.getInstance(getApplicationContext());
        server.browse(path, success);
    }

    private void setContent(JSONArray content) {
        progressBar.setVisibility(View.GONE);

        ArrayList<CollectionItem> newItems = new ArrayList<>();
        for (int i = 0; i < content.length(); i++) {
            JSONObject item = null;
            try {
                item = content.getJSONObject(i);
            } catch (Exception e) {
            }
            assert item != null;
            CollectionItem browseItem = new CollectionItem(item);
            newItems.add(browseItem);
        }
        adapter.setItems(newItems);
    }
}

@@ -1037,24 +1037,66 @@
 ress_bar);%0A%0A
+        adapter = new ExplorerAdapter();%0A%0A
         Recy
@@ -1187,78 +1187,41 @@
     
-LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this
+recyclerView.setHasFixedSize(true
 );%0A 
@@ -1257,17 +1257,21 @@
 Manager(
-l
+new L
 inearLay
@@ -1284,50 +1284,14 @@
 ager
-);%0A%0A        adapter = new ExplorerAdapter(
+(this)
 );%0A 

Set fixed size in browse recycler view