Example usage for android.widget LinearLayout setVisibility

List of usage examples for android.widget LinearLayout setVisibility

Introduction

In this page you can find the example usage for android.widget LinearLayout setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:net.pocketmine.server.HomeActivity.java

public static void hideStats() {
    if (ha != null) {
        ha.runOnUiThread(new Runnable() {
            @Override//ww w  . j a  va 2s .  c  o m
            public void run() {
                LinearLayout layout = (LinearLayout) ha.findViewById(R.id.stats);
                layout.setVisibility(View.GONE);
                statsShown = false;
            }
        });
    }
}

From source file:net.pocketmine.server.HomeActivity.java

public static void showStats(Boolean reset) {
    if (reset) {//from  ww  w.j a  va 2  s  .  c om
        online = ha.getResources().getString(R.string.unknown);
        ram = ha.getResources().getString(R.string.unknown);
        download = ha.getResources().getString(R.string.unknown);
        upload = ha.getResources().getString(R.string.unknown);
        tps = ha.getResources().getString(R.string.unknown);
        players = null;
    }
    if (ha != null) {
        ha.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                LinearLayout layout = (LinearLayout) ha.findViewById(R.id.stats);
                layout.setVisibility(View.VISIBLE);
                statsShown = true;
                TextView ip = (TextView) ha.findViewById(R.id.stat_ip);
                ip.setText(ha.getResources().getString(R.string.ip_address) + ": " + getIPAddress(true));
                setStats(online, ram, download, upload, tps);
                updatePlayerList(players);
            }
        });
    }
}

From source file:org.dkf.jmule.util.UIUtils.java

/**
 *
 * @param context -  containing Context.
 * @param showInstallationCompleteSection - true if you want to display "Your installation is now complete. Thank You" section
 * @param dismissListener - what happens when the dialog is dismissed.
 * @param referrerContextSuffix - string appended at the end of social pages click urls's ?ref=_android_ parameter.
 *//*from ww w.j a va2  s . c o m*/
public static void showSocialLinksDialog(final Context context, boolean showInstallationCompleteSection,
        DialogInterface.OnDismissListener dismissListener, String referrerContextSuffix) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    View customView = View.inflate(context, R.layout.view_social_buttons, null);
    builder.setView(customView);
    builder.setPositiveButton(context.getString(android.R.string.ok), new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    final AlertDialog socialLinksDialog = builder.create();
    socialLinksDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    socialLinksDialog.setOnDismissListener(dismissListener);

    ImageButton githubButton = (ImageButton) customView.findViewById(R.id.view_buttons_github);
    //ImageButton twitterButton = (ImageButton) customView.findViewById(R.id.view_social_buttons_twitter_button);
    //ImageButton redditButton = (ImageButton) customView.findViewById(R.id.view_social_buttons_reddit_button);

    //final String referrerParam  = "?ref=android_" + ((referrerContextSuffix!=null) ? referrerContextSuffix.trim() : "");

    githubButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            UIUtils.openURL(v.getContext(), Constants.GITHUB_PAGE);
        }
    });
    /*
            twitterButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_TWITTER_PAGE + referrerParam);
    }
            });
            
            redditButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_REDDIT_PAGE + referrerParam);
    }
            });
            
    */
    if (showInstallationCompleteSection) {
        LinearLayout installationCompleteLayout = (LinearLayout) customView
                .findViewById(R.id.view_social_buttons_installation_complete_layout);
        installationCompleteLayout.setVisibility(View.VISIBLE);
        ImageButton dismissCheckButton = (ImageButton) customView
                .findViewById(R.id.view_social_buttons_dismiss_check);
        dismissCheckButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                socialLinksDialog.dismiss();
            }
        });
    }

    socialLinksDialog.show();
}

From source file:com.frostwire.android.gui.util.UIUtils.java

/**
 * @param context                         -  containing Context.
 * @param showInstallationCompleteSection - true if you want to display "Your installation is now complete. Thank You" section
 * @param dismissListener                 - what happens when the dialog is dismissed.
 * @param referrerContextSuffix           - string appended at the end of social pages click urls's ?ref=_android_ parameter.
 *///from   ww w .ja  va 2s  . c o  m
public static void showSocialLinksDialog(final Context context, boolean showInstallationCompleteSection,
        DialogInterface.OnDismissListener dismissListener, String referrerContextSuffix) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    View customView = View.inflate(context, R.layout.view_social_buttons, null);
    builder.setView(customView);
    builder.setPositiveButton(context.getString(android.R.string.ok), (dialog, which) -> dialog.dismiss());
    final AlertDialog socialLinksDialog = builder.create();
    socialLinksDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    socialLinksDialog.setOnDismissListener(dismissListener);
    ImageButton fbButton = customView.findViewById(R.id.view_social_buttons_facebook_button);
    ImageButton twitterButton = customView.findViewById(R.id.view_social_buttons_twitter_button);
    ImageButton redditButton = customView.findViewById(R.id.view_social_buttons_reddit_button);
    final String referrerParam = "?ref=android_"
            + ((referrerContextSuffix != null) ? referrerContextSuffix.trim() : "");
    fbButton.setOnClickListener(
            v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_FACEBOOK_PAGE + referrerParam));
    twitterButton.setOnClickListener(
            v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_TWITTER_PAGE + referrerParam));
    redditButton.setOnClickListener(
            v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_REDDIT_PAGE + referrerParam));
    if (showInstallationCompleteSection) {
        LinearLayout installationCompleteLayout = customView
                .findViewById(R.id.view_social_buttons_installation_complete_layout);
        installationCompleteLayout.setVisibility(View.VISIBLE);
        ImageButton dismissCheckButton = customView.findViewById(R.id.view_social_buttons_dismiss_check);
        dismissCheckButton.setOnClickListener(v -> socialLinksDialog.dismiss());
    }
    socialLinksDialog.show();
}

From source file:de.azapps.mirakel.helper.TaskDialogHelpers.java

@SuppressLint("NewApi")
public static void handleSubtask(final Context ctx, final Task task, final OnTaskChangedListner taskChanged,
        final boolean asSubtask) {
    final List<Pair<Long, String>> names = Task.getTaskNames();
    final CharSequence[] values = new String[names.size()];
    for (int i = 0; i < names.size(); i++) {
        values[i] = names.get(i).second;
    }//w  w w . j ava  2  s . c o m
    final View v = ((Activity) ctx).getLayoutInflater().inflate(R.layout.select_subtask, null, false);
    final ListView lv = (ListView) v.findViewById(R.id.subtask_listview);
    final List<Task> tasks = Task.cursorToTaskList(
            ctx.getContentResolver().query(MirakelInternalContentProvider.TASK_URI, Task.allColumns,
                    ModelBase.ID + "=" + task.getId() + " AND " + Task.BASIC_FILTER_DISPLAY_TASKS, null, null));
    subtaskAdapter = new SubtaskAdapter(ctx, 0, tasks, task, asSubtask);
    lv.post(new Runnable() {
        @Override
        public void run() {
            lv.setAdapter(subtaskAdapter);
        }
    });
    searchString = "";
    done = false;
    content = false;
    reminder = false;
    optionEnabled = false;
    newTask = true;
    listId = SpecialList.firstSpecialSafe().getId();
    final EditText search = (EditText) v.findViewById(R.id.subtask_searchbox);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        Drawable left = ctx.getResources().getDrawable(android.R.drawable.ic_menu_search);
        Drawable right = null;
        left.setBounds(0, 0, 42, 42);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
                && ctx.getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
            right = ctx.getResources().getDrawable(android.R.drawable.ic_menu_search);
            right.setBounds(0, 0, 42, 42);
            left = null;
        }
        search.setCompoundDrawables(left, null, right, null);
    }
    search.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(final Editable s) {
            // Nothing
        }

        @Override
        public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) {
            // Nothing
        }

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
            searchString = s.toString();
            updateListView(subtaskAdapter, task, lv, ctx);
        }
    });
    final Button options = (Button) v.findViewById(R.id.subtasks_options);
    final LinearLayout wrapper = (LinearLayout) v.findViewById(R.id.subtask_option_wrapper);
    wrapper.setVisibility(View.GONE);
    options.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            if (optionEnabled) {
                wrapper.setVisibility(View.GONE);
            } else {
                wrapper.setVisibility(View.VISIBLE);
                final InputMethodManager imm = (InputMethodManager) ctx
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(search.getWindowToken(), 0);
            }
            optionEnabled = !optionEnabled;
        }
    });
    final ViewSwitcher switcher = (ViewSwitcher) v.findViewById(R.id.subtask_switcher);
    final Button subtaskNewtask = (Button) v.findViewById(R.id.subtask_newtask);
    final Button subtaskSelectOld = (Button) v.findViewById(R.id.subtask_select_old);
    final boolean darkTheme = MirakelCommonPreferences.isDark();
    if (asSubtask) {
        v.findViewById(R.id.subtask_header).setVisibility(View.GONE);
        switcher.showNext();
        newTask = false;
    } else {
        subtaskNewtask.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(final View v) {
                if (newTask) {
                    return;
                }
                switcher.showPrevious();
                subtaskNewtask
                        .setTextColor(ctx.getResources().getColor(darkTheme ? R.color.White : R.color.Black));
                subtaskSelectOld.setTextColor(ctx.getResources().getColor(R.color.Grey));
                newTask = true;
            }
        });
        subtaskSelectOld.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(final View v) {
                if (!newTask) {
                    return;
                }
                switcher.showNext();
                subtaskNewtask.setTextColor(ctx.getResources().getColor(R.color.Grey));
                subtaskSelectOld
                        .setTextColor(ctx.getResources().getColor(darkTheme ? R.color.White : R.color.Black));
                if (subtaskAdapter != null) {
                    subtaskAdapter.notifyDataSetChanged();
                }
                newTask = false;
                lv.invalidateViews();
                updateListView(subtaskAdapter, task, lv, ctx);
            }
        });
    }
    final CheckBox doneBox = (CheckBox) v.findViewById(R.id.subtask_done);
    doneBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            done = isChecked;
            updateListView(subtaskAdapter, task, lv, ctx);
        }
    });
    final CheckBox reminderBox = (CheckBox) v.findViewById(R.id.subtask_reminder);
    reminderBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            reminder = isChecked;
            updateListView(subtaskAdapter, task, lv, ctx);
        }
    });
    final Button list = (Button) v.findViewById(R.id.subtask_list);
    list.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            final List<ListMirakel> lists = ListMirakel.all(true);
            final CharSequence[] names = new String[lists.size()];
            for (int i = 0; i < names.length; i++) {
                names[i] = lists.get(i).getName();
            }
            new AlertDialog.Builder(ctx).setSingleChoiceItems(names, -1, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    listId = lists.get(which).getId();
                    updateListView(subtaskAdapter, task, lv, ctx);
                    list.setText(lists.get(which).getName());
                    dialog.dismiss();
                }
            }).show();
        }
    });
    final CheckBox contentBox = (CheckBox) v.findViewById(R.id.subtask_content);
    contentBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
            content = isChecked;
            updateListView(subtaskAdapter, task, lv, ctx);
        }
    });
    final EditText newTaskEdit = (EditText) v.findViewById(R.id.subtask_add_task_edit);
    final AlertDialog dialog = new AlertDialog.Builder(ctx).setTitle(ctx.getString(R.string.add_subtask))
            .setView(v).setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    if (newTask && newTaskEdit.getText().length() > 0) {
                        newSubtask(newTaskEdit.getText().toString(), task, ctx);
                    } else if (!newTask) {
                        final List<Task> checked = subtaskAdapter.getSelected();
                        for (final Task t : checked) {
                            if (!asSubtask) {
                                if (!t.hasSubtasksLoop(task)) {
                                    task.addSubtask(t);
                                } else {
                                    ErrorReporter.report(ErrorType.TASKS_CANNOT_FORM_LOOP);
                                }
                            } else {
                                if (!task.hasSubtasksLoop(t)) {
                                    t.addSubtask(task);
                                } else {
                                    ErrorReporter.report(ErrorType.TASKS_CANNOT_FORM_LOOP);
                                }
                            }
                        }
                    }
                    if (taskChanged != null) {
                        taskChanged.onTaskChanged(task);
                    }
                    ((Activity) ctx).getWindow()
                            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
                    dialog.dismiss();
                }
            }).setNegativeButton(android.R.string.cancel, dialogDoNothing).show();
    newTaskEdit.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                newSubtask(v.getText().toString(), task, ctx);
                v.setText(null);
                if (taskChanged != null) {
                    taskChanged.onTaskChanged(task);
                }
                dialog.dismiss();
            }
            return false;
        }
    });
}

From source file:jahirfiquitiva.iconshowcase.dialogs.ISDialogs.java

public static void showWallpaperDetailsDialog(final Context context, String wallName, String wallAuthor,
        String wallDimensions, String wallCopyright) {

    MaterialDialog dialog = new MaterialDialog.Builder(context).title(wallName)
            .customView(R.layout.wallpaper_details, false)
            .positiveText(context.getResources().getString(R.string.close)).build();

    View v = dialog.getCustomView();

    ImageView authorIcon, dimensIcon, copyrightIcon;

    if (v != null) {
        authorIcon = (ImageView) v.findViewById(R.id.icon_author);
        dimensIcon = (ImageView) v.findViewById(R.id.icon_dimensions);
        copyrightIcon = (ImageView) v.findViewById(R.id.icon_copyright);

        int light = ContextCompat.getColor(context, R.color.drawable_tint_dark);
        int dark = ContextCompat.getColor(context, R.color.drawable_tint_light);

        authorIcon.setImageDrawable(/*from www. j  a  v  a 2s .  c  om*/
                ColorUtils.getTintedIcon(context, R.drawable.ic_person, ThemeUtils.darkTheme ? light : dark));

        dimensIcon.setImageDrawable(ColorUtils.getTintedIcon(context, R.drawable.ic_dimensions,
                ThemeUtils.darkTheme ? light : dark));

        copyrightIcon.setImageDrawable(ColorUtils.getTintedIcon(context, R.drawable.ic_copyright,
                ThemeUtils.darkTheme ? light : dark));
    }

    LinearLayout author = (LinearLayout) v.findViewById(R.id.authorName);
    LinearLayout dimensions = (LinearLayout) v.findViewById(R.id.wallDimensions);
    LinearLayout copyright = (LinearLayout) v.findViewById(R.id.wallCopyright);

    TextView authorText = (TextView) v.findViewById(R.id.wallpaper_author_text);
    TextView dimensionsText = (TextView) v.findViewById(R.id.wallpaper_dimensions_text);
    TextView copyrightText = (TextView) v.findViewById(R.id.wallpaper_copyright_text);

    if (wallAuthor.equals("null") || wallAuthor.equals("")) {
        author.setVisibility(View.GONE);
    } else {
        authorText.setText(wallAuthor);
    }

    if (wallDimensions.equals("null") || wallDimensions.equals("")) {
        dimensions.setVisibility(View.GONE);
    } else {
        dimensionsText.setText(wallDimensions);
    }

    if (wallCopyright.equals("null") || wallCopyright.equals("")) {
        copyright.setVisibility(View.GONE);
    } else {
        copyrightText.setText(wallCopyright);
    }

    dialog.show();
}

From source file:com.cw.litenote.note.Note.java

/** Set outline for selected view mode
*
*   Determined by view mode: all, picture, text
*
*   Controlled factor://from ww  w  .  ja  v  a2s  .c  o m
*   - action bar: hide, show
*   - full screen: full, not full
*/
public static void setOutline(AppCompatActivity act) {
    // Set full screen or not, and action bar
    if (isViewAllMode() || isTextMode()) {
        Util.setFullScreen_noImmersive(act);
        if (act.getSupportActionBar() != null)
            act.getSupportActionBar().show();
    } else if (isPictureMode()) {
        Util.setFullScreen(act);
        if (act.getSupportActionBar() != null)
            act.getSupportActionBar().hide();
    }

    // renew pager
    showSelectedView();

    LinearLayout buttonGroup = (LinearLayout) act.findViewById(R.id.view_button_group);
    // button group
    if (Note.isPictureMode())
        buttonGroup.setVisibility(View.GONE);
    else
        buttonGroup.setVisibility(View.VISIBLE);

    TextView audioTitle = (TextView) act.findViewById(R.id.pager_audio_title);
    // audio title
    if (!Note.isPictureMode()) {
        if (!Util.isEmptyString(audioTitle.getText().toString()))
            audioTitle.setVisibility(View.VISIBLE);
        else
            audioTitle.setVisibility(View.GONE);
    }

    // renew options menu
    act.invalidateOptionsMenu();
}

From source file:net.hyx.app.volumenotification.DialogAlertNonce.java

@NonNull
@Override/* w  ww .ja  va  2s .  com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {

    View view = LayoutInflater.from(getContext()).inflate(R.layout.view_dialog_alert_nonce, null);
    TextView message_view = (TextView) view.findViewById(R.id.pref_dialog_alert_message);
    message_view.setText(message);

    if (pref_key != 0) {
        CheckBox nonce_checked = (CheckBox) view.findViewById(R.id.pref_dialog_alert_nonce_checked);
        nonce_checked.setChecked(settings.getDialogAlertNonceChecked(pref_key));
        nonce_checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                settings.edit().putBoolean("pref_dialog_alert_nonce_checked_" + pref_key, isChecked).apply();
            }
        });
    } else {
        LinearLayout nonce_view = (LinearLayout) view.findViewById(R.id.pref_dialog_alert_nonce);
        nonce_view.setVisibility(View.GONE);
    }

    return new AlertDialog.Builder(getContext()).setView(view).setPositiveButton(android.R.string.ok, null)
            .create();
}

From source file:net.hyx.app.volumenotification.dialog.NonceAlertDialog.java

@NonNull
@Override//from   w  w w .  j  a v  a  2s. co  m
public Dialog onCreateDialog(Bundle savedInstanceState) {

    View view = LayoutInflater.from(getContext()).inflate(R.layout.view_dialog_alert_nonce, null);
    TextView messageView = (TextView) view.findViewById(R.id.pref_dialog_alert_message);
    messageView.setText(message);

    if (id != 0) {
        CheckBox nonceInput = (CheckBox) view.findViewById(R.id.pref_nonce_input);
        nonceInput.setChecked(settings.getDialogAlertNonceChecked(id));
        nonceInput.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                settings.getPreferences().edit().putBoolean("pref_dialog_alert_nonce_checked_" + id, isChecked)
                        .commit();
            }
        });
    } else {
        LinearLayout nonceLayer = (LinearLayout) view.findViewById(R.id.pref_nonce_wrapper);
        nonceLayer.setVisibility(View.GONE);
    }

    return new AlertDialog.Builder(getContext()).setView(view).setPositiveButton(android.R.string.ok, null)
            .create();
}

From source file:jsettlers.main.android.gameplay.ui.fragments.menus.selection.SoldiersSelectionFragment.java

private void goneIfEmpty(LinearLayout linearLayout) {
    if (linearLayout.getChildCount() == 0) {
        linearLayout.setVisibility(View.GONE);
    }//from   w  ww. j a  v a  2 s.co m
}