Java Code Examples for android.widget.LinearLayout#findViewWithTag()

The following examples show how to use android.widget.LinearLayout#findViewWithTag() . 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: AudioControlManager.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
private void updateVolumeGroup(@NonNull final State state, @NonNull final LinearLayout group)
{
    final AppCompatSeekBar progressBar = group.findViewWithTag("tone_progress_bar");
    final ReceiverInformationMsg.Zone zone = state.getActiveZoneInfo();
    final int maxVolume = Math.min(getVolumeMax(state, zone),
            activity.getConfiguration().audioControl.getMasterVolumeMax());

    updateProgressLabel(group, R.string.master_volume, State.getVolumeLevelStr(state.volumeLevel, zone));

    final TextView minValue = group.findViewWithTag("tone_min_value");
    minValue.setText("0");

    final TextView maxValue = group.findViewWithTag("tone_max_value");
    maxValue.setText(State.getVolumeLevelStr(maxVolume, zone));

    progressBar.setMax(maxVolume);
    progressBar.setProgress(Math.max(0, state.volumeLevel));
}
 
Example 2
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 3
Source File: CallUserGridView.java    From sealtalk-android with MIT License 6 votes vote down vote up
public void updateChildInfo(String childId, UserInfo userInfo) {
    int containerCount = linearLayout.getChildCount();

    LinearLayout lastContainer = null;
    for(int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        LinearLayout child = (LinearLayout) container.findViewWithTag(childId);
        if(child != null) {
            AsyncImageView imageView = (AsyncImageView)child.getChildAt(0);
            imageView.setAvatar(userInfo.getPortraitUri());
            if(enableTitle) {
                TextView textView = (TextView)child.getChildAt(1);
                textView.setText(userInfo.getName());
            }
        }
    }
}
 
Example 4
Source File: AudioControlManager.java    From onpc with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("SetTextI18n")
private void updateToneGroup(@NonNull final State state,
                             @NonNull final String toneKey,
                             @NonNull final LinearLayout group,
                             @StringRes final int labelId,
                             int toneLevel, final int noLevel, final int maxZone)
{
    final AppCompatSeekBar progressBar = group.findViewWithTag("tone_progress_bar");
    final ReceiverInformationMsg.ToneControl toneControl = state.getToneControl(toneKey, forceAudioControl);
    final boolean isTone = toneControl != null && toneLevel != noLevel && state.getActiveZone() < maxZone;
    group.setVisibility(isTone ? View.VISIBLE : View.GONE);
    if (isTone)
    {
        updateProgressLabel(group, labelId, Integer.toString(toneLevel));

        final TextView minText = group.findViewWithTag("tone_min_value");
        if (minText != null)
        {
            minText.setText(Integer.toString(toneControl.getMin()));
        }

        final TextView maxText = group.findViewWithTag("tone_max_value");
        if (maxText != null)
        {
            maxText.setText(Integer.toString(toneControl.getMax()));
        }

        final float step = toneControl.getStep() == 0 ? 0.5f : toneControl.getStep();
        final int max = (int) ((float) (toneControl.getMax() - toneControl.getMin()) / step);
        final int progress = (int) ((float) (toneLevel - toneControl.getMin()) / step);
        progressBar.setMax(max);
        progressBar.setProgress(progress);
    }
}
 
Example 5
Source File: CallUserGridView.java    From sealtalk-android with MIT License 5 votes vote down vote up
public void removeChild(String childId) {
    int containerCount = linearLayout.getChildCount();

    LinearLayout lastContainer = null;
    List<LinearLayout> containerList = new ArrayList<>();
    for(int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        containerList.add(container);
    }
    for(LinearLayout resultContainer : containerList) {
        if(lastContainer == null) {
            LinearLayout child = (LinearLayout) resultContainer.findViewWithTag(childId);
            if (child != null) {
                resultContainer.removeView(child);
                if (resultContainer.getChildCount() == 0) {
                    linearLayout.removeView(resultContainer);
                    break;
                } else {
                    lastContainer = resultContainer;
                }
            }
        } else {
            View view = resultContainer.getChildAt(0);
            resultContainer.removeView(view);
            lastContainer.addView(view);
            if(resultContainer.getChildCount() == 0) {
                linearLayout.removeView(resultContainer);
                break;
            } else {
                lastContainer = resultContainer;
            }
        }
    }
}
 
Example 6
Source File: CallUserGridView.java    From sealtalk-android with MIT License 5 votes vote down vote up
public View findChildById(String childId) {
    int containerCount = linearLayout.getChildCount();

    for(int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        LinearLayout child = (LinearLayout) container.findViewWithTag(childId);
        if(child != null) {
            return child;
        }
    }
    return null;
}
 
Example 7
Source File: CallUserGridView.java    From sealtalk-android with MIT License 5 votes vote down vote up
public void updateChildState(String childId, String state) {
    int containerCount = linearLayout.getChildCount();

    for(int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        LinearLayout child = (LinearLayout) container.findViewWithTag(childId);
        if(child != null) {
            TextView textView = (TextView)child.findViewById(R.id.rc_voip_member_state);
            textView.setText(state);
        }
    }
}
 
Example 8
Source File: CallUserGridView.java    From sealtalk-android with MIT License 5 votes vote down vote up
public void updateChildState(String childId, boolean visible) {
    int containerCount = linearLayout.getChildCount();

    for(int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        LinearLayout child = (LinearLayout) container.findViewWithTag(childId);
        if(child != null) {
            TextView textView = (TextView)child.findViewById(R.id.rc_voip_member_state);
            textView.setVisibility(visible ? VISIBLE : GONE);
        }
    }
}