Search in sources :

Example 1 with UserProductItemAdapter

use of com.example.asus.onlinecanteen.adapter.UserProductItemAdapter in project OnlineCanteen by josephgunawan97.

the class UserProductListFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (currentStore != null)
        getActivity().setTitle(currentStore.getStoreName());
    // Order Floating Action Button
    orderButton = view.findViewById(R.id.order_floating_action_button);
    orderButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), UserOrderProductActivity.class);
            intent.putExtra(UserOrderProductActivity.CURRENT_STORE_KEY, currentStore);
            intent.putExtra(UserOrderProductActivity.PRODUCT_LIST_KEY, userProductItemAdapter.getProducts());
            startActivity(intent);
        }
    });
    // Set up recycler view
    productRecyclerView = view.findViewById(R.id.product_recycler_view);
    layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    productRecyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
    productRecyclerView.addItemDecoration(divider);
    userProductItemAdapter = new UserProductItemAdapter();
    productRecyclerView.setAdapter(userProductItemAdapter);
}
Also used : UserProductItemAdapter(com.example.asus.onlinecanteen.adapter.UserProductItemAdapter) Intent(android.content.Intent) UserOrderProductActivity(com.example.asus.onlinecanteen.activity.UserOrderProductActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

Intent (android.content.Intent)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 UserOrderProductActivity (com.example.asus.onlinecanteen.activity.UserOrderProductActivity)1 UserProductItemAdapter (com.example.asus.onlinecanteen.adapter.UserProductItemAdapter)1