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:org.fdroid.fdroid.installer.InstallConfirmActivity.java

private void startInstallConfirm() {

    final Drawable appIcon = mAppDiff.mPkgInfo.applicationInfo.loadIcon(mPm);
    final String appLabel = (String) mAppDiff.mPkgInfo.applicationInfo.loadLabel(mPm);

    View appSnippet = findViewById(R.id.app_snippet);
    ((ImageView) appSnippet.findViewById(R.id.app_icon)).setImageDrawable(appIcon);
    ((TextView) appSnippet.findViewById(R.id.app_name)).setText(appLabel);

    TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
    tabHost.setup();//ww w .  j  a  v  a 2  s  . c om
    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    TabsAdapter adapter = new TabsAdapter(this, tabHost, viewPager);
    adapter.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
        }
    });

    boolean permVisible = false;
    mScrollView = null;
    mOkCanInstall = false;
    int msg = 0;
    if (mAppDiff.mPkgInfo != null) {
        AppSecurityPermissions perms = new AppSecurityPermissions(this, mAppDiff.mPkgInfo);
        final int NP = perms.getPermissionCount(AppSecurityPermissions.WHICH_PERSONAL);
        final int ND = perms.getPermissionCount(AppSecurityPermissions.WHICH_DEVICE);
        if (mAppDiff.mInstalledAppInfo != null) {
            msg = (mAppDiff.mInstalledAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
                    ? R.string.install_confirm_update_system
                    : R.string.install_confirm_update;
            mScrollView = new CaffeinatedScrollView(this);
            mScrollView.setFillViewport(true);
            final boolean newPermissionsFound = (perms
                    .getPermissionCount(AppSecurityPermissions.WHICH_NEW) > 0);
            if (newPermissionsFound) {
                permVisible = true;
                mScrollView.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_NEW));
            } else {
                throw new RuntimeException(
                        "This should not happen. No new permissions were found but InstallConfirmActivity has been started!");
            }
            adapter.addTab(tabHost.newTabSpec(TAB_ID_NEW).setIndicator(getText(R.string.newPerms)),
                    mScrollView);
        } else {
            findViewById(R.id.tabscontainer).setVisibility(View.GONE);
            findViewById(R.id.divider).setVisibility(View.VISIBLE);
        }
        if (NP > 0 || ND > 0) {
            permVisible = true;
            LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View root = inflater.inflate(R.layout.permissions_list, null);
            if (mScrollView == null) {
                mScrollView = (CaffeinatedScrollView) root.findViewById(R.id.scrollview);
            }
            final ViewGroup privacyList = (ViewGroup) root.findViewById(R.id.privacylist);
            if (NP > 0) {
                privacyList.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_PERSONAL));
            } else {
                privacyList.setVisibility(View.GONE);
            }
            final ViewGroup deviceList = (ViewGroup) root.findViewById(R.id.devicelist);
            if (ND > 0) {
                deviceList.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_DEVICE));
            } else {
                root.findViewById(R.id.devicelist).setVisibility(View.GONE);
            }
            adapter.addTab(tabHost.newTabSpec(TAB_ID_ALL).setIndicator(getText(R.string.allPerms)), root);
        }
    }
    if (!permVisible) {
        if (mAppDiff.mInstalledAppInfo != null) {
            // This is an update to an application, but there are no
            // permissions at all.
            msg = (mAppDiff.mInstalledAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
                    ? R.string.install_confirm_update_system_no_perms
                    : R.string.install_confirm_update_no_perms;
        } else {
            // This is a new application with no permissions.
            msg = R.string.install_confirm_no_perms;
        }
        tabHost.setVisibility(View.GONE);
        findViewById(R.id.filler).setVisibility(View.VISIBLE);
        findViewById(R.id.divider).setVisibility(View.GONE);
        mScrollView = null;
    }
    if (msg != 0) {
        ((TextView) findViewById(R.id.install_confirm)).setText(msg);
    }
    mInstallConfirm.setVisibility(View.VISIBLE);
    mOk = (Button) findViewById(R.id.ok_button);
    mCancel = (Button) findViewById(R.id.cancel_button);
    mOk.setOnClickListener(this);
    mCancel.setOnClickListener(this);
    if (mScrollView == null) {
        // There is nothing to scroll view, so the ok button is immediately
        // set to install.
        mOk.setText(R.string.menu_install);
        mOkCanInstall = true;
    } else {
        mScrollView.setFullScrollAction(new Runnable() {
            @Override
            public void run() {
                mOk.setText(R.string.menu_install);
                mOkCanInstall = true;
            }
        });
    }
}

From source file:org.adblockplus.android.Preferences.java

private void hideConfigurationMsg() {
    final ViewGroup grp = (ViewGroup) findViewById(R.id.grp_configuration);
    grp.setVisibility(View.GONE);
}

From source file:android.support.v7.preference.PreferenceGroupAdapter.java

@Override
public PreferenceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final PreferenceLayout pl = mPreferenceLayouts.get(viewType);
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    TypedArray a = parent.getContext().obtainStyledAttributes(null, R.styleable.BackgroundStyle);
    Drawable background = a.getDrawable(R.styleable.BackgroundStyle_android_selectableItemBackground);
    if (background == null) {
        background = parent.getContext().getResources()
                .getDrawable(android.R.drawable.list_selector_background);
    }/*from  www  .  j  a v a  2s .  com*/
    a.recycle();

    final View view = inflater.inflate(pl.resId, parent, false);
    if (view.getBackground() == null) {
        ViewCompat.setBackground(view, background);
    }

    final ViewGroup widgetFrame = (ViewGroup) view.findViewById(android.R.id.widget_frame);
    if (widgetFrame != null) {
        if (pl.widgetResId != 0) {
            inflater.inflate(pl.widgetResId, widgetFrame);
        } else {
            widgetFrame.setVisibility(View.GONE);
        }
    }

    return new PreferenceViewHolder(view);
}

From source file:com.kubotaku.android.sample.sensordataviewer.fragments.SelectStreamTimeFragment.java

private void changeType(final int type) {
    final View view = getView();

    ViewGroup vgPreset = (ViewGroup) view.findViewById(R.id.select_time_rg_preset);
    ViewGroup vgDetail = (ViewGroup) view.findViewById(R.id.select_time_gl_detail);

    selectTimeType = type;//from w w w.  j ava2  s  .  c o  m
    switch (type) {
    case AppPreferences.SELECT_TIME_TYPE_PRESET:
        vgPreset.setVisibility(View.VISIBLE);
        vgDetail.setVisibility(View.GONE);
        break;

    case AppPreferences.SELECT_TIME_TYPE_DETAIL:
        vgPreset.setVisibility(View.GONE);
        vgDetail.setVisibility(View.VISIBLE);
        break;
    }
}

From source file:dev.drsoran.moloko.fragments.TaskFragment.java

private void setParticipantsSection(ViewGroup view, Task task) {
    final ParticipantList participants = task.getParticipants();

    if (participants != null && participants.getCount() > 0) {
        view.setVisibility(View.VISIBLE);

        for (final Participant participant : participants.getParticipants()) {
            final TextView textView = new TextView(getSherlockActivity());
            UIUtils.makeLink(textView, participant.getFullname(), new ClickableSpan() {
                @Override//ww w. j a v a  2s  . c  o m
                public void onClick(View widget) {
                    listener.onOpenContact(participant.getFullname(), participant.getUsername());
                }
            });

            view.addView(textView);
        }
    } else {
        view.setVisibility(View.GONE);
    }
}

From source file:org.solovyev.android.messenger.ListViewFilter.java

public void toggleView() {
    final View view = fragment.getView();
    final FragmentActivity activity = fragment.getActivity();

    if (view != null && activity != null && filterEditText != null) {
        final ViewGroup filterBox = (ViewGroup) view.findViewById(R.id.mpp_list_filter);
        if (filterBox != null) {
            int visibility = filterBox.getVisibility();

            final InputMethodManager manager = (InputMethodManager) activity
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            if (visibility != View.VISIBLE) {
                filterBox.setVisibility(View.VISIBLE);
                filterEditText.requestFocus();

                manager.showSoftInput(filterEditText, InputMethodManager.SHOW_IMPLICIT);

            } else if (visibility != View.GONE) {
                // if filter box is visible before hiding it clear filter query
                filterEditText.getText().clear();
                filterEditText.clearFocus();

                manager.hideSoftInputFromWindow(filterEditText.getWindowToken(),
                        InputMethodManager.HIDE_IMPLICIT_ONLY);

                filterBox.setVisibility(View.GONE);
            }/*from w ww . j ava 2 s. com*/
        }
    } else {
        Log.e(TAG, "toggleView() is called when view or activity is detached from fragment!");
    }
}

From source file:com.transsion.gallery3d.ui.FloatingActionBar.java

public void restoreActionBarFromSelection() {
    final ViewGroup actionBars[] = { mStandantActionBar, mTabActionBar, mClusterActionBar,
            mSelectionModeActionBar };//from  ww  w. ja v a  2  s .  c  o  m
    for (ViewGroup actionBar : actionBars) {
        if (actionBar != mCurrentActionBarForSelection) {
            actionBar.setVisibility(View.GONE);
        } else {
            actionBar.setVisibility(View.VISIBLE);
        }
    }
}

From source file:com.gh4a.fragment.UserFragment.java

public void fillOrganizations(List<User> organizations) {
    ViewGroup llOrgs = (ViewGroup) mContentView.findViewById(R.id.ll_orgs);
    LinearLayout llOrg = (LinearLayout) mContentView.findViewById(R.id.ll_org);
    int count = organizations != null ? organizations.size() : 0;
    LayoutInflater inflater = getLayoutInflater(null);

    llOrg.removeAllViews();//from   www  .  ja  v  a 2s .  c o m
    llOrgs.setVisibility(count > 0 ? View.VISIBLE : View.GONE);

    for (int i = 0; i < count; i++) {
        User org = organizations.get(i);
        View rowView = inflater.inflate(R.layout.selectable_label_with_avatar, llOrg, false);

        rowView.setOnClickListener(this);
        rowView.setTag(org);

        ImageView avatar = (ImageView) rowView.findViewById(R.id.iv_gravatar);
        AvatarHandler.assignAvatar(avatar, org);

        TextView nameView = (TextView) rowView.findViewById(R.id.tv_title);
        nameView.setText(org.getLogin());

        llOrg.addView(rowView);
    }
}

From source file:nu.yona.app.ui.dashboard.CustomPageAdapter.java

private ViewGroup initiateWeekActivityReport(ViewGroup collection, int position) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.detail_activity_fragment, collection, false);
    WeekActivity weekActivity = weekActivities.get(position);
    View spreadView = layout.findViewById(R.id.spreadGraphView);
    goalDesc = (YonaFontTextView) spreadView.findViewById(R.id.goalDesc);
    goalType = (YonaFontTextView) spreadView.findViewById(R.id.goalType);
    goalScore = (YonaFontTextView) spreadView.findViewById(R.id.goalScore);
    mSpreadGraph = (SpreadGraph) spreadView.findViewById(R.id.spreadGraph);
    if (isWeekControlVisible) {
        ViewGroup weekChart = (ViewGroup) layout.findViewById(R.id.week_chart);
        weekChart.setVisibility(View.VISIBLE); // week control
        showWeekChartData(weekChart, weekActivity);
    }//from  w w  w  .j  a  v a2  s. c o m
    if (weekActivity != null && weekActivity.getLinks() != null
            && (weekActivity.getLinks().getReplyComment() != null
                    || weekActivity.getLinks().getAddComment() != null)) {
        YonaApplication.getEventChangeManager().notifyChange(EventChangeManager.EVENT_SHOW_CHAT_OPTION, null);
    }
    graphView = ((FrameLayout) layout.findViewById(R.id.graphView));
    GoalsEnum goalsEnum;
    goalsEnum = GoalsEnum.fromName(weekActivity.getYonaGoal().getType());
    if (goalsEnum == GoalsEnum.BUDGET_GOAL && weekActivity.getYonaGoal().getMaxDurationMinutes() == 0) {
        goalsEnum = GoalsEnum.NOGO;
    }
    graphView.addView(inflateActivityView(inflater, goalsEnum, layout));
    updateView(new ChartItemHolder(graphView, null, goalsEnum), weekActivity, null);
    collection.addView(layout);
    return layout;
}

From source file:com.kubotaku.android.sample.sensordataviewer.SensorDataActivity.java

private void showWeatherInfo(WeatherInfo weatherInfo) {

    ViewGroup cardView = (ViewGroup) findViewById(R.id.sensor_data_card_weather);
    cardView.setVisibility(View.VISIBLE);

    final String locationName = weatherInfo.getName();
    final float currentTemp = weatherInfo.getCurrentTempCelsius();
    final Bitmap icon = weatherInfo.getIcon();
    final int humidity = weatherInfo.getHumidity();
    final int pressure = weatherInfo.getPressure();

    TextView textLocation = (TextView) findViewById(R.id.sensor_data_text_weather_location);
    textLocation.setText(locationName);//w  w w.  ja v a2s  . c o m

    TextView textCurrentTemp = (TextView) findViewById(R.id.sensor_data_text_weather_current_temp);
    textCurrentTemp.setText(String.format(Locale.getDefault(), "%.1f", currentTemp));

    TextView textMinMaxTemp = (TextView) findViewById(R.id.sensor_data_text_weather_minmax_temp);
    textMinMaxTemp.setText(String.format(Locale.getDefault(), "%d\n%dhPa", humidity, pressure));

    ImageView imageIcon = (ImageView) findViewById(R.id.sensor_data_img_weather);
    imageIcon.setImageBitmap(icon);
}