Guest User

Untitled

a guest
Apr 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. package itomych.com.jti.ui.reports.details;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.databinding.ViewDataBinding;
  6. import android.os.Bundle;
  7. import android.support.v7.app.ActionBar;
  8. import android.view.Menu;
  9. import android.view.MenuInflater;
  10. import android.view.MenuItem;
  11.  
  12. import itomych.com.jti.R;
  13. import itomych.com.jti.data.model.Report;
  14. import itomych.com.jti.ui.base.BaseActivity;
  15. import itomych.com.jti.ui.base.BaseFragment;
  16. import itomych.com.jti.ui.reports.details.fragments.NoGpsWarningFragment;
  17. import itomych.com.jti.ui.reports.details.fragments.ReportStatDialogFragment;
  18. import itomych.com.jti.ui.tutorial.TutorialFragment;
  19. import itomych.com.jti.util.ActivityUtils;
  20. import itomych.com.jti.util.log.LogUtil;
  21.  
  22. /**
  23. * Created by alexischenko on 2/28/18.
  24. */
  25.  
  26. public class ReportDetailsActivity extends BaseActivity {
  27.  
  28. public static final int CALLED_ADD_MANUAL = 0;
  29. public static final int CALLED_SHOW_SCANNER = 1;
  30. public static final int CALLED_SHOW_SAVED_REPORT = 2;
  31.  
  32. private static final String KEY_CALL_TYPE = "key_call_type";
  33. private static final String KEY_REPORT = "key_report";
  34. private static final String TAG = ReportDetailsActivity.class.getSimpleName();
  35.  
  36. private int callerType;
  37. private Report currentReport;
  38.  
  39.  
  40. public static Intent getLaunchIntent(Context context, Report report, int cameFrom) {
  41. Intent intent = new Intent(context, ReportDetailsActivity.class);
  42. intent.putExtra(KEY_REPORT, report);
  43. intent.putExtra(KEY_CALL_TYPE, cameFrom);
  44. return intent;
  45. }
  46.  
  47. @Override
  48. protected void onCreate(Bundle savedInstanceState) {
  49. super.onCreate(savedInstanceState);
  50. currentReport = getIntent().getParcelableExtra(KEY_REPORT);
  51. callerType = getIntent().getIntExtra(KEY_CALL_TYPE, 0);
  52. }
  53.  
  54. @Override
  55. protected void onDestroy() {
  56. super.onDestroy();
  57. }
  58.  
  59. @Override
  60. protected int getContentView() {
  61. return R.layout.activity_base_layout;
  62. }
  63.  
  64. @Override
  65. protected void setupDataBinding(ViewDataBinding dataBinding) {
  66. }
  67.  
  68. @Override
  69. public void lunchPinCodeCheck() {
  70. super.lunchPinCodeCheck();
  71. LogUtil.d(TAG, "lunchPinCodeCheck");
  72.  
  73.  
  74. /** TODO alexischenko 4/9/18: check we can hide No Gps Warning
  75. * case when user went to app settings and then went back to app thriugh pin-code screen */
  76.  
  77. if (getFragmentManager().getBackStackEntryCount() >1) {
  78. if (getFragmentManager().getBackStackEntryAt(1) instanceof NoGpsWarningFragment) {
  79. getFragmentManager().popBackStack();
  80. }
  81. }
  82.  
  83. }
  84.  
  85. @Override
  86. protected BaseFragment onStartFragment() {
  87. ReportDetailsFragment fragment = ReportDetailsFragment.newInstance(currentReport, callerType);
  88. ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), fragment, CONTENT_ID);
  89. return fragment;
  90. }
  91.  
  92. @Override
  93. protected void initPresenter(BaseFragment fragment) {
  94. new ReportDetailsPresenterImpl((ReportDetailsContract.View) fragment, this, currentReport);
  95. }
  96.  
  97. protected void setupActionBar(ActionBar actionBar) {
  98. actionBar.setDisplayHomeAsUpEnabled(true);
  99. actionBar.setTitle(CALLED_SHOW_SAVED_REPORT != callerType
  100. ? getResources().getString(R.string.action_button_report)
  101. : getResources().getString(R.string.action_button_report) + " " + currentReport.getFormattedDate());
  102. }
  103.  
  104. @Override
  105. public boolean onCreateOptionsMenu(Menu menu) {
  106. MenuInflater inflater = getMenuInflater();
  107. inflater.inflate(R.menu.menu, menu);
  108. menu.findItem(R.id.action_report_stat).setVisible(currentReport.isSynced());
  109. return true;
  110. }
  111.  
  112. @Override
  113. public boolean onOptionsItemSelected(MenuItem item) {
  114. switch (item.getItemId()) {
  115. case R.id.action_info:
  116. TutorialFragment tutorialFragment = new TutorialFragment();
  117. tutorialFragment.show(getSupportFragmentManager(), "");
  118. return true;
  119. case R.id.action_report_stat:
  120. ReportStatDialogFragment dialogFragment = ReportStatDialogFragment.newInstance(currentReport);
  121. dialogFragment.show(getSupportFragmentManager(), "");
  122. return true;
  123. default:
  124. return super.onOptionsItemSelected(item);
  125. }
  126. }
  127.  
  128. @Override
  129. public void onBackPressed() {
  130. super.onBackPressed();
  131. }
  132.  
  133. }
Add Comment
Please, Sign In to add comment