Esempio n. 1
0
  protected void performGetArticole() {

    String numeArticol = txtNumeArticol.getText().toString().trim();
    String tipCautare = "", tipArticol = "";

    if (tglButton.isChecked()) tipCautare = "C";
    else tipCautare = "N";

    if (tglTipArtBtn.isChecked()) tipArticol = "S";
    else tipArticol = "A";

    String localDep = UserInfo.getInstance().getCodDepart();

    if (isCV()) {
      localDep = CLPFragment1.departamentConsilier;
    } else if (UtilsUser.isAgentOrSD()) {
      localDep = UserInfo.getInstance().getCodDepart();
    } else if (UtilsUser.isKA()) {
      localDep = "00";
    }

    if (localDep.length() > 0) {
      HashMap<String, String> params = UtilsGeneral.newHashMapInstance();
      params.put("searchString", numeArticol);
      params.put("tipArticol", tipArticol);
      params.put("tipCautare", tipCautare);
      params.put("departament", localDep);

      opArticol.getArticoleDistributie(params);
    }
  }
  @Override
  public void afterTextChanged(Editable s) {
    int position = Selection.getSelectionStart(mContentEditText.getText());
    if ((mIsBackspace && position != 1) || mLastPosition == position || !mIsLocalDraft) return;

    if (position < 0) {
      position = 0;
    }
    mLastPosition = position;
    if (position > 0) {
      if (mStyleStart > position) {
        mStyleStart = position - 1;
      }

      boolean shouldBold = mBoldToggleButton.isChecked();
      boolean shouldEm = mEmToggleButton.isChecked();
      boolean shouldUnderline = mUnderlineToggleButton.isChecked();
      boolean shouldStrike = mStrikeToggleButton.isChecked();
      boolean shouldQuote = mBquoteToggleButton.isChecked();

      Object[] allSpans = s.getSpans(mStyleStart, position, Object.class);
      for (Object span : allSpans) {
        if (span instanceof StyleSpan) {
          StyleSpan styleSpan = (StyleSpan) span;
          if (styleSpan.getStyle() == Typeface.BOLD) shouldBold = false;
          else if (styleSpan.getStyle() == Typeface.ITALIC) shouldEm = false;
        } else if (span instanceof WPUnderlineSpan) {
          shouldUnderline = false;
        } else if (span instanceof StrikethroughSpan) {
          shouldStrike = false;
        } else if (span instanceof QuoteSpan) {
          shouldQuote = false;
        }
      }

      if (shouldBold)
        s.setSpan(
            new StyleSpan(android.graphics.Typeface.BOLD),
            mStyleStart,
            position,
            Spannable.SPAN_INCLUSIVE_INCLUSIVE);
      if (shouldEm)
        s.setSpan(
            new StyleSpan(android.graphics.Typeface.ITALIC),
            mStyleStart,
            position,
            Spannable.SPAN_INCLUSIVE_INCLUSIVE);
      if (shouldUnderline)
        s.setSpan(new WPUnderlineSpan(), mStyleStart, position, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
      if (shouldStrike)
        s.setSpan(
            new StrikethroughSpan(), mStyleStart, position, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
      if (shouldQuote)
        s.setSpan(new QuoteSpan(), mStyleStart, position, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    }
  }
 @Override
 protected void onPause() {
   AppPreferences.setAlternativeBoard(altBoard.isChecked());
   AppPreferences.setHideActionBar(hideActionBar.isChecked());
   try {
     AppPreferences.setTimeLimit(Integer.valueOf(timeLimit.getText().toString()));
   } catch (Exception exception) {
     Toast.makeText(this, "Invalid integer string", Toast.LENGTH_SHORT).show();
   }
   super.onPause();
 }
Esempio n. 4
0
 @Override
 protected void onStop() {
   super.onStop();
   SharedPreferences settings = getSharedPreferences(SETTING_INFOS, 0);
   settings
       .edit()
       .putBoolean("tgAutoUploadKey", tgAutoUpload.isChecked())
       .putBoolean("tgAutoUpdateKey", tgAutoUpdate.isChecked())
       .putBoolean("tgAutoFreshAdvWordKey", tgAutoFreshAdvWord.isChecked())
       .commit();
 }
  @Override
  protected void onResume() {
    super.onResume();
    // GPS OR NETWORK????
    // mgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 15000, 1, locationListener);
    // provider, update in milliseconds, update in location change, listener
    // mgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 200, 10, locationListener);

    // TO SEE NETWORK INFO AND STATUS
    // SimpleLocationListener sll = new SimpleLocationListener();
    //        mLocationListeners.add(sll);
    //        mgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5000, 5, sll);
    //
    // TO SEE GPS INFO AND STATUS
    // SimpleLocationListener sll = new SimpleLocationListener();
    // mLocationListeners.add(sll);
    // mgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 10, sll);
    ////        mgr.addGpsStatusListener(gpsStatusListener);

    if (toggleButton.isChecked()) {
      setListener(LocationManager.GPS_PROVIDER);
    } else {
      setListener(LocationManager.NETWORK_PROVIDER);
    }

    // keep screen on!
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "LOCATION TEST");
    wakeLock.acquire();
  }
        public void handleMessage(android.os.Message msg) {
          if (msg.what == EVENT_UPDATE_ARM_STATE) {
            if (mArmStateQueue.size() > 0) {
              mCurrentArmState = mArmStateQueue.remove();
            } else {
              ToggleButton autoModeToggle = (ToggleButton) findViewById(R.id.autoModeToggle);
              // 自動モードならサーチを試みる
              if (autoModeToggle.isChecked() && startAutoGrabAction()) {
                // OK
              }
              // 単に待つ
              else {
                mCurrentArmState = mWaitingArmState;
              }
            }
            if (mCurrentArmState.armStateType == ArmStateType.READY_TO_AUTO_MODE) {
              if (mObjectBundle.detected) {
                float distance =
                    CtkMath.distance(mCurrentArmState.exPosition, mObjectBundle.position);
                // オブジェクトが動いてないなら掴みにかかる
                if (distance <= AUTO_MODE_DIFF) {
                  startGrabAction(false);
                }
              }
            }

            TextView armStateText = (TextView) findViewById(R.id.armStateText);
            armStateText.setText(mCurrentArmState.armStateType.name());
            this.sendEmptyMessageDelayed(EVENT_UPDATE_ARM_STATE, mCurrentArmState.time);

            sendValues(mCurrentArmState.armAngles);
          }
        };
Esempio n. 7
0
    private void toggleWifiRepeater(final ToggleButton button) {
        startBlinkingImage((ImageView) findViewById(R.id.wifiRepeaterArrow));
        if (button.isChecked()) {
            final File flagFile = new File("/data/data/fq.router2/etc/wifi-repeater-risk-notified");
            if (flagFile.exists()) {
                startWifiRepater();
            } else {
                new AlertDialog.Builder(this)
                        .setIcon(android.R.drawable.ic_dialog_alert)
                        .setTitle(R.string.wifi_repeater_risk_alert_title)
                        .setMessage(R.string.wifi_repeater_risk_alert_message)
                        .setPositiveButton(R.string.wifi_repeater_risk_alert_ok, new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                IOUtils.writeToFile(flagFile, "OK");
                                startWifiRepater();
                                button.setChecked(true);
                            }

                        })
                        .setNegativeButton(R.string.wifi_repeater_risk_alert_cancel, null)
                        .show();
                button.setChecked(false);
            }
        } else {
            startBlinkingStatus(_(R.string.status_wifi_repeater_stopping));
            disableWifiRepeaterButton();
            StopWifiRepeaterService.execute(this);
        }
    }
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
          if (!fromUser) return;

          equalizer[0] = progress - 20;
          if (libVlc != null && button.isChecked()) libVlc.setEqualizer(equalizer);
        }
Esempio n. 9
0
  @Override
  public void onClick(View view) {
    switch (view.getId()) {
      case R.id.clickmeButton:
        String check = InputText.getText().toString();
        if (check.contentEquals("left")) {
          ashusText.setGravity(Gravity.LEFT);
          ashusText.setText("left");

        } else if (check.contentEquals("center")) {
          ashusText.setGravity(Gravity.CENTER);
          ashusText.setText("center");

        } else if (check.contentEquals("right")) {
          ashusText.setGravity(Gravity.RIGHT);
          ashusText.setText("right");

        } else if (check.contentEquals("blue")) {
          ashusText.setBackgroundColor(Color.BLUE);
        } else if (check.contains("ASHU")) {
          Random crazy = new Random();
          ashusText.setText("ASHU!!!!");
          ashusText.setTextSize(crazy.nextInt(75)); // //75 Random chocies for Text.////
          ashusText.setTextColor(
              Color.rgb(crazy.nextInt(265), crazy.nextInt(265), crazy.nextInt(265)));

          switch (crazy.nextInt(3)) // ///There 3 cases only////
          {
            case 0:
              ashusText.setGravity(Gravity.LEFT);
              break;
            case 1:
              ashusText.setGravity(Gravity.CENTER);

              break;
            case 2:
              ashusText.setGravity(Gravity.RIGHT);

              break;
          }

        } else {
          ashusText.setText("Invalid");
          ashusText.setGravity(Gravity.CENTER);
          ashusText.setTextColor(Color.RED);
        }
        break;

      case R.id.toggleButton:
        if (toggleButton.isChecked()) {
          InputText.setInputType(
              InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

        } else {
          InputText.setInputType(InputType.TYPE_CLASS_TEXT);
        }

        break;
    }
  }
Esempio n. 10
0
  /**
   * Function that depends the serviceToggleButton state try to start the QuiteSleep incoming call
   * service or stop it.
   */
  private void startStopServiceProcess() {

    try {

      boolean result =
          StartStopServicesOperations.startStopQuiteSleepService(serviceToggleButton.isChecked());

      if (serviceToggleButton.isChecked()) {

        /* Deactivate the notification toast because now use the
         * status bar notification
         */
        /*
        if (result)

        	//All right, start the service was ok!
        	Toast.makeText(
                     		this,
                     		this.getString(
                     				R.string.settings_toast_start_service),
                     		Toast.LENGTH_SHORT).show();

        else
        	//An error has ocurred!!
        	Toast.makeText(
                     		this,
                     		this.getString(
                     				R.string.settings_toast_fail_service),
                     		Toast.LENGTH_SHORT).show();
                */
      } else {
        if (result)
          // All right, stop the service was ok!
          if (QSToast.RELEASE)
            QSToast.r(
                this, this.getString(R.string.settings_toast_stop_service), Toast.LENGTH_SHORT);
          else
          // An error has ocurred!!
          if (QSToast.RELEASE)
            QSToast.r(
                this, this.getString(R.string.settings_toast_fail_service), Toast.LENGTH_SHORT);
      }
    } catch (Exception e) {
      if (QSLog.DEBUG_E)
        QSLog.e(CLASS_NAME, ExceptionUtils.exceptionTraceToString(e.toString(), e.getStackTrace()));
    }
  }
Esempio n. 11
0
  /**
   * In HTML mode, applies formatting to selected text, or inserts formatting tag at current cursor
   * position
   *
   * @param toggleButton format bar button which was clicked
   * @param tag identifier tag
   */
  private void applyFormattingHtmlMode(ToggleButton toggleButton, String tag) {
    if (mSourceViewContent == null) {
      return;
    }

    // Replace style tags with their proper HTML tags
    String htmlTag;
    if (tag.equals(getString(R.string.format_bar_tag_bold))) {
      htmlTag = "b";
    } else if (tag.equals(getString(R.string.format_bar_tag_italic))) {
      htmlTag = "i";
    } else if (tag.equals(getString(R.string.format_bar_tag_strikethrough))) {
      htmlTag = "del";
    } else if (tag.equals(getString(R.string.format_bar_tag_unorderedList))) {
      htmlTag = "ul";
    } else if (tag.equals(getString(R.string.format_bar_tag_orderedList))) {
      htmlTag = "ol";
    } else {
      htmlTag = tag;
    }

    int selectionStart = mSourceViewContent.getSelectionStart();
    int selectionEnd = mSourceViewContent.getSelectionEnd();

    if (selectionStart > selectionEnd) {
      int temp = selectionEnd;
      selectionEnd = selectionStart;
      selectionStart = temp;
    }

    boolean textIsSelected = selectionEnd > selectionStart;

    String startTag = "<" + htmlTag + ">";
    String endTag = "</" + htmlTag + ">";

    // Add li tags together with ul and ol tags
    if (htmlTag.equals("ul") || htmlTag.equals("ol")) {
      startTag = startTag + "\n\t<li>";
      endTag = "</li>\n" + endTag;
    }

    Editable content = mSourceViewContent.getText();
    if (textIsSelected) {
      // Surround selected text with opening and closing tags
      content.insert(selectionStart, startTag);
      content.insert(selectionEnd + startTag.length(), endTag);
      toggleButton.setChecked(false);
      mSourceViewContent.setSelection(selectionEnd + startTag.length() + endTag.length());
    } else if (toggleButton.isChecked()) {
      // Insert opening tag
      content.insert(selectionStart, startTag);
      mSourceViewContent.setSelection(selectionEnd + startTag.length());
    } else {
      // Insert closing tag
      content.insert(selectionEnd, endTag);
      mSourceViewContent.setSelection(selectionEnd + endTag.length());
    }
  }
Esempio n. 12
0
 public void checkButton(ToggleButton personale) {
   if (personale.isChecked()) {
     personale.setBackgroundResource(R.layout.acceso);
     personale.setText("Acceso");
   } else {
     personale.setBackgroundResource(R.layout.spento);
     personale.setText("Spento");
   }
 }
Esempio n. 13
0
 private void storeUserAccountInfo(final String userNo, final String pwd) {
   boolean isRemeberPwd = mRememberPwdToggleBtn.isChecked();
   UserAccountManager.storeUserAccount(this, userNo, isRemeberPwd ? pwd : "");
   PreferenceUtil.putBoolean(
       this,
       Constants.PREF.NAME_LONGIN_INFO,
       Constants.PREF.KEY_LONGIN_INFO_IS_REMEMBER_PWD,
       isRemeberPwd);
 }
Esempio n. 14
0
 public void checkButtonAlarm(ToggleButton personale, String log) {
   if (personale.isChecked()) {
     personale.setBackgroundResource(R.layout.rosso);
     personale.setText(log);
   } else {
     personale.setBackgroundResource(R.layout.acceso);
     personale.setText(log);
   }
 }
Esempio n. 15
0
  public void saveData() {
    m_new_video_config = (NetSDK_Media_Video_Config) m_video_config.clone();
    m_new_video_config.capture.HFlip = m_tb_h_flip.isChecked() ? "1" : "0";
    m_new_video_config.capture.VFlip = m_tb_v_flip.isChecked() ? "1" : "0";
    m_new_video_config.addHead(false);
    String xml = m_new_video_config.getCaptureXMLString();
    int ret = FunclibAgent.getInstance().SetP2PDevConfig(m_device_id, 524, xml);
    if (0 != ret) {
      toast(R.string.dlg_set_video_capture_param_fail_tip);
      return;
    }

    mTipDlg.setCallback(null);
    showTipDlg(
        R.string.dlg_set_video_capture_param_tip,
        20000,
        R.string.dlg_set_video_capture_param_timeout_tip);
  }
 public void toggleLocationProvider(View v) {
   if (toggleButton.isChecked()) {
     setListener(LocationManager.GPS_PROVIDER);
     showCurrentLocation(LocationManager.GPS_PROVIDER);
   } else {
     setListener(LocationManager.NETWORK_PROVIDER);
     showCurrentLocation(LocationManager.NETWORK_PROVIDER);
   }
 }
 private void stopScreenSharing() {
   if (mToggle.isChecked()) {
     mToggle.setChecked(false);
   }
   mScreenSharing = false;
   if (mVirtualDisplay != null) {
     mVirtualDisplay.release();
     mVirtualDisplay = null;
   }
 }
Esempio n. 18
0
  public void onSyncToggleClicked(View view) {
    // Check if the toggle button is on.
    ToggleButton button = (ToggleButton) view;
    boolean on = button.isChecked();

    if (on) {
      drops.start();
    } else {
      drops.stop();
    }
  }
Esempio n. 19
0
 private void setCategoryType(Category category) {
   if (category.getParentId() > 0) {
     category.copyTypeFromParent();
   } else {
     if (incomeExpenseButton.isChecked()) {
       category.makeThisCategoryIncome();
     } else {
       category.makeThisCategoryExpense();
     }
   }
 }
 @Override
 public void onClick(View view) {
   if (view instanceof ToggleButton) {
     ToggleButton toggleButton = (ToggleButton) view;
     int position = (Integer) toggleButton.getTag();
     if (dataList != null && mOnItemClickListener != null && position < dataList.size()) {
       mOnItemClickListener.onItemClick(
           toggleButton, position, toggleButton.isChecked(), chooseBt);
     }
   }
 }
Esempio n. 21
0
 private void toggleFreeInternet(ToggleButton button) {
     startBlinkingImage((ImageView) findViewById(R.id.freeInternetArrow));
     if (button.isChecked()) {
         startBlinkingStatus(_(R.string.status_free_internet_connecting));
         disableFreeInternetButton();
         ConnectFreeInternetService.execute(this);
     } else {
         startBlinkingStatus(_(R.string.status_free_internet_disconnecting));
         disableFreeInternetButton();
         DisconnectFreeInternetService.execute(this);
     }
 }
Esempio n. 22
0
 public void catClicked(View view) {
   if (mute.isChecked()) {
     // Don't Do anything
     isMute = true;
   } else {
     isMute = false;
     int randNum = (int) (Math.random() * 3);
     playSound(randNum);
     Log.e("number", randNum + "");
     Log.e("cat", "sound");
   }
 }
Esempio n. 23
0
  public void onToggleClicked(View view) {
    // Is the toggle on?
    ToggleButton tb = (ToggleButton) view;
    boolean on = tb.isChecked();

    if (on) {
      // Enable vibrate
      consegnato = "1";
    } else {
      // Disable vibrate
      consegnato = "0";
    }
  }
  @Override
  public void onClick(View v) {

    if (v == Cat) {
      Cat.setChecked(true);
      Marque.setChecked(false);
      Tout.setChecked(false);
      String filtrage = EtFiltrage.getText().toString();
      filtreSelonSaisieEtBtActive(filtrage, Cat.isChecked(), Marque.isChecked(), Tout.isChecked());
      // produitRecherche.removeAll(produitRecherche);
      // produitRechercheTitre.removeAll(produitRechercheTitre);
      // AfficheLeContenu("TitreCat", produitRechercheTitre,
      // ProduitListViewTitre, null);
      // AfficheLeContenu("Catégorie", produitRecherche, ProduitListView1,
      // null);
    }
    if (v == Marque) {
      Cat.setChecked(false);
      Marque.setChecked(true);
      Tout.setChecked(false);
      String filtrage = EtFiltrage.getText().toString();
      filtreSelonSaisieEtBtActive(filtrage, Cat.isChecked(), Marque.isChecked(), Tout.isChecked());
      // produitRecherche.removeAll(produitRecherche);
      // produitRechercheTitre.removeAll(produitRechercheTitre);
      // AfficheLeContenu("TitreMarque", produitRechercheTitre,
      // ProduitListViewTitre, null);
      // AfficheLeContenu("Marque", produitRecherche, ProduitListView1,
      // null);
    }
    if (v == Tout) {
      Cat.setChecked(false);
      Marque.setChecked(false);
      Tout.setChecked(true);
      String filtrage = EtFiltrage.getText().toString();
      filtreSelonSaisieEtBtActive(filtrage, Cat.isChecked(), Marque.isChecked(), Tout.isChecked());
      // produitRecherche.removeAll(produitRecherche);
      // produitRechercheTitre.removeAll(produitRechercheTitre);
      // AfficheLeContenu("TitreTout", produitRechercheTitre,
      // ProduitListViewTitre, null);
      // AfficheLeContenu("Tout", produitRecherche, ProduitListView1,
      // null);
    }
  }
Esempio n. 25
0
 /**
  * Event handler for clicking the Go! button.
  *
  * @param view
  */
 public void goSearch(View view) {
   Toast.makeText(Parameters.this, "Looking for results...", Toast.LENGTH_LONG).show();
   EditText zipCodeView = (EditText) findViewById(R.id.zipCode);
   EditText whatView = (EditText) findViewById(R.id.what);
   ToggleButton sortButton = (ToggleButton) findViewById(R.id.sortButton);
   String zipCode = zipCodeView.getText().toString();
   String what = whatView.getText().toString();
   Intent i = new Intent(this, List.class);
   i.putExtra("category", category);
   i.putExtra("zipCode", zipCode);
   i.putExtra("what", what);
   i.putExtra("sort", sortButton.isChecked());
   startActivity(i);
 }
  private void saveUserLocally() {
    AppUser newAppUser =
        new AppUser(
            mYourFullNameEdit.getText().toString(),
            mYourEmailAddressEdit.getText().toString(),
            mYourPasswordEdit.getText().toString(),
            getCompressedDOB(),
            "United Kingdom");

    newAppUser = mCycleDatabase.addAppUser(newAppUser);

    UserSettings newUserSettings =
        new UserSettings(
            newAppUser.getmAppUserId(),
            mFertilityTestingToggle.isChecked(),
            mPregnancyTestingToggle.isChecked(),
            mRemindersToggle.isChecked(),
            Integer.parseInt(mAvgCycleLength.getText().toString()),
            Integer.parseInt(mAvgPeriodLengthEdit.getText().toString()),
            14,
            Integer.parseInt(mAvgCycleLength.getText().toString()),
            14,
            13,
            mCloudBackupToggle.isChecked());

    newUserSettings = mCycleDatabase.addUserSettings(newUserSettings);

    UserData.mCurrentUser = newAppUser;
    UserData.mCurrentUserSettings = newUserSettings;

    mCycleDatabase.updateRememberedUserId(0);

    Intent i = new Intent(SignupActivity.this, CalendarMonthsActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(i);
    finish();
  }
  /**
   * Gets status of each day selection button and returns an arraylist of '{@link Day}'s
   *
   * @return ArrayList of type '{@link Day}'
   * @see Day
   */
  private ArrayList<Day> getDays() {
    ArrayList<Day> results = new ArrayList<>();

    if (sundayToggleButton.isChecked()) results.add(Day.valueOf("SU"));
    if (mondayToggleButton.isChecked()) results.add(Day.valueOf("M"));
    if (tuesdayToggleButton.isChecked()) results.add(Day.valueOf("TU"));
    if (wednesdayToggleButton.isChecked()) results.add(Day.valueOf("W"));
    if (thursdayToggleButton.isChecked()) results.add(Day.valueOf("TH"));
    if (fridayToggleButton.isChecked()) results.add(Day.valueOf("F"));
    if (saturdayToggleButton.isChecked()) results.add(Day.valueOf("SA"));

    return results;
  }
  @Override
  public void onPause() {
    super.onPause();
    button.setOnCheckedChangeListener(null);
    equalizer_presets.setOnItemSelectedListener(null);
    preamp.setOnSeekBarChangeListener(null);
    bands_layout.removeAllViews();

    SharedPreferences preferences =
        PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
    SharedPreferences.Editor editor = preferences.edit();
    editor.putBoolean("equalizer_enabled", button.isChecked());
    Preferences.putFloatArray(editor, "equalizer_values", equalizer);
    editor.putInt("equalizer_preset", equalizer_presets.getSelectedItemPosition());
    editor.commit();
  }
Esempio n. 29
0
  /////////////////////////////////////////////////////////
  // 요일 설정버튼의 값을 가져와서 Profile.week에 들어갈 값을 작성한다.
  // 형식은 mon|tue|fri와 같은 토큰 구별 방식이다.
  /////////////////////////////////////////////////////////
  String getWeekDayString() {
    String ret = "";

    // 체크되어있을때마다 추가
    if (mon.isChecked()) ret += "mon|";
    if (tue.isChecked()) ret += "tue|";
    if (wed.isChecked()) ret += "wed|";
    if (thu.isChecked()) ret += "thu|";
    if (fri.isChecked()) ret += "fri|";
    if (sat.isChecked()) ret += "sat|";
    if (sun.isChecked()) ret += "sun|";

    return ret;
  }
Esempio n. 30
0
  @Override
  public void onSensorChanged(SensorEvent event) {

    _sensorXtxt.setText(getString(R.string.sensorX, event.values[0]));
    _sensorYtxt.setText(getString(R.string.sensorY, event.values[1]));
    _sensorZtxt.setText(getString(R.string.sensorZ, event.values[2]));

    boolean hasChanged = false;
    boolean hasDirChanged = false;
    double newSpeedValue = (Math.max(-7.4, Math.min(7.4, event.values[0]))) / 7f * 0x0F;
    if (Math.abs(newSpeedValue - _previousSpeed) > NOISE) {
      _currentSpeed = (byte) (Math.floor(Math.abs(newSpeedValue)));
      hasDirChanged |= _previousSpeed < 0 && newSpeedValue > 0;
      hasDirChanged |= newSpeedValue < 0 && _previousSpeed > 0;
      _previousSpeed = newSpeedValue;
      _speedtxt.setText(getString(R.string.speedTxt, getString(speedTxtIdForSpeed())));
      hasChanged |= true;
    }

    double newDirectionValue = event.values[1];
    if (Math.abs(newDirectionValue - _previousDirection) > NOISE || hasDirChanged) {
      if (newSpeedValue >= 0)
        if (Math.abs(newDirectionValue) < 1) _currentDirection = DaguCarCommands.NORTH;
        else if (newDirectionValue < 0) _currentDirection = DaguCarCommands.NORTHEAST;
        else _currentDirection = DaguCarCommands.NORTHWEST;
      else if (newSpeedValue <= 0)
        if (Math.abs(newDirectionValue) < 1) _currentDirection = DaguCarCommands.SOUTH;
        else if (newDirectionValue < 0) _currentDirection = DaguCarCommands.SOUTHEAST;
        else _currentDirection = DaguCarCommands.SOUTHWEST;

      _previousDirection = newDirectionValue;
      _directiontxt.setText(getString(R.string.directionTxt, getDirectionTxt()));
      hasChanged |= true;
    }

    if (hasChanged && _toggleSensor.isChecked()) {
      if (D)
        Log.i(
            TAG,
            "Sensor changed command with speed: " + _currentSpeed + "/dir: " + _currentDirection);
      byte commandByte = DaguCarCommands.CreateCommand(_currentDirection, _currentSpeed);
      _commandtxt.setText(getString(R.string.commandTxt, String.format("%#x", commandByte)));
      if (_chatService != null && _chatService.getState() == BluetoothChatService.STATE_CONNECTED)
        sendMessage(commandByte);
    } else if (hasChanged)
      _commandtxt.setText(getString(R.string.commandTxt, getString(R.string.commandDisabled)));
  }