Java Code Examples for android.view.View#GONE

The following examples show how to use android.view.View#GONE . 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 want to check out the right sidebar which shows the related API usage.
Example 1
private View getRelatedView(int[] rules, int relation) {
    int id = rules[relation];
    if (id != 0) {
        DependencyGraph.Node node = mGraph.mKeyNodes.get(id);
        if (node == null) return null;
        View v = node.view;

        // Find the first non-GONE view up the chain
        while (v.getVisibility() == View.GONE) {
            rules = ((LayoutParams) v.getLayoutParams()).getRules(v.getLayoutDirection());
            node = mGraph.mKeyNodes.get((rules[relation]));
            // ignore self dependency. for more info look in git commit: da3003
            if (node == null || v == node.view) return null;
            v = node.view;
        }

        return v;
    }

    return null;
}
 
Example 2
@Override
public void onProgressChanged(WebView view, int newProgress) {
    fragment.getProgressBar().setProgress(newProgress);
    if (newProgress == 100) {
        view.postDelayed(new Runnable() {
            @Override
            public void run() {
                fragment.getProgressBar().setVisibility(View.GONE);
            }
        }, 500);
    } else {
        if (fragment.getProgressBar().getVisibility() == View.GONE) {
            fragment.getProgressBar().setVisibility(View.VISIBLE);
        }
    }
}
 
Example 3
Source Project: flowlayout   File: FlowLayout.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int childLeft = getPaddingLeft();
    int childTop = getPaddingTop();
    int lineHeight = 0;
    int myWidth = right - left;

    for (int i = 0; i < getChildCount(); i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == View.GONE) {
            continue;
        }
        int childWidth = child.getMeasuredWidth();
        int childHeight = child.getMeasuredHeight();
        lineHeight = Math.max(childHeight, lineHeight);
        if (childWidth + childLeft + getPaddingRight() > myWidth) {
            childLeft = getPaddingLeft();
            childTop += mVerticalPadding + lineHeight;
            lineHeight = childHeight;
        }
        child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
        childLeft += childWidth + mHorizontalPadding;
    }
}
 
Example 4
Source Project: Android-UtilCode   File: BarUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */

public static void setColor(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
        View fakeStatusBarView = decorView.findViewWithTag(FAKE_STATUS_BAR_VIEW_TAG);
        if (fakeStatusBarView != null) {
            if (fakeStatusBarView.getVisibility() == View.GONE) {
                fakeStatusBarView.setVisibility(View.VISIBLE);
            }
            fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        } else {
            decorView.addView(createStatusBarView(activity, color, statusBarAlpha));
        }
        setRootView(activity);
    }
}
 
Example 5
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    View v = (View)getTag();
    ViewGroup.LayoutParams params = v.getLayoutParams();
    if (params == null) {
        params = generateDefaultLayoutParams();
        v.setLayoutParams(params);
    }
    if (v.getVisibility() != View.GONE) {
        int heightSpec = getChildMeasureSpec(
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0, params.height);
        int widthSpec = getChildMeasureSpec(
                MeasureSpec.makeMeasureSpec(mGridView.getWidth(), MeasureSpec.EXACTLY), 0,
                params.width);
        v.measure(widthSpec, heightSpec);
    }
    setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), v.getMeasuredHeight());
}
 
Example 6
Source Project: XFrame   File: XStatusBar.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 * @param color        状态栏颜色值
 */
@Deprecated
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // 生成一个状态栏大小的矩形
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
        if (fakeStatusBarView != null) {
            if (fakeStatusBarView.getVisibility() == View.GONE) {
                fakeStatusBarView.setVisibility(View.VISIBLE);
            }
            fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA));
        } else {
            // 添加 statusBarView 到布局中
            contentLayout.addView(createStatusBarView(activity, color), 0);
        }
        // 内容布局不是 LinearLayout 时,设置padding top
        if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
            contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
        }
        // 设置属性
        setDrawerLayoutProperty(drawerLayout, contentLayout);
    }
}
 
Example 7
Source Project: QNRTC-Android   File: RadioGroupFlow.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int maxWidth = MeasureSpec.getSize(widthMeasureSpec);
    int childCount = getChildCount();
    int x = 0;
    int y = 0;
    int row = 0;

    for (int index = 0; index < childCount; index++) {
        final View child = getChildAt(index);
        if (child.getVisibility() != View.GONE) {
            child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);

            int width = child.getMeasuredWidth();
            int height = child.getMeasuredHeight();
            x += width;
            y = row * height + height;
            if (x > maxWidth) {
                x = width;
                row++;
                y = row * height + height;
            }
        }
    }
    setMeasuredDimension(maxWidth, y);
}
 
Example 8
@Override
public void onVisibilityChange(int visibility) {
    if (visibility == View.GONE)
        hideControls();
    else if (visibility == View.VISIBLE)
        showControls();
}
 
Example 9
private void album() {
    if (layoutAlbum.getVisibility() == View.GONE) {
        popAlbum();
    } else {
        hideAlbum();
    }
}
 
Example 10
Source Project: BotLibre   File: ChatActivity.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onResume() {
	MainActivity.searching = false;
	MainActivity.searchingPosts = false;
	if (MainActivity.browsing && (MainActivity.instance instanceof AvatarConfig)) {
		if (MainActivity.user == null || MainActivity.user.type == null || MainActivity.user.type.isEmpty() || MainActivity.user.type.equals("Basic")) {
			//MainActivity.showMessage("You must upgrade to get access to this avatar", this);
			//super.onResume();
			//return;
		}
		this.avatar = (AvatarConfig)MainActivity.instance;
		this.avatarId = this.avatar.id;
		if (this.imageView.getVisibility() == View.GONE) {
			this.imageView.setVisibility(View.VISIBLE);
		}
		if (this.videoLayout.getVisibility() == View.VISIBLE) {
			this.videoLayout.setVisibility(View.GONE);
		}
		
		HttpGetImageAction.fetchImage(this, this.avatar.avatar, this.imageView);

		AvatarConfig avatarConfig = (AvatarConfig)this.avatar.credentials();
		HttpFetchChatAvatarAction action = new HttpFetchChatAvatarAction(this, avatarConfig);
		action.execute();
	}
	MainActivity.browsing = false;
	if ((MainActivity.instance instanceof InstanceConfig) && MainActivity.instance.id.equals(this.instance.id)) {
		this.instance = (InstanceConfig)MainActivity.instance;
	} else {
		MainActivity.instance = this.instance;
	}
	if (this.changingVoice) {
		this.changingVoice = false;
		resetTTS();
	}
	super.onResume();
}
 
Example 11
public void showImageGridView() {
    // 显示转发的布局
    mForwardLayout.setVisibility(View.VISIBLE);
    if (mImageGvViewStub.getVisibility() == View.GONE) {
        mImageGvViewStub.setVisibility(View.VISIBLE);
        int imageGvResId = ResFinder.getId("umeng_comm_msg_gridview");
        mImageGv = (WrapperGridView) findViewById(imageGvResId);
        mImageGv.hasScrollBar = true;
    }

    mImageGv.setBackgroundColor(Color.TRANSPARENT);
    mImageGv.setVisibility(View.VISIBLE);
    // adapter
    FeedImageAdapter gridviewAdapter = new FeedImageAdapter(mContext);
    gridviewAdapter.addDatasOnly(mFeedItem.getImages());
    // 设置图片
    mImageGv.setAdapter(gridviewAdapter);
    // 计算列数
    mImageGv.updateColumns(3);

    // 图片GridView
    mImageGv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
            mPresenter.jumpToImageBrowser(mFeedItem.getImages(), pos);
        }
    });
}
 
Example 12
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_UPDATE_NOW:
        if (View.GONE == mLoadingView.getVisibility()) {
            startRefresh();
        } else {
            cancelRefresh();
        }
        return true;
    }
    return false;
}
 
Example 13
Source Project: Pas   File: ActivityPresenter.java    License: Apache License 2.0 5 votes vote down vote up
public void changeLoadingState(){
    if(progressBar.getVisibility()==View.GONE){
        progressBar.setVisibility(View.VISIBLE);
    }else{
        progressBar.setVisibility(View.GONE);
    }
}
 
Example 14
Source Project: StackCardsView   File: StackCardsView.java    License: Apache License 2.0 5 votes vote down vote up
void updateChildrenProgress(float progress, View scrollingView) {
    final int cnt = getChildCount();
    int startIndex = indexOfChild(scrollingView) + 1;
    if (startIndex >= cnt) {
        return;
    }
    float oriScale;
    float oriAlpha;
    float oriTranslationY;
    float maxScale;
    float maxAlpha;
    float maxTranslationY;
    float progressScale;
    for (int i = startIndex; i < cnt; i++) {
        View child = getChildAt(i);
        int oriIndex = Math.min(mScaleArray.length - 1, i - startIndex + 1);
        if (child.getVisibility() != View.GONE) {
            if (mScaleArray != null) {
                oriScale = mScaleArray[oriIndex];
                maxScale = mScaleArray[i - startIndex];
                progressScale = oriScale + (maxScale - oriScale) * progress;
                child.setScaleX(progressScale);
                child.setScaleY(progressScale);
            }

            if (mAlphaArray != null) {
                oriAlpha = mAlphaArray[oriIndex];
                maxAlpha = mAlphaArray[i - startIndex];
                child.setAlpha(oriAlpha + (maxAlpha - oriAlpha) * progress);
            }

            if (mTranslationYArray != null) {
                oriTranslationY = mTranslationYArray[oriIndex];
                maxTranslationY = mTranslationYArray[i - startIndex];
                child.setTranslationY(oriTranslationY + (maxTranslationY - oriTranslationY) * progress);
            }
        }
    }
}
 
Example 15
Source Project: 365browser   File: HistoryItemView.java    License: Apache License 2.0 5 votes vote down vote up
private void updateRemoveButtonVisibility() {
    int removeButtonVisibility =
            !PrefServiceBridge.getInstance().canDeleteBrowsingHistory() ? View.GONE
                    : mRemoveButtonVisible ? View.VISIBLE : View.INVISIBLE;
    mRemoveButton.setVisibility(removeButtonVisibility);

    int endPadding = removeButtonVisibility == View.GONE ? mEndPadding : 0;
    ApiCompatibilityUtils.setPaddingRelative(mContentView,
            ApiCompatibilityUtils.getPaddingStart(mContentView),
            mContentView.getPaddingTop(), endPadding, mContentView.getPaddingBottom());
}
 
Example 16
Source Project: ForPDA   File: TabFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
public final void setSubtitle(String newSubtitle) {
    this.subtitle = newSubtitle;
    if (subtitle == null) {
        if (toolbarSubtitleView.getVisibility() != View.GONE)
            toolbarSubtitleView.setVisibility(View.GONE);
    } else {
        if (toolbarSubtitleView.getVisibility() != View.VISIBLE)
            toolbarSubtitleView.setVisibility(View.VISIBLE);
        toolbarSubtitleView.setText(getSubtitle());
    }
}
 
Example 17
public void setVisible(boolean visible)
{
    int visibility = (visible ? View.VISIBLE : View.GONE);
    if (label != null) {
        label.setVisibility(visibility);
    }
    if (text != null) {
        text.setVisibility(visibility);
    }
    if (icon != null) {
        icon.setVisibility(visibility);
    }
}
 
Example 18
@Override
public void onBindViewHolder(ArticleCommentsAdapter.ViewHolder holder, int position) {
    Comment item = list.get(position);
    Comment.Karma karma = item.getKarma();
    holder.content.setText(item.getContent());
    if (item.isDeleted()) {
        holder.itemView.setClickable(false);
        if (holder.likeImage.getVisibility() != View.GONE) {
            holder.likeImage.setVisibility(View.GONE);
        }
        if (holder.likeCount.getVisibility() != View.GONE) {
            holder.likeCount.setVisibility(View.GONE);
        }
        if (holder.nick.getVisibility() != View.GONE) {
            holder.nick.setVisibility(View.GONE);
        }
        if (holder.date.getVisibility() != View.GONE) {
            holder.date.setVisibility(View.GONE);
        }
    } else {
        holder.itemView.setClickable(ClientHelper.getAuthState());
        if (holder.likeImage.getVisibility() != View.VISIBLE) {
            holder.likeImage.setVisibility(View.VISIBLE);
        }
        if (holder.likeCount.getVisibility() != View.VISIBLE) {
            holder.likeCount.setVisibility(View.VISIBLE);
        }

        if (holder.nick.getVisibility() != View.VISIBLE) {
            holder.nick.setVisibility(View.VISIBLE);
        }
        if (holder.date.getVisibility() != View.VISIBLE) {
            holder.date.setVisibility(View.VISIBLE);
        }

        holder.nick.setText(item.getUserNick());
        holder.date.setText(item.getDate());

        if (karma.getCount() == 0) {
            if (holder.likeCount.getVisibility() != View.GONE) {
                holder.likeCount.setVisibility(View.GONE);
            }
        } else {
            if (holder.likeCount.getVisibility() != View.VISIBLE) {
                holder.likeCount.setVisibility(View.VISIBLE);
            }
            holder.likeCount.setText(Integer.toString(karma.getCount()));
        }

        switch (karma.getStatus()) {
            case Comment.Karma.LIKED: {
                holder.likeImage.setImageDrawable(holder.heart);
                holder.likeImage.setColorFilter(likedColorFilter);
                holder.likeImage.setClickable(false);
                break;
            }
            case Comment.Karma.DISLIKED: {
                holder.likeImage.setImageDrawable(holder.heart_outline);
                holder.likeImage.setColorFilter(dislikedColorFilter);
                holder.likeImage.setClickable(false);
                break;
            }
            case Comment.Karma.NOT_LIKED: {
                holder.likeImage.setImageDrawable(holder.heart_outline);
                holder.likeImage.clearColorFilter();
                holder.likeImage.setClickable(ClientHelper.getAuthState() && ClientHelper.getUserId() != item.getUserId());
                break;
            }
        }
    }


    holder.itemView.setPadding(App.px12 * item.getLevel(), 0, 0, 0);
}
 
Example 19
private void setItemViewVisibilityById(int id, boolean visible) {
    int visible_value = visible ? View.VISIBLE : View.GONE;
    itemView.findViewById(id).setVisibility(visible_value);
}
 
Example 20
private void hideIcon() {
    if (footerIcon.getVisibility() != View.GONE) {
        footerIcon.setVisibility(View.GONE);
    }
}