gt:         if (rescheduling) return;
context: package br.org.institutotim.parapesquisa.ui.activity;
  
  import android.annotation.SuppressLint;
  import android.app.DatePickerDialog;
  import android.app.TimePickerDialog;
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.annotation.IntDef;
  import android.support.v4.util.Pair;
  import android.support.v4.view.ViewPager;
  import android.support.v7.app.ActionBar;
  import android.support.v7.widget.Toolbar;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.Spinner;
  import android.widget.TextView;
  
  import com.afollestad.materialdialogs.MaterialDialog;
  
  import org.joda.time.DateTime;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.concurrent.TimeUnit;
  
  import javax.inject.Inject;
  
  import br.org.institutotim.parapesquisa.R;
  import br.org.institutotim.parapesquisa.data.db.ParaPesquisaOpenHelper;
  import br.org.institutotim.parapesquisa.data.db.ParaPesquisaPreferences;
  import br.org.institutotim.parapesquisa.data.event.RefreshFieldEvent;
  import br.org.institutotim.parapesquisa.data.model.Answer;
  import br.org.institutotim.parapesquisa.data.model.Field;
  import br.org.institutotim.parapesquisa.data.model.FormData;
  import br.org.institutotim.parapesquisa.data.model.Section;
  import br.org.institutotim.parapesquisa.data.model.StopReason;
  import br.org.institutotim.parapesquisa.data.model.SubmissionLogAction;
  import br.org.institutotim.parapesquisa.data.model.UserData;
  import br.org.institutotim.parapesquisa.data.model.UserSubmission;
  import br.org.institutotim.parapesquisa.ui.adapter.SectionPagerAdapter;
  import br.org.institutotim.parapesquisa.ui.helper.FormHelper;
  import br.org.institutotim.parapesquisa.ui.helper.RecyclerViewHelper;
  import br.org.institutotim.parapesquisa.ui.helper.SubmissionHelper;
  import br.org.institutotim.parapesquisa.util.DateUtils;
  import butterknife.Bind;
  import butterknife.ButterKnife;
  import butterknife.OnClick;
  import de.greenrobot.event.EventBus;
  import timber.log.Timber;
  
  public class AgentSubmissionCorrectionActivity extends BaseSubmissionViewActivity implements AdapterView.OnItemSelectedListener, ViewPager.OnPageChangeListener {
  
      public static final int CORRECTIONS_READ_ONLY = 0;
      public static final int CORRECTIONS = 1;
  
      @IntDef({CORRECTIONS_READ_ONLY, CORRECTIONS})
      public @interface Correction {
      }
  
      @Bind(R.id.toolbar)
      Toolbar toolbar;
      @Bind(R.id.mode)
      Spinner mode;
      @Bind(R.id.container)
      ViewPager mContainer;
      @Bind(R.id.section_indicator)
      TextView mSectionIndicator;
  
      @Bind(R.id.next)
      View mNext;
      @Bind(R.id.previous)
      View mPrevious;
      @Bind(R.id.navigation)
      View mNavigation;
  
      @Inject
      ParaPesquisaOpenHelper mHelper;
      @Inject
      FormHelper mFormHelper;
      @Inject
      SubmissionHelper mSubmissionHelper;
      @Inject
      ParaPesquisaPreferences mPreferences;
  
      private SectionPagerAdapter mAdapter;
  
      int menu = R.menu.form;
      @Correction
      public static int correctionType;
      public static UserData user;
  
      private boolean rescheduling = false;
      private DateTime date;
  
      private DateTime mTimestamp = DateTime.now();
      private Runnable runnable;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_agent_submission_correction);
          ButterKnife.bind(this);
          getComponent().inject(this);
  
          user = mPreferences.getUser();
  
          setSupportActionBar(toolbar);
          ActionBar actionBar = getSupportActionBar();
          if (actionBar != null) {
              actionBar.setDisplayShowTitleEnabled(false);
              actionBar.setDisplayHomeAsUpEnabled(true);
          }
  
          mSubmission = getIntent().getParcelableExtra(SUBMISSION_EXTRA);
          mForm = mHelper.getForm(mSubmission.getFormId());
  
          mAdapter = SectionPagerAdapter.builderSectionForCorrection(mForm, mSubmission);
          mContainer.addOnPageChangeListener(this);
          mPrevious.setVisibility(View.INVISIBLE);
          mode.setOnItemSelectedListener(this);
          mode.setSelection(1);
  
          handleReadOnlyStatus();
  
          List<Pair<Integer, Field>> fieldList = new ArrayList<>();
          List<String> fields = new ArrayList<>();
          for (int i = 0; i < mForm.getSections().size(); i++) {
              final Section section = mForm.getSections().get(i);
              List<Field> mFields = section.getFields();
              for (int y = 0; y < mFields.size(); y++) {
                  final Field field = mFields.get(y);
                  if (RecyclerViewHelper.hasCorrection(field, mSubmission) && !getReadOnlyStatus(field.getId())) {
                      fieldList.add(new Pair<>(i, field));
                      fields.add(field.getLabel());
                  }
              }
          }
  
          runOnUiThread(() -> {
              if (!fieldList.isEmpty()) {
                  String[] fieldsArray = new String[fields.size()];
                  fields.toArray(fieldsArray);
                  new MaterialDialog.Builder(this)
                          .title(R.string.title_fields_with_peding_correction)
                          .items(fieldsArray)
                          .itemsCallback((materialDialog, view, i, charSequence) -> {
                              final Pair<Integer, Field> integerFieldPair = fieldList.get(i);
                              runnable = () -> mAdapter.scrollToField(mContainer, integerFieldPair.second);
  
                              if (mContainer.getCurrentItem() == integerFieldPair.first) {
                                  runnable.run();
                                  runnable = null;
                              } else {
                                  mContainer.setCurrentItem(integerFieldPair.first);
                              }
                          })
                          .negativeText(R.string.button_cancel)
                          .show();
              }
          });
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(this.menu, menu);
          if (!mForm.hasExtraData()) {
              menu.getItem(0).setVisible(false);
          }
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
              case android.R.id.home:
                  finish();
                  return true;
              case R.id.action_stop:
                  showReasonPopup();
                  return true;
              case R.id.action_send:
                  submitForm();
                  return true;
              case R.id.action_info:
                  openExtraDataPopup();
                  return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      private void showReasonPopup() {
          runOnUiThread(() -> {
              new MaterialDialog.Builder(this)
                      .title(R.string.title_reason_to_stop)
                      .items(mFormHelper.getStopReasonsArray(mForm.getStopReasons()))
                      .itemsCallback((materialDialog, view, i, charSequence) -> cancelOrReschedule(mForm.getStopReasons().get(i)))
                      .negativeText(R.string.button_cancel)
                      .show();
          });
      }
  
      private void cancelOrReschedule(StopReason reason) {
          if (reason.isReschedule()) {
              rescheduleSurvey(reason);
          } else {
              cancelSurvey(reason);
          }
      }
  
      private void cancelSurvey(StopReason reason) {
          new MaterialDialog.Builder(this)
                  .title(R.string.title_cancel_submission)
                  .content(R.string.message_cancel_submission)
                  .positiveText(R.string.button_yes)
                  .negativeText(R.string.button_no)
                  .autoDismiss(true)
                  .onPositive((materialDialog, dialogAction) -> {
                      mHelper.addSubmissionForCancel(mForm.getId(), mSubmission.addLog(mTimestamp, SubmissionLogAction.CANCELLED, mPreferences.getUser().getId()), reason);
                      mHelper.removeSubmission(mForm.getId(), mSubmission.getId());
                      finish();
                  })
                  .show();
      }
  
      private void rescheduleSurvey(StopReason reason) {
  