Java Code Examples for android.view.View#setActivated()

The following examples show how to use android.view.View#setActivated() . 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 File: FreeFlowContainer.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a quick, in-place update of the checked or activated state on all
 * visible item views. This should only be called when a valid choice mode
 * is active.
 */
private void updateOnScreenCheckedViews() {
	Iterator<?> it = frames.entrySet().iterator();
	View child = null;
	while (it.hasNext()) {
		Map.Entry<?, FreeFlowItem> pairs = (Map.Entry<?, FreeFlowItem>) it
				.next();
		child = pairs.getValue().view;
		boolean isChecked = isChecked(pairs.getValue().itemSection,
				pairs.getValue().itemIndex);
		if (child instanceof Checkable) {
			((Checkable) child).setChecked(isChecked);
		} else {
			child.setActivated(isChecked);
		}
	}
}
 
Example 2
Source File: TabLayout.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a selected tab is added. Unselects all other tabs in the TabLayout.
 *
 * @param position Position of the selected tab.
 */
private void setSelectedTabView(int position) {
  final int tabCount = slidingTabIndicator.getChildCount();
  if (position < tabCount) {
    for (int i = 0; i < tabCount; i++) {
      final View child = slidingTabIndicator.getChildAt(i);
      child.setSelected(i == position);
      child.setActivated(i == position);
    }
  }
}
 
Example 3
Source File: ItemSelectionSupport.java    From MultiView with Apache License 2.0 5 votes vote down vote up
@TargetApi(HONEYCOMB)
public void setViewChecked(View view, boolean checked) {
    if (view instanceof Checkable) {
        ((Checkable) view).setChecked(checked);
    } else if (Build.VERSION.SDK_INT >= HONEYCOMB) {
        view.setActivated(checked);
    }
}
 
Example 4
Source File: Workspace.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
private void updateDefaultScreenButton() {
    View overviewPanel = mLauncher.getOverviewPanel();
    if (overviewPanel != null) {
        View defaultPageButton = overviewPanel.findViewById(R.id.default_screen_button);
        defaultPageButton.setActivated(
                getScreenIdForPageIndex(getPageNearestToCenterOfScreen()) == mDefaultScreenId);
    }
}
 
Example 5
Source File: DrawerListView.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.item_drawer_list, parent, false);
    }

    // Handle activated
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (position == mActivatedPosition) {
            convertView.setActivated(true);
        } else {
            convertView.setActivated(false);
        }
    }

    TextView tv = (TextView) convertView;
    CharSequence t = mTitleArray[position];
    tv.setText(t);
    Drawable d = mDrawableArray[position];
    if (d != null) {
        d.setBounds(0, 0, mDrawableSize, mDrawableSize);
        tv.setCompoundDrawables(d, null, null, null);
    } else {
        tv.setCompoundDrawables(null, null, null, null);
    }

    return convertView;
}
 
Example 6
Source File: ForumItem.java    From something.apk with MIT License 5 votes vote down vote up
@Override
public void updateViewFromHolder(View view, ForumHolder holder) {
    holder.forum = this;
    holder.title.setText(title);
    if(showStar){
        TypedValue star = new TypedValue();
        if(view.getContext().getTheme().resolveAttribute(starred ? R.attr.inlineStarIcon : R.attr.inlineEmptyStarIcon, star, false)){
            holder.star.setVisibility(View.VISIBLE);
            holder.star.setImageResource(star.data);
        }
    }else{
        holder.star.setVisibility(View.GONE);
    }
    view.setActivated(selected);
}
 
Example 7
Source File: PagerSlidingTabStrip.java    From droidddle with Apache License 2.0 5 votes vote down vote up
void activiteCurentTab(View v) {
    v.setActivated(true);
    int count = tabsContainer.getChildCount();
    for (int i = 0; i < count; i++) {
        View view = tabsContainer.getChildAt(i);
        if (view != v) {
            view.setActivated(false);
        }
    }
}
 
Example 8
Source File: AbstractValidateableView.java    From AndroidMaterialValidation with Apache License 2.0 5 votes vote down vote up
/**
 * Adapts the activated state of all children of a specific view group.
 *
 * @param viewGroup
 *         The view group, whose children's activated states should be adapted, as an instance
 *         of the class {@link ViewGroup}. The view group may not be null
 * @param activated
 *         True, if the children should be activated, false otherwise
 */
private void setActivatedOnViewGroup(@NonNull final ViewGroup viewGroup,
                                     final boolean activated) {
    viewGroup.setActivated(activated);

    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View child = viewGroup.getChildAt(i);

        if (child instanceof ViewGroup) {
            setActivatedOnViewGroup((ViewGroup) child, activated);
        } else {
            child.setActivated(activated);
        }
    }
}
 
Example 9
Source File: TrackSelectionAdapterWrapper.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
private void updateCheckState(View itemView, int position) {
    if (itemView instanceof Checkable) {
        ((Checkable) itemView).setChecked(mCheckStates.get(position));
    } else {
        itemView.setActivated(mCheckStates.get(position));
    }
}
 
Example 10
Source File: AuthenticatorActivity.java    From google-authenticator-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateFloatView(int position) {
  View view =
      dragSortListView.getChildAt(
          position
              + dragSortListView.getHeaderViewsCount()
              - dragSortListView.getFirstVisiblePosition());
  if (view == null) {
    return null;
  }
  View userRowLayout = view.findViewById(R.id.user_row_layout);
  if (userRowLayout != null) {
    userRowLayout.setPressed(false);
    userRowLayout.setSelected(false);
    userRowLayout.setActivated(false);
  }

  // Take a picture of the selected item and add it to the holder with shadow we have prepared.
  view.setDrawingCacheEnabled(true);
  floatBitmap = Bitmap.createBitmap(view.getDrawingCache());
  view.setDrawingCacheEnabled(false);

  if (floatView == null) {
    LayoutInflater inflater = activity.getLayoutInflater();
    floatView = inflater.inflate(R.layout.user_row_dragged, null);
  }
  ImageView imageView = floatView.findViewById(R.id.user_row_dragged_image);
  imageView.setImageBitmap(floatBitmap);
  imageView.setLayoutParams(new RelativeLayout.LayoutParams(view.getWidth(), view.getHeight()));

  return floatView;
}
 
Example 11
Source File: MainFragment.java    From android-spotify-demo with MIT License 4 votes vote down vote up
private void setDeFocus(int res_id, View view){
    switch (res_id)
    {
        case R.id.nav_home:
            home.setTint(defocusMode);
            view.setBackground(home);
            homeText.setTextColor(defocusMode);
            homeText.setTypeface(Typeface.DEFAULT);
            view.setActivated(false);
            break;
        case R.id.nav_browse:
            browse.setTint(defocusMode);
            view.setBackground(browse);
            browseText.setTextColor(defocusMode);
            browseText.setTypeface(Typeface.DEFAULT);
            view.setActivated(false);
            break;
        case R.id.nav_search:
            search.setTint(defocusMode);
            view.setBackground(search);
            searchText.setTextColor(defocusMode);
            searchText.setTypeface(Typeface.DEFAULT);
            view.setActivated(false);
            break;
        case R.id.nav_radio:
            radio.setTint(defocusMode);
            view.setBackground(radio);
            radioText.setTextColor(defocusMode);
            radioText.setTypeface(Typeface.DEFAULT);
            view.setActivated(false);
            break;
        case R.id.nav_library:
            library.setTint(defocusMode);
            view.setBackground(library);
            libraryText.setTextColor(defocusMode);
            libraryText.setTypeface(Typeface.DEFAULT);
            view.setActivated(false);
            break;
        case -1:
            break;
        default:
            break;
    }
}
 
Example 12
Source File: NavDrawer.java    From smartcard-reader with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onClick(View view) {
    if (view.getId() == mResId) {
        // already on it, just close nav drawer
        mDrawerLayout.closeDrawers();
        return;
    }
    mParentItem.setActivated(false);
    view.setActivated(true);
    mCurrentItem = view;

    final Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    boolean finishCurrent = false;
    final int viewId = view.getId();
    switch(viewId) {
        case R.id.app_select:
            intent.setClass(mActivity, AppSelectActivity.class);
            finishCurrent = true;
            break;

        case R.id.batch_select:
            intent.setClass(mActivity, BatchSelectActivity.class);
            finishCurrent = true;
            break;

        case R.id.emv_read:
            intent.setClass(mActivity, EmvReadActivity.class);
            finishCurrent = true;
            break;

        case R.id.apps:
            intent.setClass(mActivity, AppListActivity.class);
            finishCurrent = false;
            break;

        case R.id.settings:
            intent.setClass(mActivity, SettingsActivity.class);
            finishCurrent = false;
            break;
    }
    final boolean finish = finishCurrent;
    mHandler.removeCallbacksAndMessages(null);
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            mActivity.startActivity(intent);
            if (finish) {
                mActivity.finish();
            }
            mActivity.overridePendingTransition(R.anim.abc_fade_in,
                    R.anim.abc_fade_out);
        }
    }, 225);

    mDrawerLayout.closeDrawers();
}
 
Example 13
Source File: ViewCompatHC.java    From letv with Apache License 2.0 4 votes vote down vote up
public static void setActivated(View view, boolean activated) {
    view.setActivated(activated);
}
 
Example 14
Source File: ThreadItem.java    From something.apk with MIT License 4 votes vote down vote up
@Override
public void updateViewFromHolder(View view, ThreadHolder holder) {
    holder.title.setText(threadTitle);
    if(unread >= 0){
        holder.unread.setVisibility(View.VISIBLE);
        holder.unread.setText(Integer.toString(unread));
    }else{
        holder.unread.setVisibility(View.GONE);
    }
    GradientDrawable unreadBackground = (GradientDrawable) holder.unread.getBackground();
    switch (bookmark){
        case 0:
            unreadBackground.setColor(SomeTheme.bookmark_unread);
            break;
        case 1:
            unreadBackground.setColor(SomeTheme.bookmark_normal);
            break;
        case 2:
            unreadBackground.setColor(SomeTheme.bookmark_red);
            break;
        case 3:
            unreadBackground.setColor(SomeTheme.bookmark_gold);
            break;
    }

    holder.unread.setAlpha(unread > 0 ? 1.0f : 0.5f);
    holder.subtext.setText(lastPost);

    if (pinned) {
        holder.subtext.setCompoundDrawablesWithIntrinsicBounds(R.drawable.sticky, 0, 0, 0);
    }
    else {
        holder.subtext.setCompoundDrawablesWithIntrinsicBounds(R.drawable.pages, 0, 0, 0);
    }

    if (!TextUtils.isEmpty(tagUrl)) {
        holder.tagImage.setImageUrl(tagUrl, FastVolley.getImageLoader());
        holder.tagImage.setVisibility(View.VISIBLE);
    }
    else {
        holder.tagImage.setVisibility(View.GONE);
    }

    view.setAlpha(closed ? 0.5f : 1f);
    view.setActivated(selected);
}
 
Example 15
Source File: PrivateMessageFolderItem.java    From something.apk with MIT License 4 votes vote down vote up
@Override
public void updateViewFromHolder(View view, PMFolderHolder holder) {
    holder.title.setText(title);
    view.setActivated(selected);
}
 
Example 16
Source File: MainListAdapter.java    From Passbook with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View view = convertView;
    ViewHolder holder;
    AccountManager.Account account = mEntries.get(position);
    boolean checked = mChecked.get(position);
    if (convertView == null) {
        view = inflate(parent);
    }
    else {
        holder = (ViewHolder) view.getTag();
        if(holder.mInflate) {
            view = inflate(parent);
        }
    }
    if (mDeleted.get(position)) {
        final View deletedView = view;
        view.post(() -> animateDeletion(deletedView, position));
    }
    holder = (ViewHolder) view.getTag();
    holder.mTextView.setText(account.getAccountName());
    holder.mIconView.setPressed(checked);
    holder.mIconView.setTag(position);
    int srcId = checked ? R.drawable.checkmark : mIcons.get(position);
    String iconUrl = checked ? null : account.getIconUrl();
    if (!checked) {
        holder.mIconView.setColorFilter(COLORS[account.getCategoryId() & 0x0f]);
    } else {
        holder.mIconView.clearColorFilter();
    }
    final ImageView iconView = holder.mIconView;
    Picasso.get().load(iconUrl).placeholder(srcId)
            .transform(new CircleTransform())
            .fit().into(holder.mIconView, new Callback() {
        @Override
        public void onSuccess() {
            iconView.clearColorFilter();
        }

        @Override
        public void onError(Exception e) {

        }
    });
    final View currentView = view;
    holder.mIconView.setOnClickListener(v -> {
        v.clearAnimation();
        v.setAnimation(FLIP1);
        v.startAnimation(FLIP1);
        AnimationListener listener = getAnimListener(currentView, (ImageButton) v,
                Integer.parseInt(v.getTag().toString()), FLIP1, FLIP2);
        FLIP1.setAnimationListener(listener);
        FLIP2.setAnimationListener(listener);
    });
    if(mAnimationEnabled) {
        long timestamp = System.currentTimeMillis();
        long delta = timestamp - mLastTimestamp;
        mLastTimestamp = timestamp;

        Animation animation = AnimationUtils.loadAnimation(mContext,
                position < mLastPosition ? R.anim.down_from_top : R.anim.up_from_bottom);
        if(delta > TIME_INTERVAL) {
            animation.setStartOffset(0);
            mAdjustment = 0;
        }
        else{
            mAdjustment += TIME_INTERVAL - delta;
            if(mAdjustment > 100) {
                mAdjustment = 100;
            }
            animation.setStartOffset(mAdjustment);
        }
        view.startAnimation(animation);
    }
    view.setActivated(checked);
    mLastPosition = position;
    return view;
}
 
Example 17
Source File: OverlayManager.java    From android with Apache License 2.0 4 votes vote down vote up
@Override public boolean onFling(float posX, float posY, float velocityX, float velocityY) {
  final View findMe = mapView.getFindMe();
  findMe.setActivated(false);
  return false;
}
 
Example 18
Source File: Utility11.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void viewSetActivated(View view, boolean activated) {
    view.setActivated(activated);
}
 
Example 19
Source File: DrawerUtils.java    From MaterialDrawer-Xamarin with Apache License 2.0 4 votes vote down vote up
/**
 * helper method to handle the onClick of the footer
 *
 * @param drawer
 * @param drawerItem
 * @param v
 * @param fireOnClick true if we should call the listener, false if not, null to not call the listener and not close the drawer
 */
public static void onFooterDrawerItemClick(DrawerBuilder drawer, IDrawerItem drawerItem, View v, Boolean fireOnClick) {
    boolean checkable = !(drawerItem != null && drawerItem instanceof Selectable && !((Selectable) drawerItem).isSelectable());
    if (checkable) {
        drawer.resetStickyFooterSelection();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            v.setActivated(true);
        }
        v.setSelected(true);

        //remove the selection in the list
        drawer.getAdapter().handleSelection(null, -1);

        //set currentSelection to -1 because we selected a stickyFooter element
        drawer.mCurrentSelection = -1;

        //find the position of the clicked footer item
        if (drawer.mStickyFooterView != null && drawer.mStickyFooterView instanceof LinearLayout) {
            LinearLayout footer = (LinearLayout) drawer.mStickyFooterView;
            for (int i = 0; i < footer.getChildCount(); i++) {
                if (footer.getChildAt(i) == v) {
                    drawer.mCurrentStickyFooterSelection = i;
                    break;
                }
            }
        }
    }


    if (fireOnClick != null) {
        boolean consumed = false;
        if (fireOnClick && drawer.mOnDrawerItemClickListener != null) {
            consumed = drawer.mOnDrawerItemClickListener.onItemClick(v, -1, drawerItem);
        }

        if (!consumed) {
            //close the drawer after click
            drawer.closeDrawerDelayed();
        }
    }
}
 
Example 20
Source File: Utilities.java    From call_manage with MIT License 2 votes vote down vote up
/**
 * Toggle the active state of a view
 *
 * @param view the view to toggle
 */
public static void toggleViewActivation(View view) {
    view.setActivated(!view.isActivated());
}