Search in sources :

Example 1 with FormRecyclerAdapter

use of com.cpjd.roblu.ui.forms.FormRecyclerAdapter in project Roblu by wdavies973.

the class MetricSortFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.metric_tab, container, false);
    /*
         * Receive parameters
         */
    Bundle bundle = this.getArguments();
    metrics = (ArrayList<RMetric>) bundle.getSerializable("metrics");
    processMethod = bundle.getInt("processMethod");
    eventID = bundle.getInt("eventID");
    /*
         * Attach metrics to the RecyclerView
         */
    rv = view.findViewById(R.id.metric_recycler);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(view.getContext());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(linearLayoutManager);
    ((SimpleItemAnimator) rv.getItemAnimator()).setSupportsChangeAnimations(false);
    FormRecyclerAdapter adapter = new FormRecyclerAdapter(view.getContext(), this);
    rv.setAdapter(adapter);
    // setup gesture listener
    ItemTouchHelper.Callback callback = new FormRecyclerTouchHelper(adapter, true);
    ItemTouchHelper helper = new ItemTouchHelper(callback);
    helper.attachToRecyclerView(rv);
    adapter.setMetrics(metrics);
    return view;
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) Bundle(android.os.Bundle) FormRecyclerAdapter(com.cpjd.roblu.ui.forms.FormRecyclerAdapter) FormRecyclerTouchHelper(com.cpjd.roblu.ui.forms.FormRecyclerTouchHelper) RMetric(com.cpjd.roblu.models.metrics.RMetric) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Aggregations

Bundle (android.os.Bundle)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 View (android.view.View)1 TextView (android.widget.TextView)1 RMetric (com.cpjd.roblu.models.metrics.RMetric)1 FormRecyclerAdapter (com.cpjd.roblu.ui.forms.FormRecyclerAdapter)1 FormRecyclerTouchHelper (com.cpjd.roblu.ui.forms.FormRecyclerTouchHelper)1