Java Code Examples for android.widget.TextView#getTag()

The following examples show how to use android.widget.TextView#getTag() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FixMath   File: PlayActivity.java    License: Apache License 2.0 6 votes vote down vote up
void animClickFigures(String figureType){

        for (int i = Up; i <= Down; i++) {
            for (int x = 0; x <= 4; x++) {
                String TextViewId = "var" + i + "x" + x;
                int id = getResources().getIdentifier(TextViewId, "id", getPackageName());
                TextView allTextContainer = (TextView) findViewById(id);
                if(allTextContainer.getTag() != null) {
                    String containerTags = allTextContainer.getTag().toString();

                    if (containerTags.equals(figureType)) {
                        YoYo.with(Techniques.RubberBand)
                                .duration(500)
                                .playOn(allTextContainer);
                    }
                }

            }
        }
    }
 
Example 2
Source Project: Bailan   File: SubTabNavigator.java    License: Apache License 2.0 6 votes vote down vote up
private void setCurrentIntemSelect(int position) {
    drawBackground();
    TextView tv = (TextView) getChildAt(position);
    tv.setTextColor(tabSelectTextColor);
    int tag = (int) tv.getTag();
    switch (tag) {
        case TAG_LEFT_VIEW:
            tv.setBackgroundDrawable(mLeftSelectDrawable);
            break;
        case TAG_NONE_VIEW:
            tv.setBackgroundDrawable(mSimpleSelectDrawable);
            break;
        case TAG_RIGHT_VIEW:
            tv.setBackgroundDrawable(mRightSelectDrawable);
            break;
    }
}
 
Example 3
Source Project: IdeaTrackerPlus   File: MainActivity.java    License: MIT License 6 votes vote down vote up
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

    if (actionId == EditorInfo.IME_ACTION_GO
            || actionId == EditorInfo.IME_ACTION_DONE
            || actionId == EditorInfo.IME_ACTION_NEXT
            || actionId == EditorInfo.IME_ACTION_SEND
            || actionId == EditorInfo.IME_ACTION_SEARCH
            || actionId == EditorInfo.IME_NULL) {

        switch ((int) v.getTag()) {
            case 1:
                mNoteField.requestFocus();
                break;

            case 2:
                sendIdeaFromDialog();
                break;

            default:
                break;
        }
        return true;
    }
    return false;
}
 
Example 4
Source Project: FixMath   File: PlayActivity.java    License: Apache License 2.0 6 votes vote down vote up
void blockGoodAnswerFigures(String figureType){

            for (int i = Up; i <= Down; i++) {
                for (int x = 0; x <= 4; x++) {
                    String TextViewId = "var" + i + "x" + x;
                    int id = getResources().getIdentifier(TextViewId, "id", getPackageName());
                    TextView allTextContainer = (TextView) findViewById(id);
                    if(allTextContainer.getTag() != null) {
                        String containerTags = allTextContainer.getTag().toString();

                        if (containerTags.equals(figureType)) {
                            SetFiguresColor(allTextContainer, figureType);
                            allTextContainer.setEnabled(false);
                        }
                    }

                }
            }

    }
 
Example 5
Source Project: Markwon   File: AsyncDrawableScheduler.java    License: Apache License 2.0 6 votes vote down vote up
public static void unschedule(@NonNull TextView view) {

        // @since 4.0.0
        if (view.getTag(R.id.markwon_drawables_scheduler_last_text_hashcode) == null) {
            return;
        }
        view.setTag(R.id.markwon_drawables_scheduler_last_text_hashcode, null);


        final AsyncDrawableSpan[] spans = extractSpans(view);
        if (spans != null
                && spans.length > 0) {
            for (AsyncDrawableSpan span : spans) {
                span.getDrawable().setCallback2(null);
            }
        }
    }
 
Example 6
Source Project: Bailan   File: SubTabNavigator.java    License: Apache License 2.0 6 votes vote down vote up
private void setCurrentIntemSelect(int position) {
    drawBackground();
    TextView tv = (TextView) getChildAt(position);
    tv.setTextColor(tabSelectTextColor);
    int tag = (int) tv.getTag();
    switch (tag) {
        case TAG_LEFT_VIEW:
            tv.setBackgroundDrawable(mLeftSelectDrawable);
            break;
        case TAG_NONE_VIEW:
            tv.setBackgroundDrawable(mSimpleSelectDrawable);
            break;
        case TAG_RIGHT_VIEW:
            tv.setBackgroundDrawable(mRightSelectDrawable);
            break;
    }
}
 
Example 7
@Override public void onClick(View v) {

        TextView textView = (TextView) v;
        String text = (String) textView.getTag();

        if (textView == mTopSelectedTextView) {
            mTopSelectedTextView = null;
            textView.setSelected(false);
        } else if (textView == mBottomSelectedTextView) {
            mBottomSelectedTextView = null;
            textView.setSelected(false);
        } else if (mTopGridData.contains(text)) {
            if (mTopSelectedTextView != null) {
                mTopSelectedTextView.setSelected(false);
            }
            mTopSelectedTextView = textView;
            textView.setSelected(true);
        } else {
            if (mBottomSelectedTextView != null) {
                mBottomSelectedTextView.setSelected(false);
            }
            mBottomSelectedTextView = textView;
            textView.setSelected(true);
        }
    }
 
Example 8
Source Project: RichText   File: GlideImageGetter.java    License: MIT License 5 votes vote down vote up
private void checkTag(TextView textView) {
    //noinspection unchecked
    HashSet<ImageTarget> ts = (HashSet<ImageTarget>) textView.getTag(TARGET_TAG);
    if (ts != null) {
        if (ts == targets) {
            return;
        }
        for (ImageTarget target : ts) {
            target.recycle();
        }
        ts.clear();
    }
    textView.setTag(TARGET_TAG, targets);
}
 
Example 9
private void updateView(android.os.Message paramMsg) {
    FileState file = (FileState) paramMsg.obj;

    if (mListView != null) {
        TextView htvView = (TextView) mListView.findViewWithTag(FileUtils
                .getNameByPath(file.fileName));

        if (htvView != null) {
            int itemPosition = (Integer) htvView.getTag(ITEM_POSITION);
            int visiblePos = mListView.getFirstVisiblePosition();
            int offset = itemPosition - visiblePos;

            Message itemMessage = (Message) getItem(itemPosition);
            itemMessage.setPercent(file.percent);

            // 只有在可见区域才更新
            if (offset < 0)
                return;

            else {
                if (file.percent != 100) {
                    htvView.setText(file.percent + "");
                }
                else {
                    htvView.setVisibility(View.GONE);
                }
            }

        }
    }
}
 
Example 10
private void pickDate(TextView tv) {
    Object tag = tv.getTag();
    final Calendar cal = (tag == null ? Calendar.getInstance() : (Calendar) tag);

    DatePickerDialog picker = new DatePickerDialog(getContext(),
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int day) {
                    cal.set(Calendar.YEAR, year);
                    cal.set(Calendar.MONTH, month);
                    cal.set(Calendar.DAY_OF_MONTH, day);

                    DateFormat DF = Helper.getDateInstance(getContext());

                    tv.setTag(cal);
                    tv.setText(DF.format(cal.getTime()));
                }
            },
            cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));

    picker.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            tv.setTag(null);
            tv.setText(null);
        }
    });

    picker.show();
}
 
Example 11
private void onAnswerResult(GamePlayViewModel.AnswerResult answerResult) {
    if (answerResult.correct) {
        TextView textView = findUsedWordTextViewByUsedWordId(answerResult.usedWordId);
        if (textView != null) {
            UsedWord uw = (UsedWord) textView.getTag();

            if (getPreferences().grayscale()) {
                uw.getAnswerLine().color = mGrayColor;
            }
            textView.setBackgroundColor(uw.getAnswerLine().color);
            textView.setText(uw.getString());
            textView.setTextColor(Color.WHITE);
            textView.setPaintFlags(textView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

            Animator anim = AnimatorInflater.loadAnimator(this, R.animator.zoom_in_out);
            anim.setTarget(textView);
            anim.start();
        }

        mSoundPlayer.play(SoundPlayer.Sound.Correct);
    }
    else {
        mLetterBoard.popStreakLine();

        mSoundPlayer.play(SoundPlayer.Sound.Wrong);
    }
}
 
Example 12
Source Project: MaterialQQLite   File: ChatMsgAdapter.java    License: Apache License 2.0 5 votes vote down vote up
private void setBubble(TextView txtContent, ChatMsg chatMsg) {		
	Integer nOldBubble = (Integer)txtContent.getTag();
	if (null == nOldBubble || nOldBubble != chatMsg.m_nBubble) {
		int left = txtContent.getPaddingLeft();
        int right = txtContent.getPaddingRight();
        int top = txtContent.getPaddingTop();
        int bottom = txtContent.getPaddingBottom();

        boolean bIsUser = (ChatMsg.RIGHT == chatMsg.m_nType);
		boolean bUseDefBubble = true;
		
		if (chatMsg.m_nBubble != 0) {				
			//
		}
		
		if (bUseDefBubble) {
			if (bIsUser) {
				txtContent.setBackgroundResource(R.drawable.btn_style7);
				txtContent.setTextColor(0xFFFFFFFF);
                   txtContent.setTextIsSelectable(true);
				txtContent.setLinkTextColor(0xFF0000FF);
			} else {
				txtContent.setBackgroundResource(R.drawable.btn_style6);
				txtContent.setTextColor(0xFF000000);
                   txtContent.setTextIsSelectable(true);
				txtContent.setLinkTextColor(0xFF0000FF);
			}
			txtContent.setTag(0);
		}
		
		txtContent.setPadding(left, top, right, bottom);
	}
}
 
Example 13
Source Project: FixMath   File: TimeKeyboard.java    License: Apache License 2.0 5 votes vote down vote up
public void BackSpaceNumbersInFigures(TextView viewClicked){
    String tag =  viewClicked.getTag().toString();

    if(!viewClicked.getText().equals("")) {
        for (int x = 0; x <= 4; x++) {
            String TextViewId = "t_var" + x ;

            int id = context.getResources().getIdentifier(TextViewId, "id", context.getPackageName());
            TextView allTextContainer = (TextView) ((Activity)context).getWindow().getDecorView().findViewById(id);



            if(allTextContainer.getTag() != null) {
                String containerTags = allTextContainer.getTag().toString();

                if (containerTags.equals(tag)) {

                    allTextContainer.setText("");
                    BackSpaceAnim(allTextContainer);

                    allTextContainer.setTextSize(30);

                    TimeTab[x] = "";
                    helperInt = TimeTab[x].length();
                }
            }

        }
    }else{
        View keyboardView = ((Activity)context).getWindow().getDecorView().findViewById(R.id.t_keyboard);
        YoYo.with(Techniques.Shake)
                .duration(400)
                .playOn(keyboardView);
        sfxManager.KeyboardErrorPlay();
    }


}
 
Example 14
private void fillWordsList(FlowLayout view) {
    for (int i = 0; i < view.getChildCount(); i++) {
        final TextView word = (TextView) view.getChildAt(i);
        if (word.getTag() instanceof String)
            words.add(word);
    }
}
 
Example 15
Source Project: glide-support   File: GlideImageGetter.java    License: The Unlicense 5 votes vote down vote up
public static void clear(TextView view) {
	view.setText(null);
	Object tag = view.getTag();
	if (tag instanceof GlideImageGetter) {
		((GlideImageGetter)tag).clear();
		view.setTag(null);
	}
}
 
Example 16
Source Project: CreditCardView   File: CreditCardFragment.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_NEXT && v.getTag() instanceof FieldValidator) {
        FieldValidator fieldValidator = (FieldValidator) v.getTag();

        if (fieldValidator.isValid()) {
            nextPage();
        }

        return true;
    }

    return false;
}
 
Example 17
Source Project: imsdk-android   File: TextMessageProcessor.java    License: MIT License 4 votes vote down vote up
@Override
public void update() {
    TextView tv = target.get();
    if (tv.getTag(R.string.atom_ui_title_add_emotion) != null)
        tv.invalidate();
}
 
Example 18
protected ImageView findMinusButton(TextView textView) {
    return (ImageView) textView.getTag(R.id.bMinus);
}
 
Example 19
@Override
public void onResponse(ImageContainer response, boolean isImmediate) {
    if (mTextView.getTag(R.id.poste_image_getter) == UrlImageGetter.this && response.getBitmap() != null) {
        BitmapDrawable drawable = new BitmapDrawable(mRes, response.getBitmap());
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        String src = response.getRequestUrl();
        // redraw the image by invalidating the container
        // 由于下面重新设置了ImageSpan,所以这里invalidate就不必要了吧
        // urlDrawable.invalidateSelf();
        // UrlImageGetter.this.mTextView.invalidate();

        // TODO 这种方式基本完美解决显示图片问题, blog?
        // 把提取到下面显示的图片在放出来? 然后点击任何图片 进入到 帖子图片浏览界面。。?
        TextView v = UrlImageGetter.this.mTextView;
        CharSequence text = v.getText();
        if (!(text instanceof Spannable)) {
            return;
        }
        Spannable spanText = (Spannable) text;
        @SuppressWarnings("unchecked") ArrayList<String> imgs = (ArrayList<String>) v.getTag(R.id.poste_image_data);
        ImageSpan[] imageSpans = spanText.getSpans(0, spanText.length(), ImageSpan.class);
        L.i("%b X Recycled %b src: %s", isImmediate, response.getBitmap().isRecycled(), src);
        for (ImageSpan imgSpan : imageSpans) {
            int start = spanText.getSpanStart(imgSpan);
            int end = spanText.getSpanEnd(imgSpan);
            L.i("%d-%d :%s", start, end, imgSpan.getSource());
            String url = imgSpan.getSource();
            url = checkUrl(url);
            if (src.equals(url)) {
                spanText.removeSpan(imgSpan);
                ImageSpan is = new ImageSpan(drawable, src, ImageSpan.ALIGN_BASELINE);
                spanText.setSpan(is, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
            if (imgs != null && imgs.contains(src)) {
                ImageClickableSpan ics = new ImageClickableSpan(src);
                spanText.setSpan(ics, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

        }
        v.setText(spanText);
    }

}
 
Example 20
Source Project: FixMath   File: TimeKeyboard.java    License: Apache License 2.0 2 votes vote down vote up
public void PrintNumbersInFigures(int number, View viewClicked){
    String tag =  viewClicked.getTag().toString();

    String numberToString = Integer.toString(number);




    if(tag != null) {
            for (int x = 0; x <= 4; x++) {
                String TextViewId = "t_var" + x ;

                int id = context.getResources().getIdentifier(TextViewId, "id", context.getPackageName());
                TextView allTextContainer = (TextView) ((Activity)context).getWindow().getDecorView().findViewById(id);

                String ImageViewId = "t_var_ImageView_" + x ;

                int IMid = context.getResources().getIdentifier(ImageViewId, "id", context.getPackageName());
                ImageView ImageViewContainer = (ImageView) ((Activity)context).getWindow().getDecorView().findViewById(IMid);

                if(allTextContainer.getTag() != null) {
                    String containerTags = allTextContainer.getTag().toString();

                    if (containerTags.equals(tag)) {

                        allTextContainer.setText(TimeTab[x] + "" +  numberToString);
                        WritneAnim(ImageViewContainer);


                        if(allTextContainer.getText().length() < 2){
                            allTextContainer.setTextSize(30);
                        }else if(allTextContainer.getText().length() == 2){
                            allTextContainer.setTextSize(19);
                        }
                        TimeTab[x] += numberToString;
                        helperInt = TimeTab[x].length();
                    }
                }

            }
        }


}