use of flying.grub.tamtime.data.persistence.FavoriteStops in project TamTime by flyingrub.
the class OneStopActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_slidingtabs);
Bundle bundle = getIntent().getExtras();
stop_zone_id = bundle.getInt("stop_zone_id");
stop = Data.getData().getMap().getStopZoneById(stop_zone_id);
toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setTitle(stop.getName());
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setAdapter(new OneStopPageAdapter(getSupportFragmentManager()));
favoriteStops = new FavoriteStops(getApplicationContext());
favoriteStopLine = new FavoriteStopLine(getApplicationContext());
slidingTabLayout = new SlidingTabLayout(getApplicationContext());
slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.textClearColor));
slidingTabLayout.setDividerColors(getResources().getColor(R.color.primaryColor));
slidingTabLayout.setViewPager(viewPager);
}
use of flying.grub.tamtime.data.persistence.FavoriteStops in project TamTime by flyingrub.
the class FavoriteStopsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.view_recycler_load, container, false);
setHasOptionsMenu(true);
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.progress);
linearLayout.setVisibility(View.GONE);
TextView textView = (TextView) view.findViewById(R.id.empty_view);
textView.setText(getString(R.string.no_favorite_stop));
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
recyclerView.setHasFixedSize(false);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setBackgroundColor(getResources().getColor(R.color.windowBackgroundCard));
favoriteStops = new FavoriteStops(getActivity());
getActivity().setTitle(getString(R.string.all_stops_favs));
if (favoriteStops.getFavoriteStop().size() == 0) {
textView.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
return view;
}
adapter = new FavoriteAdapter(favoriteStops.getFavoriteStop());
recyclerView.setAdapter(adapter);
adapter.SetOnItemClickListener(new FavoriteAdapter.OnItemClickListener() {
@Override
public void onItemClick(View v, int position) {
selectitem(position);
}
});
adapter.SetOnMenuClickListener(new FavoriteAdapter.OnMenuClickListener() {
@Override
public void onItemClick(View v, final int position) {
// Creating the instance of PopupMenu
PopupMenu popup = new PopupMenu(getActivity(), v);
// Inflating the Popup using xml file
popup.getMenuInflater().inflate(R.menu.delete_menu, popup.getMenu());
// registering popup with OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
favoriteStops.remove(position);
recyclerView.swapAdapter(new FavoriteAdapter(favoriteStops.getFavoriteStop()), false);
return true;
}
});
// showing popup menu
popup.show();
}
});
return view;
}
Aggregations