コード例 #1
0
  private void updateTextDataUI() {

    if (!mIsTimestampDisplayMode) {
      if (mDataBufferLastSize != mDataBuffer.size()) {

        final int bufferSize = mDataBuffer.size();
        if (bufferSize > maxPacketsToPaintAsText) {
          mDataBufferLastSize = bufferSize - maxPacketsToPaintAsText;
          mTextSpanBuffer.clear();
          addTextToSpanBuffer(
              mTextSpanBuffer, getString(R.string.uart_text_dataomitted) + "\n", mInfoColor);
        }

        // Log.d(TAG, "update packets: "+(bufferSize-mDataBufferLastSize));
        for (int i = mDataBufferLastSize; i < bufferSize; i++) {
          final UartDataChunk dataChunk = mDataBuffer.get(i);
          final boolean isRX = dataChunk.getMode() == UartDataChunk.TRANSFERMODE_RX;
          final String data = dataChunk.getData();
          final String formattedData = mShowDataInHexFormat ? asciiToHex(data) : data;
          addTextToSpanBuffer(mTextSpanBuffer, formattedData, isRX ? mRxColor : mTxColor);
        }

        mDataBufferLastSize = mDataBuffer.size();
        mBufferTextView.setText(mTextSpanBuffer);
        mBufferTextView.setSelection(
            0, mTextSpanBuffer.length()); // to automatically scroll to the end
      }
    }
  }
コード例 #2
0
  private void recreateDataView() {

    if (mIsTimestampDisplayMode) {
      mBufferListAdapter.clear();

      final int bufferSize = mDataBuffer.size();
      for (int i = 0; i < bufferSize; i++) {

        final UartDataChunk dataChunk = mDataBuffer.get(i);
        final boolean isRX = dataChunk.getMode() == UartDataChunk.TRANSFERMODE_RX;
        final String data = dataChunk.getData();
        final String formattedData = mShowDataInHexFormat ? asciiToHex(data) : data;

        final String currentDateTimeString =
            DateFormat.getTimeInstance().format(new Date(dataChunk.getTimestamp()));
        mBufferListAdapter.add(
            new TimestampData(
                "[" + currentDateTimeString + "] " + (isRX ? "RX" : "TX") + ": " + formattedData,
                isRX ? mRxColor : mTxColor));
        //                mBufferListAdapter.add("[" + currentDateTimeString + "] " + (isRX ? "RX" :
        // "TX") + ": " + formattedData);
      }
      mBufferListView.setSelection(mBufferListAdapter.getCount());
    } else {
      mDataBufferLastSize = 0;
      mTextSpanBuffer.clear();
      mBufferTextView.setText("");
    }
  }
コード例 #3
0
 public void reset() {
   mCombinedText.setLength(0);
   mStateFeedback.clear();
   for (final Combiner c : mCombiners) {
     c.reset();
   }
 }
コード例 #4
0
  public void onClickClear(View view) {
    mTextSpanBuffer.clear();
    mDataBufferLastSize = 0;
    mBufferListAdapter.clear();
    mBufferTextView.setText("");

    mDataBuffer.clear();
    mSentBytes = 0;
    mReceivedBytes = 0;
    updateUI();
  }
コード例 #5
0
ファイル: CustomEditText.java プロジェクト: hemantgo/OLX_App
 private void updateErrorText() {
   mErrorText.clear();
   mErrorText.clearSpans();
   final int length = mTextInputLayout.getEditText().length();
   if (length > 0) {
     mErrorText.append(String.valueOf(length));
     mErrorText.append(" / ");
     mErrorText.append(String.valueOf(mMaxLen));
     mErrorText.setSpan(
         mAlignmentSpan, 0, mErrorText.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
     if (hasValidLength()) {
       mErrorText.setSpan(
           mNormalTextAppearance, 0, mErrorText.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
     }
   }
   mTextInputLayout.setError(mErrorText);
 }
  /**
   * Format the given phone number using {@link PhoneNumberUtils#formatNumber(android.text.Editable,
   * int)}. This helper method uses {@link #sEditable} and {@link #sFormattingType} to prevent
   * allocations between multiple calls.
   *
   * <p>Because of the shared {@link #sEditable} builder, <b>this method is not thread safe</b>, and
   * should only be called from the GUI thread.
   *
   * <p>If the given String object is null or empty, return an empty String.
   */
  private String formatPhoneNumber(String number) {
    if (TextUtils.isEmpty(number)) {
      return "";
    }

    // If "number" is really a SIP address, don't try to do any formatting at all.
    if (PhoneNumberUtils.isUriNumber(number)) {
      return number;
    }

    // Cache formatting type if not already present
    if (sFormattingType == FORMATTING_TYPE_INVALID) {
      sFormattingType = PhoneNumberUtils.getFormatTypeForLocale(Locale.getDefault());
    }

    sEditable.clear();
    sEditable.append(number);

    PhoneNumberUtils.formatNumber(sEditable, sFormattingType);
    return sEditable.toString();
  }
コード例 #7
0
 private void clearLog() {
   log.clear();
   if (logView != null) {
     logView.setText("");
   }
 }
コード例 #8
0
 private void updateStateFeedback() {
   mStateFeedback.clear();
   for (int i = mCombiners.size() - 1; i >= 0; --i) {
     mStateFeedback.append(mCombiners.get(i).getCombiningStateFeedback());
   }
 }
コード例 #9
0
  /** Constructor */
  public TutorialJAJP(OpenWnnJAJP ime, View inputView, DefaultSoftKeyboardJAJP inputManager) {
    mInputManager = inputManager;
    mInputView = inputView;
    mIme = ime;

    Context context = inputView.getContext();
    int inputWidth = inputView.getWidth();
    Resources r = inputView.getContext().getResources();
    final int x = inputWidth / 20;
    r.getDimensionPixelOffset(R.dimen.bubble_pointer_offset);

    SpannableStringBuilder spannable = new SpannableStringBuilder();
    Bubble button;

    spannable.clear();
    spannable.append(r.getText(R.string.tip_to_step1));

    setSpan(spannable, "\u25cb", R.drawable.tutorial_12key_key);
    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble,
            x,
            0,
            spannable,
            R.string.touch_to_continue,
            false);
    mBubbles.add(button);

    spannable.clear();
    spannable.append(r.getText(R.string.tip_to_step2_a));

    setSpan(spannable, "\u25cb", R.drawable.tutorial_12key_toggle);
    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble,
            x,
            0,
            spannable,
            R.string.touch_to_continue,
            true);
    mBubbles.add(button);

    spannable.append(r.getText(R.string.tip_to_step2_b));

    setSpan(spannable, "\u2192", R.drawable.tutorial_12key_right);

    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble,
            x,
            0,
            spannable,
            R.string.touch_to_continue,
            true);
    mBubbles.add(button);

    spannable.append(r.getText(R.string.tip_to_step2_c));

    setSpan(spannable, "\u25cb", R.drawable.tutorial_12key_toggle);

    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble,
            x,
            0,
            spannable,
            R.string.touch_to_continue,
            true);
    mBubbles.add(button);

    spannable.append(r.getText(R.string.tip_to_step2_d));

    setSpan(spannable, "\u25a0", R.drawable.tutorial_12key_space_jp);

    setSpan(spannable, "\u2193", R.drawable.tutorial_12key_enter);

    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble,
            x,
            0,
            spannable,
            R.string.touch_to_continue,
            true);
    mBubbles.add(button);

    spannable.clear();
    spannable.append(r.getText(R.string.tip_to_step3_a));

    setSpan(spannable, "\u25a0", R.drawable.tutorial_12key_mode);
    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble_moji,
            x,
            0,
            spannable,
            R.string.touch_to_continue,
            false);
    mBubbles.add(button);

    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble_moji,
            x,
            0,
            R.string.tip_to_step3_b,
            R.string.touch_to_continue);
    mBubbles.add(button);

    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble_moji,
            x,
            0,
            R.string.tip_to_step3_c,
            R.string.touch_to_continue);
    mBubbles.add(button);

    spannable.clear();
    spannable.append(r.getText(R.string.tip_to_step4));

    setSpan(spannable, "\u25a0", R.drawable.tutorial_12key_mode);
    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble_moji,
            x,
            0,
            spannable,
            R.string.touch_to_try,
            false);
    mBubbles.add(button);

    spannable.clear();
    spannable.append(r.getText(R.string.tip_to_step5));

    setSpan(spannable, "\u2190", R.drawable.tutorial_back);

    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble,
            x,
            0,
            spannable,
            R.string.touch_to_continue,
            false);
    mBubbles.add(button);

    button =
        new Bubble(
            context,
            inputView,
            R.drawable.dialog_bubble,
            x,
            0,
            R.string.tip_to_step6,
            R.string.touch_to_finish);
    mBubbles.add(button);
  }