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:com.oasisfeng.nevo.decorators.media.MediaPlayerDecorator.java

/** @return continue or not */
private boolean findClickable(final ViewGroup views, final Predicate<View> callback) {
    for (int i = 0; i < views.getChildCount(); i++) {
        final View view = views.getChildAt(i);
        if (view instanceof ViewGroup) {
            if (!findClickable((ViewGroup) view, callback))
                return false;
        } else if (view.hasOnClickListeners())
            if (!callback.apply(view))
                return false;
    }//from w  w  w.j  a v  a2s.  c  om
    return true;
}

From source file:com.njlabs.amrita.aid.gpms.ui.PendingPassActivity.java

public void cancelPass(final View v) {
    String requestId = (String) v.getTag();
    ProgressBar progressBar = null;// w ww .j  a va  2 s  .  c  o m
    ViewGroup row = (ViewGroup) v.getParent();
    for (int itemPos = 0; itemPos < row.getChildCount(); itemPos++) {
        View view = row.getChildAt(itemPos);
        if (view instanceof ProgressBar) {
            progressBar = (ProgressBar) view;
            break;
        }
    }

    if (progressBar != null) {
        progressBar.setVisibility(View.VISIBLE);
        v.setVisibility(View.GONE);
    }

    final ProgressBar finalProgressBar = progressBar;

    gpms.cancelPass(requestId, new SuccessResponse() {
        @Override
        public void onSuccess() {
            swipeRefreshLayout.setRefreshing(true);
            loadData();
            Snackbar.make(parentView, "Pass cancelled successfully.", Snackbar.LENGTH_LONG).show();

            Bundle bundle = new Bundle();
            bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "GPMS");
            bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Cancel Pass");
            bundle.putString(FirebaseAnalytics.Param.CHARACTER,
                    gpms.getStudentName() + " - " + gpms.getStudentRollNo());
            tracker.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
        }

        @Override
        public void onFailure(Throwable throwable) {
            Ln.e(throwable);
            if (finalProgressBar != null) {
                finalProgressBar.setVisibility(View.GONE);
                v.setVisibility(View.VISIBLE);
            }
            Snackbar.make(parentView, "An error occurred while cancelling your pass", Snackbar.LENGTH_LONG)
                    .show();
        }
    });
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

private View getFirstNonLabelView(ViewGroup row) {
    int i;/*from   w  w  w . j  a v a 2s.  c o  m*/
    for (i = 0; i < row.getChildCount(); i++) {
        if (!(row.getChildAt(i) instanceof TextView)) {
            break;
        } else if (row.getChildAt(i) instanceof EditText) {
            break;
        }
    }
    return row.getChildAt(i);
}

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.viewer.WebViewInjector.java

@Override
public void onActivityLifecycleChanged(Activity activity, Stage stage) {
    ComponentName targetComponentName = new ComponentName(activity, mClass.getName());

    ComponentName currentComponentName = activity.getComponentName();
    if (!currentComponentName.equals(targetComponentName))
        return;/*  w w w.  jav a2  s .c o m*/

    switch (stage) {
    case RESUMED:
        // As soon as, we are trying to register inject of idle resource during on Resume.
        // We need to do this only first time. And yes, I know it is dirty. Any suggestions welcomed :)
        if (!mInjected) {
            FragmentActivity htmlViewerActivity = (FragmentActivity) activity;
            WebViewFragment fragment = (WebViewFragment) htmlViewerActivity.getSupportFragmentManager()
                    .findFragmentByTag(WebViewFragment.TAG);
            ViewGroup holder = (ViewGroup) fragment.getView().findViewById(R.id.webViewPlaceholder);
            // We need to wait for the activity to be created before getting a reference
            // to the webview
            JSWebView webView = (JSWebView) holder.getChildAt(0);

            mWebViewIdlingResource.inject(webView);
            mInjected = true;
        }
        break;
    case STOPPED:
        // Clean up reference
        if (activity.isFinishing())
            mWebViewIdlingResource.clear();
        break;
    default: // NOP
    }
}

From source file:com.jaspervanriet.huntingthatproduct.Views.FeedContextMenuManager.java

private void showContextMenuFromView(final View openingView, int feedItem,
        FeedContextMenu.OnFeedContextMenuItemClickListener listener, boolean isMainActivity) {
    if (!isContextMenuShowing) {
        isContextMenuShowing = true;/*  w w w  .  j  a  v a 2  s . c o m*/
        contextMenuView = new FeedContextMenu(openingView.getContext());
        contextMenuView.bindToItem(feedItem);
        contextMenuView.addOnAttachStateChangeListener(this);
        contextMenuView.setOnFeedMenuItemClickListener(listener);
        ViewGroup viewGroup = (ViewGroup) openingView.getRootView().findViewById(android.R.id.content);
        RelativeLayout relativeLayout;
        if (isMainActivity) {
            DrawerLayout drawerLayout = (DrawerLayout) viewGroup.getChildAt(0);
            relativeLayout = (RelativeLayout) drawerLayout.getChildAt(0);
        } else {
            relativeLayout = (RelativeLayout) viewGroup.getChildAt(0);
        }
        relativeLayout.addView(contextMenuView);
        contextMenuView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                contextMenuView.getViewTreeObserver().removeOnPreDrawListener(this);
                setupContextMenuInitialPosition(openingView);
                performShowAnimation();
                return false;
            }
        });
    }
}

From source file:mobi.cangol.mobile.navigation.DrawerMenuLayout.java

public void attachToActivity(Activity activity, boolean isFloatActionBarEnabled) {
    // get the window background
    TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    int background = a.getResourceId(0, 0);
    a.recycle();/*from   w  ww.  jav a2s.co m*/

    this.isFloatActionBarEnabled = isFloatActionBarEnabled;

    if (isFloatActionBarEnabled) {
        ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
        ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
        if (decorChild.getBackground() != null) {
            this.setBackgroundDrawable(decorChild.getBackground());
            decorChild.setBackgroundDrawable(null);
        } else {
            if (this.getBackground() == null)
                this.setBackgroundResource(background);
        }
        decor.removeView(decorChild);
        decor.addView(this, 0);
        getContentView().addView(decorChild);
    } else {
        ViewGroup contentParent = (ViewGroup) activity.findViewById(android.R.id.content);
        ViewGroup content = (ViewGroup) contentParent.getChildAt(0);
        contentParent.removeView(content);
        contentParent.addView(this, 0);
        getContentView().addView(content);
    }
}

From source file:gr.plushost.prototypeapp.widgets.LabelView.java

public void remove() {
    if (getParent() == null || _labelViewContainerID == -1) {
        return;// w  w  w  .  jav  a 2s. c  om
    }

    ViewGroup frameContainer = (ViewGroup) getParent();
    assert (frameContainer.getChildCount() == 2);
    View target = frameContainer.getChildAt(0);

    ViewGroup parentContainer = (ViewGroup) frameContainer.getParent();
    int groupIndex = parentContainer.indexOfChild(frameContainer);
    if (frameContainer.getParent() instanceof RelativeLayout) {
        for (int i = 0; i < parentContainer.getChildCount(); i++) {
            if (i == groupIndex) {
                continue;
            }
            View view = parentContainer.getChildAt(i);
            RelativeLayout.LayoutParams para = (RelativeLayout.LayoutParams) view.getLayoutParams();
            for (int j = 0; j < para.getRules().length; j++) {
                if (para.getRules()[j] == _labelViewContainerID) {
                    para.getRules()[j] = target.getId();
                }
            }
            view.setLayoutParams(para);
        }
    }

    ViewGroup.LayoutParams frameLayoutParam = frameContainer.getLayoutParams();
    target.setLayoutParams(frameLayoutParam);
    parentContainer.removeViewAt(groupIndex);
    frameContainer.removeView(target);
    frameContainer.removeView(this);
    parentContainer.addView(target, groupIndex);
    _labelViewContainerID = -1;
}

From source file:com.forrestguice.suntimeswidget.LocationDialog.java

public AlertDialog toAlertDialog() {
    ViewGroup dialogFrame = (ViewGroup) this.getWindow().getDecorView();
    View dialogContent = dialogFrame.getChildAt(0);
    dialogFrame.removeView(dialogContent);

    AlertDialog.Builder builder = new AlertDialog.Builder(myParent);
    builder.setView(dialogContent);//from   w w  w .j  a va 2s .  co  m
    AlertDialog dialog = builder.create();

    dialog.setButton(AlertDialog.BUTTON_NEGATIVE, myParent.getString(R.string.location_dialog_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    getFixHelper.cancelGetFix();
                    dialog.dismiss();

                    if (onCanceled != null) {
                        onCanceled.onClick(dialog, which);
                    }
                }
            });

    dialog.setButton(AlertDialog.BUTTON_POSITIVE, myParent.getString(R.string.location_dialog_ok),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    getFixHelper.cancelGetFix();
                    saveSettings(myParent);
                    dialog.dismiss();

                    if (onAccepted != null) {
                        onAccepted.onClick(dialog, which);
                    }
                }
            });

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            loadSettings(myParent);
        }
    });

    dialog.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialogInterface) {
        }
    });

    return dialog;
}

From source file:kiv.janecekz.ma.ToneFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.tone, container, false);
    RelativeLayout space = (RelativeLayout) root.findViewById(R.id.sunspace);
    space.setOnTouchListener(TouchControl.getInstance());

    circle = (ImageView) root.findViewById(R.id.circle);

    inAnim = TouchControl.getAnimation(TouchControl.ANIMATION_IN, 300);
    outAnim = TouchControl.getAnimation(TouchControl.ANIMATION_OUT, 300);

    input = (EditText) root.findViewById(R.id.tone_value_edit);
    input.setOnEditorActionListener(this);

    TextView sharp = (TextView) root.findViewById(R.id.sharp);
    sharp.setOnClickListener(this);

    ViewGroup defList = (ViewGroup) root.findViewById(R.id.tone_list);
    for (int i = 0; i < defList.getChildCount(); i++) {
        TextView v = (TextView) defList.getChildAt(i);
        v.setOnClickListener(this);
    }/*from w w  w  .ja v a 2  s.  c o  m*/
    return root;
}

From source file:net.sf.asap.Player.java

private View getContentView() {
    ViewGroup vg = (ViewGroup) getWindow().getDecorView();
    return vg.getChildAt(0);
}