You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StopPickerActivity.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.rthoni.stssaguenay.ui.activities;
  2. import android.os.Bundle;
  3. import android.support.v7.app.AppCompatActivity;
  4. import com.luticate.utils.business.LuPromise;
  5. import com.rthoni.stssaguenay.R;
  6. import com.rthoni.stssaguenay.dbo.StopsDbo;
  7. import com.rthoni.stssaguenay.ui.fragments.StopPickerFragment;
  8. import com.rthoni.stssaguenay.ui.fragments.StopRoutesPickerFragment;
  9. public class StopPickerActivity extends AppCompatActivity {
  10. private StopPickerFragment _stopPickerFragment;
  11. @Override
  12. protected void onCreate(Bundle savedInstanceState) {
  13. super.onCreate(savedInstanceState);
  14. setContentView(R.layout.activity_stop_picker);
  15. if (getSupportActionBar() != null) {
  16. getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  17. }
  18. goToStops();
  19. }
  20. @Override
  21. public boolean onSupportNavigateUp() {
  22. if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
  23. return super.onSupportNavigateUp();
  24. }
  25. getSupportFragmentManager().popBackStack();
  26. return true;
  27. }
  28. public void goToStops()
  29. {
  30. StopPickerFragment f = new StopPickerFragment();
  31. f.setOnStopSelectedConsumer(new LuPromise.LuConsumer<StopsDbo>() {
  32. @Override
  33. public void execute(StopsDbo data) {
  34. goToRoutes(data);
  35. }
  36. });
  37. getSupportFragmentManager()
  38. .beginTransaction()
  39. .replace(R.id.container, f)
  40. .commit();
  41. }
  42. public void goToRoutes(StopsDbo stopDbo)
  43. {
  44. StopRoutesPickerFragment f = new StopRoutesPickerFragment();
  45. f.setStopsDbo(stopDbo);
  46. getSupportFragmentManager()
  47. .beginTransaction()
  48. .replace(R.id.container, f)
  49. .addToBackStack("StopRoutesPickerFragment")
  50. .commit();
  51. }
  52. }