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

Commit 5e91b7ea authored by Lucas Silva's avatar Lucas Silva
Browse files

Allow other layouts to be passed into the dream view adatper.

This will let the OOBE flow use a different layout than the regular
Settings view.

Bug: 221227402
Test: locally on device
Change-Id: I27545b7dad1d789adcae8589480d29bc5231c98c
parent c7709aeb
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.dream;

import android.annotation.LayoutRes;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
@@ -40,6 +41,7 @@ import java.util.List;
 */
public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private final List<IDreamItem> mItemList;
    private final @LayoutRes int mLayoutRes;
    private int mLastSelectedPos = -1;

    /**
@@ -116,15 +118,16 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
        }
    }

    public DreamAdapter(List<IDreamItem> itemList) {
    public DreamAdapter(@LayoutRes int layoutRes, List<IDreamItem> itemList) {
        mItemList = itemList;
        mLayoutRes = layoutRes;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
        View view = LayoutInflater.from(viewGroup.getContext())
                .inflate(R.layout.dream_preference_layout, viewGroup, false);
                .inflate(mLayoutRes, viewGroup, false);
        return new DreamViewHolder(view, viewGroup.getContext());
    }

+4 −3
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ public class DreamPickerController extends BasePreferenceController {
    public void displayPreference(PreferenceScreen screen) {
        super.displayPreference(screen);

        mAdapter = new DreamAdapter(mDreamInfos.stream()
        mAdapter = new DreamAdapter(R.layout.dream_preference_layout,
                mDreamInfos.stream()
                        .map(DreamItem::new)
                        .collect(Collectors.toList()));