@Override
 public void handleMessage(Message msg) {
   uploadbar.setProgress(msg.getData().getInt("length"));
   float num = (float) uploadbar.getProgress() / (float) uploadbar.getMax();
   int result = (int) (num * 100);
   resultView.setText(result + "%");
   if (uploadbar.getProgress() == uploadbar.getMax()) {
     Toast.makeText(MainActivity.this, R.string.success, 1).show();
   }
 }
 @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);
 }
Exemple #3
0
  public void Gain50Exp(View view) {
    user.gain_exp(50);
    mProgress.incrementProgressBy(50);

    Snackbar snackbar = Snackbar.make(view, "You got 50 EXP!", Snackbar.LENGTH_LONG);
    snackbar.setAction("Action", null).show();

    if (mProgress.getProgress() >= mProgress.getMax()) {
      LevelUp(view);
    }
  }
  private void editProgressBars() {
    player.pullFromDatabase();
    ProgressBar healthbar = (ProgressBar) findViewById(R.id.progressBar_health);
    healthbar.setMax(100); // TODO calc the max health
    healthbar.setProgress(player.getHealth());
    TextView health = (TextView) findViewById(R.id.txt_health_ratio);
    health.setText(healthbar.getProgress() + "/" + healthbar.getMax());

    ProgressBar xpbar = (ProgressBar) findViewById(R.id.progressBar_experience);
    Resources res = getResources();
    int[] levels = res.getIntArray(R.array.Levels);
    xpbar.setMax(190000); // Cap Level
    for (int i = 0; i < levels.length; i++) {
      if (levels[i] > player.getXP()) {
        xpbar.setMax(levels[i]);
        EditText level = (EditText) findViewById(R.id.editText_Level);
        level.setText("" + ++i);
        break;
      }
    }
    xpbar.setProgress(player.getXP());
    TextView xp = (TextView) findViewById(R.id.txt_experience_ratio);
    xp.setText(xpbar.getProgress() + "/" + xpbar.getMax());
  }
        @Override
        public void handleMessage(Message msg) {

          progressBarh.setProgress(msg.getData().getInt("size"));

          float temp = (float) progressBarh.getProgress() / (float) progressBarh.getMax();

          int progress = (int) (temp * 100);
          if (progress == 100) {
            Toast.makeText(DownImageActivity.this, "下载完成!", Toast.LENGTH_LONG).show();
            dialog.dismiss();

            File mFile = new File(msg.getData().getString("uri"));
            Intent install = new Intent();
            install.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            install.setAction(android.content.Intent.ACTION_VIEW);
            install.setDataAndType(Uri.fromFile(mFile), "application/vnd.android.package-archive");
            startActivity(install);
          }
          dialog.setMessage("下载进度:" + progress + " %");
        }
  private void increaseProgressBy(int val) {
    if (expBar.getProgress() + val >= expBar.getMax()) {
      stLevel++;
      qAnswered = 0;
      level.setText(String.valueOf(stLevel));

      if ((val - (expBar.getMax() - expBar.getProgress())) > 0) {
        expBar.setProgress(val - (expBar.getMax() - expBar.getProgress()));
      } else {
        expBar.setProgress(0);
      }
      expBar.setMax((int) (expBar.getMax() * LEVEL_SCALE));
      experience.setText(String.valueOf(expBar.getProgress()) + "/" + expBar.getMax());
      Toast.makeText(
              this,
              "Congratulations!\nYou've reached level " + level.getText().toString(),
              Toast.LENGTH_SHORT)
          .show();
    } else {
      expBar.setProgress(expBar.getProgress() + val);
      experience.setText(String.valueOf(expBar.getProgress()) + "/" + expBar.getMax());
    }

    if (stLevel % 2 == 0 && qAnswered < 3) {
      qButton.setEnabled(true);
      saveProgressInfo("QANSWERED", qAnswered);
      setupAlert();

    } else {
      qButton.setEnabled(false);
    }

    saveProgressInfo("LEVEL", level.getText().toString());
    saveProgressInfo("EXPERIENCE", String.valueOf(expBar.getProgress()));
    saveProgressInfo("EXPCAP", String.valueOf(expBar.getMax()));
  }
 @Override
 public Integer get(ProgressBar pb) {
   return pb.getProgress();
 }
        @Override
        public void handleMessage(Message msg) {

          switch (msg.what) {
            case 1:
              {
                uploadbar.setProgress(msg.getData().getInt("length"));
                float num = (float) uploadbar.getProgress() / (float) uploadbar.getMax();
                int result = (int) (num * 100);
                resultView.setText(result + "%");
                if (uploadbar.getProgress() == uploadbar.getMax()) {

                  Toast.makeText(SubmitActivity.this, R.string.success, 1).show();
                }
              }
              break;
              // 上传视频
            case 2:
              {
                try {
                  postVedioInfo();

                } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
              break;
            case 3:
              {
                if (sinax) showShare(true, "SinaWeibo", false);
                if (tecentx) showShare(true, "TencentWeibo", false);
                if (renrenx) showShare(true, "Renren", false);
                if (doubanx) showShare(true, "Douban", false);

                jumpActivity(SquareActivity.class);
              }
              break;
            case 4:
              {
                HashMap<String, Integer> map = (HashMap<String, Integer>) msg.obj;
                int whichItem = map.get("whichItem");
                int whichpop = map.get("whichPop");

                if (whichpop == CLASSFICATION_POP) {
                  classificationTextView.setText(classficationlist.get(whichItem));
                  choose_classfication_popupWindow.dismiss();
                } else if (whichpop == ChooseGroup_POP) {
                  String chooseString = grouplist.get(whichItem);
                  if (addShareGroupTextView
                      .getText()
                      .toString()
                      .equals(getString(R.string.submit_shareGroupOriginalString))) {

                    addShareGroupTextView.setText(chooseString);
                    shareGroupId = groupMap.get(chooseString);
                  } else {
                    addShareGroupTextView.setText(
                        addShareGroupTextView.getText().toString() + ";" + chooseString);
                    shareGroupId = shareGroupId + ";" + groupMap.get(chooseString);
                  }
                }
              }
              break;
            case 5:
              {
                showToastMessage(msg.obj.toString());
              }
              break;
              // 获取到了分类信息,准备获取分组信息
            case GET_CLASSFICATION:
              {
                initGroup();
              }
            default:
              break;
          }
        }
  /** Returns the progress of the ProgressBar in a PROGRESS_HORIZONTAL type SuperCardToast. */
  public int getProgress() {

    return mProgressBar.getProgress();
  }
  public void testIfRGBSeekBarsDoChangeColor()
      throws SecurityException, IllegalArgumentException, NoSuchFieldException,
          IllegalAccessException {
    final int RGB_TAB_INDEX = 1;
    testOpenColorPickerOnClickOnColorButton();
    TabHost tabHost = (TabHost) mSolo.getView(R.id.colorview_tabColors);
    TabWidget colorTabWidget = tabHost.getTabWidget();
    mSolo.clickOnView(colorTabWidget.getChildAt(RGB_TAB_INDEX), true);
    mSolo.waitForText(mSolo.getString(R.string.color_red));
    final Paint originalStrokePaint =
        (Paint)
            PrivateAccess.getMemberValue(
                BaseTool.class, PaintroidApplication.currentTool, "mCanvasPaint");
    final int originalPaintColor = originalStrokePaint.getColor();
    final ArrayList<ProgressBar> currentProgressBars = mSolo.getCurrentViews(ProgressBar.class);
    assertEquals("No progress bars for ARGB :-(", currentProgressBars.size(), 4);
    final ArrayList<TextView> currentTextViews =
        mSolo.getCurrentViews(TextView.class, mSolo.getView(R.id.rgb_base_layout));
    assertEquals("Missing some text views RGBA and ARGV-values", 9, currentTextViews.size());
    int textValueCounter = 1;
    for (; textValueCounter < currentTextViews.size(); textValueCounter += 2) {
      int textValueAsInteger =
          Integer.parseInt((String) currentTextViews.get(textValueCounter).getText());
      assertTrue(
          "Not in range 0<=textValue<=255", textValueAsInteger >= 0 && textValueAsInteger <= 255);
    }

    textValueCounter = 1;
    for (ProgressBar barToChange : currentProgressBars) {
      int changeSeekBarTo = (barToChange.getProgress() + 33) % barToChange.getMax();
      mSolo.setProgressBar(barToChange, changeSeekBarTo);
      mSolo.sleep(50);
      if (textValueCounter == 4) { // alpha 0-100%
        int expectetAlphaTextValue = (int) (changeSeekBarTo / 2.55f);
        assertEquals(
            "Text value did not change index:" + textValueCounter,
            expectetAlphaTextValue,
            Integer.parseInt((String) currentTextViews.get(textValueCounter * 2 - 1).getText()));
      } else
        assertEquals(
            "Text value did not change index:" + textValueCounter,
            changeSeekBarTo,
            Integer.parseInt((String) currentTextViews.get(textValueCounter * 2 - 1).getText()));
      textValueCounter++;
    }
    mSolo.goBack();
    final Paint rgbChangedStrokePaint =
        (Paint)
            PrivateAccess.getMemberValue(
                BaseTool.class, PaintroidApplication.currentTool, "mCanvasPaint");
    final int rgbChangedPaintColor = rgbChangedStrokePaint.getColor();
    assertFalse(
        "Alpha value did not change",
        Color.alpha(rgbChangedPaintColor) == Color.alpha(originalPaintColor));
    assertFalse(
        "Red value did not change",
        Color.red(rgbChangedPaintColor) == Color.red(originalPaintColor));
    assertFalse(
        "Green value did not change",
        Color.green(rgbChangedPaintColor) == Color.green(originalPaintColor));
    assertFalse(
        "Blue value did not change",
        Color.blue(rgbChangedPaintColor) == Color.blue(originalPaintColor));
  }