1960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam/* 2960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * Copyright (C) 2015 The Android Open Source Project 3960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * 4960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * Licensed under the Apache License, Version 2.0 (the "License"); 5960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * you may not use this file except in compliance with the License. 6960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * You may obtain a copy of the License at 7960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * 8960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * http://www.apache.org/licenses/LICENSE-2.0 9960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * 10960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * Unless required by applicable law or agreed to in writing, software 11960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * distributed under the License is distributed on an "AS IS" BASIS, 12960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * See the License for the specific language governing permissions and 14960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * limitations under the License. 15960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam */ 16960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 17960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lampackage com.android.setupwizardlib.items; 18960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 19960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lamimport android.content.Context; 20960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lamimport android.util.AttributeSet; 21960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 22960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam/** 23960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * Abstract implementation of an item, which implements {@link IItem} and takes care of implementing 24960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam * methods for {@link ItemHierarchy} for items representing itself. 25960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam */ 26960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lampublic abstract class AbstractItem extends AbstractItemHierarchy implements IItem { 27960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 28960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam public AbstractItem() { 29960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam super(); 30960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam } 31960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 32960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam public AbstractItem(Context context, AttributeSet attrs) { 33960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam super(context, attrs); 34960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam } 35960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 36960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam @Override 37960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam public int getCount() { 38960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam return 1; 39960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam } 40960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 41960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam @Override 42960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam public IItem getItemAt(int position) { 43960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam return this; 44960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam } 45960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam 46960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam @Override 47960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam public ItemHierarchy findItemById(int id) { 48960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam if (id == getId()) { 49960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam return this; 50960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam } 51960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam return null; 52960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam } 53ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam 54ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam /** 55ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam * Convenience method to notify the adapter that the contents of this item has changed. This 56ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam * only includes non-structural changes. Changes that causes the item to be removed should use 57ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam * the other notification methods. 58ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam * 59ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam * @see #notifyItemRangeChanged(int, int) 60ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam * @see #notifyItemRangeInserted(int, int) 61ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam * @see #notifyItemRangeRemoved(int, int) 62ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam */ 63ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam public void notifyItemChanged() { 64ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam notifyItemRangeChanged(0, 1); 65ab45bdf67a01ba13efb45334cc43f9632de6f034Maurice Lam } 66960c0ea0b1d36904beef0f01715dd43a211e88caMaurice Lam} 67