Search in sources :

Example 1 with HomeAdapter

use of flying.grub.tamtime.adapter.HomeAdapter in project TamTime by flyingrub.

the class HomeFragment method setupFavStopLine.

public void setupFavStopLine() {
    homeAdapter = new HomeAdapter(favoriteStopLine.getFavStopLines(), getActivity(), favHomeView, searchView);
    homeAdapter.SetOnItemClickListener(new HomeAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View view, final int position) {
            PopupMenu popup = new PopupMenu(getActivity(), view);
            // Inflating the Popup using xml file
            popup.getMenuInflater().inflate(R.menu.remove_from_home, popup.getMenu());
            // registering popup with OnMenuItemClickListener
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    favoriteStopLine.removeLineStop(position - 1);
                    setupFavStopLine();
                    return true;
                }
            });
            popup.show();
        }
    });
    favStopLinesRecycler.swapAdapter(homeAdapter, false);
}
Also used : HomeAdapter(flying.grub.tamtime.adapter.HomeAdapter) MenuItem(android.view.MenuItem) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SearchView(flying.grub.tamtime.layout.SearchView) FavHomeView(flying.grub.tamtime.layout.FavHomeView) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

PopupMenu (android.support.v7.widget.PopupMenu)1 RecyclerView (android.support.v7.widget.RecyclerView)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 HomeAdapter (flying.grub.tamtime.adapter.HomeAdapter)1 FavHomeView (flying.grub.tamtime.layout.FavHomeView)1 SearchView (flying.grub.tamtime.layout.SearchView)1