Search in sources :

Example 1 with SearchView

use of flying.grub.tamtime.layout.SearchView in project TamTime by flyingrub.

the class HomeFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.view_recycler, container, false);
    setHasOptionsMenu(true);
    getActivity().setTitle(getString(R.string.home));
    favoriteStopLine = new FavoriteStopLine(getContext());
    favHomeView = new FavHomeView(getActivity());
    favHomeView.setUpdateStopLine(new FavHomeView.AddStopLine() {

        @Override
        public void update(StopZone stop, Line line) {
            favoriteStopLine.addLineStop(line, stop);
            setupFavStopLine();
        }
    });
    searchView = new SearchView(getActivity());
    favStopLinesRecycler = (RecyclerView) view.findViewById(R.id.recycler_view);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    favStopLinesRecycler.setLayoutManager(layoutManager);
    favStopLinesRecycler.setItemAnimator(new DefaultItemAnimator());
    favStopLinesRecycler.setHasFixedSize(false);
    favStopLinesRecycler.setBackgroundColor(getResources().getColor(R.color.windowBackgroundCard));
    setupFavStopLine();
    return view;
}
Also used : FavoriteStopLine(flying.grub.tamtime.data.persistence.FavoriteStopLine) Line(flying.grub.tamtime.data.map.Line) SearchView(flying.grub.tamtime.layout.SearchView) FavHomeView(flying.grub.tamtime.layout.FavHomeView) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SearchView(flying.grub.tamtime.layout.SearchView) FavHomeView(flying.grub.tamtime.layout.FavHomeView) StopZone(flying.grub.tamtime.data.map.StopZone) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) FavoriteStopLine(flying.grub.tamtime.data.persistence.FavoriteStopLine)

Example 2 with SearchView

use of flying.grub.tamtime.layout.SearchView 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

RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 FavHomeView (flying.grub.tamtime.layout.FavHomeView)2 SearchView (flying.grub.tamtime.layout.SearchView)2 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 PopupMenu (android.support.v7.widget.PopupMenu)1 MenuItem (android.view.MenuItem)1 HomeAdapter (flying.grub.tamtime.adapter.HomeAdapter)1 Line (flying.grub.tamtime.data.map.Line)1 StopZone (flying.grub.tamtime.data.map.StopZone)1 FavoriteStopLine (flying.grub.tamtime.data.persistence.FavoriteStopLine)1