Java Code Examples for android.widget.ImageButton#getVisibility()

The following examples show how to use android.widget.ImageButton#getVisibility() . 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: MyGridView.java    From Jreader with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void run() {
    isDrag = true; //设置可以拖拽
    mVibrator.vibrate(50); //震动一下
    mStartDragItemView.setVisibility(View.INVISIBLE);//隐藏该item
    for (int i = 0;i < getChildCount();i++) {
        final View mGridItemView = getChildAt(i);
        mDeleteButton = (ImageButton) mGridItemView.findViewById(R.id.item_close_Im);
        mDeleteButton.setOnClickListener(MyGridView.this);
        if(mDeleteButton.getVisibility()!=VISIBLE) {
            //   mDeleteButton.setVisibility(VISIBLE);
        }

    }
    //根据我们按下的点显示item镜像
    createDragImage(mDragBitmap, mDownX, mDownY);

  //  setIsShowDeleteButton(true);


}
 
Example 2
Source File: DragGridView.java    From Jreader with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void run() {
    isDrag = true; //设置可以拖拽
    mVibrator.vibrate(50); //震动一下
    mStartDragItemView.setVisibility(View.INVISIBLE);//隐藏该item

    //根据我们按下的点显示item镜像
    createDragImage(mDragBitmap, mDownX, mDownY);

    setIsShowDeleteButton(true);
    for (int i = 0;i < getChildCount();i++) {
        final View mGridItemView = getChildAt(i);
        mDeleteButton = (ImageButton) mGridItemView.findViewById(R.id.item_close_Im);
        mDeleteButton.setOnClickListener(DragGridView.this);
        if(mDeleteButton.getVisibility()!=VISIBLE) {
         //   mDeleteButton.setVisibility(VISIBLE);
        }

    }

}
 
Example 3
Source File: ViewUtils.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
public static void fadeInButton(final ImageButton button, final int duration)
{
    if (Build.VERSION.SDK_INT >= 12)
    {
        button.clearAnimation();

        if (button.getVisibility() != View.VISIBLE) {
            button.setAlpha(0f);
            button.setVisibility(View.VISIBLE);
        }
        if (button.getAlpha() != 1f) {
            button.animate().setDuration(duration).alpha(1f);
        }

    } else {
        button.setVisibility(View.VISIBLE);
    }
}
 
Example 4
Source File: ButtonManager.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize a known button with a click listener and a drawable resource id,
 * and a content description resource id.
 * Sets the button visible.
 */
public void initializePushButton(int buttonId, View.OnClickListener cb,
                                 int imageId, int contentDescriptionId)
{
    ImageButton button = getImageButtonOrError(buttonId);
    button.setOnClickListener(cb);
    if (imageId != NO_RESOURCE)
    {
        button.setImageResource(imageId);
    }
    if (contentDescriptionId != NO_RESOURCE)
    {
        button.setContentDescription(mAppController
                .getAndroidContext().getResources().getString(contentDescriptionId));
    }

    if (!button.isEnabled())
    {
        button.setEnabled(true);
        if (mListener != null)
        {
            mListener.onButtonEnabledChanged(this, buttonId);
        }
    }
    button.setTag(R.string.tag_enabled_id, buttonId);

    if (button.getVisibility() != View.VISIBLE)
    {
        button.setVisibility(View.VISIBLE);
        if (mListener != null)
        {
            mListener.onButtonVisibilityChanged(this, buttonId);
        }
    }
}
 
Example 5
Source File: ToolbarTablet.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar);

    mHomeButton = (TintedImageButton) findViewById(R.id.home_button);
    mBackButton = (TintedImageButton) findViewById(R.id.back_button);
    mForwardButton = (TintedImageButton) findViewById(R.id.forward_button);
    mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button);
    mShowTabStack = DeviceClassManager.isAccessibilityModeEnabled(getContext())
            || CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK);

    mTabSwitcherButtonDrawable =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false);
    mTabSwitcherButtonDrawableLight =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true);

    mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button);
    mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable);
    updateSwitcherButtonVisibility(mShowTabStack);

    mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button);

    mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
    mMenuButtonWrapper.setVisibility(
            shouldShowMenuButton() ? View.VISIBLE : View.GONE);

    if (mAccessibilitySwitcherButton.getVisibility() == View.GONE
            && mMenuButtonWrapper.getVisibility() == View.GONE) {
        ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0,
                getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0);
    }

    // Initialize values needed for showing/hiding toolbar buttons when the activity size
    // changes.
    mShouldAnimateButtonVisibilityChange = false;
    mToolbarButtonsVisible = true;
    mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton};
}
 
Example 6
Source File: ToolbarTablet.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar);

    mHomeButton = (TintedImageButton) findViewById(R.id.home_button);
    mBackButton = (TintedImageButton) findViewById(R.id.back_button);
    mForwardButton = (TintedImageButton) findViewById(R.id.forward_button);
    mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button);
    mShowTabStack = DeviceClassManager.isAccessibilityModeEnabled(getContext())
            || CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK);

    mTabSwitcherButtonDrawable =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false);
    mTabSwitcherButtonDrawableLight =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true);

    mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button);
    mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable);
    updateSwitcherButtonVisibility(mShowTabStack);

    mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button);

    mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
    mMenuButtonWrapper.setVisibility(View.VISIBLE);

    if (mAccessibilitySwitcherButton.getVisibility() == View.GONE
            && mMenuButtonWrapper.getVisibility() == View.GONE) {
        ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0,
                getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0);
    }

    mSaveOfflineButton = (TintedImageButton) findViewById(R.id.save_offline_button);

    // Initialize values needed for showing/hiding toolbar buttons when the activity size
    // changes.
    mShouldAnimateButtonVisibilityChange = false;
    mToolbarButtonsVisible = true;
    mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton};
}
 
Example 7
Source File: ZoomableView.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
private void cover_off(LinearLayout cover, final ImageButton cornerButton) {
    if (bottomFadeDescription && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1)
        cover.animate().alpha(0f);

    if (animateCloseButton && cornerButton.getVisibility() != View.GONE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        cornerButton.animate().alpha(0f).withEndAction(new Runnable() {
            @Override
            public void run() {
                cornerButton.setEnabled(false);
            }
        });
}
 
Example 8
Source File: ZoomableView.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
private void cover_on(LinearLayout cover, final ImageButton cornerButton) {
    if (bottomFadeDescription && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1)
        cover.animate().alpha(1f);

    if (animateCloseButton && cornerButton.getVisibility() != View.GONE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        cornerButton.animate().alpha(1f).withEndAction(new Runnable() {
            @Override
            public void run() {
                cornerButton.setEnabled(true);
            }
        });

}
 
Example 9
Source File: ToolbarTablet.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar);

    mHomeButton = (TintedImageButton) findViewById(R.id.home_button);
    mBackButton = (TintedImageButton) findViewById(R.id.back_button);
    mForwardButton = (TintedImageButton) findViewById(R.id.forward_button);
    mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button);
    mSecurityButton = (TintedImageButton) findViewById(R.id.security_button);
    mShowTabStack = AccessibilityUtil.isAccessibilityEnabled();

    mTabSwitcherButtonDrawable =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false);
    mTabSwitcherButtonDrawableLight =
            TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true);

    mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button);
    mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable);
    updateSwitcherButtonVisibility(mShowTabStack);

    mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button);

    mMenuButton = (TintedImageButton) findViewById(R.id.menu_button);
    mMenuButtonWrapper.setVisibility(View.VISIBLE);

    if (mAccessibilitySwitcherButton.getVisibility() == View.GONE
            && mMenuButtonWrapper.getVisibility() == View.GONE) {
        ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0,
                getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0);
    }

    mSaveOfflineButton = (TintedImageButton) findViewById(R.id.save_offline_button);

    // Initialize values needed for showing/hiding toolbar buttons when the activity size
    // changes.
    mShouldAnimateButtonVisibilityChange = false;
    mToolbarButtonsVisible = true;
    mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton};
}
 
Example 10
Source File: ViewUtils.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
public static void fadeOutButton(final ImageButton button, final int duration)
{
    if (button.getVisibility() != View.GONE)
    {
        if (Build.VERSION.SDK_INT >= 12)
        {
            button.clearAnimation();
            if (button.getAlpha() == 0f) {
                button.setVisibility(View.GONE);

            } else {
                button.setAlpha(1f);
                button.animate().setDuration(duration).alpha(0f).setListener(new AnimatorListenerAdapter()
                {
                    @Override
                    public void onAnimationEnd(Animator animation)
                    {
                        super.onAnimationEnd(animation);
                        button.setVisibility(View.GONE);
                        //noinspection ConstantConditions
                        if (Build.VERSION.SDK_INT >= 12)
                        {
                            button.setAlpha(1f);
                            button.animate().setListener(null);
                            button.clearAnimation();
                        }
                    }
                });
            }

        } else {
            button.setVisibility(View.GONE);
        }
    }
}
 
Example 11
Source File: MyGridView.java    From Jreader with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    Log.d("MyGridView","onItemLongClick");
    isDrag = true; //设置可以拖拽
    setIsShowDeleteButton(true);
   // mDragAdapter.nitifyDataRefresh();
    mVibrator.vibrate(50); //震动一下

    for (int i = 0;i < getChildCount();i++) {
        final View mGridItemView = getChildAt(i);
        mDeleteButton = (ImageButton) mGridItemView.findViewById(R.id.item_close_Im);
        mDeleteButton.setOnClickListener(MyGridView.this);
        if(mDeleteButton.getVisibility()!=VISIBLE) {
          //  mDeleteButton.setVisibility(VISIBLE);
        }
    }
    mDragPosition = position;
    //根据position获取该item所对应的View
    mStartDragItemView = getChildAt(mDragPosition - getFirstVisiblePosition());

    //
    mPoint2ItemTop = mDownY - mStartDragItemView.getTop();
    mPoint2ItemLeft = mDownX - mStartDragItemView.getLeft();

    mOffset2Top = (int)( downRawY - mDownY);
    mOffset2Left = (int) (downRawX - mDownX);
    //获取DragGridView自动向上滚动的偏移量,小于这个值,DragGridView向下滚动
    mDownScrollBorder = getHeight() / 5;
    //获取DragGridView自动向下滚动的偏移量,大于这个值,DragGridView向上滚动
    mUpScrollBorder = getHeight() * 4/5;

    //开启mDragItemView绘图缓存
    mStartDragItemView.setDrawingCacheEnabled(true);

    //获取mDragItemView在缓存中的Bitmap对象
    mDragBitmap = Bitmap.createBitmap(mStartDragItemView.getDrawingCache());
    //这一步很关键,释放绘图缓存,避免出现重复的镜像
    mStartDragItemView.destroyDrawingCache();

    mStartDragItemView.setVisibility(View.INVISIBLE);//隐藏该item
    //根据我们按下的点显示item镜像
    createDragImage(mDragBitmap, mDownX, mDownY);

    return true;
}