private void setProgressDrawable() {
   if (mProgressBackgroundColor != -1) {
     Drawable progressDrawable = mProgressbar.getProgressDrawable();
     if (progressDrawable != null) {
       progressDrawable.setColorFilter(mProgressBackgroundColor, PorterDuff.Mode.SRC_IN);
     }
   }
 }
 @Override
 public View newInstance(@NonNull Context context) {
   mProgressBar = (ProgressBar) View.inflate(context, R.layout.progress_indicator, null);
   if (selectedDotColor != DEFAULT_COLOR)
     mProgressBar.getProgressDrawable().setColorFilter(selectedDotColor, PorterDuff.Mode.SRC_IN);
   if (unselectedDotColor != DEFAULT_COLOR)
     mProgressBar
         .getIndeterminateDrawable()
         .setColorFilter(unselectedDotColor, PorterDuff.Mode.SRC_IN);
   return mProgressBar;
 }
 @Override
 protected void initView() {
   initWebView();
   swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
   swipeRefreshLayout.setOnRefreshListener(this);
   swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
   progressBar = (ProgressBar) findViewById(R.id.progressBar);
   int color = ResourcesUtils.getColor(this, R.color.colorPrimary);
   progressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
   url = getIntent().getStringExtra(KEY_URL);
   webView.loadUrl(AppConstants.RequestPath.ACTIVITY_CONTENT + url);
   findViewById(R.id.iv_back).setOnClickListener(this);
 }
  @Override
  public void processProperties(KrollDict d) {
    super.processProperties(d);

    if (d.containsKey(TiC.PROPERTY_MESSAGE)) {
      handleSetMessage(TiConvert.toString(d, TiC.PROPERTY_MESSAGE));
    }
    if (d.containsKey(TiC.PROPERTY_COLOR)) {
      final int color = TiConvert.toColor(d, TiC.PROPERTY_COLOR);
      progress.getProgressDrawable().setColorFilter(color, Mode.SRC_IN);
      handleSetMessageColor(color);
    }
    updateProgress();
  }
  @Override
  public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) {
    super.propertyChanged(key, oldValue, newValue, proxy);

    if (key.equals(TiC.PROPERTY_VALUE) || key.equals("min") || key.equals("max")) {
      updateProgress();
    } else if (key.equals(TiC.PROPERTY_MESSAGE)) {
      String message = TiConvert.toString(newValue);
      if (message != null) {
        handleSetMessage(message);
      }
    } else if (key.equals(TiC.PROPERTY_COLOR)) {
      final int color = TiConvert.toColor(TiConvert.toString(newValue));
      progress.getProgressDrawable().setColorFilter(color, Mode.SRC_IN);
      handleSetMessageColor(color);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_temp_result);

    ActionBar actionbar = getSupportActionBar();
    actionbar.setDisplayHomeAsUpEnabled(true);

    // google sync lat long
    tvLat = (TextView) findViewById(R.id.tvLatResult);
    tvLong = (TextView) findViewById(R.id.tvLongResult);

    buildGoogleApiClient();
    if (mGoogleApiClient != null) {
      mGoogleApiClient.connect();
    } else {
      Toast.makeText(this, "Not connected...", Toast.LENGTH_SHORT).show();
    }
    btnSave = (Button) findViewById(R.id.btnSave);
    btnSave.setText("WAIT..");
    btnSave.setEnabled(false);
    //        btnSave.setBackgroundColor(Color.LTGRAY);

    btnMetadata = (Button) findViewById(R.id.btnMetadata);
    btnMetadata.setVisibility(View.GONE);
    btnMetadata.setEnabled(false);

    spnLeafType = (Spinner) findViewById(R.id.spnLeaftype);
    etSPAD = (EditText) findViewById(R.id.etSPAD);
    etNitro = (EditText) findViewById(R.id.etNitro);
    etKeterangan = (EditText) findViewById(R.id.etKeterangan);
    imgview = (ImageView) findViewById(R.id.imgLeafTemp);
    tvResultECV = (TextView) findViewById(R.id.tvResultECV);
    tvPxlGreen = (TextView) findViewById(R.id.tvPxlGreenResult);
    tvPxlWhite = (TextView) findViewById(R.id.tvPxlWhiteResult);

    tvProgress = (TextView) findViewById(R.id.tvProgress);
    progressBar = (ProgressBar) findViewById(R.id.progressBar1);
    progressBar
        .getProgressDrawable()
        .setColorFilter(0xff00be8c, android.graphics.PorterDuff.Mode.SRC_ATOP);

    dispatchTakePictureIntent();
    // Intent iCamera = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    // startActivityForResult(iCamera, 0);
  }
Exemple #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);
    ButterKnife.bind(this);

    // 显示toolbar并绑定drawerToggle
    ViewUtils.setToolbar(this, mToolbar, true, "天气");
    ViewUtils.setDrawerToggle(this, mDrawerLayout, mToolbar);

    initData();
    initWebView();
    swipeRefreshLayout.setOnRefreshListener(this);
    int color = getResources().getColor(R.color.cyan_base);
    progressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
    // url = getIntent().getStringExtra(KEY_URL);
    url = SINA_WEATHER_URL;
    webView.loadUrl(url);
  }
  private void setAllWidgetDisabled(Boolean param) {
    if (param) {
      btnSave.setText("SAVED!");
      btnSave.setClickable(false);
      btnSave.setBackgroundColor(Color.LTGRAY);

      etNitro.setEnabled(false);
      etSPAD.setEnabled(false);
      etKeterangan.setEnabled(false);
      spnLeafType.setEnabled(false);

      tvResultECV.setTextColor(Color.LTGRAY);
      tvLat.setTextColor(Color.LTGRAY);
      tvLong.setTextColor(Color.LTGRAY);
      tvProgress.setTextColor(Color.LTGRAY);
      tvPxlGreen.setTextColor(Color.LTGRAY);
      tvPxlWhite.setTextColor(Color.LTGRAY);

      progressBar
          .getProgressDrawable()
          .setColorFilter(0xffffffff, android.graphics.PorterDuff.Mode.SRC_ATOP);
    }
  }
Exemple #9
0
  private void startTimer() {
    // change visibility of minute + and - buttons, minutes text and delay
    showMinutes(false);
    // setting color to the progress with color filters
    // rgb color picker http://www.hexcolortool.com/#2f4efe color picker
    // red
    mProgressBar
        .getBackground()
        .setColorFilter(Color.argb(255, 255, 87, 34), PorterDuff.Mode.SRC_IN);
    mProgressBar
        .getProgressDrawable()
        .setColorFilter(Color.argb(255, 255, 87, 34), PorterDuff.Mode.SRC_IN);
    // max needs to be set so progress shows correctly
    mProgressBar.setMax((textViewToInt((minutes)) * 60));

    // change visibility of minute + and - buttons and minutes
    showMinutes(false);
    timerStopped = false;

    // set counter value
    counter = (textViewToInt(minutes) * 60) - 18;

    countDownTimer =
        new CountDownTimer(totalTimeCountInMilliseconds, 500) {
          @Override
          public void onTick(long millisUntilFinished) {

            // show time
            long seconds = millisUntilFinished / 1000;
            mProgressBar.setProgress((int) (millisUntilFinished / 1000));
            textViewShowTime.setText(
                String.format("%02d", seconds / 60) + ":" + String.format("%02d", seconds % 60));

            // every 10 seconds read volt, if volt decreasing is ongoing it will skip this
            if ((int) seconds == counter && decreaseThread == null) {
              Log.i(TAG, "EVERY 10 SECONDS");

              mBluetoothLeService.readVoltage();
            }
            // every 12 seconds read polarity, if volt decreasing is ongoing it will skip this
            if ((int) seconds == (counter - 2) && decreaseThread == null) {
              Log.i(TAG, "EVERY 12 SECONDS");
              mBluetoothLeService.readPolarity();
              counter -= 10;
            }

            // halftime
            if (millisUntilFinished < (totalTimeCountInMilliseconds / 2)) {
              // blue
              mProgressBar
                  .getBackground()
                  .setColorFilter(Color.argb(255, 48, 79, 254), PorterDuff.Mode.SRC_IN);
              mProgressBar
                  .getProgressDrawable()
                  .setColorFilter(Color.argb(255, 48, 79, 254), PorterDuff.Mode.SRC_IN);

              // check if polarity has changed
              if (!polarityChanged) {
                changePolarity();
              }
            }

            // check if increaseVoltToMax thread is done and max_volt is false
            if (increaseThread.getState() == Thread.State.TERMINATED && !max_volt) {
              setButtonDisabled(true);
              max_volt = true;
            }

            // check if decreaseThread has initialized
            if (decreaseThread != null) {
              // check if decreaseThread is running
              if (decreaseThread.getState() != Thread.State.TERMINATED) {
                setButtonDisabled(false);
              }
            }

            // start decrease volt to zero when until time is equal volts/2 plus 2
            if ((millisUntilFinished / 1000) == (textViewToInt(volts) / 2 + 2)) {
              int volt = textViewToInt(volts);
              decreaseThread = decreaseVoltToZero(volt);
            }
          }

          public void onFinish() {
            // when the timer is finished
            textViewShowTime.setText(getBaseContext().getResources().getString(R.string.done));
            textViewShowTime.setVisibility(View.VISIBLE);
            buttonStartTime.setVisibility(View.GONE);
            buttonStopTime.setVisibility(View.GONE);
            mProgressBar.getBackground().clearColorFilter();
            mProgressBar
                .getBackground()
                .setColorFilter(Color.argb(255, 0, 230, 118), PorterDuff.Mode.SRC_IN);
            mProgressBar
                .getProgressDrawable()
                .setColorFilter(Color.argb(255, 0, 230, 118), PorterDuff.Mode.SRC_IN);
            // turn off bluetooth connection to the device and let the customer know
            stopTreatment();
          }
        }.start();
  }
Exemple #10
0
  private void findViews() {

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    nestedScrollView = (NestedScrollView) findViewById(R.id.nsv);
    prefs = getSharedPreferences("user_prefs", MODE_PRIVATE);
    // Button
    addVoltButton = (Button) findViewById(R.id.addVoltButton);
    addMinuteButton = (Button) findViewById(R.id.addMinuteButton);
    decreaseVoltButton = (Button) findViewById(R.id.decreaseVoltButton);
    decreaseMinuteButton = (Button) findViewById(R.id.decreaseMinuteButton);
    buttonStartTime = (Button) findViewById(R.id.btnStartTime);
    buttonStopTime = (Button) findViewById(R.id.btnStopTime);
    minuteHelpText = (TextView) findViewById(R.id.minuteHelpText);
    // TextViews
    textViewShowTime = (TextView) findViewById(R.id.tvTimeCount);
    volts = (TextView) findViewById(R.id.volts);
    volts.setText(prefs.getInt("volts", 20) + "");

    minutes = (TextView) findViewById(R.id.minutes);
    minutes.setText(prefs.getInt("minutes", 2) + "");

    // checkbox
    delayCheckBox = (CheckBox) findViewById(R.id.delayCheckBox);
    delayCheckBox.setChecked(prefs.getBoolean("delay", false));
    delaytimer = delayCheckBox.isChecked();

    voltageTextView = (TextView) findViewById(R.id.voltage_textview);
    polarityTextView = (TextView) findViewById(R.id.polarity_textview);

    // Progress Bar
    mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
    //  Floating Action Button
    // fab = (FloatingActionButton) findViewById(R.id.fab);

    // Views
    rootview = (RelativeLayout) findViewById(R.id.rootview);
    connect_button_view = (RelativeLayout) findViewById(R.id.connect_button_view);
    connectDeviceButton = (Button) findViewById(R.id.connect_device_button);

    // set connect view
    setVisibility(CONNECT_VIEW);

    // this should make the screen stay on when rootview is visible
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    if (rootview != null && rootview.getVisibility() == View.VISIBLE) {
      rootview.setKeepScreenOn(true);
    }

    mProgressBar
        .getBackground()
        .setColorFilter(Color.argb(255, 0, 230, 118), PorterDuff.Mode.SRC_IN);
    mProgressBar
        .getProgressDrawable()
        .setColorFilter(Color.argb(255, 0, 230, 118), PorterDuff.Mode.SRC_IN);

    // Listeners
    addMinuteButton.setOnClickListener(this);
    addVoltButton.setOnClickListener(this);
    decreaseVoltButton.setOnClickListener(this);
    decreaseMinuteButton.setOnClickListener(this);
    buttonStartTime.setOnClickListener(this);
    buttonStopTime.setOnClickListener(this);
    // fab.setOnClickListener(this);
    connectDeviceButton.setOnClickListener(this);
    textViewShowTime.setOnClickListener(this);
    delayCheckBox.setOnCheckedChangeListener(this);

    final Snackbar snackbar =
        Snackbar.make(
                nestedScrollView, "Bluetooth has not been enabled", Snackbar.LENGTH_INDEFINITE)
            .setAction(
                "ENABLE",
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    // ENABLE DEVICE'S BLUETOOTH
                    setDeviceBluetooth(true);
                  }
                });

    bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    boolean isEnabled = bluetoothAdapter.isEnabled();
    if (!isEnabled) {

      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder
          .setTitle(getBaseContext().getResources().getString(R.string.use_bluetooth))
          .setMessage(getBaseContext().getResources().getString(R.string.need_bluetooth_pliz))
          .setCancelable(false)
          .setPositiveButton(
              getBaseContext().getResources().getString(R.string.yes),
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  // ENABLE DEVICE'S BLUETOOTH
                  setDeviceBluetooth(true);
                  dialog.dismiss();
                }
              })
          .setNegativeButton(
              getBaseContext().getResources().getString(R.string.no),
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  snackbar.show();
                  dialog.dismiss();
                }
              });
      AlertDialog alertDialog = builder.create();

      alertDialog.show();
    }
  }
 @Override
 public void setSelectedIndicatorColor(int color) {
   this.selectedDotColor = color;
   if (mProgressBar != null)
     mProgressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
 }
 public ProgressClient(ProgressBar progressBar) {
   int color = progressBar.getContext().getResources().getColor(R.color.app_color_dark);
   progressBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
   this.progressBar = progressBar;
 }