Example usage for android.view ViewGroup setVisibility

List of usage examples for android.view ViewGroup setVisibility

Introduction

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

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:com.topfeeds4j.sample.app.activities.MainActivity.java

private void changeToSinglePageMode(TabLayout tabs, ViewGroup singleContainer) {
    mViewPager.setVisibility(View.GONE);
    tabs.setVisibility(View.GONE);
    singleContainer.setVisibility(View.VISIBLE);
    mProviderSpr.setVisibility(View.VISIBLE);
    //No wifi and force to use single mode.
    createSingleModeSelections();//  w  w  w  . j  a v a  2  s.com
}

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

private void initializeViews(View container) {
    mLogoView.setVisibility(View.GONE);
    // Create custom views.
    LayoutInflater inflater = getThemeInflater(LayoutInflater.from(getActivity()));
    ViewGroup backgroundContainer = (ViewGroup) container.findViewById(R.id.background_container);
    View background = onCreateBackgroundView(inflater, backgroundContainer);
    if (background != null) {
        backgroundContainer.setVisibility(View.VISIBLE);
        backgroundContainer.addView(background);
    }//  w w w  .j a va  2  s. c  om
    ViewGroup contentContainer = (ViewGroup) container.findViewById(R.id.content_container);
    View content = onCreateContentView(inflater, contentContainer);
    if (content != null) {
        contentContainer.setVisibility(View.VISIBLE);
        contentContainer.addView(content);
    }
    ViewGroup foregroundContainer = (ViewGroup) container.findViewById(R.id.foreground_container);
    View foreground = onCreateForegroundView(inflater, foregroundContainer);
    if (foreground != null) {
        foregroundContainer.setVisibility(View.VISIBLE);
        foregroundContainer.addView(foreground);
    }
    // Make views visible which were invisible while logo animation is running.
    container.findViewById(R.id.page_container).setVisibility(View.VISIBLE);
    container.findViewById(R.id.content_container).setVisibility(View.VISIBLE);
    if (getPageCount() > 1) {
        mPageIndicator.setPageCount(getPageCount());
        mPageIndicator.onPageSelected(mCurrentPageIndex, false);
    }
    if (mCurrentPageIndex == getPageCount() - 1) {
        mStartButton.setVisibility(View.VISIBLE);
    } else {
        mPageIndicator.setVisibility(View.VISIBLE);
    }
    // Header views.
    mTitleView.setText(getPageTitle(mCurrentPageIndex));
    mDescriptionView.setText(getPageDescription(mCurrentPageIndex));
}

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);/*from w  ww  . j  a  v a2 s . co  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.univ.helsinki.app.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (FeedResource.getInstance().getSharedPrefs().getBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH,
            false)) {//from   w  ww .  ja va2s .  com

        getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
        getActionBar().hide();

        hideTitle();
    }

    setContentView(R.layout.activity_main);

    splashLayout = (ViewGroup) findViewById(R.id.splashLayout);

    if (FeedResource.getInstance().getSharedPrefs().getBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH,
            false)) {
        // record the fact that the app has been started at least once
        FeedResource.getInstance().getSharedPrefs().edit()
                .putBoolean(Constant.SHARED_PREFS_KEY_ISFIRST_LAUNCH, false).commit();

        final ViewGroup splashLayout = (ViewGroup) findViewById(R.id.splashLayout);

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                activateSplashScreen(splashLayout);
            }
        }, Constant.SPLASH_SCREEN_TIME_OUT);

    } else {
        splashLayout.setVisibility(View.GONE);
    }

    FeedResource.getInstance().inti(this);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    mSensorFeedAdapter = new SensorFeedAdapter(this);

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
            switch (position) {
            case 0: {
                // on focus when first fragment
                //Toast.makeText(getApplicationContext(), "onPageSelected :" + position, Toast.LENGTH_SHORT).show();

                List<SensorFeed> mtempAllowedSensorFeedList = new ArrayList<SensorFeed>();
                // update the list over here.. to avoid empty shell
                for (SensorFeed sensor : FeedResource.getInstance().getSensorFeedList()) {

                    boolean isChecked = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
                            .getBoolean(sensor.getSensorKey(), false);

                    if (isChecked)
                        mtempAllowedSensorFeedList.add(sensor);
                }
                // update the list with new created list
                mSensorFeedAdapter.setFeedList(mtempAllowedSensorFeedList);

            }
                break;
            }// switch ends
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

private void setDaysInCalendar() {
    Calendar auxCalendar = Calendar.getInstance(locale);
    auxCalendar.setTime(currentCalendar.getTime());
    auxCalendar.set(Calendar.DAY_OF_MONTH, 1);
    int firstDayOfMonth = auxCalendar.get(Calendar.DAY_OF_WEEK);
    TextView dayOfMonthText;/*from  ww  w.j  ava2s .c  o  m*/
    ViewGroup dayOfMonthContainer;

    // Calculate dayOfMonthIndex
    int dayOfMonthIndex = getWeekIndex(firstDayOfMonth, auxCalendar);

    for (int i = 1; i <= auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); i++, dayOfMonthIndex++) {
        dayOfMonthContainer = (ViewGroup) view.findViewWithTag(DAY_OF_MONTH_CONTAINER + dayOfMonthIndex);
        dayOfMonthText = (TextView) view.findViewWithTag(DAY_OF_MONTH_TEXT + dayOfMonthIndex);
        if (dayOfMonthText == null) {
            break;
        }
        dayOfMonthContainer.setOnClickListener(onDayOfMonthClickListener);
        dayOfMonthText.setVisibility(View.VISIBLE);
        dayOfMonthText.setText(String.valueOf(i));
        dayOfMonthText.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_day_of_month));
        dayOfMonthContainer.setBackgroundResource(0);
    }

    // If the last week row has no visible days, hide it or show it in case
    ViewGroup weekRow = (ViewGroup) view.findViewWithTag("weekRow6");
    dayOfMonthText = (TextView) view.findViewWithTag("dayOfMonthText36");
    if (dayOfMonthText.getVisibility() == INVISIBLE) {
        weekRow.setVisibility(GONE);
    } else {
        weekRow.setVisibility(VISIBLE);
    }
    updateBackgroundSelectDays();
}

From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java

/**
 * Animation for keypad slide up from bottom
 */// w  w  w.ja  v  a 2s. co m
public void animSlidePanelUp(ViewGroup slidePanelUp) {
    Animation slideUp = AnimationUtils.loadAnimation(getContext(), R.anim.panel_slide_up);
    slidePanelUp.startAnimation(slideUp);
    slidePanelUp.setVisibility(View.VISIBLE);
}

From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java

/**
 * Animation for keypad slide down and disappear
 *///  w w w . j  a v a 2 s  .co m
public void animSlidePanelDown(ViewGroup slidePanelDown) {
    Animation slideDown = AnimationUtils.loadAnimation(getContext(), R.anim.panel_slide_down);
    slidePanelDown.startAnimation(slideDown);
    slidePanelDown.setVisibility(View.GONE);
}

From source file:org.apache.cordova.CordovaWebViewImpl.java

@Override
@Deprecated//  w  ww .j av a  2s  .  c  o m
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }

    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;

    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) engine.getView().getParent();
    parent.addView(view, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER));

    // Hide the content view.
    engine.getView().setVisibility(View.GONE);

    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}

From source file:com.google.android.apps.muzei.settings.SettingsActivity.java

private void updateRenderLocally(boolean renderLocally) {
    if (mRenderLocally == renderLocally) {
        return;//from   w  w w  . ja  v  a  2 s .co m
    }

    mRenderLocally = renderLocally;

    final View uiContainer = findViewById(R.id.container);
    final ViewGroup localRenderContainer = (ViewGroup) findViewById(R.id.local_render_container);

    FragmentManager fm = getSupportFragmentManager();
    Fragment localRenderFragment = fm.findFragmentById(R.id.local_render_container);
    if (mRenderLocally) {
        if (localRenderFragment == null) {
            fm.beginTransaction()
                    .add(R.id.local_render_container, MuzeiRendererFragment.createInstance(false, false))
                    .commit();
        }
        if (localRenderContainer.getAlpha() == 1) {
            localRenderContainer.setAlpha(0);
        }
        localRenderContainer.setVisibility(View.VISIBLE);
        localRenderContainer.animate().alpha(1).setDuration(2000).withEndAction(null);
        uiContainer.setBackgroundColor(0x00000000); // for ripple touch feedback
    } else {
        if (localRenderFragment != null) {
            fm.beginTransaction().remove(localRenderFragment).commit();
        }
        localRenderContainer.animate().alpha(0).setDuration(1000).withEndAction(new Runnable() {
            @Override
            public void run() {
                localRenderContainer.setVisibility(View.GONE);
            }
        });
        uiContainer.setBackground(null);
    }
}

From source file:org.apache.cordova.X5CordovaWebViewImpl.java

@Override
@Deprecated// w ww .  j  a  v a  2 s .  co  m
public void showCustomView(View view, CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    LOG.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }

    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;

    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) engine.getView().getParent();
    parent.addView(view, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER));

    // Hide the content view.
    engine.getView().setVisibility(View.GONE);

    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}