List of usage examples for android.view View setTag
public void setTag(int key, final Object tag)
From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java
private void tryUpdateSelection(boolean allowAnimate) { final View selectionToolbarContainer = findViewById(R.id.selection_toolbar_container); if (mUpdatePosition >= 0) { mChosenPhotosAdapter.notifyItemChanged(mUpdatePosition); mUpdatePosition = -1;// w ww .j a va 2 s. co m } else { mChosenPhotosAdapter.notifyDataSetChanged(); } int selectedCount = mMultiSelectionController.getSelectedCount(); final boolean toolbarVisible = selectedCount > 0; mSelectionToolbar.getMenu().findItem(R.id.action_force_now).setVisible(selectedCount < 2); Boolean previouslyVisible = (Boolean) selectionToolbarContainer.getTag(0xDEADBEEF); if (previouslyVisible == null) { previouslyVisible = Boolean.FALSE; } if (previouslyVisible != toolbarVisible) { selectionToolbarContainer.setTag(0xDEADBEEF, toolbarVisible); int duration = allowAnimate ? getResources().getInteger(android.R.integer.config_shortAnimTime) : 0; if (toolbarVisible) { selectionToolbarContainer.setVisibility(View.VISIBLE); selectionToolbarContainer.setTranslationY(-selectionToolbarContainer.getHeight()); selectionToolbarContainer.animate().translationY(0f).setDuration(duration).withEndAction(null); mAddButton.animate().scaleX(0f).scaleY(0f).setDuration(duration).withEndAction(new Runnable() { @Override public void run() { mAddButton.setVisibility(View.INVISIBLE); } }); } else { selectionToolbarContainer.animate().translationY(-selectionToolbarContainer.getHeight()) .setDuration(duration).withEndAction(new Runnable() { @Override public void run() { selectionToolbarContainer.setVisibility(View.INVISIBLE); } }); mAddButton.setVisibility(View.VISIBLE); mAddButton.animate().scaleY(1f).scaleX(1f).setDuration(duration).withEndAction(null); } } if (toolbarVisible) { mSelectionToolbar.setTitle(Integer.toString(selectedCount)); } }
From source file:com.retroteam.studio.retrostudio.EditorLandscape.java
/** * Create all the views associated with a measure. * @param v/*from w ww .j av a 2 s . c o m*/ * @param projectLoad */ private void addMeasure(View v, boolean projectLoad) { int whichtrack = (int) v.getTag(R.id.TAG_ROW); int whichmeasure = (int) v.getTag(R.id.TAG_COLUMN); if (!projectLoad) { theproject.track(whichtrack).addMeasure(); } GridLayout myparent = (GridLayout) v.getParent(); ImageView measure = new ImageView(getApplicationContext()); measure.setImageResource(R.drawable.measure_new_empty); measure.setLayoutParams(new LinearLayout.LayoutParams((int) (displaysize.x / 3.32), LinearLayout.LayoutParams.MATCH_PARENT)); measure.setTag(R.id.TAG_ROW, whichtrack); measure.setTag(R.id.TAG_COLUMN, whichmeasure); measure.setTag(R.bool.TAG_HASNOTES, false); measure.setTag(R.id.TAG_GUISNAP, 0); measure.setTag(R.id.TAG_FILLED_NOTES, new ArrayList<int[]>()); measure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /// int whichtrack = (int) v.getTag(R.id.TAG_ROW); int whichmeasure = (int) v.getTag(R.id.TAG_COLUMN); editMeasure(v); } }); myparent.addView(measure, whichmeasure + 1); v.setTag(R.id.TAG_COLUMN, whichmeasure + 1); }
From source file:com.benefit.buy.library.http.query.AbstractAQuery.java
/** * Inflate a view from xml layout. This method is similar to LayoutInflater.inflate() but with sanity checks against * the layout type of the convert view. If the convertView is null or the convertView type doesn't matches layoutId * type, a new view is inflated. Otherwise the convertView will be returned for reuse. * @param convertView the view to be reused * @param layoutId the desired view type * @param root the view root for layout params, can be null * @return self/* w ww . ja v a 2 s . com*/ */ public View inflate(View convertView, int layoutId, ViewGroup root) { if (convertView != null) { Integer layout = (Integer) convertView.getTag(Constants.TAG_LAYOUT); if ((layout != null) && (layout.intValue() == layoutId)) { return convertView; } } LayoutInflater inflater = null; if (act != null) { inflater = act.getLayoutInflater(); } else { inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); } View view = inflater.inflate(layoutId, root, false); view.setTag(Constants.TAG_LAYOUT, layoutId); return view; }
From source file:android.support.transition.ChangeTransform.java
private ObjectAnimator createTransformAnimator(TransitionValues startValues, TransitionValues endValues, final boolean handleParentChange) { Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX); Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX); if (startMatrix == null) { startMatrix = MatrixUtils.IDENTITY_MATRIX; }/*from w ww. ja v a 2 s . com*/ if (endMatrix == null) { endMatrix = MatrixUtils.IDENTITY_MATRIX; } if (startMatrix.equals(endMatrix)) { return null; } final Transforms transforms = (Transforms) endValues.values.get(PROPNAME_TRANSFORMS); // clear the transform properties so that we can use the animation matrix instead final View view = endValues.view; setIdentityTransforms(view); final float[] startMatrixValues = new float[9]; startMatrix.getValues(startMatrixValues); final float[] endMatrixValues = new float[9]; endMatrix.getValues(endMatrixValues); final PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, startMatrixValues); PropertyValuesHolder valuesProperty = PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), startMatrixValues, endMatrixValues); Path path = getPathMotion().getPath(startMatrixValues[Matrix.MTRANS_X], startMatrixValues[Matrix.MTRANS_Y], endMatrixValues[Matrix.MTRANS_X], endMatrixValues[Matrix.MTRANS_Y]); PropertyValuesHolder translationProperty = PropertyValuesHolderUtils.ofPointF(TRANSLATIONS_PROPERTY, path); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, valuesProperty, translationProperty); final Matrix finalEndMatrix = endMatrix; AnimatorListenerAdapter listener = new AnimatorListenerAdapter() { private boolean mIsCanceled; private Matrix mTempMatrix = new Matrix(); @Override public void onAnimationCancel(Animator animation) { mIsCanceled = true; } @Override public void onAnimationEnd(Animator animation) { if (!mIsCanceled) { if (handleParentChange && mUseOverlay) { setCurrentMatrix(finalEndMatrix); } else { view.setTag(R.id.transition_transform, null); view.setTag(R.id.parent_matrix, null); } } ViewUtils.setAnimationMatrix(view, null); transforms.restore(view); } @Override public void onAnimationPause(Animator animation) { Matrix currentMatrix = pathAnimatorMatrix.getMatrix(); setCurrentMatrix(currentMatrix); } @Override public void onAnimationResume(Animator animation) { setIdentityTransforms(view); } private void setCurrentMatrix(Matrix currentMatrix) { mTempMatrix.set(currentMatrix); view.setTag(R.id.transition_transform, mTempMatrix); transforms.restore(view); } }; animator.addListener(listener); AnimatorUtils.addPauseListener(animator, listener); return animator; }
From source file:com.androidquery.AbstractAQuery.java
/** * Inflate a view from xml layout.//from ww w .j ava2 s . co m * * This method is similar to LayoutInflater.inflate() but with sanity checks against the * layout type of the convert view. * * If the convertView is null or the convertView type doesn't matches layoutId type, a new view * is inflated. Otherwise the convertView will be returned for reuse. * * @param convertView the view to be reused * @param layoutId the desired view type * @param root the view root for layout params, can be null * @return self * */ public View inflate(View convertView, int layoutId, ViewGroup root) { if (convertView != null) { Integer layout = (Integer) convertView.getTag(AQuery.TAG_LAYOUT); if (layout != null && layout.intValue() == layoutId) { return convertView; } } LayoutInflater inflater = null; if (act != null) { inflater = act.getLayoutInflater(); } else { inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); } View view = inflater.inflate(layoutId, root, false); view.setTag(AQuery.TAG_LAYOUT, layoutId); return view; }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void setActionView(View action) { mAdapter = new SettingsLayoutAdapter(mLayoutViewRowClicked, mLayoutViewOnFocus); mAdapter.setLayoutRows(mLayout.getLayoutRows()); if (action instanceof VerticalGridView) { mListView = (VerticalGridView) action; } else {// w w w.j a v a 2 s . c o m mListView = (VerticalGridView) action.findViewById(R.id.list); if (mListView == null) { throw new IllegalArgumentException("No ListView exists."); } mListView.setWindowAlignmentOffset(0); mListView.setWindowAlignmentOffsetPercent(WINDOW_ALIGNMENT_OFFSET_PERCENT); mListView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE); View selectorView = action.findViewById(R.id.selector); if (selectorView != null) { mListView.setOnScrollListener(new SelectorAnimator(selectorView, mListView)); } } mListView.requestFocusFromTouch(); mListView.setAdapter(mAdapter); int initialSelectedIndex; if (mSelectedIndex >= 0 && mSelectedIndex < mLayout.getLayoutRows().size()) { // "mSelectedIndex" is a valid index and so must have been initialized from a Bundle in // the "onCreate" member and the only way it could be a valid index is if it was saved // by "onSaveInstanceState" since it is initialized to "-1" (an invalid value) in the // constructor. initialSelectedIndex = mSelectedIndex; } else { // First time this fragment is being instantiated, i.e. did not reach here via the // "onSaveInstanceState" route. Initialize the index from the starting index defined // in the "Layout". initialSelectedIndex = mLayout.getSelectedIndex(); } mListView.setSelectedPositionSmooth(initialSelectedIndex); action.setTag(R.id.list, mListView); action.setTag(R.id.selector, action.findViewById(R.id.selector)); }
From source file:com.android.calendar.selectcalendars.SelectSyncedCalendarsMultiAccountAdapter.java
@Override protected void bindChildView(View view, Context context, Cursor cursor, boolean isLastChild) { final long id = cursor.getLong(ID_COLUMN); String name = cursor.getString(NAME_COLUMN); String owner = cursor.getString(OWNER_COLUMN); final String accountName = cursor.getString(ACCOUNT_COLUMN); final String accountType = cursor.getString(ACCOUNT_TYPE_COLUMN); int color = Utils.getDisplayColorFromColor(cursor.getInt(COLOR_COLUMN)); final View colorSquare = view.findViewById(R.id.color); colorSquare.setEnabled(mCache.hasColors(accountName, accountType)); colorSquare.setBackgroundColor(color); final View delegateParent = (View) colorSquare.getParent(); delegateParent.post(new Runnable() { @Override/*from ww w. j ava 2s. c om*/ public void run() { final Rect r = new Rect(); colorSquare.getHitRect(r); r.top -= mColorViewTouchAreaIncrease; r.bottom += mColorViewTouchAreaIncrease; r.left -= mColorViewTouchAreaIncrease; r.right += mColorViewTouchAreaIncrease; delegateParent.setTouchDelegate(new TouchDelegate(r, colorSquare)); } }); colorSquare.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mCache.hasColors(accountName, accountType)) { return; } if (mColorPickerDialog == null) { mColorPickerDialog = CalendarColorPickerDialog.newInstance(id, mIsTablet); } else { mColorPickerDialog.setCalendarId(id); } mFragmentManager.executePendingTransactions(); if (!mColorPickerDialog.isAdded()) { mColorPickerDialog.show(mFragmentManager, COLOR_PICKER_DIALOG_TAG); } } }); if (mIsDuplicateName.containsKey(name) && mIsDuplicateName.get(name) && !name.equalsIgnoreCase(owner)) { name = new StringBuilder(name).append(Utils.OPEN_EMAIL_MARKER).append(owner) .append(Utils.CLOSE_EMAIL_MARKER).toString(); } setText(view, R.id.calendar, name); // First see if the user has already changed the state of this calendar Boolean sync = mCalendarChanges.get(id); if (sync == null) { sync = cursor.getInt(SYNCED_COLUMN) == 1; mCalendarInitialStates.put(id, sync); } CheckBox button = (CheckBox) view.findViewById(R.id.sync); button.setChecked(sync); setText(view, R.id.status, sync ? mSyncedText : mNotSyncedText); view.setTag(TAG_ID_CALENDAR_ID, id); view.setTag(TAG_ID_SYNC_CHECKBOX, button); view.setOnClickListener(this); }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void initializeContentView(View content) { TextView titleView = (TextView) content.findViewById(R.id.title); TextView breadcrumbView = (TextView) content.findViewById(R.id.breadcrumb); TextView descriptionView = (TextView) content.findViewById(R.id.description); titleView.setText(mTitle);// w w w.j av a 2s . c o m breadcrumbView.setText(mBreadcrumb); descriptionView.setText(mDescription); final ImageView iconImageView = (ImageView) content.findViewById(R.id.icon); iconImageView.setBackgroundColor(mIconBackgroundColor); // Force text fields to be focusable when accessibility is enabled. if (AccessibilityHelper.forceFocusableViews(getActivity())) { titleView.setFocusable(true); titleView.setFocusableInTouchMode(true); descriptionView.setFocusable(true); descriptionView.setFocusableInTouchMode(true); breadcrumbView.setFocusable(true); breadcrumbView.setFocusableInTouchMode(true); } if (mIcon != null) { iconImageView.setImageDrawable(mIcon); updateViewSize(iconImageView); } else if (mIconBitmap != null) { iconImageView.setImageBitmap(mIconBitmap); updateViewSize(iconImageView); } else if (mIconUri != null) { iconImageView.setVisibility(View.INVISIBLE); /* BitmapDownloader bitmapDownloader = BitmapDownloader.getInstance( content.getContext()); mBitmapCallBack = new BitmapCallback() { @Override public void onBitmapRetrieved(Bitmap bitmap) { if (bitmap != null) { mIconBitmap = bitmap; iconImageView.setVisibility(View.VISIBLE); iconImageView.setImageBitmap(bitmap); updateViewSize(iconImageView); } } }; bitmapDownloader.getBitmap(new BitmapWorkerOptions.Builder( content.getContext()).resource(mIconUri) .width(iconImageView.getLayoutParams().width).build(), mBitmapCallBack); */ } else { iconImageView.setVisibility(View.GONE); } content.setTag(R.id.title, titleView); content.setTag(R.id.breadcrumb, breadcrumbView); content.setTag(R.id.description, descriptionView); content.setTag(R.id.icon, iconImageView); }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void setContentView(View content) { TextView titleView = (TextView) content.findViewById(R.id.title); TextView breadcrumbView = (TextView) content.findViewById(R.id.breadcrumb); TextView descriptionView = (TextView) content.findViewById(R.id.description); titleView.setText(mTitle);//from w ww . j ava 2 s . com breadcrumbView.setText(mBreadcrumb); descriptionView.setText(mDescription); final ImageView iconImageView = (ImageView) content.findViewById(R.id.icon); if (mIconBackgroundColor != Color.TRANSPARENT) { iconImageView.setBackgroundColor(mIconBackgroundColor); } if (AccessibilityHelper.forceFocusableViews(getActivity())) { titleView.setFocusable(true); titleView.setFocusableInTouchMode(true); descriptionView.setFocusable(true); descriptionView.setFocusableInTouchMode(true); breadcrumbView.setFocusable(true); breadcrumbView.setFocusableInTouchMode(true); } if (mIconResourceId != 0) { iconImageView.setImageResource(mIconResourceId); updateViewSize(iconImageView); } else { if (mIconBitmap != null) { iconImageView.setImageBitmap(mIconBitmap); updateViewSize(iconImageView); } else { if (mIconUri != null) { iconImageView.setVisibility(View.INVISIBLE); DrawableDownloader bitmapDownloader = DrawableDownloader.getInstance(content.getContext()); mBitmapCallBack = new BitmapCallback() { @Override public void onBitmapRetrieved(Drawable bitmap) { if (bitmap != null) { mIconBitmap = (bitmap instanceof BitmapDrawable) ? ((BitmapDrawable) bitmap).getBitmap() : null; iconImageView.setVisibility(View.VISIBLE); iconImageView.setImageDrawable(bitmap); updateViewSize(iconImageView); } } }; bitmapDownloader.getBitmap(new BitmapWorkerOptions.Builder(content.getContext()) .resource(mIconUri).width(iconImageView.getLayoutParams().width).build(), mBitmapCallBack); } else { iconImageView.setVisibility(View.GONE); } } } content.setTag(R.id.title, titleView); content.setTag(R.id.breadcrumb, breadcrumbView); content.setTag(R.id.description, descriptionView); content.setTag(R.id.icon, iconImageView); }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void setActionView(View action) { mAdapter = new DialogActionAdapter(new Action.Listener() { @Override//from w ww . j a v a2s.c om public void onActionClicked(Action action) { // eat events if action is disabled or only displays info if (!action.isEnabled() || action.infoOnly()) { return; } /** * If the custom lister has been set using * {@link #setListener(DialogActionAdapter.Listener)}, use it. * If not, use the activity's default listener. */ if (mListener != null) { mListener.onActionClicked(action); } else if (getActivity() instanceof Action.Listener) { Action.Listener listener = (Action.Listener) getActivity(); listener.onActionClicked(action); } } }, new Action.OnFocusListener() { @Override public void onActionFocused(Action action) { if (getActivity() instanceof Action.OnFocusListener) { Action.OnFocusListener listener = (Action.OnFocusListener) getActivity(); listener.onActionFocused(action); } } }, mActions); if (action instanceof VerticalGridView) { mListView = (VerticalGridView) action; } else { mListView = (VerticalGridView) action.findViewById(R.id.list); if (mListView == null) { throw new IllegalStateException("No ListView exists."); } // mListView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE); // mListView.setWindowAlignmentOffsetPercent(0.5f); // mListView.setItemAlignmentOffset(0); // mListView.setItemAlignmentOffsetPercent(VerticalGridView.ITEM_ALIGN_OFFSET_PERCENT_DISABLED); mListView.setWindowAlignmentOffset(0); mListView.setWindowAlignmentOffsetPercent(50f); mListView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE); View selectorView = action.findViewById(R.id.selector); if (selectorView != null) { mSelectorAnimator = new SelectorAnimator(selectorView, mListView); mListView.setOnScrollListener(mSelectorAnimator); } } mListView.requestFocusFromTouch(); mListView.setAdapter(mAdapter); mListView.setSelectedPosition((mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction()); action.setTag(R.id.list, mListView); action.setTag(R.id.selector, action.findViewById(R.id.selector)); }