Search in sources :

Example 1 with FiltersAdapter

use of com.pankaj.maukascholars.adapters.FiltersAdapter in project Precisely by Pankaj-Baranwal.

the class Filters method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Constants.toolbar_title = "Filters";
    setContentView(R.layout.activity_filters);
    if (sp.contains(key)) {
        try {
            JSONArray jO = new JSONArray(sp.getString(key, ""));
            Constants.clickedFilters.clear();
            for (int i = 0; i < jO.length(); i++) Constants.clickedFilters.add(jO.getInt(i));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    setupFilters();
    proceed = findViewById(R.id.proceed);
    proceed.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (clickedFilters.size() > 0) {
                loadActivity(VerticalViewPagerActivity.class);
            } else
                Toast.makeText(Filters.this, "Please select at least one filter!", Toast.LENGTH_SHORT).show();
        }
    });
    RecyclerView recyclerView = findViewById(R.id.recyclerview);
    FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(this);
    layoutManager.setFlexWrap(FlexWrap.WRAP);
    layoutManager.setFlexDirection(FlexDirection.ROW);
    layoutManager.setAlignItems(AlignItems.STRETCH);
    recyclerView.setLayoutManager(layoutManager);
    RecyclerView.Adapter adapter = new FiltersAdapter(this, filters, filters_image_urls);
    recyclerView.setAdapter(adapter);
}
Also used : FiltersAdapter(com.pankaj.maukascholars.adapters.FiltersAdapter) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 FlexboxLayoutManager (com.google.android.flexbox.FlexboxLayoutManager)1 FiltersAdapter (com.pankaj.maukascholars.adapters.FiltersAdapter)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1