File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
lib/src/main/java/org/evilbinary/tv/widget Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 11package org .evilbinary .tv .widget ;
22
33import android .content .Context ;
4+ import android .os .Build ;
45import android .util .AttributeSet ;
56import android .view .KeyEvent ;
67import android .view .View ;
@@ -30,20 +31,25 @@ public void setCurrentPosition(int pos) {
3031
3132 @ Override
3233 public boolean dispatchKeyEvent (KeyEvent event ) {
33-
34- View focused =findFocus ();
35- int pos = indexOfChild (focused );
36- if (pos >= 0 && pos < getChildCount () ) {
37- setCurrentPosition (pos );
38- postInvalidate ();
34+ if (Build .VERSION .SDK_INT <= Build .VERSION_CODES .JELLY_BEAN_MR2 ) {
35+ View focused = findFocus ();
36+ int pos = indexOfChild (focused );
37+ if (pos >= 0 && pos < getChildCount ()) {
38+ setCurrentPosition (pos );
39+ postInvalidate ();
40+ }
3941 }
4042
4143 return super .dispatchKeyEvent (event );
4244 }
4345
4446 @ Override
4547 protected int getChildDrawingOrder (int childCount , int i ) {
46-
48+ View v = getFocusedChild ();
49+ int pos = indexOfChild (v );
50+ if (pos >= 0 && pos < childCount )
51+ setCurrentPosition (pos );
52+
4753 if (i == childCount - 1 ) {//这是最后一个需要刷新的item
4854 return position ;
4955 }
You can’t perform that action at this time.
0 commit comments