android.widget.FrameLayout#getChildCount ( )源码实例Demo

下面列出了android.widget.FrameLayout#getChildCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void onShow(DialogInterface dialog) {
    if (getView() != null) {
        ScrollView vMessageScrollView = (ScrollView) getView().findViewById(R.id.sdl_message_scrollview);
        ListView vListView = (ListView) getView().findViewById(R.id.sdl_list);
        FrameLayout vCustomViewNoScrollView = (FrameLayout) getView().findViewById(R.id.sdl_custom);
        boolean customViewNoScrollViewScrollable = false;
        if (vCustomViewNoScrollView.getChildCount() > 0) {
            View firstChild = vCustomViewNoScrollView.getChildAt(0);
            if (firstChild instanceof ViewGroup) {
                customViewNoScrollViewScrollable = isScrollable((ViewGroup) firstChild);
            }
        }
        boolean listViewScrollable = isScrollable(vListView);
        boolean messageScrollable = isScrollable(vMessageScrollView);
        boolean scrollable = listViewScrollable || messageScrollable || customViewNoScrollViewScrollable;
        modifyButtonsBasedOnScrollableContent(scrollable);
    }
}
 
源代码2 项目: v9porn   文件: PictureAdapter.java
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
    FrameLayout view = (FrameLayout) object;
    for (int i = 0; i < view.getChildCount(); i++) {
        View childView = view.getChildAt(i);
        if (childView instanceof PhotoView) {
            childView.setOnClickListener(null);
            childView.setOnLongClickListener(null);
            GlideApp.with(container).clear(childView);
            view.removeViewAt(i);
            Logger.t(TAG).d("clean photoView");
        }
    }
    container.removeView(view);
    Logger.t(TAG).d("destroyItem");
}
 
源代码3 项目: DoraemonKit   文件: UIUtils.java
/**
 * 获得app的contentView
 *
 * @param activity
 * @return
 */
public static View getDokitAppContentView(Activity activity) {
    FrameLayout decorView = (FrameLayout) activity.getWindow().getDecorView();
    View mAppContentView = (View) decorView.getTag(R.id.dokit_app_contentview_id);
    if (mAppContentView != null) {
        return mAppContentView;
    }
    for (int index = 0; index < decorView.getChildCount(); index++) {
        View child = decorView.getChildAt(index);
        //LogHelper.i(TAG, "childId=====>" + getIdText(child));
        //解决与布局边框工具冲突的问题
        if ((child instanceof LinearLayout && TextUtils.isEmpty(getIdText(child).trim())) || child instanceof FrameLayout) {
            //如果是DokitBorderView 则返回他下面的第一个子child
            if (getIdText(child).trim().equals(STR_VIEW_BORDER_Id)) {
                mAppContentView = ((ViewBorderFrameLayout) child).getChildAt(0);
            } else {
                mAppContentView = child;
            }
            mAppContentView.setTag(R.id.dokit_app_contentview_id);
            break;
        }
    }

    return mAppContentView;
}
 
源代码4 项目: v9porn   文件: PictureAdapter.java
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
    FrameLayout view = (FrameLayout) object;
    for (int i = 0; i < view.getChildCount(); i++) {
        View childView = view.getChildAt(i);
        if (childView instanceof PhotoView) {
            childView.setOnClickListener(null);
            childView.setOnLongClickListener(null);
            GlideApp.with(container).clear(childView);
            view.removeViewAt(i);
            Logger.t(TAG).d("clean photoView");
        }
    }
    container.removeView(view);
    Logger.t(TAG).d("destroyItem");
}
 
源代码5 项目: visual-goodies   文件: RecyclerViewFragment.java
/**
 * Sets a view to be displayed when the list is empty with optional LayoutParams.
 * @param view Displayed when the list is empty.
 * @param params Information about how view's layout in the countainer.
 */
public void setEmptyView(View view, FrameLayout.LayoutParams params){
    emptyView = view;
    isEmptyViewEmptyText = true;
    FrameLayout frameLayout = (FrameLayout) getView();
    if (frameLayout == null)
        return;
    //In order to avoid having more than one emptyViews added to the layout
    if (frameLayout.getChildCount() > 2)
        frameLayout.removeViewAt(2);
    if (this.emptyText != null)
        frameLayout.findViewById(android.R.id.text1).setVisibility(View.GONE);
    if (params == null) {
        params = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.CENTER;
    }

    frameLayout.addView(view, 1, params);
    this.emptyViewAddedToLayout = true;
    actuallySetEmptyView();
}
 
源代码6 项目: weixin   文件: AppUtil.java
/**
 * 截取scrollview的屏幕
 * **/
public static Bitmap getBitmapByView(FrameLayout scrollView) {
	int h = 0;
	int w = 0;
	Bitmap bitmap = null;
	// 获取listView实际高度
	for (int i = 0; i < scrollView.getChildCount(); i++) {
		h += scrollView.getChildAt(i).getHeight();
		w += scrollView.getChildAt(i).getWidth();
		// scrollView.getChildAt(i).setBackgroundResource(R.drawable.bg3);
	}
	Log.d(LOGTAG, "实际高度:" + h);
	Log.d(LOGTAG, " 高度:" + scrollView.getHeight());

	// 创建对应大小的bitmap
	bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
	final Canvas canvas = new Canvas(bitmap);
	scrollView.draw(canvas);
	// 测试输出
	// FileOutputStream out = null;
	// try {
	// out = new FileOutputStream("/sdcard/screen_test.png");
	// } catch (FileNotFoundException e) {
	// e.printStackTrace();
	// }
	// try {
	// if (null != out) {
	// bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
	// out.flush();
	// out.close();
	// }
	// } catch (IOException e) {
	// // TODO: handle exception
	// }
	return bitmap;
}
 
源代码7 项目: YCAudioPlayer   文件: WebViewActivity.java
private void showErrorPage() {
    FrameLayout webParentView = (FrameLayout) mWebView.getParent();
    initErrorPage();//初始化自定义页面
    while (webParentView.getChildCount() > 1) {
        webParentView.removeViewAt(0);
    }
    @SuppressWarnings("deprecation")
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT);
    webParentView.addView(mErrorView, 0, lp);
    mIsErrorPage = true;
}
 
源代码8 项目: Telegram   文件: Bulletin.java
public static Bulletin find(@NonNull FrameLayout containerLayout) {
    for (int i = 0, size = containerLayout.getChildCount(); i < size; i++) {
        final View view = containerLayout.getChildAt(i);
        if (view instanceof Layout) {
            return ((Layout) view).bulletin;
        }
    }
    return null;
}
 
public void removeBarValues() {

		if (oldFrameLayout != null)
			removeClickedBar();

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);
			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				View childView = rootFrame.getChildAt(j);

				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {
							BarAnimation anim = new BarAnimation(((Bar) view), (int) (mDataList.get(i).getBarValue() * 100), 0);
							anim.setDuration(250);
							((Bar) view).startAnimation(anim);
						}
					}
				}
			}


		}
		isBarsEmpty = true;
	}
 
public void resetBarValues() {

		if (oldFrameLayout != null)
			removeClickedBar();

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);
			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				View childView = rootFrame.getChildAt(j);

				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {
							BarAnimation anim = new BarAnimation(((Bar) view), 0, (int) (mDataList.get(i).getBarValue() * 100));
							anim.setDuration(250);
							((Bar) view).startAnimation(anim);
						}
					}
				}


			}
		}
		isBarsEmpty = false;
	}
 
源代码11 项目: FuAgoraDemoDroid   文件: VideoViewAdapter.java
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    VideoUserStatusHolder myHolder = ((VideoUserStatusHolder) holder);

    final VideoStatusData user = mUsers.get(position);

    Log.d("VideoViewAdapter", "onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView);

    log.debug("onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView);

    FrameLayout holderView = (FrameLayout) myHolder.itemView;

    if (holderView.getChildCount() == 0) {
        SurfaceView target = user.mView;
        stripSurfaceView(target);
        holderView.addView(target, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }

    holderView.setOnTouchListener(new OnDoubleTapListener(mContext) {
        @Override
        public void onDoubleTap(View view, MotionEvent e) {
            if (mListener != null) {
                mListener.onItemDoubleClick(view, user);
            }
        }

        @Override
        public void onSingleTapUp() {
        }
    });

}
 
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    VideoUserStatusHolder myHolder = ((VideoUserStatusHolder) holder);

    final VideoStatusData user = mUsers.get(position);

    log.debug("onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView);

    FrameLayout holderView = (FrameLayout) myHolder.itemView;

    holderView.setOnTouchListener(new OnDoubleTapListener(mContext) {
        @Override
        public void onDoubleTap(View view, MotionEvent e) {
            if (mListener != null) {
                mListener.onItemDoubleClick(view, user);
            }
        }

        @Override
        public void onSingleTapUp() {
        }
    });

    if (holderView.getChildCount() == 0) {
        SurfaceView target = user.mView;
        stripSurfaceView(target);
        holderView.addView(target, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }
}
 
源代码13 项目: Taskbar   文件: HomeActivityDelegate.java
@Override
public boolean onDrag(View v, DragEvent event) {
    switch(event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
        default:
            // do nothing
            break;
        case DragEvent.ACTION_DRAG_ENTERED:
            FrameLayout container = (FrameLayout) v;
            if(container.getChildCount() == 0
                    || startDragIndex == desktopIcons.indexOfChild(container)) {
                v.setBackgroundColor(U.getAccentColor(HomeActivityDelegate.this));
                v.setAlpha(0.5f);
            }
            break;
        case DragEvent.ACTION_DRAG_ENDED:
            View view = (View) event.getLocalState();
            view.setVisibility(View.VISIBLE);
            // fall through
        case DragEvent.ACTION_DRAG_EXITED:
            v.setBackground(null);
            v.setAlpha(1);
            break;
        case DragEvent.ACTION_DROP:
            FrameLayout container2 = (FrameLayout) v;
            if(container2.getChildCount() == 0) {
                // Dropped, reassign View to ViewGroup
                View view2 = (View) event.getLocalState();
                ViewGroup owner = (ViewGroup) view2.getParent();
                owner.removeView(view2);
                container2.addView(view2);

                endDragIndex = desktopIcons.indexOfChild(container2);
                reassignDroppedIcon();
            }
            break;
    }
    return true;
}
 
源代码14 项目: timelapse-sony   文件: SingleFragmentActivity.java
@Override
protected void onStart() {
    super.onStart();

    FrameLayout frameLayout = findViewById(R.id.fragment_container);
    if(frameLayout != null && frameLayout.getChildCount() > 0) {
        mSnackBarConnectionLost = Snackbar.make(frameLayout.getChildAt(0),
                getString(R.string.connection_with_camera_lost), Snackbar.LENGTH_INDEFINITE);
    } else {
        mNotConnectedMessage = false;
    }

}
 
public void disableBar(int index) {

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				if ((int) rootFrame.getTag() != index)
					continue;

				rootFrame.setEnabled(false);
				rootFrame.setClickable(false);

				View childView = rootFrame.getChildAt(j);
				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {

							Bar bar = (Bar) view;

							LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
							layerDrawable.mutate();

							ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

							GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();

							if (progressLayer != null) {

								if (mProgressDisableColor > 0)
									progressLayer.setColor(ContextCompat.getColor(mContext, mProgressDisableColor));
								else
									progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
							}
						} else {
							TextView titleTxtView = (TextView) view;
							if (mProgressDisableColor > 0)
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, mProgressDisableColor));
							else
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
						}
					}
				}
			}
		}
	}
 
public void enableBar(int index) {

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				if ((int) rootFrame.getTag() != index)
					continue;

				rootFrame.setEnabled(true);
				rootFrame.setClickable(true);

				View childView = rootFrame.getChildAt(j);
				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {

							Bar bar = (Bar) view;

							LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
							layerDrawable.mutate();

							ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

							GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();

							if (progressLayer != null) {

								if (mProgressColor > 0)
									progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor));
								else
									progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
							}
						} else {
							TextView titleTxtView = (TextView) view;
							if (mProgressDisableColor > 0)
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor));
							else
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
						}
					}
				}
			}
		}
	}
 
public void selectBar(int index) {

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				if ((int) rootFrame.getTag() != index)
					continue;

				if (oldFrameLayout != null)
					clickBarOff(oldFrameLayout);

				clickBarOn(rootFrame);
				oldFrameLayout = rootFrame;
			}
		}
	}
 
public void deselectBar(int index) {
	final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

	for (int i = 0; i < barsCount; i++) {

		FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

		int rootChildCount = rootFrame.getChildCount();

		for (int j = 0; j < rootChildCount; j++) {

			if ((int) rootFrame.getTag() != index)
				continue;

			clickBarOff(rootFrame);
		}
	}
}
 
源代码19 项目: FloatUtil   文件: Window.java
public Window(WindowWrapper windowWrapper) {
    super(windowWrapper.getContext());

    mContext = windowWrapper.getContext();
    mWindowWrapper = windowWrapper;

    this.id = mWindowWrapper.WindowId;
    this.originalParams = windowWrapper.onRequestLayoutParams();
    this.flags = windowWrapper.onRequestWindowFlags();
    this.touchInfo = new TouchInfo();
    touchInfo.ratio = (float) originalParams.width / originalParams.height;
    this.data = new Bundle();

    // create the window contents
    FrameLayout content = new FrameLayout(mContext);
    content.setId(android.R.id.content);
    addView(content);

    mLongPressRunnable = new Runnable() {

        @Override
        public void run() {
            if (mWindowWrapper.handleLongClick()){
                touchInfo.isLongPress = true;
                mWindowWrapper.onLongPressed();
            }
        }
    };

    content.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            // pass all touch events to the implementation
            boolean consumed = false;

            final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager();


            dispatchLongPress(event);
            // handle move and bring to front
            consumed = windowManager.onTouchHandleMove(Window.this, v, event)
                    || consumed;

            // alert implementation
            consumed = mWindowWrapper.onTouchBody(Window.this, v, event)
                    || consumed;

            return consumed;
        }
    });


    // attach the view corresponding to the id from the
    // implementation
    windowWrapper.onCreateAndAttachView(content);

    // make sure the implementation attached the view
    if (content.getChildCount() == 0) {
        Log.e(TAG, "You must attach your view to the given frame in onCreateAndAttachView()");
    }

    // attach the existing tag from the frame to the window
    setTag(content.getTag());
    windowWrapper.isCreated = true;
}
 
private void clickBarOff(FrameLayout frameLayout) {

		pins.get((int) frameLayout.getTag()).setVisibility(View.INVISIBLE);


		isOldBarClicked = false;

		int childCount = frameLayout.getChildCount();

		for (int i = 0; i < childCount; i++) {

			View childView = frameLayout.getChildAt(i);
			if (childView instanceof LinearLayout) {

				LinearLayout linearLayout = (LinearLayout) childView;
				Bar bar = (Bar) linearLayout.getChildAt(0);
				TextView titleTxtView = (TextView) linearLayout.getChildAt(1);

				LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
				layerDrawable.mutate();

				ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

				GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();
				if (progressLayer != null) {
					progressLayer.setColor(ContextCompat.getColor(mContext, mProgressColor));
				}
				titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleColor));
			}
		}
	}