Пример #1
0
 private void showOkAlertDialog() {
   this.alertDialogActiveType = MONTH_ALERT_DIALOG;
   AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(AppData.getCurrentActivity());
   alertDialogBuilder.setTitle(
       AppData.getCurrentActivity().getString(R.string.msgInputBatchProccessFinished));
   alertDialogBuilder.setMessage(
       AppData.getCurrentActivity().getString(R.string.msgSeeInputHours));
   alertDialogBuilder.setPositiveButton(
       AppData.getCurrentActivity().getString(R.string.msgYES),
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           BatchMenuActivity.this.alertDialogActiveType = NO_DIALOG;
           launchMonthActivity();
         }
       });
   alertDialogBuilder.setNegativeButton(
       AppData.getCurrentActivity().getString(R.string.msgNO),
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           BatchMenuActivity.this.alertDialogActiveType = NO_DIALOG;
           finish();
         }
       });
   alertDialog = alertDialogBuilder.show();
 }
Пример #2
0
    @Override
    protected void onPostExecute(Integer result) {
      Log.d(BatchAsyncTask.class.toString(), "onPostExecute...");

      this.closeDialog();
      if (result == 1) {
        BatchMenuActivity activity = (BatchMenuActivity) AppData.getCurrentActivity();
        activity.showOkAlertDialog();
      } else {
        showToastMessage(AppData.getCurrentActivity().getString(R.string.msgInputBatchError));
      }
    }
Пример #3
0
    @Override
    protected Integer doInBackground(BatchDataBean... batchData) {
      Log.d(BatchAsyncTask.class.toString(), "doInBackground...");
      WebConnection webConnection = ConnectionFacade.getWebConnection();
      this.batchData = batchData[0];

      Integer result = 0;
      try {
        List<DayRecord> listDays =
            webConnection.getListDaysAndActivitiesForMonthAndYear(
                this.batchData.getNumMonth(), this.batchData.getYear(), false);
        listDays = DayUtils.fillListDaysWithOnlyActivityDay(listDays, this.batchData);

        totalDays = listDays.size();
        BatchMenuActivity activity = (BatchMenuActivity) AppData.getCurrentActivity();
        activity.pDialog.setMax(totalDays);

        int processed = 0;
        for (DayRecord day : listDays) {
          webConnection.saveDayBatch(day, true);
          processed++;
          publishProgress(processed);
        }
        result = 1;
      } catch (ConnectionException e) {
        Log.e(LOGTAG, "Error en el proceso de imputación de mes", e);
        result = -1;
      }
      return result;
    }
Пример #4
0
    @Override
    protected void onProgressUpdate(Integer... values) {
      Log.d(BatchAsyncTask.class.toString(), "onProgressUpdate...");
      super.onProgressUpdate(values);

      BatchMenuActivity activity = (BatchMenuActivity) AppData.getCurrentActivity();
      if (activity.pDialog.getMax() == DEFAULT_MAX_PROGRESS_DIALOG) {
        activity.pDialog.setMax(totalDays);
      }
      activity.pDialog.setProgress(values[0]);
    }
Пример #5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(LOGTAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.batch_menu);
    AppData.setCurrentActivity(this);

    restoreFromChangeOrientation(savedInstanceState);

    List<String> listMonths = ConnectionFacade.getWebConnection().getMonths();
    List<String> listYears = ConnectionFacade.getWebConnection().getYears();
    List<String> listProjects = ConnectionFacade.getWebConnection().getArrayProjects();

    linkMonthSpinner(listMonths);
    linkYearsSpinner(listYears);
    linkProjectSpinner(listProjects);
    linkSubProjectSpinner((String) this.projectSpinner.getSelectedItem());
    linkTypeHourSpinner();
    taskEditText = (EditText) findViewById(R.id.batchTaskEditText);

    markTodayMonthYearSelected();
  }
Пример #6
0
 private void showToastMessage(String message) {
   Toast toast = Toast.makeText(AppData.getCurrentActivity(), message, Toast.LENGTH_LONG);
   toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 20);
   toast.show();
 }
Пример #7
0
 private void closeDialog() {
   BatchMenuActivity activity = (BatchMenuActivity) AppData.getCurrentActivity();
   activity.closeDialog();
 }
Пример #8
0
 @Override
 protected void onRestart() {
   super.onRestart();
   AppData.setCurrentActivity(this);
 }