19106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn/* 29106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Copyright (C) 2014 The Android Open Source Project 39106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 49106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 59106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * in compliance with the License. You may obtain a copy of the License at 69106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 79106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * http://www.apache.org/licenses/LICENSE-2.0 89106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 99106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Unless required by applicable law or agreed to in writing, software distributed under the License 109106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 119106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * or implied. See the License for the specific language governing permissions and limitations under 129106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * the License. 139106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 149106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbournpackage android.support.v17.leanback.widget; 159106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 169106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbournimport android.content.Context; 179106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbournimport android.content.res.TypedArray; 189106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbournimport android.graphics.Rect; 199106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbournimport android.support.v17.leanback.R; 209106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbournimport android.support.v7.widget.RecyclerView; 219106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbournimport android.util.AttributeSet; 2201ce047bc251d73d24c3ddd60aa280cf9930570bDake Guimport android.view.Gravity; 23372d07bb41510d91a6a662a1906aceb0ee759481Craig Stoutimport android.view.KeyEvent; 24372d07bb41510d91a6a662a1906aceb0ee759481Craig Stoutimport android.view.MotionEvent; 259106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbournimport android.view.View; 269106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 279106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn/** 289106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Base class for vertically and horizontally scrolling lists. The items come 299106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * from the {@link RecyclerView.Adapter} associated with this view. 309106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @hide 319106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 32a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbournabstract class BaseGridView extends RecyclerView { 339106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 349106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 35adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * Always keep focused item at a aligned position. Developer can use 36adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * WINDOW_ALIGN_XXX and ITEM_ALIGN_XXX to define how focused item is aligned. 37adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * In this mode, the last focused position will be remembered and restored when focus 38adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * is back to the view. 39adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu */ 40adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu public final static int FOCUS_SCROLL_ALIGNED = 0; 41adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu 42adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu /** 43adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * Scroll to make the focused item inside client area. 44adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu */ 45adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu public final static int FOCUS_SCROLL_ITEM = 1; 46adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu 47adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu /** 48adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * Scroll a page of items when focusing to item outside the client area. 49adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * The page size matches the client area size of RecyclerView. 50adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu */ 51adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu public final static int FOCUS_SCROLL_PAGE = 2; 52adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu 53adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu /** 549106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * The first item is aligned with the low edge of the viewport. When 559106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * navigating away from the first item, the focus maintains a middle 569106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * location. 579106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * <p> 58f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * For HorizontalGridView, low edge refers to left edge when RTL is false or 59f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * right edge when RTL is true. 60f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * For VerticalGridView, low edge refers to top edge. 61f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * <p> 629106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * The middle location is calculated by "windowAlignOffset" and 639106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * "windowAlignOffsetPercent"; if neither of these two is defined, the 649106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * default value is 1/2 of the size. 659106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 669106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public final static int WINDOW_ALIGN_LOW_EDGE = 1; 679106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 689106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 699106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * The last item is aligned with the high edge of the viewport when 709106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * navigating to the end of list. When navigating away from the end, the 719106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * focus maintains a middle location. 729106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * <p> 73f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * For HorizontalGridView, high edge refers to right edge when RTL is false or 74f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * left edge when RTL is true. 75f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * For VerticalGridView, high edge refers to bottom edge. 76f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * <p> 779106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * The middle location is calculated by "windowAlignOffset" and 789106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * "windowAlignOffsetPercent"; if neither of these two is defined, the 799106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * default value is 1/2 of the size. 809106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 819106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public final static int WINDOW_ALIGN_HIGH_EDGE = 1 << 1; 829106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 839106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 849106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * The first item and last item are aligned with the two edges of the 859106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * viewport. When navigating in the middle of list, the focus maintains a 869106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * middle location. 879106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * <p> 889106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * The middle location is calculated by "windowAlignOffset" and 899106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * "windowAlignOffsetPercent"; if neither of these two is defined, the 909106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * default value is 1/2 of the size. 919106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 929106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public final static int WINDOW_ALIGN_BOTH_EDGE = 939106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn WINDOW_ALIGN_LOW_EDGE | WINDOW_ALIGN_HIGH_EDGE; 949106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 959106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 969106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * The focused item always stays in a middle location. 979106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * <p> 989106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * The middle location is calculated by "windowAlignOffset" and 999106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * "windowAlignOffsetPercent"; if neither of these two is defined, the 1009106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * default value is 1/2 of the size. 1019106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 1029106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public final static int WINDOW_ALIGN_NO_EDGE = 0; 1039106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 1049106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 1059106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Value indicates that percent is not used. 1069106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 1079106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public final static float WINDOW_ALIGN_OFFSET_PERCENT_DISABLED = -1; 1089106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 1099106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 1109106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Value indicates that percent is not used. 1119106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 1129106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public final static float ITEM_ALIGN_OFFSET_PERCENT_DISABLED = -1; 1139106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 114372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 1151102fc6fafe721522f2b67f86d89feda87096265Dake Gu * Dont save states of any child views. 1161102fc6fafe721522f2b67f86d89feda87096265Dake Gu */ 1171102fc6fafe721522f2b67f86d89feda87096265Dake Gu public static final int SAVE_NO_CHILD = 0; 1181102fc6fafe721522f2b67f86d89feda87096265Dake Gu 1191102fc6fafe721522f2b67f86d89feda87096265Dake Gu /** 1201102fc6fafe721522f2b67f86d89feda87096265Dake Gu * Only save on screen child views, the states are lost when they become off screen. 1211102fc6fafe721522f2b67f86d89feda87096265Dake Gu */ 1221102fc6fafe721522f2b67f86d89feda87096265Dake Gu public static final int SAVE_ON_SCREEN_CHILD = 1; 1231102fc6fafe721522f2b67f86d89feda87096265Dake Gu 1241102fc6fafe721522f2b67f86d89feda87096265Dake Gu /** 1251102fc6fafe721522f2b67f86d89feda87096265Dake Gu * Save on screen views plus save off screen child views states up to 1261102fc6fafe721522f2b67f86d89feda87096265Dake Gu * {@link #getSaveChildrenLimitNumber()}. 1271102fc6fafe721522f2b67f86d89feda87096265Dake Gu */ 1281102fc6fafe721522f2b67f86d89feda87096265Dake Gu public static final int SAVE_LIMITED_CHILD = 2; 1291102fc6fafe721522f2b67f86d89feda87096265Dake Gu 1301102fc6fafe721522f2b67f86d89feda87096265Dake Gu /** 1311102fc6fafe721522f2b67f86d89feda87096265Dake Gu * Save on screen views plus save off screen child views without any limitation. 1321102fc6fafe721522f2b67f86d89feda87096265Dake Gu * This might cause out of memory, only use it when you are dealing with limited data. 1331102fc6fafe721522f2b67f86d89feda87096265Dake Gu */ 1341102fc6fafe721522f2b67f86d89feda87096265Dake Gu public static final int SAVE_ALL_CHILD = 3; 1351102fc6fafe721522f2b67f86d89feda87096265Dake Gu 1361102fc6fafe721522f2b67f86d89feda87096265Dake Gu /** 137372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Listener for intercepting touch dispatch events. 138372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 139372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public interface OnTouchInterceptListener { 140372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 141372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Returns true if the touch dispatch event should be consumed. 142372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 143372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public boolean onInterceptTouchEvent(MotionEvent event); 144372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 145372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 146372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 147372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Listener for intercepting generic motion dispatch events. 148372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 149372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public interface OnMotionInterceptListener { 150372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 151372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Returns true if the touch dispatch event should be consumed. 152372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 153372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public boolean onInterceptMotionEvent(MotionEvent event); 154372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 155372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 156372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 157372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Listener for intercepting key dispatch events. 158372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 159372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public interface OnKeyInterceptListener { 160372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 161372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Returns true if the key dispatch event should be consumed. 162372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 163372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public boolean onInterceptKeyEvent(KeyEvent event); 164372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 165372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 1669106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn protected final GridLayoutManager mLayoutManager; 1679106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 16894920246f7f5a0d4dae794058020cd67c5701056Dake Gu /** 16994920246f7f5a0d4dae794058020cd67c5701056Dake Gu * Animate layout changes from a child resizing or adding/removing a child. 17094920246f7f5a0d4dae794058020cd67c5701056Dake Gu */ 17194920246f7f5a0d4dae794058020cd67c5701056Dake Gu private boolean mAnimateChildLayout = true; 17294920246f7f5a0d4dae794058020cd67c5701056Dake Gu 173ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu private boolean mHasOverlappingRendering = true; 174ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu 17594920246f7f5a0d4dae794058020cd67c5701056Dake Gu private RecyclerView.ItemAnimator mSavedItemAnimator; 17694920246f7f5a0d4dae794058020cd67c5701056Dake Gu 177372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout private OnTouchInterceptListener mOnTouchInterceptListener; 178372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout private OnMotionInterceptListener mOnMotionInterceptListener; 179372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout private OnKeyInterceptListener mOnKeyInterceptListener; 180372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 181a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbourn public BaseGridView(Context context, AttributeSet attrs, int defStyle) { 1829106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn super(context, attrs, defStyle); 1839106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager = new GridLayoutManager(this); 1849106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn setLayoutManager(mLayoutManager); 1859421aa6ca7de4174ddbe2e10fbb05cb31685ffccDake Gu setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); 1869106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn setHasFixedSize(true); 187182f3350d5f3cef04d160c673b6969df28e9439cDake Gu setChildrenDrawingOrderEnabled(true); 188b23ee09bf4aee03bc403abf39016c8ca5ecf301cDake Gu setWillNotDraw(true); 189b23ee09bf4aee03bc403abf39016c8ca5ecf301cDake Gu setOverScrollMode(View.OVER_SCROLL_NEVER); 1904b3edb53b158518329719439db18b0cbd38f27e9Dake Gu // Disable change animation by default on leanback. 1914b3edb53b158518329719439db18b0cbd38f27e9Dake Gu // Change animation will create a new view and cause undesired 1924b3edb53b158518329719439db18b0cbd38f27e9Dake Gu // focus animation between the old view and new view. 1934b3edb53b158518329719439db18b0cbd38f27e9Dake Gu getItemAnimator().setSupportsChangeAnimations(false); 1949106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 1959106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 196a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbourn protected void initBaseGridViewAttributes(Context context, AttributeSet attrs) { 197a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbourn TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.lbBaseGridView); 198a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbourn boolean throughFront = a.getBoolean(R.styleable.lbBaseGridView_focusOutFront, false); 199a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbourn boolean throughEnd = a.getBoolean(R.styleable.lbBaseGridView_focusOutEnd, false); 2009106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setFocusOutAllowed(throughFront, throughEnd); 2019106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setVerticalMargin( 202a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbourn a.getDimensionPixelSize(R.styleable.lbBaseGridView_verticalMargin, 0)); 2039106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setHorizontalMargin( 204a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbourn a.getDimensionPixelSize(R.styleable.lbBaseGridView_horizontalMargin, 0)); 20501ce047bc251d73d24c3ddd60aa280cf9930570bDake Gu if (a.hasValue(R.styleable.lbBaseGridView_android_gravity)) { 20601ce047bc251d73d24c3ddd60aa280cf9930570bDake Gu setGravity(a.getInt(R.styleable.lbBaseGridView_android_gravity, Gravity.NO_GRAVITY)); 20701ce047bc251d73d24c3ddd60aa280cf9930570bDake Gu } 2089106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn a.recycle(); 2099106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 2109106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 2119106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 212adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * Set the strategy used to scroll in response to item focus changing: 213adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * <ul> 214adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * <li>{@link #FOCUS_SCROLL_ALIGNED} (default) </li> 215adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * <li>{@link #FOCUS_SCROLL_ITEM}</li> 216adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * <li>{@link #FOCUS_SCROLL_PAGE}</li> 217adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * </ul> 218adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu */ 219adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu public void setFocusScrollStrategy(int scrollStrategy) { 220adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu if (scrollStrategy != FOCUS_SCROLL_ALIGNED && scrollStrategy != FOCUS_SCROLL_ITEM 221adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu && scrollStrategy != FOCUS_SCROLL_PAGE) { 222adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu throw new IllegalArgumentException("Invalid scrollStrategy"); 223adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu } 224adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu mLayoutManager.setFocusScrollStrategy(scrollStrategy); 225adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu requestLayout(); 226adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu } 227adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu 228adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu /** 229adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * Returns the strategy used to scroll in response to item focus changing. 230adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * <ul> 231adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * <li>{@link #FOCUS_SCROLL_ALIGNED} (default) </li> 232adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * <li>{@link #FOCUS_SCROLL_ITEM}</li> 233adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * <li>{@link #FOCUS_SCROLL_PAGE}</li> 234adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu * </ul> 235adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu */ 236adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu public int getFocusScrollStrategy() { 237adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu return mLayoutManager.getFocusScrollStrategy(); 238adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu } 239adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu 240adc2a01f5701cbcc044754119b572abcf31c7c5fDake Gu /** 2419106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Set how the focused item gets aligned in the view. 2429106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 2439106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @param windowAlignment {@link #WINDOW_ALIGN_BOTH_EDGE}, 2449106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * {@link #WINDOW_ALIGN_LOW_EDGE}, {@link #WINDOW_ALIGN_HIGH_EDGE} or 2459106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * {@link #WINDOW_ALIGN_NO_EDGE}. 2469106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 2479106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setWindowAlignment(int windowAlignment) { 2489106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setWindowAlignment(windowAlignment); 2499106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn requestLayout(); 2509106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 2519106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 2529106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 2539106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Get how the focused item gets aligned in the view. 2549106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 2559106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @return {@link #WINDOW_ALIGN_BOTH_EDGE}, {@link #WINDOW_ALIGN_LOW_EDGE}, 2569106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * {@link #WINDOW_ALIGN_HIGH_EDGE} or {@link #WINDOW_ALIGN_NO_EDGE}. 2579106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 2589106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public int getWindowAlignment() { 2599106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn return mLayoutManager.getWindowAlignment(); 2609106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 2619106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 2629106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 263f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * Set the offset in pixels for window alignment. 2649106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 265f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * @param offset The number of pixels to offset. If the offset is positive, 266f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * it is distance from low edge (see {@link #WINDOW_ALIGN_LOW_EDGE}); 267f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * if the offset is negative, the absolute value is distance from high 268f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * edge (see {@link #WINDOW_ALIGN_HIGH_EDGE}). 269f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * Default value is 0. 2709106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 2719106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setWindowAlignmentOffset(int offset) { 2729106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setWindowAlignmentOffset(offset); 2739106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn requestLayout(); 2749106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 2759106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 2769106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 277f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * Get the offset in pixels for window alignment. 2789106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 279f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * @return The number of pixels to offset. If the offset is positive, 280f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * it is distance from low edge (see {@link #WINDOW_ALIGN_LOW_EDGE}); 281f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * if the offset is negative, the absolute value is distance from high 282f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * edge (see {@link #WINDOW_ALIGN_HIGH_EDGE}). 283f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * Default value is 0. 2849106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 2859106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public int getWindowAlignmentOffset() { 2869106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn return mLayoutManager.getWindowAlignmentOffset(); 2879106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 2889106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 2899106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 2909106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Set offset percent for window alignment in addition to {@link 29160d34fdccbe92a77e01b2cc63ffcab092a91009fTim Kilbourn * #getWindowAlignmentOffset()}. 2929106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 2939106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @param offsetPercent Percentage to offset. E.g., 40 means 40% of the 2949106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * width from low edge. Use 2959106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * {@link #WINDOW_ALIGN_OFFSET_PERCENT_DISABLED} to disable. 296f032181dec150eadd94cdc936c6e18d83443d9c7Dake Gu * Default value is 50. 2979106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 2989106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setWindowAlignmentOffsetPercent(float offsetPercent) { 2999106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setWindowAlignmentOffsetPercent(offsetPercent); 3009106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn requestLayout(); 3019106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 3029106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 3039106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 3049106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Get offset percent for window alignment in addition to 30560d34fdccbe92a77e01b2cc63ffcab092a91009fTim Kilbourn * {@link #getWindowAlignmentOffset()}. 3069106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 3079106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @return Percentage to offset. E.g., 40 means 40% of the width from the 3089106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * low edge, or {@link #WINDOW_ALIGN_OFFSET_PERCENT_DISABLED} if 3099106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * disabled. Default value is 50. 3109106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 3119106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public float getWindowAlignmentOffsetPercent() { 3129106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn return mLayoutManager.getWindowAlignmentOffsetPercent(); 3139106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 3149106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 3159106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 3169106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Set the absolute offset in pixels for item alignment. 3179106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 3189106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @param offset The number of pixels to offset. Can be negative for 3199106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * alignment from the high edge, or positive for alignment from the 3209106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * low edge. 3219106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 3229106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setItemAlignmentOffset(int offset) { 3239106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setItemAlignmentOffset(offset); 3249106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn requestLayout(); 3259106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 3269106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 3279106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 3289106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Get the absolute offset in pixels for item alignment. 3299106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 3309106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @return The number of pixels to offset. Will be negative for alignment 3319106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * from the high edge, or positive for alignment from the low edge. 3329106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Default value is 0. 3339106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 3349106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public int getItemAlignmentOffset() { 3359106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn return mLayoutManager.getItemAlignmentOffset(); 3369106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 3379106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 3389106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 339e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu * Set to true if include padding in calculating item align offset. 340e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu * 341e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu * @param withPadding When it is true: we include left/top padding for positive 342e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu * item offset, include right/bottom padding for negative item offset. 343e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu */ 344e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu public void setItemAlignmentOffsetWithPadding(boolean withPadding) { 345e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu mLayoutManager.setItemAlignmentOffsetWithPadding(withPadding); 346e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu requestLayout(); 347e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu } 348e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu 349e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu /** 350e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu * Returns true if include padding in calculating item align offset. 351e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu */ 352e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu public boolean isItemAlignmentOffsetWithPadding() { 353e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu return mLayoutManager.isItemAlignmentOffsetWithPadding(); 354e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu } 355e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu 356e43e9266c4b7e4902fefb5d2a0cacca90a3d2681Dake Gu /** 3579106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Set offset percent for item alignment in addition to {@link 35860d34fdccbe92a77e01b2cc63ffcab092a91009fTim Kilbourn * #getItemAlignmentOffset()}. 3599106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 3609106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @param offsetPercent Percentage to offset. E.g., 40 means 40% of the 3619106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * width from the low edge. Use 3629106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * {@link #ITEM_ALIGN_OFFSET_PERCENT_DISABLED} to disable. 3639106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 3649106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setItemAlignmentOffsetPercent(float offsetPercent) { 3659106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setItemAlignmentOffsetPercent(offsetPercent); 3669106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn requestLayout(); 3679106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 3689106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 3699106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 3709106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Get offset percent for item alignment in addition to {@link 37160d34fdccbe92a77e01b2cc63ffcab092a91009fTim Kilbourn * #getItemAlignmentOffset()}. 3729106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 3739106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @return Percentage to offset. E.g., 40 means 40% of the width from the 3749106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * low edge, or {@link #ITEM_ALIGN_OFFSET_PERCENT_DISABLED} if 3759106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * disabled. Default value is 50. 3769106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 3779106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public float getItemAlignmentOffsetPercent() { 3789106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn return mLayoutManager.getItemAlignmentOffsetPercent(); 3799106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 3809106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 3819106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 3829106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Set the id of the view to align with. Use zero (default) for the item 3839106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * view itself. 3849106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 3859106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setItemAlignmentViewId(int viewId) { 3869106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setItemAlignmentViewId(viewId); 3879106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 3889106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 3899106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 3909106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Get the id of the view to align with, or zero for the item view itself. 3919106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 3929106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public int getItemAlignmentViewId() { 3939106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn return mLayoutManager.getItemAlignmentViewId(); 3949106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 3959106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 3969106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 3979106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Set the margin in pixels between two child items. 3989106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 3999106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setItemMargin(int margin) { 4009106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setItemMargin(margin); 4019106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn requestLayout(); 4029106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4039106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4049106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 4059106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Set the margin in pixels between two child items vertically. 4069106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 4079106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setVerticalMargin(int margin) { 4089106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setVerticalMargin(margin); 4099106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn requestLayout(); 4109106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4119106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4129106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 4139106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Get the margin in pixels between two child items vertically. 4149106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 4159106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public int getVerticalMargin() { 4169106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn return mLayoutManager.getVerticalMargin(); 4179106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4189106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4199106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 420cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn * Set the margin in pixels between two child items horizontally. 421cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn */ 422cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn public void setHorizontalMargin(int margin) { 423cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn mLayoutManager.setHorizontalMargin(margin); 424cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn requestLayout(); 425cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn } 426cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn 427cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn /** 428cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn * Get the margin in pixels between two child items horizontally. 429cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn */ 430cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn public int getHorizontalMargin() { 431cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn return mLayoutManager.getHorizontalMargin(); 432cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn } 433cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn 434cfbb302b7a67d1633b1a68f659ed41aa71702507Tim Kilbourn /** 435a8a3b898da49324e83ea32c3f08776a481312166Tim Kilbourn * Register a callback to be invoked when an item in BaseGridView has 436b33714d135e006cf3bdba09788c27d4791b8632eCraig Stout * been selected. Note that the listener may be invoked when there is a 437b33714d135e006cf3bdba09788c27d4791b8632eCraig Stout * layout pending on the view, affording the listener an opportunity to 438b33714d135e006cf3bdba09788c27d4791b8632eCraig Stout * adjust the upcoming layout based on the selection state. 439b33714d135e006cf3bdba09788c27d4791b8632eCraig Stout * 440b33714d135e006cf3bdba09788c27d4791b8632eCraig Stout * @param listener The listener to be invoked. 4419106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 4429106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setOnChildSelectedListener(OnChildSelectedListener listener) { 4439106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setOnChildSelectedListener(listener); 4449106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4459106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4469106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 4479106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Change the selected item immediately without animation. 4489106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 449025aa57d4fdd4e79289303c7dc54169311728f7bCraig Stout public void setSelectedPosition(int position) { 4509106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setSelection(this, position); 4519106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4529106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4539106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 4549106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Change the selected item and run an animation to scroll to the target 4559106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * position. 4569106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 457025aa57d4fdd4e79289303c7dc54169311728f7bCraig Stout public void setSelectedPositionSmooth(int position) { 4589106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.setSelectionSmooth(this, position); 4599106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4609106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4619106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 462025aa57d4fdd4e79289303c7dc54169311728f7bCraig Stout * Get the selected item position. 4639106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 464025aa57d4fdd4e79289303c7dc54169311728f7bCraig Stout public int getSelectedPosition() { 4659106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn return mLayoutManager.getSelection(); 4669106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4679106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4689106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 4699106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Set if an animation should run when a child changes size or when adding 4709106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * or removing a child. 4719106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * <p><i>Unstable API, might change later.</i> 4729106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 4739106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void setAnimateChildLayout(boolean animateChildLayout) { 47494920246f7f5a0d4dae794058020cd67c5701056Dake Gu if (mAnimateChildLayout != animateChildLayout) { 47594920246f7f5a0d4dae794058020cd67c5701056Dake Gu mAnimateChildLayout = animateChildLayout; 47694920246f7f5a0d4dae794058020cd67c5701056Dake Gu if (!mAnimateChildLayout) { 47794920246f7f5a0d4dae794058020cd67c5701056Dake Gu mSavedItemAnimator = getItemAnimator(); 47894920246f7f5a0d4dae794058020cd67c5701056Dake Gu super.setItemAnimator(null); 47994920246f7f5a0d4dae794058020cd67c5701056Dake Gu } else { 48094920246f7f5a0d4dae794058020cd67c5701056Dake Gu super.setItemAnimator(mSavedItemAnimator); 48194920246f7f5a0d4dae794058020cd67c5701056Dake Gu } 48294920246f7f5a0d4dae794058020cd67c5701056Dake Gu } 4839106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4849106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4859106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 4869106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Return true if an animation will run when a child changes size or when 4879106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * adding or removing a child. 4889106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * <p><i>Unstable API, might change later.</i> 4899106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 4909106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public boolean isChildLayoutAnimated() { 49194920246f7f5a0d4dae794058020cd67c5701056Dake Gu return mAnimateChildLayout; 4929106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 4939106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 4949106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 4955a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu * Describes how the child views are positioned. Defaults to 4968e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing * GRAVITY_TOP|GRAVITY_START. 4975a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu * 4985a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu * @param gravity See {@link android.view.Gravity} 4995a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu */ 5005a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu public void setGravity(int gravity) { 5015a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu mLayoutManager.setGravity(gravity); 5025a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu requestLayout(); 5035a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu } 5045a2782ae17df5331a594fe03d5d89251a8b9f6d4Dake Gu 5059106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn @Override 5069421aa6ca7de4174ddbe2e10fbb05cb31685ffccDake Gu public boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { 5079421aa6ca7de4174ddbe2e10fbb05cb31685ffccDake Gu return mLayoutManager.gridOnRequestFocusInDescendants(this, direction, 5089421aa6ca7de4174ddbe2e10fbb05cb31685ffccDake Gu previouslyFocusedRect); 5099106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 5109106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn 5119106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn /** 5129106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Get the x/y offsets to final position from current position if the view 5139106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * is selected. 5149106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * 5159106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @param view The view to get offsets. 5169106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * @param offsets offsets[0] holds offset of X, offsets[1] holds offset of 5179106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn * Y. 5189106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn */ 5199106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn public void getViewSelectedOffsets(View view, int[] offsets) { 5209106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn mLayoutManager.getViewSelectedOffsets(view, offsets); 5219106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn } 522182f3350d5f3cef04d160c673b6969df28e9439cDake Gu 523182f3350d5f3cef04d160c673b6969df28e9439cDake Gu @Override 524182f3350d5f3cef04d160c673b6969df28e9439cDake Gu public int getChildDrawingOrder(int childCount, int i) { 525182f3350d5f3cef04d160c673b6969df28e9439cDake Gu return mLayoutManager.getChildDrawingOrder(this, childCount, i); 526182f3350d5f3cef04d160c673b6969df28e9439cDake Gu } 527182f3350d5f3cef04d160c673b6969df28e9439cDake Gu 528182f3350d5f3cef04d160c673b6969df28e9439cDake Gu final boolean isChildrenDrawingOrderEnabledInternal() { 529182f3350d5f3cef04d160c673b6969df28e9439cDake Gu return isChildrenDrawingOrderEnabled(); 530182f3350d5f3cef04d160c673b6969df28e9439cDake Gu } 53179ea84679035f18acc581896ff028a4866361b04Dake Gu 53279ea84679035f18acc581896ff028a4866361b04Dake Gu /** 53379ea84679035f18acc581896ff028a4866361b04Dake Gu * Disable or enable focus search. 53479ea84679035f18acc581896ff028a4866361b04Dake Gu */ 5353c23ada8bc25a05bbaa8c479a9df72e8172c4349Dake Gu public final void setFocusSearchDisabled(boolean disabled) { 5363c23ada8bc25a05bbaa8c479a9df72e8172c4349Dake Gu mLayoutManager.setFocusSearchDisabled(disabled); 53779ea84679035f18acc581896ff028a4866361b04Dake Gu } 53879ea84679035f18acc581896ff028a4866361b04Dake Gu 53979ea84679035f18acc581896ff028a4866361b04Dake Gu /** 54079ea84679035f18acc581896ff028a4866361b04Dake Gu * Return true if focus search is disabled. 54179ea84679035f18acc581896ff028a4866361b04Dake Gu */ 54279ea84679035f18acc581896ff028a4866361b04Dake Gu public final boolean isFocusSearchDisabled() { 5433c23ada8bc25a05bbaa8c479a9df72e8172c4349Dake Gu return mLayoutManager.isFocusSearchDisabled(); 54479ea84679035f18acc581896ff028a4866361b04Dake Gu } 54579ea84679035f18acc581896ff028a4866361b04Dake Gu 546e34cae48707e70442aca13e1b4ab55757292828dDake Gu /** 5472f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * Enable or disable layout. All children will be removed when layout is 5482f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * disabled. 5492f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu */ 5502f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu public void setLayoutEnabled(boolean layoutEnabled) { 5512f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu mLayoutManager.setLayoutEnabled(layoutEnabled); 5522f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu } 5532f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu 5542f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu /** 555d7618ab69ef591dd5342b9481c4954bfc7e9110cDake Gu * Change and override children's visibility. 556d7618ab69ef591dd5342b9481c4954bfc7e9110cDake Gu */ 557d7618ab69ef591dd5342b9481c4954bfc7e9110cDake Gu public void setChildrenVisibility(int visibility) { 558d7618ab69ef591dd5342b9481c4954bfc7e9110cDake Gu mLayoutManager.setChildrenVisibility(visibility); 559d7618ab69ef591dd5342b9481c4954bfc7e9110cDake Gu } 560d7618ab69ef591dd5342b9481c4954bfc7e9110cDake Gu 561d7618ab69ef591dd5342b9481c4954bfc7e9110cDake Gu /** 5624510b275c55d9a3dae13af38196d3bc6affd3dfcDake Gu * Enable or disable pruning child. Disable is useful during transition. 5634510b275c55d9a3dae13af38196d3bc6affd3dfcDake Gu */ 5644510b275c55d9a3dae13af38196d3bc6affd3dfcDake Gu public void setPruneChild(boolean pruneChild) { 5654510b275c55d9a3dae13af38196d3bc6affd3dfcDake Gu mLayoutManager.setPruneChild(pruneChild); 5664510b275c55d9a3dae13af38196d3bc6affd3dfcDake Gu } 5674510b275c55d9a3dae13af38196d3bc6affd3dfcDake Gu 5684510b275c55d9a3dae13af38196d3bc6affd3dfcDake Gu /** 569709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu * Enable or disable scrolling. Disable is useful during transition. 570709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu */ 571709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu public void setScrollEnabled(boolean scrollEnabled) { 572709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu mLayoutManager.setScrollEnabled(scrollEnabled); 573709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu } 574709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu 575709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu /** 576709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu * Returns true if scrolling is enabled. 577709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu */ 578709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu public boolean isScrollEnabled() { 579709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu return mLayoutManager.isScrollEnabled(); 580709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu } 581709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu 582709bb7083a089e788d84ffa81f2c4f60a1bc8cf2Dake Gu /** 5839020c0aec57b4e8994d66b7cd1a89c225e9bfa11Craig Stout * Returns true if the view at the given position has a same row sibling 5849020c0aec57b4e8994d66b7cd1a89c225e9bfa11Craig Stout * in front of it. 585e34cae48707e70442aca13e1b4ab55757292828dDake Gu * 586e34cae48707e70442aca13e1b4ab55757292828dDake Gu * @param position Position in adapter. 587e34cae48707e70442aca13e1b4ab55757292828dDake Gu */ 588e34cae48707e70442aca13e1b4ab55757292828dDake Gu public boolean hasPreviousViewInSameRow(int position) { 589e34cae48707e70442aca13e1b4ab55757292828dDake Gu return mLayoutManager.hasPreviousViewInSameRow(position); 590e34cae48707e70442aca13e1b4ab55757292828dDake Gu } 5910fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu 5920fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu /** 5930fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu * Enable or disable the default "focus draw at last" order rule. 5940fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu */ 5950fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu public void setFocusDrawingOrderEnabled(boolean enabled) { 5960fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu super.setChildrenDrawingOrderEnabled(enabled); 5970fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu } 5980fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu 5990fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu /** 6000fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu * Returns true if default "focus draw at last" order rule is enabled. 6010fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu */ 6020fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu public boolean isFocusDrawingOrderEnabled() { 6030fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu return super.isChildrenDrawingOrderEnabled(); 6040fcad32410ad29031630bb9cc2da35d33a4aa906Dake Gu } 605372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 606372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 607372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Sets the touch intercept listener. 608372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 609372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public void setOnTouchInterceptListener(OnTouchInterceptListener listener) { 610372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout mOnTouchInterceptListener = listener; 611372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 612372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 613372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 614372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Sets the generic motion intercept listener. 615372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 616372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public void setOnMotionInterceptListener(OnMotionInterceptListener listener) { 617372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout mOnMotionInterceptListener = listener; 618372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 619372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 620372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout /** 621372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout * Sets the key intercept listener. 622372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout */ 623372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public void setOnKeyInterceptListener(OnKeyInterceptListener listener) { 624372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout mOnKeyInterceptListener = listener; 625372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 626372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 627372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout @Override 628372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public boolean dispatchKeyEvent(KeyEvent event) { 629372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout if (mOnKeyInterceptListener != null) { 630372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout if (mOnKeyInterceptListener.onInterceptKeyEvent(event)) { 631372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout return true; 632372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 633372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 634372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout return super.dispatchKeyEvent(event); 635372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 636372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 637372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout @Override 638372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public boolean dispatchTouchEvent(MotionEvent event) { 639372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout if (mOnTouchInterceptListener != null) { 640372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout if (mOnTouchInterceptListener.onInterceptTouchEvent(event)) { 641372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout return true; 642372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 643372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 644372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout return super.dispatchTouchEvent(event); 645372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 646372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout 647372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout @Override 648372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout public boolean dispatchGenericFocusedEvent(MotionEvent event) { 649372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout if (mOnMotionInterceptListener != null) { 650372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout if (mOnMotionInterceptListener.onInterceptMotionEvent(event)) { 651372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout return true; 652372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 653372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 654372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout return super.dispatchGenericFocusedEvent(event); 655372d07bb41510d91a6a662a1906aceb0ee759481Craig Stout } 6561102fc6fafe721522f2b67f86d89feda87096265Dake Gu 6571102fc6fafe721522f2b67f86d89feda87096265Dake Gu /** 6581102fc6fafe721522f2b67f86d89feda87096265Dake Gu * @return policy for saving children. One of {@link #SAVE_NO_CHILD} 6591102fc6fafe721522f2b67f86d89feda87096265Dake Gu * {@link #SAVE_ON_SCREEN_CHILD} {@link #SAVE_LIMITED_CHILD} {@link #SAVE_ALL_CHILD}. 6601102fc6fafe721522f2b67f86d89feda87096265Dake Gu */ 6611102fc6fafe721522f2b67f86d89feda87096265Dake Gu public final int getSaveChildrenPolicy() { 6621102fc6fafe721522f2b67f86d89feda87096265Dake Gu return mLayoutManager.mChildrenStates.getSavePolicy(); 6631102fc6fafe721522f2b67f86d89feda87096265Dake Gu } 6641102fc6fafe721522f2b67f86d89feda87096265Dake Gu 6651102fc6fafe721522f2b67f86d89feda87096265Dake Gu /** 6661102fc6fafe721522f2b67f86d89feda87096265Dake Gu * @return The limit number when {@link #getSaveChildrenPolicy()} is 6671102fc6fafe721522f2b67f86d89feda87096265Dake Gu * {@link #SAVE_LIMITED_CHILD} 6681102fc6fafe721522f2b67f86d89feda87096265Dake Gu */ 6691102fc6fafe721522f2b67f86d89feda87096265Dake Gu public final int getSaveChildrenLimitNumber() { 6701102fc6fafe721522f2b67f86d89feda87096265Dake Gu return mLayoutManager.mChildrenStates.getLimitNumber(); 6711102fc6fafe721522f2b67f86d89feda87096265Dake Gu } 6721102fc6fafe721522f2b67f86d89feda87096265Dake Gu 6731102fc6fafe721522f2b67f86d89feda87096265Dake Gu /** 6741102fc6fafe721522f2b67f86d89feda87096265Dake Gu * Set policy for saving children. 6751102fc6fafe721522f2b67f86d89feda87096265Dake Gu * @param savePolicy One of {@link #SAVE_NO_CHILD} {@link #SAVE_ON_SCREEN_CHILD} 6761102fc6fafe721522f2b67f86d89feda87096265Dake Gu * {@link #SAVE_LIMITED_CHILD} {@link #SAVE_ALL_CHILD}. 6771102fc6fafe721522f2b67f86d89feda87096265Dake Gu */ 6781102fc6fafe721522f2b67f86d89feda87096265Dake Gu public final void setSaveChildrenPolicy(int savePolicy) { 6791102fc6fafe721522f2b67f86d89feda87096265Dake Gu mLayoutManager.mChildrenStates.setSavePolicy(savePolicy); 6801102fc6fafe721522f2b67f86d89feda87096265Dake Gu } 6811102fc6fafe721522f2b67f86d89feda87096265Dake Gu 6821102fc6fafe721522f2b67f86d89feda87096265Dake Gu /** 6831102fc6fafe721522f2b67f86d89feda87096265Dake Gu * Set limit number when {@link #getSaveChildrenPolicy()} is {@link #SAVE_LIMITED_CHILD}. 6841102fc6fafe721522f2b67f86d89feda87096265Dake Gu */ 6851102fc6fafe721522f2b67f86d89feda87096265Dake Gu public final void setSaveChildrenLimitNumber(int limitNumber) { 6861102fc6fafe721522f2b67f86d89feda87096265Dake Gu mLayoutManager.mChildrenStates.setLimitNumber(limitNumber); 6871102fc6fafe721522f2b67f86d89feda87096265Dake Gu } 6881102fc6fafe721522f2b67f86d89feda87096265Dake Gu 689ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu @Override 690ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu public boolean hasOverlappingRendering() { 691ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu return mHasOverlappingRendering; 692ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu } 693ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu 694ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu public void setHasOverlappingRendering(boolean hasOverlapping) { 695ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu mHasOverlappingRendering = hasOverlapping; 696ceb7ab2ddd6e157cd4ade0f14a382c39428163c4Dake Gu } 6978e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing 6988e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing /** 6998e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing * Notify layout manager that layout directionality has been updated 7008e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing */ 7018e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing @Override 7028e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing public void onRtlPropertiesChanged(int layoutDirection) { 7038e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing mLayoutManager.onRtlPropertiesChanged(layoutDirection); 7048e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing } 7058e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing 7068e3566285de4ac771d6188f62fe947e23d371a3dKris Giesing 7079106804a84e5e8733e0b9313f749fa1f726e5d11Tim Kilbourn} 708