Example usage for android.view ViewGroup getChildAt

List of usage examples for android.view ViewGroup getChildAt

Introduction

In this page you can find the example usage for android.view ViewGroup getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java

private HashMap<Integer, String> processTextAnnotations(ViewGroup viewGroup) {
    HashMap<Integer, String> allTextAnnotations = new HashMap<>();
    if (viewGroup != null) {
        for (int i = 0; i < viewGroup.getChildCount(); ++i) {
            View child = viewGroup.getChildAt(i);
            if (child instanceof TextAnnotationImageView) {
                TextAnnotationImageView textAnnotationView = (TextAnnotationImageView) child;

                int key = Integer.valueOf(textAnnotationView.getAnnotationNumberView().getText().toString());
                // If no text was entered, just set the empty string
                String annotationInputText = "";
                if (textAnnotationView.getAnnotationInputText() != null) {
                    annotationInputText = (textAnnotationView.getAnnotationInputText()).trim();
                }// w w w  .  j a  va2s.  c o m
                int annotationImageResource = textAnnotationView.getImageResourceId();
                float getX = child.getX();
                float getY = child.getY();
                String value = annotationInputText + Utils.SEPARATOR + annotationImageResource + Utils.SEPARATOR
                        + getX + Utils.SEPARATOR + getY;
                allTextAnnotations.put(key, value);
            }
        }
    }

    return allTextAnnotations;
}

From source file:net.ibaixin.chat.view.PagerSlidingTabStrip.java

/**
 * ?????view/*  www. j a va 2s .  c  o m*/
 * @param position ??0
 * @return ???view
 */
public View getCurrentTargetView(int position) {
    ViewGroup viewGroup = (ViewGroup) mTabLayout.getChildAt(position);
    View view = viewGroup.getChildAt(1);
    return view;
}

From source file:de.mrapp.android.bottomsheet.view.DraggableView.java

/**
 * Returns, whether a touch event at a specific position targets a view, which can be scrolled
 * up./*w  w  w .ja  v  a  2 s  .  c om*/
 *
 * @param x
 *         The horizontal position of the touch event in pixels as a {@link Float} value
 * @param y
 *         The vertical position of the touch event in pixels as a {@link Float} value
 * @param viewGroup
 *         The view group, which should be used to search for scrollable child views, as an
 *         instance of the class {@link ViewGroup}. The view group may not be null
 * @return True, if the touch event targets a view, which can be scrolled up, false otherwise
 */
private boolean isScrollUpEvent(final float x, final float y, @NonNull final ViewGroup viewGroup) {
    int location[] = new int[2];
    viewGroup.getLocationOnScreen(location);

    if (x >= location[0] && x <= location[0] + viewGroup.getWidth() && y >= location[1]
            && y <= location[1] + viewGroup.getHeight()) {
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View view = viewGroup.getChildAt(i);

            if (ViewCompat.canScrollVertically(view, -1)) {
                return true;
            } else if (view instanceof ViewGroup) {
                return isScrollUpEvent(x, y, (ViewGroup) view);
            }
        }
    }

    return false;
}

From source file:com.juick.android.JuickMessagesAdapter.java

public static View findViewForCoordinates(ViewGroup view, float x, float y) {
    int childCount = view.getChildCount();
    for (int i = childCount - 1; i >= 0; i--) {
        View child = view.getChildAt(i);
        child.getHitRect(hitRect);// w  w  w .  j av  a2s. c o m
        if (hitRect.top < y && hitRect.top + hitRect.bottom > y && hitRect.left < x && hitRect.right > x) {
            View retval = null;
            if (child instanceof ViewGroup) {
                retval = findViewForCoordinates((ViewGroup) child, x - hitRect.left, y - hitRect.top);
            }
            if (retval == null)
                retval = child;
            return retval;
        }
    }
    return null;
}

From source file:android.support.car.app.CarFragmentActivity.java

private void dumpViewHierarchy(String prefix, PrintWriter writer, View view) {
    writer.print(prefix);// w w  w  .java2  s  . c  o m
    if (view == null) {
        writer.println("null");
        return;
    }
    writer.println(viewToString(view));
    if (!(view instanceof ViewGroup)) {
        return;
    }
    ViewGroup grp = (ViewGroup) view;
    final int N = grp.getChildCount();
    if (N <= 0) {
        return;
    }
    prefix = prefix + "  ";
    for (int i = 0; i < N; i++) {
        dumpViewHierarchy(prefix, writer, grp.getChildAt(i));
    }
}

From source file:bottombar.BottomBar.java

private BottomBarTab findTabInLayout(ViewGroup child) {
    for (int i = 0; i < child.getChildCount(); i++) {
        View candidate = child.getChildAt(i);

        if (candidate instanceof BottomBarTab) {
            return (BottomBarTab) candidate;
        }//from  ww w.j a  va 2s.c  o  m
    }

    return null;
}

From source file:com.mfh.framework.uikit.widget.SideSlidingTabStrip.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (!allowWidthFull)
        return;/*from ww  w.  j  a  va2  s.c om*/
    ViewGroup tabsLayout = getTabsLayout();
    if (tabsLayout == null || tabsLayout.getMeasuredWidth() >= getMeasuredWidth())
        return;
    if (tabsLayout.getChildCount() <= 0)
        return;

    if (tabViews == null) {
        tabViews = new ArrayList<>();
    } else {
        tabViews.clear();
    }
    for (int w = 0; w < tabsLayout.getChildCount(); w++) {
        tabViews.add(tabsLayout.getChildAt(w));
    }

    adjustChildHeightWithParent(tabViews,
            getMeasuredHeight() - tabsLayout.getPaddingTop() - tabsLayout.getPaddingBottom(), widthMeasureSpec,
            heightMeasureSpec);

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

From source file:com.matcontrol.control.BottomSheetBehavior_v25.java

private View findScrollingChild(View view) {
    if (view instanceof NestedScrollingChild) {
        return view;
    }/*from w  w  w .  j  a  v a 2  s  . c  om*/

    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        for (int i = 0, count = group.getChildCount(); i < count; i++) {
            View scrollingChild = findScrollingChild(group.getChildAt(i));
            if (scrollingChild != null) {
                return scrollingChild;
            }
        }
    }
    return null;
}

From source file:com.ndn.menurandom.ImageDownloader.java

private void makeFrameLayout(ImageView imageView) {
    boolean isExist = false;
    ViewGroup vg = (ViewGroup) imageView.getParent();
    if (vg instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) vg;
        String tag = (String) frameLayout.getTag();
        if (tag != null && tag.equals("fl_imagedownloader")) {
            isExist = true;/*www  .j a  v a 2s .  c  o m*/
        }
    }

    if (!isExist) {
        int childCount = vg.getChildCount();
        int index = 0;
        while (index < childCount) {
            if (imageView == vg.getChildAt(index)) {
                break;
            }
            index++;
        }
        vg.removeViewAt(index);

        FrameLayout frameLayout = new FrameLayout(vg.getContext().getApplicationContext());
        frameLayout.setTag("fl_imagedownloader");
        ViewGroup.LayoutParams lpImageView = (ViewGroup.LayoutParams) imageView.getLayoutParams();
        frameLayout.setLayoutParams(lpImageView);
        imageView.setLayoutParams(new LayoutParams(lpImageView.width, lpImageView.height));
        frameLayout.setPadding(imageView.getPaddingLeft(), imageView.getPaddingTop(),
                imageView.getPaddingRight(), imageView.getPaddingBottom());
        imageView.setPadding(0, 0, 0, 0);
        frameLayout.addView(imageView);
        vg.addView(frameLayout, index);

        ProgressBar progressBar = new ProgressBar(frameLayout.getContext());
        progressBar.setTag("pb_imagedownloader");
        int leftRightPadding = (imageView.getLayoutParams().width - 50) / 2;
        int topBottomPadding = (imageView.getLayoutParams().height - 50) / 2;
        progressBar.setPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding);
        frameLayout.addView(progressBar);

    }
}

From source file:com.coact.kochzap.CaptureActivity.java

private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {

    maybeSetClipboard(resultHandler);/* w  w  w  .  j ava2  s.  c o  m*/

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    if (resultHandler.getDefaultButtonID() != null
            && prefs.getBoolean(PreferencesActivity.KEY_AUTO_OPEN_WEB, false)) {
        resultHandler.handleButtonPress(resultHandler.getDefaultButtonID());
        return;
    }

    statusView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
    if (barcode == null) {
        barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.launcher_icon));
    } else {
        barcodeImageView.setImageBitmap(barcode);
    }

    TextView formatTextView = (TextView) findViewById(R.id.format_text_view);
    formatTextView.setText(rawResult.getBarcodeFormat().toString());

    TextView typeTextView = (TextView) findViewById(R.id.type_text_view);
    typeTextView.setText(resultHandler.getType().toString());

    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
    timeTextView.setText(formatter.format(rawResult.getTimestamp()));

    TextView metaTextView = (TextView) findViewById(R.id.meta_text_view);
    View metaTextViewLabel = findViewById(R.id.meta_text_view_label);
    metaTextView.setVisibility(View.GONE);
    metaTextViewLabel.setVisibility(View.GONE);
    Map<ResultMetadataType, Object> metadata = rawResult.getResultMetadata();
    if (metadata != null) {
        StringBuilder metadataText = new StringBuilder(20);
        for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) {
            if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) {
                metadataText.append(entry.getValue()).append('\n');
            }
        }
        if (metadataText.length() > 0) {
            metadataText.setLength(metadataText.length() - 1);
            metaTextView.setText(metadataText);
            metaTextView.setVisibility(View.VISIBLE);
            metaTextViewLabel.setVisibility(View.VISIBLE);
        }
    }

    CharSequence displayContents = resultHandler.getDisplayContents();
    TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
    contentsTextView.setText(displayContents);
    int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
    contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
    supplementTextView.setText("");
    supplementTextView.setOnClickListener(null);
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PreferencesActivity.KEY_SUPPLEMENTAL,
            true)) {
        SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, resultHandler.getResult(),
                historyManager, this);
    }

    int buttonCount = resultHandler.getButtonCount();
    ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view);
    buttonView.requestFocus();
    for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) {
        TextView button = (TextView) buttonView.getChildAt(x);
        if (x < buttonCount) {
            button.setVisibility(View.VISIBLE);
            button.setText(resultHandler.getButtonText(x));
            button.setOnClickListener(new ResultButtonListener(resultHandler, x));
        } else {
            button.setVisibility(View.GONE);
        }
    }

}