use of flying.grub.tamtime.layout.FavHomeView 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;
}
use of flying.grub.tamtime.layout.FavHomeView 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);
}
Aggregations