예제 #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
 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();
 }
예제 #6
0
 private void closeDialog() {
   BatchMenuActivity activity = (BatchMenuActivity) AppData.getCurrentActivity();
   activity.closeDialog();
 }