1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.wallpaper.picker; 17 18 import android.content.Context; 19 import android.util.AttributeSet; 20 import android.widget.LinearLayout; 21 22 import androidx.annotation.Nullable; 23 24 /** The SectionView base for views hosting in the {@link CustomizationPickerFragment}. */ 25 public abstract class SectionView extends LinearLayout { 26 27 /** The callback for the section view updates. */ 28 public interface SectionViewListener { onViewActivated(@ullable Context context, boolean viewActivated)29 void onViewActivated(@Nullable Context context, boolean viewActivated); 30 } 31 32 protected SectionViewListener mSectionViewListener; 33 private String mTitle; 34 SectionView(Context context, @Nullable AttributeSet attrs)35 public SectionView(Context context, @Nullable AttributeSet attrs) { 36 super(context, attrs); 37 } 38 setTitle(String title)39 public void setTitle(String title) { 40 mTitle = title; 41 } 42 getTitle()43 public String getTitle() { 44 return mTitle; 45 } 46 47 /** Sets the listener to the {@code SectionView} instance for reacting the view changes. */ setViewListener(SectionViewListener sectionViewListener)48 public void setViewListener(SectionViewListener sectionViewListener) { 49 mSectionViewListener = sectionViewListener; 50 } 51 } 52