public void updateView(int downLoadedBytes, int totalBytes, int status) {
    if (DownloadUtils.isDownloading(status)) {
      downloadProgress.setVisibility(View.VISIBLE);
      downloadProgress.setMax(0);
      downloadProgress.setProgress(0);
      downloadSize.setVisibility(View.VISIBLE);
      downloadPercent.setVisibility(View.VISIBLE);
      downloadCancel.setVisibility(View.VISIBLE);

      if (totalBytes < 0) {
        downloadProgress.setIndeterminate(true);
        downloadPercent.setText("0%");
        downloadSize.setText("0M/0M");
      } else {
        downloadProgress.setIndeterminate(false);
        downloadProgress.setMax(totalBytes);
        downloadProgress.setProgress(downLoadedBytes);
        downloadPercent.setText(DownloadUtils.getNotiPercent(downLoadedBytes, totalBytes));
        downloadSize.setText(
            DownloadUtils.getAppSize(downLoadedBytes) + "/" + DownloadUtils.getAppSize(totalBytes));
      }
    } else {
      downloadProgress.setMax(0);
      downloadProgress.setProgress(0);
      processView.setVisibility(View.GONE);

      if (status == DownloadManager.STATUS_FAILED) {
      } else if (status == DownloadManager.STATUS_SUCCESSFUL) {
      } else {
      }
    }
  }
 private ProgressBar initProgressbar(View view, int id) {
   ProgressBar ret = (ProgressBar) view.findViewById(id);
   ret.setProgress(0);
   ret.setMax(100);
   ret.setProgress(50);
   return ret;
 }
  public void updateProgress(boolean updateOnlyProgress) {
    BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask =
        downloadListIndexThread.getCurrentRunningTask();
    if (updateOnlyProgress) {
      if (!basicProgressAsyncTask.isIndeterminate()) {
        progressPercent.setText(basicProgressAsyncTask.getProgressPercentage() + "%");
        determinateProgressBar.setProgress(basicProgressAsyncTask.getProgressPercentage());
      }
    } else {
      boolean visible =
          basicProgressAsyncTask != null && basicProgressAsyncTask.getStatus() != Status.FINISHED;
      progressView.setVisibility(visible ? View.VISIBLE : View.GONE);
      if (visible) {
        boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
        indeterminateProgressBar.setVisibility(!indeterminate ? View.GONE : View.VISIBLE);
        determinateProgressBar.setVisibility(indeterminate ? View.GONE : View.VISIBLE);
        cancel.setVisibility(indeterminate ? View.GONE : View.VISIBLE);
        progressPercent.setVisibility(indeterminate ? View.GONE : View.VISIBLE);

        progressMessage.setText(basicProgressAsyncTask.getDescription());
        if (!indeterminate) {
          progressPercent.setText(basicProgressAsyncTask.getProgressPercentage() + "%");
          determinateProgressBar.setProgress(basicProgressAsyncTask.getProgressPercentage());
        }
      }
      updateDownloadButton(false);
    }
  }
Example #4
0
  @Override
  public void updateProgress(boolean updateOnlyProgress) {
    BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask =
        DownloadActivity.downloadListIndexThread.getCurrentRunningTask();
    // needed when rotation is performed and progress can be null
    if (progressView == null) {
      return;
    }
    if (updateOnlyProgress) {
      if (!basicProgressAsyncTask.isIndeterminate()) {
        progressPercent.setText(basicProgressAsyncTask.getProgressPercentage() + "%");
        determinateProgressBar.setProgress(basicProgressAsyncTask.getProgressPercentage());
      }
    } else {
      boolean visible =
          basicProgressAsyncTask != null
              && basicProgressAsyncTask.getStatus() != AsyncTask.Status.FINISHED;
      progressView.setVisibility(visible ? View.VISIBLE : View.GONE);
      if (visible) {
        boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
        indeterminateProgressBar.setVisibility(!indeterminate ? View.GONE : View.VISIBLE);
        determinateProgressBar.setVisibility(indeterminate ? View.GONE : View.VISIBLE);
        cancel.setVisibility(indeterminate ? View.GONE : View.VISIBLE);
        progressPercent.setVisibility(indeterminate ? View.GONE : View.VISIBLE);

        progressMessage.setText(basicProgressAsyncTask.getDescription());
        if (!indeterminate) {
          progressPercent.setText(basicProgressAsyncTask.getProgressPercentage() + "%");
          determinateProgressBar.setProgress(basicProgressAsyncTask.getProgressPercentage());
        }
      }
      updateDownloadButton(false);
    }
  }
Example #5
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   Device device = getItem(position);
   if (convertView == null) {
     convertView =
         LayoutInflater.from(mContext).inflate(R.layout.item_device_list, parent, false);
   }
   TextView tvName = (TextView) convertView.findViewById(R.id.device_name);
   TextView tvIP = (TextView) convertView.findViewById(R.id.device_ip);
   TextView tvTraffic = (TextView) convertView.findViewById(R.id.device_traffic);
   View imgBlocked = convertView.findViewById(R.id.blocked);
   ProgressBar pbTrafficBar = (ProgressBar) convertView.findViewById(R.id.traffic_bar);
   tvName.setText(device.name());
   tvIP.setText(device.lastIP());
   imgBlocked.setVisibility(device.isBlocked() ? View.VISIBLE : View.GONE);
   if (device.isActive()) {
     pbTrafficBar.setVisibility(View.VISIBLE);
     tvName.setTextColor(Color.BLACK);
     tvTraffic.setText(String.format("%.2f", device.lastSpeed() / 1000) + " kb/s");
     if (mTotalTraffic > 0)
       pbTrafficBar.setProgress(Math.round(device.lastSpeed() / mTotalTraffic * 100));
     else pbTrafficBar.setProgress(0);
     if (device.prioritizedUntil() == Device.NOT_PRIORITIZED) {
       convertView.findViewById(R.id.priority).setVisibility(View.INVISIBLE);
     } else {
       if (device.prioritizedUntil() == Device.INDETERMINATE_PRIORITY) {
         ((TextView) convertView.findViewById(R.id.priority_until))
             .setText(R.string.indeterminite_priority_access);
         convertView.findViewById(R.id.until).setVisibility(View.INVISIBLE);
       } else {
         convertView.findViewById(R.id.until).setVisibility(View.VISIBLE);
         long now = System.currentTimeMillis() / 1000;
         if (device.prioritizedUntil() < now) {
           convertView.findViewById(R.id.priority).setVisibility(View.INVISIBLE);
           ((TextView) convertView.findViewById(R.id.priority_until))
               .setText(R.string.indeterminite_priority_access);
         } else {
           convertView.findViewById(R.id.priority).setVisibility(View.VISIBLE);
           Calendar undoTime = Calendar.getInstance();
           undoTime.setTimeInMillis(device.prioritizedUntil());
           String time =
               undoTime.get(Calendar.HOUR)
                   + ":"
                   + String.format("%02d", undoTime.get(Calendar.MINUTE));
           ((TextView) convertView.findViewById(R.id.priority_until))
               .setText(R.string.priority_access_until);
           ((TextView) convertView.findViewById(R.id.until)).setText(time);
         }
       }
     }
   } else {
     tvName.setTextColor(Color.GRAY);
     pbTrafficBar.setVisibility(View.GONE);
     tvTraffic.setText("");
     convertView.findViewById(R.id.priority).setVisibility(View.INVISIBLE);
   }
   return convertView;
 }
 private void updateProgress(int percent) {
   if (percent <= 0) {
     mProgressBar.setProgress(0);
   } else if (percent <= 100) {
     mProgressBar.setProgress(percent);
   } else {
     mProgressBar.setProgress(100);
   }
 }
  private void updateUICounter() {
    passedSenconds++;
    int seconds = passedSenconds % 60;
    int minutes = (passedSenconds / 60) % 60;
    txtCounter.setText(String.format("%02d : %02d", minutes, seconds));

    if (seconds <= 30) {
      prgPhase.setProgress(seconds);
    } else {
      prgPhase.setProgress(seconds - 30);
    }
  }
        @Override
        public View getView(int position, View v, ViewGroup parent) {

          Overførsler.Overførsel ovf = liste.get(position);
          AQuery aq;
          if (v == null) {
            v =
                getLayoutInflater(null)
                    .inflate(R.layout.nav1_overfoersler_listeelem, parent, false);
            v.setBackgroundResource(0);
            aq = new AQuery(v);
            aq.id(R.id.startStop).clicked(OverførslerFrag.this);
            aq.id(R.id.slet).clicked(OverførslerFrag.this);
          } else {
            aq = new AQuery(v);
          }
          // Skjul stiplet linje over øverste listeelement
          // aq.id(R.id.stiplet_linje).visibility(position == 0 ? View.INVISIBLE : View.VISIBLE);
          aq.id(R.id.startStop)
              .tag(ovf); // sæt udsendelsen ind som tag, så vi kan se dem i onClick()
          aq.id(R.id.slet).tag(ovf);
          if (App.PRODUKTION) aq.id(R.id.startStop).gone();
          if (App.PRODUKTION) aq.id(R.id.slet).gone();

          aq.id(R.id.linje1).text(ovf.trin.titel + "\n" + ovf.emne.navn);
          //              .textColor(hs.getStatus == DownloadManager.STATUS_SUCCESSFUL ? Color.BLACK
          // : App.color.grå60);

          //      aq.id(R.id.linje2).text(ovf.statusTekst()+"\n"+ovf.optagelse.url);
          aq.id(R.id.linje2).text(ovf.statusTekst());

          String status = ovf.getStatus();

          aq.id(R.id.slet).visibility(status == FÆRDIG ? View.GONE : View.VISIBLE);
          aq.id(R.id.startStop)
              .visibility(status == FÆRDIG ? View.GONE : View.VISIBLE)
              .image(
                  status == PAUSET
                      ? android.R.drawable.ic_media_play
                      : android.R.drawable.ic_media_pause);
          aq.id(R.id.progressBar).visibility(status == FÆRDIG ? View.GONE : View.VISIBLE);
          ProgressBar progressBar = aq.getProgressBar();
          if (App.fejlsøgning) {
            progressBar.setMax(1000);
            progressBar.setProgress((int) (1000 * Math.random()));
          } else {
            progressBar.setMax(ovf.filstørrelse);
            progressBar.setProgress(ovf.overført);
          }

          return v;
        }
Example #9
0
  public void runBattle() {

    if (fightingMonster != null) {

      // load monster on screen
      int counter = 0;
      while (fightingMonster.getImage() == null && counter != 1000) {}

      final ProgressBar progBar = (ProgressBar) findViewById(R.id.progressBar);
      progBar.setMax(fightingMonster.getHealth());
      progBar.setProgress(fightingMonster.getHealth());
      ImageView imgV = (ImageView) findViewById(R.id.myImageView);

      final ProgressBar userHealthBar = (ProgressBar) findViewById(R.id.userHealthBar);
      user.setHealth(12 * user.getLevel());
      userHealthBar.setMax(user.getHealth());
      userHealthBar.setProgress(user.getHealth());
      Random rndNumGen = new Random();
      // Generate 2 numbers (one for each combatant) who ever gets higher wins
      int playerScore = rndNumGen.nextInt(10);
      int monsterScore = rndNumGen.nextInt(9);
      imgV.setImageBitmap(fightingMonster.getImage());
      imgV.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Random rndNumGen = new Random();
              // Generate 2 numbers (one for each combatant) who ever gets higher wins
              int playerScore = rndNumGen.nextInt(10);
              int monsterScore = rndNumGen.nextInt(9);
              if (playerScore >= monsterScore) {
                fightingMonster.hit();
                userHealthBar.setProgress(user.getHealth());
              } else if (monsterScore >= playerScore) {
                user.hit();
                progBar.setProgress(fightingMonster.getHealth());
              }
              if (fightingMonster.getHealth() == 0) {
                Toast.makeText(MainActivity.this, "Health 0", Toast.LENGTH_LONG).show();
                user.increaseLevel();
                dbhelper.updateUser(user);

                loadMainPage(
                    "Congratulations you defeated "
                        + fightingMonster.getName()
                        + " your new level is "
                        + user.getLevel());
              }
            }
          });
    }
  }
  public void loadOfflineValues() {
    mUserLevel.setText(dataMan.getLevel() + "");
    mRadicalsProgress.setText(dataMan.getRadicalsProgress() + "");
    mRadicalsTotal.setText(dataMan.getRadicalsProgress() + "");
    mKanjiProgress.setText(dataMan.getKanjiProgress() + "");
    mKanjiTotal.setText(dataMan.getKanjiTotal() + "");

    mRadicalPercentage.setText(dataMan.getRadicalsPercentage() + "");
    mKanjiPercentage.setText(dataMan.getKanjiPercentage() + "");

    mRadicalProgressBar.setProgress(dataMan.getRadicalsPercentage());
    mKanjiProgressBar.setProgress(dataMan.getKanjiPercentage());
  }
  public void setData(String url, String speed, String progress, String isPaused) {
    if (hasInited) {
      HashMap<Integer, String> item = getItemDataMap(url, speed, progress, isPaused);

      titleText.setText(NetworkUtils.getFileNameFromUrl(item.get(KEY_URL)));
      speedText.setText(speed);
      if (TextUtils.isEmpty(progress)) {
        progressBar.setProgress(0);
      } else {
        progressBar.setProgress(Integer.parseInt(item.get(KEY_PROGRESS)));
      }
    }
  }
  @Override
  public void getActionsLayout(Context ctx, final LinearLayout cont) {
    WindowManager mWinMgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    int displayWidth = mWinMgr.getDefaultDisplay().getWidth();
    cont.removeAllViews();
    final TextView cmd = new TextView(ctx);

    cmd.setText(Html.fromHtml("<b>Reading:</b> " + getOutputCelsius() + "°C"));
    if (prefs.isLightThemeSelected()) cmd.setTextColor(ctx.getResources().getColor(R.color.black));
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    cmd.setLayoutParams(lp);
    lp.setMargins(2, 0, 0, 2);
    // cmd.setGravity(Gravity.TOP);
    cont.addView(cmd);

    ProgressBar par = new ProgressBar(ctx, null, android.R.attr.progressBarStyleHorizontal);
    // ProgressBar sfumata
    final ShapeDrawable pgDrawable =
        new ShapeDrawable(new RoundRectShape(Constants.roundedCorners, null, null));
    final LinearGradient gradient =
        new LinearGradient(
            0,
            0,
            displayWidth / 2,
            0,
            ctx.getResources().getColor(color.aa_blue),
            ctx.getResources().getColor(color.aa_red),
            android.graphics.Shader.TileMode.CLAMP);
    pgDrawable.getPaint().setStrokeWidth(3);
    pgDrawable.getPaint().setDither(true);
    pgDrawable.getPaint().setShader(gradient);

    ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    par.setProgressDrawable(progress);
    par.setBackgroundResource(android.R.drawable.progress_horizontal);

    RelativeLayout.LayoutParams lp2 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    lp2.setMargins(2, 2, 4, 2);
    par.setLayoutParams(lp2);
    par.setMax(50);
    par.setProgress(20);
    par.setProgress(0);
    par.setMax(40);
    par.setProgress((int) getOutputFloat());

    cont.addView(par);
  }
 public void updateProgress(String id, int current, int total, String messString) {
   double cur = current;
   double tot = total;
   double result = (cur / tot) * 100;
   LNReaderApplication.getInstance().updateDownload(id, (int) result, messString);
   if (loadingBar != null && loadingBar.getVisibility() == View.VISIBLE) {
     loadingBar.setIndeterminate(false);
     loadingBar.setMax(total);
     loadingBar.setProgress(current);
     loadingBar.setProgress(0);
     loadingBar.setProgress(current);
     loadingBar.setMax(total);
   }
 }
Example #14
0
  public void calcCantPorTipoCalif() {
    int cantCalif = calificaciones.size(), sumatoriaCalif = 0;

    int cantExc = 0, cantMbn = 0, cantBn = 0, cantReg = 0, cantMal = 0;

    for (int i = 0; i < calificaciones.size(); i++) {
      sumatoriaCalif += calificaciones.get(i);

      switch (calificaciones.get(i)) {
        case 5:
          cantExc++;
          break;
        case 4:
          cantMbn++;
          break;
        case 3:
          cantBn++;
          break;
        case 2:
          cantReg++;
          break;
        case 1:
          cantMal++;
          break;
      }
    }

    System.out.println(
        "SumatoriaCalif = "
            + sumatoriaCalif
            + " Cantidades: "
            + cantExc
            + "   "
            + cantMbn
            + "   "
            + cantBn
            + "   "
            + cantReg
            + "   "
            + cantMal);

    barraEstadisticaExcelente.setProgress((cantExc * 100) / cantCalif);
    barraEstadisticaMuyBueno.setProgress((cantMbn * 100) / cantCalif);
    barraEstadisticaBueno.setProgress((cantBn * 100) / cantCalif);
    barraEstadisticaRegular.setProgress((cantReg * 100) / cantCalif);
    barraEstadisticaMalo.setProgress((cantMal * 100) / cantCalif);

    calificacionGeneralTaxista.setProgress((sumatoriaCalif / cantCalif) * 2);
    calificacionGeneralTaxista.setEnabled(false);
  }
 public void setData(HashMap<Integer, String> item) {
   if (hasInited) {
     titleText.setText(NetworkUtils.getFileNameFromUrl(item.get(KEY_URL)));
     speedText.setText(item.get(KEY_SPEED));
     String progress = item.get(KEY_PROGRESS);
     if (TextUtils.isEmpty(progress)) {
       progressBar.setProgress(0);
     } else {
       progressBar.setProgress(Integer.parseInt(progress));
     }
     if (Boolean.parseBoolean(item.get(KEY_IS_PAUSED))) {
       onPause();
     }
   }
 }
 @Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case GUI_START_NOTIFIER:
       if (!Thread.currentThread().isInterrupted()) {
         /*设置为当前进度*/
         mProgressBar.setProgress(progress);
         /*将显示信息显示在屏幕上*/
         progress_detail_info.setText(
             getResources().getText(R.string.str_progress_loading)
                 + "("
                 + progress
                 + "%)\n"
                 + "Progress:"
                 + Integer.toString(mProgressBar.getProgress())
                 + "\n"
                 + "Indeterminate:"
                 + Boolean.toString(mProgressBar.isIndeterminate()));
         mHandler.postDelayed(progressThread, 1000);
       }
       break;
     case GUI_STOP_NOTIFIER:
       /*隐藏进度条*/
       mProgressBar.setVisibility(View.GONE);
       /*显示加载成功*/
       progress_detail_info.setText(R.string.str_progress_done);
       /*停止线程*/
       Thread.currentThread().interrupt();
       break;
   }
   super.handleMessage(msg);
 }
  @Override
  public View getView(final int index, View itemView, final ViewGroup parent) {
    if (itemView == null) {
      itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.bookmark, parent, false);

      final BookmarkView text = (BookmarkView) itemView.findViewById(R.id.bookmarkName);
      text.setActions(actions);

      final ProgressBar bar = (ProgressBar) itemView.findViewById(R.id.bookmarkPage);
      bar.setProgressDrawable(
          context.getResources().getDrawable(R.drawable.viewer_goto_dlg_progress));
    }

    final Bookmark b = getBookmark(index);

    final TextView text = (TextView) itemView.findViewById(R.id.bookmarkName);
    text.setText(b.name);
    text.setTag(b);

    final ProgressBar bar = (ProgressBar) itemView.findViewById(R.id.bookmarkPage);
    bar.setMax(lastPage != null ? lastPage.index.viewIndex : 0);
    bar.setProgress(b.page.viewIndex);

    final View btn = itemView.findViewById(R.id.bookmark_remove);
    if (b.service) {
      btn.setVisibility(View.GONE);
    } else {
      btn.setVisibility(View.VISIBLE);
      btn.setOnClickListener(actions.getOrCreateAction(R.id.actions_showDeleteBookmarkDlg));
      btn.setTag(b);
    }

    return itemView;
  }
        public void handleMessage(Message msg) {
          int p = msg.getData().getInt("PERCENT");

          // 當事件進度抵達100時,關掉/隱藏 progressDialog/progressBar
          if (p > 100) {
            if (which_progress.equals("progress_dialog")) {
              myDialog.dismiss();

              // Button3 & Button4:ProgressBar.
            } else if (which_progress.equals("progress_bar1")) {
              progressbar1.setVisibility(View.GONE);
              text_progressbar1.setText("Button3");
            } else {
              progressbar2.setVisibility(View.GONE);
              text_progressbar2.setText("Button4");
              text_percent.setText("100%");
            }

          } else {
            if (which_progress.equals("progress_dialog")) {
              myDialog.setProgress(p);

              // Button4:ProgressBar Horizontal.
            } else if (which_progress.equals("progress_bar2")) {
              progressbar2.setProgress(p);
              text_percent.setText(p + "%");
            }
          }
        }
Example #19
0
 @Override
 protected void onProgressUpdate(Integer... values) {
   int count = values[0];
   progressView.setProgress(count); // 设置下载进度
   textView.setText("进度:" + count + "%");
   super.onProgressUpdate(values);
 }
Example #20
0
  /** @hide */
  protected int setProgress() {
    if (mPlayer == null || mDragging) {
      return 0;
    }
    int position = mPlayer.getCurrentPosition();
    int duration = mPlayer.getDuration();
    /// M: add log for seldom ALPS01020394. @{
    MmsLog.d(
        "MmsMediaController", "setProgress, position: " + position + ", duration: " + duration);
    /// @}
    if (mProgress != null) {
      if (duration > 0) {
        // use long to avoid overflow
        long pos = 1000L * position / duration;
        mProgress.setProgress((int) pos);
      }
      int percent = mPlayer.getBufferPercentage();
      mProgress.setSecondaryProgress(percent * 10);
    }

    if (mEndTime != null) mEndTime.setText(stringForTime(duration));
    if (mCurrentTime != null) mCurrentTime.setText(stringForTime(position));

    // If duration is short, refresh every 100ms
    if (duration < 10000) {
      return 900;
    }
    return position;
  }
  public void m_click(View view) {
    if (progressBar.getVisibility() == View.VISIBLE) {
      progressBar.setProgress(0);

      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  while (progressBar.getProgress() <= 80) {

                    int progress = progressBar.getProgress();
                    //						textView.setText(progress);
                    Message message = new Message();
                    message.obj = progress;
                    m_handler.sendMessage(message);
                    progress = progress + 1;
                    progressBar.setProgress(progress);

                    try {
                      Thread.sleep(10);
                    } catch (InterruptedException e) {
                      e.printStackTrace();
                    }
                  }
                }
              })
          .start();
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_zen, null);

    progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
    progressBar.setProgress(0);
    progressBar.setVisibility(View.INVISIBLE);

    liview = (ListView) v.findViewById(R.id.listView);
    liview.setAdapter(mAdapter);
    liview.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            if (mActionMode != null) {
              return false;
            }
            mPosition = position;
            // Start the CAB using the ActionMode.Callback defined above
            mActionMode = getActivity().startActionMode(mActionModeCallback);
            view.setSelected(true);
            return true;
          }
        });
    return v;
  }
 @Override
 public void onServiceConnected(ComponentName name, IBinder service) {
   mServiceBinder = (CheckBinder) service;
   Intent extrasIntent = getIntent();
   String action = extrasIntent.getAction();
   boolean b =
       mServiceBinder.getTaskRunnningStatus(UpdateService.TASK_ID_DOWNLOAD)
           == ThreadTask.RUNNING_STATUS_UNSTART;
   if (ACTION_CHECK.equals(action) && b) {
     Intent intent = new Intent(DownloadActivity.this, UpdateService.class);
     intent.putExtra(
         UpdateService.KEY_START_COMMAND, UpdateService.START_COMMAND_START_CHECKING);
     startService(intent);
     setCheckView();
   } else if (ACTION_DOWNLOAD.equals(action) || !b) {
     setDownloadView();
   }
   if (DownloadTask.FAIL_ACTION.equals(action)) {
     setDownloadView();
     mPercent.setVisibility(View.VISIBLE);
     mPercent.setText(R.string.download_error);
   } else if (DownloadTask.SUCCEED_ACTION.equals(action)) {
     setDownloadView();
     mPercent.setVisibility(View.VISIBLE);
     mPercent.setText(getString(R.string.Download_succeed));
     mProgress.setProgress(100);
     mCombineBtn.setText(R.string.download_update);
     mCombineBtn.setTag(Integer.valueOf(R.string.download_update));
   }
 }
  /**
   * Sets the progress of the ProgressBar in a PROGRESS_HORIZONTAL type SuperCardToast. <br>
   *
   * @param progress Max default is 100
   */
  public void setProgress(int progress) {

    if (mProgressBar != null) {

      mProgressBar.setProgress(progress);
    }
  }
  public void updateMetaUi() {
    Book book = mSpritzer.getBook();
    Metadata meta = book.getMetadata();
    Author author = meta.getAuthors().get(0);
    int curChapter = mSpritzer.getCurrentChapter();

    mAuthorView.setText(author.getFirstname() + " " + author.getLastname());
    mTitleView.setText(meta.getFirstTitle());
    String chapterText;
    if (book.getSpine().getResource(curChapter).getTitle() == null
        || book.getSpine().getResource(curChapter).getTitle().trim().compareTo("") == 0) {
      chapterText = String.format("Chapter %d", curChapter);
    } else {
      chapterText = book.getSpine().getResource(curChapter).getTitle();
    }

    int startSpan = chapterText.length();
    chapterText =
        String.format(
            "%s  %s m left",
            chapterText,
            (mSpritzer.getMinutesRemainingInQueue() == 0)
                ? "<1"
                : String.valueOf(mSpritzer.getMinutesRemainingInQueue()));
    int endSpan = chapterText.length();
    Spannable spanRange = new SpannableString(chapterText);
    TextAppearanceSpan tas = new TextAppearanceSpan(mChapterView.getContext(), R.style.MinutesToGo);
    spanRange.setSpan(tas, startSpan, endSpan, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    mChapterView.setText(spanRange);

    mProgress.setMax(mSpritzer.getMaxChapter());
    mProgress.setProgress(curChapter);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // create view and bind
    View view = inflater.inflate(R.layout.fragment_htfdemo_progress, container, false);
    ButterKnife.bind(this, view);

    // progress
    long numPrayed = 3;
    long numPeople = 130;
    prayedFor.setText(String.format(getString(R.string.prayed_for), numPrayed, numPeople));
    progress.setProgress((int) ((float) numPrayed / numPeople * 100.0f));
    progress.requestLayout();

    numberOfDaysPraying.setText(getString(R.string.day) + " " + 1);

    exitButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            ((MainActivity) getActivity()).loadMainFragment();
          }
        });

    return view;
  }
Example #27
0
  public void onResume() {
    bar.setProgress(0);

    builder
        .setView(dialogLayout)
        .setCancelable(true)
        .setPositiveButton(
            "Begin!",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                /*Toast
                .makeText(FitTest.this, "Begin!", Toast.LENGTH_LONG)
                .show();*/
                new heartProgressTask().execute();
              }
            })
        .setNegativeButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                /*Toast
                .makeText(FitTest.this, "Cancel!", Toast.LENGTH_LONG)
                .show();*/
                cancelSelected();
              }
            });
    alertDialog = builder.create();
    alertDialog.show();

    super.onResume();
  } // end of onResume
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case MY_MSG:
              double amp = (double) msg.obj;

              if ((amp > mThreshold) && !mCalib) {
                mHitCount++;
                if (mHitCount > mHitMax) {
                  // Intentos superados
                  showMessage("Limite de ruido superado reiteradamente");
                  mp.start();
                  stopAlarm();
                }
              }

              decibelsTx.setText("Nivel de Ruido: " + msg.obj + "dB");
              double barValue = (100 * (double) msg.obj) / (120);
              barDB.setProgress((int) barValue);

              break;
            case MAXOVER_MSG:
              mMax = false;
              break;
            case ERROR_MSG:
              Toast.makeText(mContext, "Error " + msg.obj, Toast.LENGTH_LONG).show();
              break;
            default:
              super.handleMessage(msg);
              break;
          }
        }
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();

          if (action.equalsIgnoreCase(ACTION_SHOW_PROGRESSBAR)) {
            setSupportProgressBarIndeterminateVisibility(true);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
          } else if (action.equalsIgnoreCase(ACTION_HIDE_PROGRESSBAR)) {
            setSupportProgressBarIndeterminateVisibility(false);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
          } else if (action.equalsIgnoreCase(ACTION_SHOW_TEXTINFO)) {
            String info = intent.getStringExtra("info");
            int max = intent.getIntExtra("max", 0);
            int progress = intent.getIntExtra("progress", 100);
            mInfoText.setText(info);
            mInfoProgress.setMax(max);
            mInfoProgress.setProgress(progress);

            if (info == null) {
              /* Cancel any upcoming visibility change */
              mHandler.removeMessages(ACTIVITY_SHOW_INFOLAYOUT);
              mInfoLayout.setVisibility(View.GONE);
            } else {
              /* Slightly delay the appearance of the progress bar to avoid unnecessary flickering */
              if (!mHandler.hasMessages(ACTIVITY_SHOW_INFOLAYOUT)) {
                Message m = new Message();
                m.what = ACTIVITY_SHOW_INFOLAYOUT;
                mHandler.sendMessageDelayed(m, 300);
              }
            }
          }
        }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View v = convertView;
   if (v == null) {
     LayoutInflater vi =
         (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     v = vi.inflate(R.layout.download_list_item, null);
   }
   DownloadModel d = downloads.get(position);
   if (d != null) {
     TextView name = (TextView) v.findViewById(R.id.download_name);
     TextView message = (TextView) v.findViewById(R.id.download_Message);
     ProgressBar progress = (ProgressBar) v.findViewById(R.id.download_progress_bar);
     if (name != null) {
       name.setText(d.getDownloadName());
     }
     if (progress != null) {
       progress.setProgress(d.getDownloadProgress());
     }
     if (message != null) {
       if (d.getDownloadMessage() != null) {
         message.setText(d.getDownloadMessage());
         message.setVisibility(View.VISIBLE);
       } else {
         message.setVisibility(View.GONE);
       }
     }
   }
   return v;
 }