Java Code Examples for androidx.appcompat.widget.AppCompatImageButton#setVisibility()

The following examples show how to use androidx.appcompat.widget.AppCompatImageButton#setVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainNavigationDrawer.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
private void updateItem(@NonNull final MenuItem m, final @DrawableRes int iconId, final String title, final ButtonListener editListener)
{
    if (m.getActionView() != null && m.getActionView() instanceof LinearLayout)
    {
        final LinearLayout l = (LinearLayout)m.getActionView();
        ((AppCompatImageView) l.findViewWithTag("ICON")).setImageResource(iconId);
        ((AppCompatTextView)l.findViewWithTag("TEXT")).setText(title);
        final AppCompatImageButton editBtn = l.findViewWithTag("EDIT");
        if (editListener != null)
        {
            editBtn.setVisibility(View.VISIBLE);
            editBtn.setOnClickListener(v -> editListener.onEditItem());
            Utils.setButtonEnabled(activity, editBtn, true);
        }
        else
        {
            editBtn.setVisibility(View.GONE);
        }
    }
    m.setVisible(true);
}
 
Example 2
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void setButtonsVisibility(List<AppCompatImageButton> buttons, int flag)
{
    for (AppCompatImageButton b : buttons)
    {
        b.setVisibility(flag);
    }
}
 
Example 3
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void updateInputSource(@DrawableRes int imageId, final boolean visible)
{
    AppCompatImageButton btn = rootView.findViewById(R.id.btn_input_selector);
    btn.setImageResource(imageId);
    btn.setVisibility(visible ? View.VISIBLE : View.GONE);
    setButtonEnabled(btn, false);
}
 
Example 4
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void updateMultiroomGroupBtn(AppCompatImageButton b, @Nullable final State state)
{
    if (state != null && isGroupMenu())
    {
        final boolean isMaster = state.getMultiroomRole() == MultiroomDeviceInformationMsg.RoleType.SRC;
        b.setVisibility(View.VISIBLE);
        setButtonEnabled(b, true);
        setButtonSelected(b, isMaster);
        b.setContentDescription(activity.getString(R.string.cmd_multiroom_group));

        prepareButtonListeners(b, null, () ->
        {
            if (activity.isConnected())
            {
                final AlertDialog alertDialog = MultiroomManager.createDeviceSelectionDialog(
                        activity, b.getContentDescription());
                alertDialog.show();
                Utils.fixIconColor(alertDialog, android.R.attr.textColorSecondary);
            }
        });
    }
    else
    {
        b.setVisibility(View.GONE);
        setButtonEnabled(b, false);
    }
}
 
Example 5
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
private void updateFeedButton(final AppCompatImageButton btn, final MenuStatusMsg.Feed feed)
{
    btn.setVisibility(feed.isImageValid() ? View.VISIBLE : View.GONE);
    if (feed.isImageValid())
    {
        btn.setImageResource(feed.getImageId());
        setButtonEnabled(btn, true);
        setButtonSelected(btn, feed == MenuStatusMsg.Feed.LOVE);
    }
}
 
Example 6
Source File: DeviceFragment.java    From onpc with GNU General Public License v3.0 4 votes vote down vote up
private void updateDeviceInformation(@Nullable final State state)
{
    // Host
    ((TextView) rootView.findViewById(R.id.device_info_address)).setText(
            (state != null) ? state.getHostAndPort() : "");

    // Friendly name
    final boolean isFnValid = state != null
            && state.isFriendlyName();
    final LinearLayout fnLayout = rootView.findViewById(R.id.device_friendly_name);
    fnLayout.setVisibility(isFnValid ? View.VISIBLE : View.GONE);
    if (isFnValid)
    {
        // Friendly name
        friendlyName.setText(state.getDeviceName(true));
    }

    // Receiver information
    final boolean isRiValid = state != null
            && state.isReceiverInformation()
            && !state.deviceProperties.isEmpty();
    final LinearLayout riLayout = rootView.findViewById(R.id.device_receiver_information);
    riLayout.setVisibility(isRiValid ? View.VISIBLE : View.GONE);
    if (isRiValid)
    {
        // Common properties
        ((TextView) rootView.findViewById(R.id.device_brand)).setText(state.deviceProperties.get("brand"));
        ((TextView) rootView.findViewById(R.id.device_model)).setText(state.getModel());
        ((TextView) rootView.findViewById(R.id.device_year)).setText(state.deviceProperties.get("year"));
        // Firmware version
        {
            StringBuilder version = new StringBuilder();
            version.append(state.deviceProperties.get("firmwareversion"));
            if (state.firmwareStatus != FirmwareUpdateMsg.Status.NONE)
            {
                version.append(", ").append(getStringValue(state.firmwareStatus.getDescriptionId()));
            }
            ((TextView) rootView.findViewById(R.id.device_firmware)).setText(version.toString());
        }
        // Update button
        {
            final AppCompatImageButton b = rootView.findViewById(R.id.btn_firmware_update);
            b.setVisibility((state.firmwareStatus == FirmwareUpdateMsg.Status.NEW_VERSION ||
                    state.firmwareStatus == FirmwareUpdateMsg.Status.NEW_VERSION_FORCE) ?
                    View.VISIBLE : View.GONE);
            if (b.getVisibility() == View.VISIBLE)
            {
                setButtonEnabled(b, true);
            }
        }
        // Google cast version
        ((TextView) rootView.findViewById(R.id.google_cast_version)).setText(state.googleCastVersion);
    }

    final int[] deviceInfoLayout = new int[]{
            R.id.device_info_layout,
            R.id.device_info_divider
    };
    for (int layoutId : deviceInfoLayout)
    {
        rootView.findViewById(layoutId).setVisibility(isFnValid || isRiValid ? View.VISIBLE : View.GONE);
    }
}