UpNavigatibleFragment.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package de.tudarmstadt.informatik.hostage.ui2.fragment;
  2. import android.app.Fragment;
  3. /**
  4. * This abstract fragments allows the definition of an child - parent relation of fragments. It is necessary for the app to allow Up navigation of fragments.
  5. *
  6. * @author Alexander Brakowski
  7. * @created 12.03.14 16:20
  8. */
  9. public abstract class UpNavigatibleFragment extends TrackerFragment {
  10. /**
  11. * Holds a reference to the parent fragment
  12. */
  13. private Class<?> mUpFragment;
  14. /**
  15. * Indicates whether the fragment is up navigatible
  16. */
  17. private boolean mIsUpNavigatible = false;
  18. private boolean mAllowBack = false;
  19. /**
  20. * Retrieves the parent fragment to be used for up navigation
  21. * @return the parent fragment
  22. */
  23. public Class<?> getUpFragment(){
  24. return mUpFragment;
  25. }
  26. /**
  27. * Sets the parent fragment of this fragment.
  28. * @param upFragment the fragment to set as parent
  29. */
  30. public void setUpFragment(Class<?> upFragment){
  31. this.mUpFragment = upFragment;
  32. }
  33. /**
  34. * Checks whether this fragment can be navigated up
  35. *
  36. * @return true if this fragment can be up navigated,
  37. * false otherwise
  38. */
  39. public boolean isUpNavigatible(){
  40. return mIsUpNavigatible;
  41. }
  42. /**
  43. * Sets the state of up navigation for this fragment
  44. * @param isUpNavigatible true to allow up navigation
  45. * false no up navigation
  46. */
  47. public void setUpNavigatible(boolean isUpNavigatible){
  48. this.mIsUpNavigatible = isUpNavigatible;
  49. }
  50. public boolean getAllowBack(){
  51. return mAllowBack;
  52. }
  53. public void setAllowBack(boolean allowBack){
  54. this.mAllowBack = allowBack;
  55. }
  56. }