Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36acce0c authored by Matthew DeVore's avatar Matthew DeVore
Browse files

[SettingsLib] method set toolbar's active item

Bug: 409354332
Test: manual
Flag: EXEMPT library update
Change-Id: If583d523f9bc7cfef6a12181d4166dd1770240bc
parent ffa299c3
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -276,21 +276,32 @@ public class CollapsingToolbarDelegate {
        layout.onItemSelected(itemList);
    }

    private @Nullable ScrollableToolbarItemLayout getToolbarItemsLayout() {
        if (mFloatingToolbarLayout == null) {
            return null;
        }
        return mFloatingToolbarLayout.findViewById(R.id.floating_toolbar_items);
    }

    /**
     * Sets the item selected listener for the floating toolbar.
     */
    public void setOnItemSelectedListener(
            ScrollableToolbarItemLayout.OnItemSelectedListener listener) {
        if (mFloatingToolbarLayout == null) {
            return;
        var layout = getToolbarItemsLayout();
        if (layout != null) {
            layout.setOnItemSelectedListener(listener);
        }
        ScrollableToolbarItemLayout layout = mFloatingToolbarLayout.findViewById(
                R.id.floating_toolbar_items);
        if (layout == null) {
            return;
    }

        layout.setOnItemSelectedListener(listener);
    /**
     * Sets the selected toolbar item by its zero-based index.
     */
    public void setSelectedItem(int position) {
        var layout = getToolbarItemsLayout();
        if (layout != null) {
            layout.setSelectedItem(position);
        }
    }

    private void initSupportActionBar(@NonNull LayoutInflater inflater) {