/** @return current time */
  private long refreshNow() {
    if (MusicUtils.mService == null) return 500;
    try {
      long pos = mPosOverride < 0 ? MusicUtils.mService.position() : mPosOverride;
      long remaining = 1000 - (pos % 1000);
      if ((pos >= 0) && (mDuration > 0)) {
        mCurrentTime.setText(MusicUtils.makeTimeString(getActivity(), pos / 1000));

        if (MusicUtils.mService.isPlaying()) {
          mCurrentTime.setVisibility(View.VISIBLE);
          mCurrentTime.setTextColor(getResources().getColor(R.color.transparent_black));
        } else {
          // blink the counter
          int col = mCurrentTime.getCurrentTextColor();
          mCurrentTime.setTextColor(
              col == getResources().getColor(R.color.transparent_black)
                  ? getResources().getColor(R.color.holo_blue_dark)
                  : getResources().getColor(R.color.transparent_black));
          remaining = 500;
        }

        mProgress.setProgress((int) (1000 * pos / mDuration));
      } else {
        mCurrentTime.setText("--:--");
        mProgress.setProgress(1000);
      }
      return remaining;
    } catch (RemoteException ex) {
      ex.printStackTrace();
    }
    return 500;
  }
コード例 #2
0
    @Override
    public void inflate(LayoutInflater inflater, ViewGroup navDrawerView) {
      ViewGroup container = (ViewGroup) navDrawerView.findViewById(containerId);
      if (container == null)
        throw new RuntimeException(
            "Nav drawer item " + text + " could not be attached to ViewGroup. View not found.");
      //            The root View of the inflated hierarchy.
      // If root was supplied, this is the root View;
      // otherwise it is the root of the inflated XML file.
      //          这个方法,如果root View提供了,返回的就是root view。如果root没有提供,返回的才是xml的根view。
      //            view = inflater.inflate(R.layout.list_item_nav_drawer, container);
      view = inflater.inflate(R.layout.list_item_nav_drawer, container, false);
      container.addView(view);

      view.setOnClickListener(this);

      icon = (ImageView) view.findViewById(R.id.list_item_nav_drawer_icon);
      textView = (TextView) view.findViewById(R.id.list_item_nav_drawer_text);
      badgeTextView = (TextView) view.findViewById(R.id.list_item_nav_drawer_badge);
      defaultTextColor = textView.getCurrentTextColor();

      icon.setImageResource(iconDrawabel);
      textView.setText(text);
      if (badge != null) {
        badgeTextView.setText(badge);
      } else {
        badgeTextView.setVisibility(View.GONE);
      }
    }
コード例 #3
0
 private void captureValues(TransitionValues transitionValues) {
   if (transitionValues.view instanceof TextView) {
     TextView textview = (TextView) transitionValues.view;
     transitionValues.values.put(PROPNAME_TEXT, textview.getText());
     if (textview instanceof EditText) {
       transitionValues.values.put(PROPNAME_TEXT_SELECTION_START, textview.getSelectionStart());
       transitionValues.values.put(PROPNAME_TEXT_SELECTION_END, textview.getSelectionEnd());
     }
     if (mChangeBehavior > CHANGE_BEHAVIOR_KEEP) {
       transitionValues.values.put(PROPNAME_TEXT_COLOR, textview.getCurrentTextColor());
     }
   }
 }
コード例 #4
0
  public void updateTotal() {
    mTotalWeeklyClasses = 0;
    mTotalDelays = 0;

    for (SubjectCard materia : mSubjectCards) {
      mTotalWeeklyClasses += materia.getData().getWeeklyClasses();
      mTotalDelays += materia.getData().getDelays();
    }

    if ((int) (2 * Math.ceil((float) 0.10f * 16 * mTotalWeeklyClasses)) - mTotalDelays
        <= 0.2f * (int) Math.ceil((float) 0.10f * 16 * mTotalWeeklyClasses)) {
      if (mTotalAbsencesTextView.getCurrentTextColor() != Color.RED) {
        AnimatorCreationUtil.ofTextColor(mTotalAbsencesTextView, 300, Color.RED).start();
      }
    } else if (mTotalAbsencesTextView.getCurrentTextColor() != Color.DKGRAY) {
      AnimatorCreationUtil.ofTextColor(mTotalAbsencesTextView, 300, Color.DKGRAY).start();
    }

    mTotalAbsencesTextView.setText(
        "Total: "
            + (float) mTotalDelays / 2
            + "/"
            + ((int) Math.ceil((float) 0.10f * 16 * mTotalWeeklyClasses)));
  }
コード例 #5
0
ファイル: MainActivity.java プロジェクト: jsimpson66/Podax
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      boolean isHeader = getItemViewType(position) == HEADER;
      int layoutId = isHeader ? R.layout.drawer_header_listitem : R.layout.drawer_listitem;
      if (convertView == null) convertView = LayoutInflater.from(_context).inflate(layoutId, null);
      if (convertView == null) return null;

      TextView tv = (TextView) convertView;
      if (_defaultTextColor == 0) _defaultTextColor = tv.getCurrentTextColor();

      final Item item = _items[position];
      tv.setText(item.label);
      tv.setCompoundDrawablesWithIntrinsicBounds(item.drawable, 0, 0, 0);
      return tv;
    }
コード例 #6
0
  public int captureBitmapCache(String in) {
    TextView tv = (TextView) MyApp.context.findViewById(R.id.ocrTextview);
    String tvText = tv.getText().toString();
    float tvTextSize = tv.getTextSize();
    int tvColor = tv.getCurrentTextColor();
    Bitmap bitmap = null;

    tv.setTextSize(36);
    tv.setTextColor(Color.CYAN);
    tv.setTypeface(Typeface.SANS_SERIF);

    tv.setText(in);

    while (bitmap == null) {
      // http://stackoverflow.com/questions/2339429/android-view-getdrawingcache-returns-null-only-null
      tv.measure(
          MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
          MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
      tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());

      tv.setDrawingCacheEnabled(true);
      tv.buildDrawingCache(true);
      bitmap = Bitmap.createBitmap(tv.getDrawingCache());
      tv.destroyDrawingCache();
      tv.setDrawingCacheEnabled(false);
    }

    FileOutputStream fos = null;
    int res = -1;
    try {
      fos = new FileOutputStream(currentDirectory() + "/files/" + MyApp.SCREENSHOT_FILENAME);
      if (fos != null) {
        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos);
        fos.close();
        res = 0;
      }
    } catch (Throwable e) {
      Log.i(MyApp.TAG, e.getMessage().toString());
      res = -1;
    }

    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, tvTextSize);
    tv.setTypeface(Typeface.MONOSPACE);
    tv.setText(tvText);
    tv.setTextColor(tvColor);
    return res;
  }
コード例 #7
0
ファイル: DrawerAdapter.java プロジェクト: rascyber/Plumble
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    int viewType = getItemViewType(position);
    if (v == null) {
      if (viewType == HEADER_TYPE)
        v = LayoutInflater.from(getContext()).inflate(R.layout.list_drawer_header, null, false);
      else if (viewType == ITEM_TYPE)
        v = LayoutInflater.from(getContext()).inflate(R.layout.list_drawer_item, null, false);
    }

    if (viewType == HEADER_TYPE) {
      DrawerHeader header = (DrawerHeader) getItem(position);
      TextView title = (TextView) v.findViewById(R.id.drawer_header_title);

      switch ((int) getItemId(position)) {
        case HEADER_CONNECTED_SERVER:
          if (mProvider.isConnected()) {
            title.setText(mProvider.getConnectedServerName());
            break;
          }
        default:
          title.setText(header.title);
          break;
      }
    } else if (viewType == ITEM_TYPE) {
      DrawerItem item = (DrawerItem) getItem(position);
      TextView title = (TextView) v.findViewById(R.id.drawer_item_title);
      ImageView icon = (ImageView) v.findViewById(R.id.drawer_item_icon);
      title.setText(item.title);
      icon.setImageResource(item.icon);

      boolean enabled = isEnabled(position);

      // Set text and icon color+alpha based on enabled/disabled state
      int textColor = title.getCurrentTextColor();
      textColor &= 0x00FFFFFF; // Clear alpha bits
      textColor |=
          enabled
              ? 0xFF000000
              : 0x55000000; // Set alpha bits depending on whether the state is enabled or disabled
      title.setTextColor(textColor);
      icon.setColorFilter(textColor, PorterDuff.Mode.MULTIPLY);
    }

    return v;
  }
コード例 #8
0
ファイル: DoorHanger.java プロジェクト: Antonius32/Pale-Moon
  public void addLink(String label, String url, String delimiter) {
    String title = mTextView.getText().toString();
    SpannableString titleWithLink = new SpannableString(title + delimiter + label);
    URLSpan linkSpan =
        new URLSpan(url) {
          @Override
          public void onClick(View view) {
            Tabs.getInstance().loadUrlInTab(getURL());
          }
        };

    // Prevent text outside the link from flashing when clicked.
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(mTextView.getCurrentTextColor());
    titleWithLink.setSpan(colorSpan, 0, title.length(), 0);

    titleWithLink.setSpan(linkSpan, title.length() + 1, titleWithLink.length(), 0);
    mTextView.setText(titleWithLink);
    mTextView.setMovementMethod(LinkMovementMethod.getInstance());
  }
コード例 #9
0
 private void styleTextView(int position, TextView tv) {
   TiViewProxy rowProxy = (TiViewProxy) this.getItem(position);
   if (fontProperties != null) {
     TiUIHelper.styleText(
         tv,
         fontProperties[TiUIHelper.FONT_FAMILY_POSITION],
         fontProperties[TiUIHelper.FONT_SIZE_POSITION],
         fontProperties[TiUIHelper.FONT_WEIGHT_POSITION],
         fontProperties[TiUIHelper.FONT_STYLE_POSITION]);
   }
   if (!setDefaultTextColor) {
     defaultTextColor = tv.getCurrentTextColor();
     setDefaultTextColor = true;
   }
   if (rowProxy.hasProperty(TiC.PROPERTY_COLOR)) {
     final int color = TiConvert.toColor((String) rowProxy.getProperty(TiC.PROPERTY_COLOR));
     tv.setTextColor(color);
   } else {
     tv.setTextColor(defaultTextColor);
   }
 }
コード例 #10
0
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    assert context != null;

    View view =
        new DialogBuilder(context)
            .setTitle(R.string.permissions_dialog_title)
            .setView(R.layout.dialog_permissions)
            .createSkeletonView();

    // Make title more red
    TextView title = (TextView) view.findViewById(R.id.title);
    title.setTextColor(title.getCurrentTextColor() & 0xFFFF3333 | 0xFF << 16);

    ListView listView = (ListView) view.findViewById(R.id.list);
    mAdapter = new PermissionAdapter(context, new ArrayList<Permission>());
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            PermissionAdapter adapter = (PermissionAdapter) parent.getAdapter();
            Permission item = adapter.getItem(position);

            try {
              startActivity(item.getIntentSettings());
            } catch (ActivityNotFoundException e) {
              int msg = item.getErrorResource();
              if (msg != 0) ToastUtils.showLong(getActivity(), msg);
            }
          }
        });

    return new AlertDialog.Builder(context)
        .setView(view)
        .setNeutralButton(R.string.later, null)
        .create();
  }
コード例 #11
0
    @Override
    public void onClick(View v) {
      TextView tv = (TextView) v;
      String selectedDate = tv.getTag().toString();
      ((TextView) findViewById(R.id.text1)).setTextColor(Color.parseColor("#D7D7D7"));
      ((TextView) findViewById(R.id.text2)).setTextColor(Color.parseColor("#D7D7D7"));
      ((TextView) findViewById(R.id.text3)).setTextColor(Color.parseColor("#D7D7D7"));
      if (!(((TextView) findViewById(R.id.text4)).getCurrentTextColor()
          == Color.parseColor("#FF0000")))
        ((TextView) findViewById(R.id.text4)).setTextColor(Color.parseColor("#D7D7D7"));
      ((TextView) findViewById(R.id.text5)).setTextColor(Color.parseColor("#D7D7D7"));
      ((TextView) findViewById(R.id.text6)).setTextColor(Color.parseColor("#D7D7D7"));
      ((TextView) findViewById(R.id.text7)).setTextColor(Color.parseColor("#D7D7D7"));

      if (!(tv.getCurrentTextColor() == Color.parseColor("#FF0000"))) tv.setTextColor(Color.BLUE);
      Log.e("===selected date", selectedDate);
      mselectedDate = selectedDate;
      getAttendanceWebService(selectedDate);
      //			Toast.makeText(ChildrenTimeTableActivity.this, selectedDate,wind
      // Toast.LENGTH_LONG).show();
      //    getChildTimeTabel(selectedDate);
    }
コード例 #12
0
ファイル: MessageHeader.java プロジェクト: jae-63/k-9
  @Override
  protected void onFinishInflate() {
    mAnsweredIcon = findViewById(R.id.answered);
    mForwardedIcon = findViewById(R.id.forwarded);
    mFromView = (TextView) findViewById(R.id.from);
    mToView = (TextView) findViewById(R.id.to);
    mToLabel = (TextView) findViewById(R.id.to_label);
    mCcView = (TextView) findViewById(R.id.cc);
    mCcLabel = (TextView) findViewById(R.id.cc_label);

    mContactBadge = (QuickContactBadge) findViewById(R.id.contact_badge);

    mSubjectView = (TextView) findViewById(R.id.subject);
    mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view);
    mChip = findViewById(R.id.chip);
    mDateView = (TextView) findViewById(R.id.date);
    mFlagged = (CheckBox) findViewById(R.id.flagged);

    defaultSubjectColor = mSubjectView.getCurrentTextColor();
    mFontSizes.setViewTextSize(mSubjectView, mFontSizes.getMessageViewSubject());
    mFontSizes.setViewTextSize(mDateView, mFontSizes.getMessageViewDate());
    mFontSizes.setViewTextSize(
        mAdditionalHeadersView, mFontSizes.getMessageViewAdditionalHeaders());

    mFontSizes.setViewTextSize(mFromView, mFontSizes.getMessageViewSender());
    mFontSizes.setViewTextSize(mToView, mFontSizes.getMessageViewTo());
    mFontSizes.setViewTextSize(mToLabel, mFontSizes.getMessageViewTo());
    mFontSizes.setViewTextSize(mCcView, mFontSizes.getMessageViewCC());
    mFontSizes.setViewTextSize(mCcLabel, mFontSizes.getMessageViewCC());

    mFromView.setOnClickListener(this);
    mToView.setOnClickListener(this);
    mCcView.setOnClickListener(this);

    mMessageHelper = MessageHelper.getInstance(mContext);

    mSubjectView.setVisibility(VISIBLE);
    hideAdditionalHeaders();
  }
コード例 #13
0
  // Please use run(...) instead
  public static void justify(TextView textView) {
    Paint paint = new Paint();

    String[] blocks;
    float spaceOffset = 0;
    float textWrapWidth = 0;

    int spacesToSpread;
    float wrappedEdgeSpace;
    String block;
    String[] lineAsWords;
    String wrappedLine;
    String smb = "";
    Object[] wrappedObj;

    // Pull widget properties
    paint.setColor(textView.getCurrentTextColor());
    paint.setTypeface(textView.getTypeface());
    paint.setTextSize(textView.getTextSize());

    textWrapWidth = textView.getWidth();
    spaceOffset = paint.measureText(" ");
    blocks = textView.getText().toString().split("((?<=\n)|(?=\n))");

    if (textWrapWidth < 20) {
      return;
    }

    for (int i = 0; i < blocks.length; i++) {
      block = blocks[i];

      if (block.length() == 0) {
        continue;
      } else if (block.equals("\n")) {
        smb += block;
        continue;
      }

      block = block.trim();

      if (block.length() == 0) continue;

      wrappedObj = TextJustifyUtils.createWrappedLine(block, paint, spaceOffset, textWrapWidth);
      wrappedLine = ((String) wrappedObj[0]);
      wrappedEdgeSpace = (Float) wrappedObj[1];
      lineAsWords = wrappedLine.split(" ");
      spacesToSpread =
          (int) (wrappedEdgeSpace != Float.MIN_VALUE ? wrappedEdgeSpace / spaceOffset : 0);

      for (String word : lineAsWords) {
        smb += word + " ";

        if (--spacesToSpread > 0) {
          smb += " ";
        }
      }

      smb = smb.trim();

      if (blocks[i].length() > 0) {
        blocks[i] = blocks[i].substring(wrappedLine.length());

        if (blocks[i].length() > 0) {
          smb += "\n";
        }

        i--;
      }
    }

    textView.setGravity(Gravity.LEFT);
    textView.setText(smb);
  }
コード例 #14
0
  @Override
  public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
    int mappingCount = 0;
    if (attrs != null) {
      for (int i = 0, size = attrs.getAttributeCount(); i < size; ++i) {
        String value = attrs.getAttributeValue(i);
        if (!value.startsWith("?")) continue;
        int attrId =
            resources.getIdentifier(
                value.substring(1), null, null); // Integer.parseInt(value.substring(1));
        if (attrId == 0) {
          Logger.e(TAG, "couldn't get id for attribute: " + value);
          continue;
        }
        int index = customAttrs.indexOfKey(attrId);
        if (index >= 0) {
          mappingKeys[mappingCount] = attrs.getAttributeNameResource(i);
          mappingValues[mappingCount] = customAttrs.valueAt(index);
          ++mappingCount;
        }
      }
    }

    if (mappingCount == 0 && textColorPrimaryOverridden == textColorPrimaryOriginal) return null;

    View view = instantiate(name, context, attrs);
    if (view == null) return null;

    boolean shouldOverrideTextColor =
        textColorPrimaryOverridden != textColorPrimaryOriginal && view instanceof TextView;
    for (int i = 0; i < mappingCount; ++i) {
      switch (mappingKeys[i]) {
        case android.R.attr.background:
          view.setBackgroundColor(mappingValues[i]);
          break;
        case android.R.attr.textColor:
          if (view instanceof TextView) {
            ((TextView) view).setTextColor(mappingValues[i]);
            shouldOverrideTextColor = false;
          } else {
            Logger.e(
                TAG,
                "couldn't apply attribute 'textColor' on class "
                    + name
                    + " (not instance of TextView)");
          }
          break;
        case android.R.attr.divider:
          if (view instanceof ListView) {
            ListView listView = (ListView) view;
            int dividerHeight = listView.getDividerHeight();
            listView.setDivider(new ColorDrawable(mappingValues[i]));
            listView.setDividerHeight(dividerHeight);
          } else {
            Logger.e(
                TAG,
                "couldn't apply attribute 'divider' on class "
                    + name
                    + " (not instance of ListView)");
          }
          break;
        default:
          String attrResName = null;
          try {
            attrResName = resources.getResourceName(mappingKeys[i]);
          } catch (Exception e) {
            attrResName = Integer.toString(mappingKeys[i]);
          }
          Logger.e(TAG, "couldn't apply attribure '" + attrResName + "' on class " + name);
      }
    }

    if (shouldOverrideTextColor) {
      TextView tv = (TextView) view;
      if (tv.getCurrentTextColor() == textColorPrimaryOriginal) {
        tv.setTextColor(textColorPrimaryOverridden);
      }
    }

    return view;
  }
コード例 #15
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_advanced_options, container, false);
    getDialog().setCancelable(true);
    getDialog().setCanceledOnTouchOutside(true);

    mPlaybackSpeed = (TextView) root.findViewById(R.id.playback_speed);
    mPlaybackSpeed.setOnFocusChangeListener(mFocusListener);
    mPlaybackSpeed.setOnClickListener(this);
    mPlaybackSpeed.setOnLongClickListener(this);

    mSleep = (TextView) root.findViewById(R.id.sleep);
    mSleep.setOnClickListener(this);
    mSleep.setOnFocusChangeListener(mFocusListener);

    mJumpTitle = (TextView) root.findViewById(R.id.jump_title);
    mJumpTitle.setOnClickListener(this);

    if (mMode == MODE_VIDEO) {
      mPlayAsAudio = (ImageView) root.findViewById(R.id.play_as_audio_icon);
      mPlayAsAudio.setOnClickListener(this);

      mChaptersTitle = (TextView) root.findViewById(R.id.jump_chapter_title);
      mChaptersTitle.setOnFocusChangeListener(mFocusListener);
      mChaptersTitle.setOnClickListener(this);

      mAudioDelay = (TextView) root.findViewById(R.id.audio_delay);
      mAudioDelay.setOnFocusChangeListener(mFocusListener);
      mAudioDelay.setOnClickListener(this);

      mSpuDelay = (TextView) root.findViewById(R.id.spu_delay);
      mSpuDelay.setOnFocusChangeListener(mFocusListener);
      mSpuDelay.setOnClickListener(this);
    } else {
      root.findViewById(R.id.audio_delay).setVisibility(View.GONE);
      root.findViewById(R.id.spu_delay).setVisibility(View.GONE);
      root.findViewById(R.id.jump_chapter_title).setVisibility(View.GONE);
      root.findViewById(R.id.play_as_audio_icon).setVisibility(View.GONE);
    }

    if (mMode == MODE_AUDIO) {
      mEqualizer = (TextView) root.findViewById(R.id.opt_equalizer);
      mEqualizer.setOnClickListener(this);
    } else root.findViewById(R.id.opt_equalizer).setVisibility(View.GONE);

    mTextColor = mSleep.getCurrentTextColor();

    if (getDialog() != null) {
      int dialogWidth =
          getResources()
              .getDimensionPixelSize(
                  mMode == MODE_VIDEO
                      ? R.dimen.adv_options_video_width
                      : R.dimen.adv_options_music_width);
      int dialogHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
      getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
      getDialog()
          .getWindow()
          .setBackgroundDrawableResource(
              Util.getResourceFromAttribute(getActivity(), R.attr.rounded_bg));
    }
    return root;
  }
コード例 #16
0
  /** Returns the message text color of the SuperCardToast. */
  public int getTextColor() {

    return mMessageTextView.getCurrentTextColor();
  }
コード例 #17
0
 // Old Android versions don't seem to have the 'setAlpha()' method.
 private void setAlphaOnText(TextView v, float alpha) {
   int alpha_bits = ((int) (0xFF * alpha)) << 24;
   v.setTextColor(v.getCurrentTextColor() & 0xFFFFFF | alpha_bits);
 }