Example usage for android.view ViewGroup addView

List of usage examples for android.view ViewGroup addView

Introduction

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

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:com.scoreflex.Scoreflex.java

/**
 * Attach the given view above the activity's view hierarchy.
 *
 * @param activity/* ww  w.  j  a  v a  2 s . c o m*/
 *            The activity that will host the view.
 * @param view
 *            The view to attach.
 * @param gravity
 *            Chooses if the view should be up are down of the screen.
 */

private static void attachView(Activity activity, View view, int gravity) {
    ViewGroup contentView = (ViewGroup) activity.getWindow().getDecorView().findViewById(android.R.id.content);
    // final float scale =
    // activity.getResources().getDisplayMetrics().density;

    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            getDensityIndependantPixel(
                    activity.getResources().getDimensionPixelSize(R.dimen.scoreflex_panel_height)),
            gravity);
    view.setLayoutParams(layoutParams);
    view.setVisibility(View.GONE);
    contentView.addView(view);
    // activity.addContentView(view, layoutParams);
    if (view instanceof ScoreflexView)
        ((ScoreflexView) view).addDropShadow(gravity);
}

From source file:android.support.v17.leanback.app.GuidedStepFragment.java

/**
 * {@inheritDoc}/*w  w w .ja  v  a  2  s  . c o m*/
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG)
        Log.v(TAG, "onCreateView");

    resolveTheme();
    inflater = getThemeInflater(inflater);

    GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment,
            container, false);

    root.setFocusOutStart(isFocusOutStartAllowed());
    root.setFocusOutEnd(isFocusOutEndAllowed());

    ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment);
    ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment);

    Guidance guidance = onCreateGuidance(savedInstanceState);
    View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance);
    guidanceContainer.addView(guidanceView);

    View actionsView = mActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(actionsView);

    View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(buttonActionsView);

    GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() {

        @Override
        public void onImeOpen() {
            runImeAnimations(true);
        }

        @Override
        public void onImeClose() {
            runImeAnimations(false);
        }

        @Override
        public long onGuidedActionEditedAndProceed(GuidedAction action) {
            return GuidedStepFragment.this.onGuidedActionEditedAndProceed(action);
        }

        @Override
        public void onGuidedActionEditCanceled(GuidedAction action) {
            GuidedStepFragment.this.onGuidedActionEditCanceled(action);
        }
    };

    mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepFragment.this.onGuidedActionClicked(action);
            if (isSubActionsExpanded()) {
                collapseSubActions();
            } else if (action.hasSubActions()) {
                expandSubActions(action);
            }
        }
    }, this, mActionsStylist, false);
    mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepFragment.this.onGuidedActionClicked(action);
        }
    }, this, mButtonActionsStylist, false);
    mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            if (mActionsStylist.isInExpandTransition()) {
                return;
            }
            if (GuidedStepFragment.this.onSubGuidedActionClicked(action)) {
                collapseSubActions();
            }
        }
    }, this, mActionsStylist, true);
    mAdapterGroup = new GuidedActionAdapterGroup();
    mAdapterGroup.addAdpter(mAdapter, mButtonAdapter);
    mAdapterGroup.addAdpter(mSubAdapter, null);
    mAdapterGroup.setEditListener(editListener);
    mActionsStylist.setEditListener(editListener);

    mActionsStylist.getActionsGridView().setAdapter(mAdapter);
    if (mActionsStylist.getSubActionsGridView() != null) {
        mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter);
    }
    mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter);
    if (mButtonActions.size() == 0) {
        // when there is no button actions, we dont need show the second panel, but keep
        // the width zero to run ChangeBounds transition.
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams();
        lp.weight = 0;
        buttonActionsView.setLayoutParams(lp);
    } else {
        // when there are two actions panel, we need adjust the weight of action to
        // guidedActionContentWidthWeightTwoPanels.
        Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity();
        TypedValue typedValue = new TypedValue();
        if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) {
            View actionsRoot = root.findViewById(R.id.action_fragment_root);
            float weight = typedValue.getFloat();
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams();
            lp.weight = weight;
            actionsRoot.setLayoutParams(lp);
        }
    }

    int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex
            : getFirstCheckedAction();
    setSelectedActionPosition(pos);

    setSelectedButtonActionPosition(0);

    // Add the background view.
    View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState);
    if (backgroundView != null) {
        FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root);
        backgroundViewRoot.addView(backgroundView, 0);
    }
    return root;
}

From source file:android.support.v17.leanback.app.GuidedStepSupportFragment.java

/**
 * {@inheritDoc}//from  www. jav a  2  s  .  c  o  m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG)
        Log.v(TAG, "onCreateView");

    resolveTheme();
    inflater = getThemeInflater(inflater);

    GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment,
            container, false);

    root.setFocusOutStart(isFocusOutStartAllowed());
    root.setFocusOutEnd(isFocusOutEndAllowed());

    ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment);
    ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment);

    Guidance guidance = onCreateGuidance(savedInstanceState);
    View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance);
    guidanceContainer.addView(guidanceView);

    View actionsView = mActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(actionsView);

    View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(buttonActionsView);

    GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() {

        @Override
        public void onImeOpen() {
            runImeAnimations(true);
        }

        @Override
        public void onImeClose() {
            runImeAnimations(false);
        }

        @Override
        public long onGuidedActionEditedAndProceed(GuidedAction action) {
            return GuidedStepSupportFragment.this.onGuidedActionEditedAndProceed(action);
        }

        @Override
        public void onGuidedActionEditCanceled(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionEditCanceled(action);
        }
    };

    mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionClicked(action);
            if (isSubActionsExpanded()) {
                collapseSubActions();
            } else if (action.hasSubActions()) {
                expandSubActions(action);
            }
        }
    }, this, mActionsStylist, false);
    mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionClicked(action);
        }
    }, this, mButtonActionsStylist, false);
    mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            if (mActionsStylist.isInExpandTransition()) {
                return;
            }
            if (GuidedStepSupportFragment.this.onSubGuidedActionClicked(action)) {
                collapseSubActions();
            }
        }
    }, this, mActionsStylist, true);
    mAdapterGroup = new GuidedActionAdapterGroup();
    mAdapterGroup.addAdpter(mAdapter, mButtonAdapter);
    mAdapterGroup.addAdpter(mSubAdapter, null);
    mAdapterGroup.setEditListener(editListener);
    mActionsStylist.setEditListener(editListener);

    mActionsStylist.getActionsGridView().setAdapter(mAdapter);
    if (mActionsStylist.getSubActionsGridView() != null) {
        mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter);
    }
    mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter);
    if (mButtonActions.size() == 0) {
        // when there is no button actions, we dont need show the second panel, but keep
        // the width zero to run ChangeBounds transition.
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams();
        lp.weight = 0;
        buttonActionsView.setLayoutParams(lp);
    } else {
        // when there are two actions panel, we need adjust the weight of action to
        // guidedActionContentWidthWeightTwoPanels.
        Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity();
        TypedValue typedValue = new TypedValue();
        if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) {
            View actionsRoot = root.findViewById(R.id.action_fragment_root);
            float weight = typedValue.getFloat();
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams();
            lp.weight = weight;
            actionsRoot.setLayoutParams(lp);
        }
    }

    int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex
            : getFirstCheckedAction();
    setSelectedActionPosition(pos);

    setSelectedButtonActionPosition(0);

    // Add the background view.
    View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState);
    if (backgroundView != null) {
        FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root);
        backgroundViewRoot.addView(backgroundView, 0);
    }
    return root;
}

From source file:com.rbware.github.androidcouchpotato.app.GuidedStepFragment.java

/**
 * {@inheritDoc}//w w  w. j a v a2 s.c o  m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG)
        Log.v(TAG, "onCreateView");

    resolveTheme();
    inflater = getThemeInflater(inflater);

    GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment,
            container, false);

    root.setFocusOutStart(isFocusOutStartAllowed());
    root.setFocusOutEnd(isFocusOutEndAllowed());

    ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment);
    ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment);

    Guidance guidance = onCreateGuidance(savedInstanceState);
    View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance);
    guidanceContainer.addView(guidanceView);

    View actionsView = mActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(actionsView);

    View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(buttonActionsView);

    GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() {

        @Override
        public void onImeOpen() {
            runImeAnimations(true);
        }

        @Override
        public void onImeClose() {
            runImeAnimations(false);
        }

        @Override
        public long onGuidedActionEditedAndProceed(GuidedAction action) {
            return GuidedStepFragment.this.onGuidedActionEditedAndProceed(action);
        }

        @Override
        public void onGuidedActionEditCanceled(GuidedAction action) {
            GuidedStepFragment.this.onGuidedActionEditCanceled(action);
        }
    };

    mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepFragment.this.onGuidedActionClicked(action);
            if (isSubActionsExpanded()) {
                collapseSubActions();
            } else if (action.hasSubActions()) {
                expandSubActions(action);
            }
        }
    }, this, mActionsStylist, false);
    mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepFragment.this.onGuidedActionClicked(action);
        }
    }, this, mButtonActionsStylist, false);
    mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            if (mActionsStylist.isInExpandTransition()) {
                return;
            }
            if (GuidedStepFragment.this.onSubGuidedActionClicked(action)) {
                collapseSubActions();
            }
        }
    }, this, mActionsStylist, true);
    mAdapterGroup = new GuidedActionAdapterGroup();
    mAdapterGroup.addAdpter(mAdapter, mButtonAdapter);
    mAdapterGroup.addAdpter(mSubAdapter, null);
    mAdapterGroup.setEditListener(editListener);
    mActionsStylist.setEditListener(editListener);

    mActionsStylist.getActionsGridView().setAdapter(mAdapter);
    if (mActionsStylist.getSubActionsGridView() != null) {
        mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter);
    }
    mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter);
    if (mButtonActions.size() == 0) {
        // when there is no button actions, we don't need show the second panel, but keep
        // the width zero to run ChangeBounds transition.
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams();
        lp.weight = 0;
        buttonActionsView.setLayoutParams(lp);
    } else {
        // when there are two actions panel, we need adjust the weight of action to
        // guidedActionContentWidthWeightTwoPanels.
        Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity();
        TypedValue typedValue = new TypedValue();
        if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) {
            View actionsRoot = root.findViewById(R.id.action_fragment_root);
            float weight = typedValue.getFloat();
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams();
            lp.weight = weight;
            actionsRoot.setLayoutParams(lp);
        }
    }

    int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex
            : getFirstCheckedAction();
    setSelectedActionPosition(pos);

    setSelectedButtonActionPosition(0);

    // Add the background view.
    View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState);
    if (backgroundView != null) {
        FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root);
        backgroundViewRoot.addView(backgroundView, 0);
    }
    return root;
}

From source file:com.rbware.github.androidcouchpotato.app.GuidedStepSupportFragment.java

/**
 * {@inheritDoc}//from ww w  .  j av a  2s. c  o m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG)
        Log.v(TAG, "onCreateView");

    resolveTheme();
    inflater = getThemeInflater(inflater);

    GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment,
            container, false);

    root.setFocusOutStart(isFocusOutStartAllowed());
    root.setFocusOutEnd(isFocusOutEndAllowed());

    ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment);
    ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment);

    Guidance guidance = onCreateGuidance(savedInstanceState);
    View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance);
    guidanceContainer.addView(guidanceView);

    View actionsView = mActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(actionsView);

    View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(buttonActionsView);

    GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() {

        @Override
        public void onImeOpen() {
            runImeAnimations(true);
        }

        @Override
        public void onImeClose() {
            runImeAnimations(false);
        }

        @Override
        public long onGuidedActionEditedAndProceed(GuidedAction action) {
            return GuidedStepSupportFragment.this.onGuidedActionEditedAndProceed(action);
        }

        @Override
        public void onGuidedActionEditCanceled(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionEditCanceled(action);
        }
    };

    mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionClicked(action);
            if (isSubActionsExpanded()) {
                collapseSubActions();
            } else if (action.hasSubActions()) {
                expandSubActions(action);
            }
        }
    }, this, mActionsStylist, false);
    mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionClicked(action);
        }
    }, this, mButtonActionsStylist, false);
    mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            if (mActionsStylist.isInExpandTransition()) {
                return;
            }
            if (GuidedStepSupportFragment.this.onSubGuidedActionClicked(action)) {
                collapseSubActions();
            }
        }
    }, this, mActionsStylist, true);
    mAdapterGroup = new GuidedActionAdapterGroup();
    mAdapterGroup.addAdpter(mAdapter, mButtonAdapter);
    mAdapterGroup.addAdpter(mSubAdapter, null);
    mAdapterGroup.setEditListener(editListener);
    mActionsStylist.setEditListener(editListener);

    mActionsStylist.getActionsGridView().setAdapter(mAdapter);
    if (mActionsStylist.getSubActionsGridView() != null) {
        mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter);
    }
    mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter);
    if (mButtonActions.size() == 0) {
        // when there is no button actions, we don't need show the second panel, but keep
        // the width zero to run ChangeBounds transition.
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams();
        lp.weight = 0;
        buttonActionsView.setLayoutParams(lp);
    } else {
        // when there are two actions panel, we need adjust the weight of action to
        // guidedActionContentWidthWeightTwoPanels.
        Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity();
        TypedValue typedValue = new TypedValue();
        if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) {
            View actionsRoot = root.findViewById(R.id.action_fragment_root);
            float weight = typedValue.getFloat();
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams();
            lp.weight = weight;
            actionsRoot.setLayoutParams(lp);
        }
    }

    int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex
            : getFirstCheckedAction();
    setSelectedActionPosition(pos);

    setSelectedButtonActionPosition(0);

    // Add the background view.
    View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState);
    if (backgroundView != null) {
        FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root);
        backgroundViewRoot.addView(backgroundView, 0);
    }
    return root;
}

From source file:com.activiti.android.ui.form.FormManager.java

protected void generateForm(LayoutInflater li, boolean isEdition) {
    boolean hasTab = false;

    if (!version.is120OrAbove()) {
        generateForm11(li, isEdition);//  w w  w . jav a 2s  . c o  m
        return;
    }

    ViewGroup rootView;

    // Generate Tabs
    if (data.getTabs() != null && !data.getTabs().isEmpty()) {
        rootView = (ViewGroup) li.inflate(R.layout.form_root_tabs, null);

        hasTab = true;
        tabLayout = (TabLayout) rootView.findViewById(R.id.task_form_tabs_container);
        tabLayout.setVisibility(View.VISIBLE);

        tabHookViewIndex = new HashMap<>(data.getTabs().size());
        formTabFieldIndex = new LinkedHashMap<>(data.getTabs().size());

        int i = 0;
        for (FormTabRepresentation tabRepresentation : data.getTabs()) {
            TabLayout.Tab tab = tabLayout.newTab().setText(tabRepresentation.getTitle())
                    .setTag(tabRepresentation.getId());
            tabLayout.addTab(tab);
            ViewGroup tabHookView = (ViewGroup) li.inflate(R.layout.form_tab_children, null);
            tabHookViewIndex.put(tabRepresentation.getId(), tabHookView);
            tabHookView.setVisibility(View.GONE);
            rootView.addView(tabHookView);

            formTabFieldIndex.put(tabRepresentation.getId(),
                    new TabField(tab, tabRepresentation, i, tabHookView));

            i++;
        }

        tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                formTabFieldIndex.get(tab.getTag()).getHookView().setVisibility(View.VISIBLE);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                formTabFieldIndex.get(tab.getTag()).getHookView().setVisibility(View.GONE);
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
                formTabFieldIndex.get(tab.getTag()).getHookView().setVisibility(View.VISIBLE);
            }
        });

        tabLayout.getTabAt(0).select();

    } else {
        rootView = (ViewGroup) li.inflate(R.layout.form_root, null);
    }

    ViewGroup hookView = rootView;
    fieldsIndex = new HashMap<>(data.getFields().size());

    // Generate Fields
    ViewGroup groupRoot = null;
    BaseField field;
    for (FormFieldRepresentation fieldData : data.getFields()) {
        if (FormFieldTypes.GROUP.equals(fieldData.getType())) {
            if (groupRoot != null) {
                rootView.addView(groupRoot);
            }
            // Header
            field = generateField(fieldData, rootView, isEdition);
            groupRoot = null;

            if (fieldData instanceof ContainerRepresentation) {
                // Create groupView
                if (groupRoot == null) {
                    groupRoot = (ViewGroup) li.inflate(R.layout.form_fields_group, null);
                }

                if (hasTab && fieldData.getTab() != null) {
                    hookView = (ViewGroup) tabHookViewIndex.get(fieldData.getTab())
                            .findViewById(R.id.tab_group_container);
                } else {
                    hookView = (ViewGroup) groupRoot.findViewById(R.id.form_group_container);
                }

                Map<String, List<FormFieldRepresentation>> fields = ((ContainerRepresentation) fieldData)
                        .getFields();
                for (Map.Entry<String, List<FormFieldRepresentation>> entry : fields.entrySet()) {
                    for (FormFieldRepresentation representation : entry.getValue()) {
                        formFieldIndex.put(representation.getId(), representation);
                        field = generateField(representation, hookView, isEdition);
                        fieldsOrderIndex.add(field);
                        fieldsIndex.put(representation.getId(), field);

                        // Mark All fields in edition mode
                        if (isEdition) {
                            // Mark required Field
                            if (representation.isRequired()) {
                                mandatoryFields.add(field);
                            }

                            if (representation instanceof RestFieldRepresentation) {
                                field.setFragment(fr);
                            }
                        }

                        // If requires fragment for pickers.
                        if (field.isPickerRequired()) {
                            field.setFragment(fr);
                        }
                    }
                }
            }
        } else if (FormFieldTypes.CONTAINER.equals(fieldData.getType())) {
            // Create groupView
            if (groupRoot == null) {
                groupRoot = (ViewGroup) li.inflate(R.layout.form_fields_group, null);
            }

            if (hasTab && fieldData.getTab() != null) {
                hookView = (ViewGroup) tabHookViewIndex.get(fieldData.getTab())
                        .findViewById(R.id.tab_group_container);
            } else {
                hookView = (ViewGroup) groupRoot.findViewById(R.id.form_group_container);
            }

            Map<String, List<FormFieldRepresentation>> fields = ((ContainerRepresentation) fieldData)
                    .getFields();
            for (Map.Entry<String, List<FormFieldRepresentation>> entry : fields.entrySet()) {
                for (FormFieldRepresentation representation : entry.getValue()) {
                    field = generateField(representation, hookView, isEdition);
                    fieldsOrderIndex.add(field);
                    fieldsIndex.put(representation.getId(), field);

                    // Mark All fields in edition mode
                    if (isEdition) {
                        // Mark required Field
                        if (representation.isRequired()) {
                            mandatoryFields.add(field);
                        }

                        if (representation instanceof RestFieldRepresentation) {
                            field.setFragment(fr);
                        }
                    }

                    // If requires fragment for pickers.
                    if (field.isPickerRequired()) {
                        field.setFragment(fr);
                    }
                }
            }
        } else if (FormFieldTypes.DYNAMIC_TABLE.equals(fieldData.getType())
                || (FormFieldTypes.READONLY.equals(fieldData.getType())
                        && fieldData.getParams().get("field") != null
                        && (FormFieldTypes.DYNAMIC_TABLE.toString()
                                .equals(((HashMap) fieldData.getParams().get("field")).get("type"))))) {
            // Create groupView
            if (groupRoot == null) {
                groupRoot = (ViewGroup) li.inflate(R.layout.form_fields_group, null);
            }

            if (hasTab && fieldData.getTab() != null) {
                hookView = (ViewGroup) tabHookViewIndex.get(fieldData.getTab())
                        .findViewById(R.id.tab_group_container);
            } else {
                hookView = (ViewGroup) groupRoot.findViewById(R.id.form_group_container);
            }

            if (fieldData instanceof DynamicTableRepresentation) {
                field = generateField(fieldData, hookView, isEdition);
                fieldsOrderIndex.add(field);
                continue;
            }
        }
    }

    // Now time to evaluate everyone
    evaluateViews();

    // Add Container to root ?
    if (groupRoot != null) {
        rootView.addView(groupRoot);
    }

    vRoot.addView(rootView);

    // OUTCOME
    if (!isEdition) {
        return;
    }
    View vr;
    if (data.getOutcomes() == null || data.getOutcomes().size() == 0) {
        outcomeIndex = new HashMap<>(1);
        vr = generateOutcome(rootView, getActivity().getString(R.string.form_default_outcome_complete), li);
        outcomeIndex.put(getActivity().getString(R.string.form_default_outcome_complete), vr);
    } else {
        outcomeIndex = new HashMap<>(data.getOutcomes().size());
        for (FormOutcomeRepresentation outcomeData : data.getOutcomes()) {
            vr = generateOutcome(rootView, outcomeData.getName(), li);
            outcomeIndex.put(outcomeData.getName(), vr);
        }
    }
}

From source file:com.ipassistat.ipa.adapter.BannerPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = imageIdList.get(position);
    final Advertise advertise = mAdvertise.get(position);
    view.setOnClickListener(new View.OnClickListener() {
        @Override/*from w  w  w .  j a v a 2s .  c om*/
        public void onClick(View v) {

            try {
                if (advertise.getAdImg_url().startsWith("code@@")) {
                    /*Intent intent = new Intent();
                    String[] s = advertise.getAdImg_url().split("code@@");
                    intent.putExtra(IntentKey.GOODS_ID, s[1]);
                    intent.putExtra(IntentKey.GOODS_TYPE,
                          advertise.getProductType());
                    intent.setClass(context, GoodsDetailActivity.class);
                    context.startActivity(intent);
                    MobclickAgent.onEvent(context, "1211",s[1]);*/
                } else {
                    String[] s = advertise.getAdImg_url().split("url@@");
                    ShareInfoEntity shareEntity = new ShareInfoEntity();
                    shareEntity.setTitle(advertise.getShare_title());
                    shareEntity.setContent(advertise.getShare_cotent());
                    shareEntity.setPicUrl(advertise.getShare_pic());
                    shareEntity.setTargetUrl(s[1]);
                    shareEntity.setSMSContent(advertise.getShare_cotent());

                    IntentUtil.startWebView(context, "", s[1], "1084", shareEntity);
                }
            } catch (Exception e) {
                LogUtil.outLogDetail(e.getMessage());
            }

        }
    });
    container.addView(view);
    return view;
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private Animator getRevealAnimator(View source, int revealColor) {
    final ViewGroup containerView = (ViewGroup) source.getRootView().findViewById(android.R.id.content);

    final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth());
    containerView.offsetDescendantRectToMyCoords(source, sourceBounds);

    final int centerX = sourceBounds.centerX();
    final int centerY = sourceBounds.centerY();

    final int xMax = Math.max(centerX, containerView.getWidth() - centerX);
    final int yMax = Math.max(centerY, containerView.getHeight() - centerY);

    final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f;
    final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax);

    final CircleView revealView = new CircleView(source.getContext()).setCenterX(centerX).setCenterY(centerY)
            .setFillColor(revealColor);// ww w  .  j a  v a 2  s  .  co  m
    containerView.addView(revealView);

    final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius,
            endRadius);
    revealAnimator.setInterpolator(PathInterpolatorCompat.create(0.0f, 0.0f, 0.2f, 1.0f));

    final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    fadeAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            containerView.removeView(revealView);
        }
    });

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(TimerFragment.ANIMATION_TIME_MILLIS);
    animatorSet.playSequentially(revealAnimator, fadeAnimator);

    return revealAnimator;
}

From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java

/**
 * Layout suggestions to the suggestions strip. And returns the start index of more
 * suggestions./*from w  w  w.j av a  2  s  . co m*/
 *
 * @param suggestedWords suggestions to be shown in the suggestions strip.
 * @param stripView the suggestions strip view.
 * @param placerView the view where the debug info will be placed.
 * @return the start index of more suggestions.
 */
public int layoutAndReturnStartIndexOfMoreSuggestions(final SuggestedWords suggestedWords,
        final ViewGroup stripView, final ViewGroup placerView) {
    if (suggestedWords.isPunctuationSuggestions()) {
        return layoutPunctuationsAndReturnStartIndexOfMoreSuggestions((PunctuationSuggestions) suggestedWords,
                stripView);
    }

    final int startIndexOfMoreSuggestions = setupWordViewsAndReturnStartIndexOfMoreSuggestions(suggestedWords,
            mSuggestionsCountInStrip);
    final TextView centerWordView = mWordViews.get(mCenterPositionInStrip);
    final int stripWidth = stripView.getWidth();
    final int centerWidth = getSuggestionWidth(mCenterPositionInStrip, stripWidth);
    if (suggestedWords.size() == 1 || getTextScaleX(centerWordView.getText(), centerWidth,
            centerWordView.getPaint()) < MIN_TEXT_XSCALE) {
        // Layout only the most relevant suggested word at the center of the suggestion strip
        // by consolidating all slots in the strip.
        final int countInStrip = 1;
        mMoreSuggestionsAvailable = (suggestedWords.size() > countInStrip);
        layoutWord(mCenterPositionInStrip, stripWidth - mPadding);
        stripView.addView(centerWordView);
        setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
        if (SuggestionStripView.DBG) {
            layoutDebugInfo(mCenterPositionInStrip, placerView, stripWidth);
        }
        final Integer lastIndex = (Integer) centerWordView.getTag();
        return (lastIndex == null ? 0 : lastIndex) + 1;
    }

    final int countInStrip = mSuggestionsCountInStrip;
    mMoreSuggestionsAvailable = (suggestedWords.size() > countInStrip);
    int x = 0;
    for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) {
        if (positionInStrip != 0) {
            final View divider = mDividerViews.get(positionInStrip);
            // Add divider if this isn't the left most suggestion in suggestions strip.
            addDivider(stripView, divider);
            x += divider.getMeasuredWidth();
        }

        final int width = getSuggestionWidth(positionInStrip, stripWidth);
        final TextView wordView = layoutWord(positionInStrip, width);
        stripView.addView(wordView);
        setLayoutWeight(wordView, getSuggestionWeight(positionInStrip), ViewGroup.LayoutParams.MATCH_PARENT);
        x += wordView.getMeasuredWidth();

        if (SuggestionStripView.DBG) {
            layoutDebugInfo(positionInStrip, placerView, x);
        }
    }
    return startIndexOfMoreSuggestions;
}

From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripLayoutHelper.java

/**
 * Layout suggestions to the suggestions strip. And returns the start index of more
 * suggestions./*from w w  w .  j  av a 2s  . c  o  m*/
 *
 * @param suggestedWords suggestions to be shown in the suggestions strip.
 * @param stripView the suggestions strip view.
 * @param placerView the view where the debug info will be placed.
 * @return the start index of more suggestions.
 */
public int layoutAndReturnStartIndexOfMoreSuggestions(final SuggestedWords suggestedWords,
        final ViewGroup stripView, final ViewGroup placerView) {

    if (suggestedWords.isPunctuationSuggestions()) {
        return layoutPunctuationsAndReturnStartIndexOfMoreSuggestions((PunctuationSuggestions) suggestedWords,
                stripView);
    }
    final int startIndexOfMoreSuggestions = setupWordViewsAndReturnStartIndexOfMoreSuggestions(suggestedWords,
            mSuggestionsCountInStrip);
    final TextView centerWordView = mWordViews.get(mCenterPositionInStrip);
    final int stripWidth = stripView.getWidth();
    final int centerWidth = getSuggestionWidth(mCenterPositionInStrip, stripWidth);
    if (suggestedWords.size() == 1 || getTextScaleX(centerWordView.getText(), centerWidth,
            centerWordView.getPaint()) < MIN_TEXT_XSCALE) {
        // Layout only the most relevant suggested word at the center of the suggestion strip
        // by consolidating all slots in the strip.
        final int countInStrip = 1;
        mMoreSuggestionsAvailable = (suggestedWords.size() > countInStrip);
        layoutWord(mCenterPositionInStrip, stripWidth - mPadding);
        stripView.addView(centerWordView);
        setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
        if (SuggestionStripView.DBG) {
            layoutDebugInfo(mCenterPositionInStrip, placerView, stripWidth);
        }
        final Integer lastIndex = (Integer) centerWordView.getTag();
        return (lastIndex == null ? 0 : lastIndex) + 1;
    }

    //  final int countInStrip = mSuggestionsCountInStrip;

    //
    // Changes apply here
    //
    // Increase the strip size coloum

    final int countInStrip = mSuggestionsCountInStrip;

    mMoreSuggestionsAvailable = (suggestedWords.size() > countInStrip);
    int x = 0;
    for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) {
        if (positionInStrip != 0) {
            final View divider = mDividerViews.get(positionInStrip);
            // Add divider if this isn't the left most suggestion in suggestions strip.
            addDivider(stripView, divider);
            x += divider.getMeasuredWidth();
        }

        final int width = getSuggestionWidth(positionInStrip, stripWidth);
        final TextView wordView = layoutWord(positionInStrip, width);

        stripView.addView(wordView);
        setLayoutWeight(wordView, getSuggestionWeight(positionInStrip), ViewGroup.LayoutParams.MATCH_PARENT);
        x += wordView.getMeasuredWidth();

        if (SuggestionStripView.DBG) {
            layoutDebugInfo(positionInStrip, placerView, x);
        }
    }
    return startIndexOfMoreSuggestions;
}