copy AdapterView, AbsSpinner and Gallery from AOSP

copied from tag android-6.0.1_r81

existing GTK based implementation was moved from AbsSpinner to Spinner
This commit is contained in:
Julian Winkler 2024-11-23 09:36:42 +01:00 committed by Mis012
parent f53ad02e6f
commit 332d3d1137
12 changed files with 3065 additions and 321 deletions

View file

@ -129,7 +129,6 @@ libtranslationlayer_so = shared_library('translation_layer_main', [
'src/api-impl-jni/widgets/android_view_SurfaceView.c',
'src/api-impl-jni/widgets/android_webkit_WebView.c',
'src/api-impl-jni/widgets/android_widget_AbsListView.c',
'src/api-impl-jni/widgets/android_widget_AbsSpinner.c',
'src/api-impl-jni/widgets/android_widget_Button.c',
'src/api-impl-jni/widgets/android_widget_CheckBox.c',
'src/api-impl-jni/widgets/android_widget_CompoundButton.c',
@ -141,6 +140,7 @@ libtranslationlayer_so = shared_library('translation_layer_main', [
'src/api-impl-jni/widgets/android_widget_Progressbar.c',
'src/api-impl-jni/widgets/android_widget_RadioButton.c',
'src/api-impl-jni/widgets/android_widget_ScrollView.c',
'src/api-impl-jni/widgets/android_widget_Spinner.c',
'src/api-impl-jni/widgets/android_widget_SeekBar.c',
'src/api-impl-jni/widgets/android_widget_TextView.c',
'src/sk_area/sk_area.c',

View file

@ -199,6 +199,20 @@ extern "C" {
#define android_widget_AbsListView_TEXT_DIRECTION_LTR 3L
#undef android_widget_AbsListView_TEXT_DIRECTION_RTL
#define android_widget_AbsListView_TEXT_DIRECTION_RTL 4L
#undef android_widget_AbsListView_ITEM_VIEW_TYPE_IGNORE
#define android_widget_AbsListView_ITEM_VIEW_TYPE_IGNORE -1L
#undef android_widget_AbsListView_ITEM_VIEW_TYPE_HEADER_OR_FOOTER
#define android_widget_AbsListView_ITEM_VIEW_TYPE_HEADER_OR_FOOTER -2L
#undef android_widget_AbsListView_SYNC_SELECTED_POSITION
#define android_widget_AbsListView_SYNC_SELECTED_POSITION 0L
#undef android_widget_AbsListView_SYNC_FIRST_POSITION
#define android_widget_AbsListView_SYNC_FIRST_POSITION 1L
#undef android_widget_AbsListView_SYNC_MAX_DURATION_MILLIS
#define android_widget_AbsListView_SYNC_MAX_DURATION_MILLIS 100L
#undef android_widget_AbsListView_INVALID_POSITION
#define android_widget_AbsListView_INVALID_POSITION -1L
#undef android_widget_AbsListView_INVALID_ROW_ID
#define android_widget_AbsListView_INVALID_ROW_ID -9223372036854775808LL
/*
* Class: android_widget_AbsListView
* Method: native_constructor

View file

@ -1,229 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class android_widget_AbsSpinner */
#ifndef _Included_android_widget_AbsSpinner
#define _Included_android_widget_AbsSpinner
#ifdef __cplusplus
extern "C" {
#endif
#undef android_widget_AbsSpinner_NO_ID
#define android_widget_AbsSpinner_NO_ID -1L
#undef android_widget_AbsSpinner_NOT_FOCUSABLE
#define android_widget_AbsSpinner_NOT_FOCUSABLE 0L
#undef android_widget_AbsSpinner_FOCUSABLE
#define android_widget_AbsSpinner_FOCUSABLE 1L
#undef android_widget_AbsSpinner_FOCUSABLE_MASK
#define android_widget_AbsSpinner_FOCUSABLE_MASK 1L
#undef android_widget_AbsSpinner_FITS_SYSTEM_WINDOWS
#define android_widget_AbsSpinner_FITS_SYSTEM_WINDOWS 2L
#undef android_widget_AbsSpinner_VISIBLE
#define android_widget_AbsSpinner_VISIBLE 0L
#undef android_widget_AbsSpinner_INVISIBLE
#define android_widget_AbsSpinner_INVISIBLE 4L
#undef android_widget_AbsSpinner_GONE
#define android_widget_AbsSpinner_GONE 8L
#undef android_widget_AbsSpinner_VISIBILITY_MASK
#define android_widget_AbsSpinner_VISIBILITY_MASK 12L
#undef android_widget_AbsSpinner_ENABLED
#define android_widget_AbsSpinner_ENABLED 0L
#undef android_widget_AbsSpinner_DISABLED
#define android_widget_AbsSpinner_DISABLED 32L
#undef android_widget_AbsSpinner_ENABLED_MASK
#define android_widget_AbsSpinner_ENABLED_MASK 32L
#undef android_widget_AbsSpinner_WILL_NOT_DRAW
#define android_widget_AbsSpinner_WILL_NOT_DRAW 128L
#undef android_widget_AbsSpinner_DRAW_MASK
#define android_widget_AbsSpinner_DRAW_MASK 128L
#undef android_widget_AbsSpinner_SCROLLBARS_NONE
#define android_widget_AbsSpinner_SCROLLBARS_NONE 0L
#undef android_widget_AbsSpinner_SCROLLBARS_HORIZONTAL
#define android_widget_AbsSpinner_SCROLLBARS_HORIZONTAL 256L
#undef android_widget_AbsSpinner_SCROLLBARS_VERTICAL
#define android_widget_AbsSpinner_SCROLLBARS_VERTICAL 512L
#undef android_widget_AbsSpinner_SCROLLBARS_MASK
#define android_widget_AbsSpinner_SCROLLBARS_MASK 768L
#undef android_widget_AbsSpinner_FILTER_TOUCHES_WHEN_OBSCURED
#define android_widget_AbsSpinner_FILTER_TOUCHES_WHEN_OBSCURED 1024L
#undef android_widget_AbsSpinner_OPTIONAL_FITS_SYSTEM_WINDOWS
#define android_widget_AbsSpinner_OPTIONAL_FITS_SYSTEM_WINDOWS 2048L
#undef android_widget_AbsSpinner_FADING_EDGE_NONE
#define android_widget_AbsSpinner_FADING_EDGE_NONE 0L
#undef android_widget_AbsSpinner_FADING_EDGE_HORIZONTAL
#define android_widget_AbsSpinner_FADING_EDGE_HORIZONTAL 4096L
#undef android_widget_AbsSpinner_FADING_EDGE_VERTICAL
#define android_widget_AbsSpinner_FADING_EDGE_VERTICAL 8192L
#undef android_widget_AbsSpinner_FADING_EDGE_MASK
#define android_widget_AbsSpinner_FADING_EDGE_MASK 12288L
#undef android_widget_AbsSpinner_CLICKABLE
#define android_widget_AbsSpinner_CLICKABLE 16384L
#undef android_widget_AbsSpinner_DRAWING_CACHE_ENABLED
#define android_widget_AbsSpinner_DRAWING_CACHE_ENABLED 32768L
#undef android_widget_AbsSpinner_SAVE_DISABLED
#define android_widget_AbsSpinner_SAVE_DISABLED 65536L
#undef android_widget_AbsSpinner_SAVE_DISABLED_MASK
#define android_widget_AbsSpinner_SAVE_DISABLED_MASK 65536L
#undef android_widget_AbsSpinner_WILL_NOT_CACHE_DRAWING
#define android_widget_AbsSpinner_WILL_NOT_CACHE_DRAWING 131072L
#undef android_widget_AbsSpinner_FOCUSABLE_IN_TOUCH_MODE
#define android_widget_AbsSpinner_FOCUSABLE_IN_TOUCH_MODE 262144L
#undef android_widget_AbsSpinner_DRAWING_CACHE_QUALITY_LOW
#define android_widget_AbsSpinner_DRAWING_CACHE_QUALITY_LOW 524288L
#undef android_widget_AbsSpinner_DRAWING_CACHE_QUALITY_HIGH
#define android_widget_AbsSpinner_DRAWING_CACHE_QUALITY_HIGH 1048576L
#undef android_widget_AbsSpinner_DRAWING_CACHE_QUALITY_AUTO
#define android_widget_AbsSpinner_DRAWING_CACHE_QUALITY_AUTO 0L
#undef android_widget_AbsSpinner_DRAWING_CACHE_QUALITY_MASK
#define android_widget_AbsSpinner_DRAWING_CACHE_QUALITY_MASK 1572864L
#undef android_widget_AbsSpinner_LONG_CLICKABLE
#define android_widget_AbsSpinner_LONG_CLICKABLE 2097152L
#undef android_widget_AbsSpinner_DUPLICATE_PARENT_STATE
#define android_widget_AbsSpinner_DUPLICATE_PARENT_STATE 4194304L
#undef android_widget_AbsSpinner_SCROLLBARS_INSIDE_OVERLAY
#define android_widget_AbsSpinner_SCROLLBARS_INSIDE_OVERLAY 0L
#undef android_widget_AbsSpinner_SCROLLBARS_INSIDE_INSET
#define android_widget_AbsSpinner_SCROLLBARS_INSIDE_INSET 16777216L
#undef android_widget_AbsSpinner_SCROLLBARS_OUTSIDE_OVERLAY
#define android_widget_AbsSpinner_SCROLLBARS_OUTSIDE_OVERLAY 33554432L
#undef android_widget_AbsSpinner_SCROLLBARS_OUTSIDE_INSET
#define android_widget_AbsSpinner_SCROLLBARS_OUTSIDE_INSET 50331648L
#undef android_widget_AbsSpinner_SCROLLBARS_INSET_MASK
#define android_widget_AbsSpinner_SCROLLBARS_INSET_MASK 16777216L
#undef android_widget_AbsSpinner_SCROLLBARS_OUTSIDE_MASK
#define android_widget_AbsSpinner_SCROLLBARS_OUTSIDE_MASK 33554432L
#undef android_widget_AbsSpinner_SCROLLBARS_STYLE_MASK
#define android_widget_AbsSpinner_SCROLLBARS_STYLE_MASK 50331648L
#undef android_widget_AbsSpinner_KEEP_SCREEN_ON
#define android_widget_AbsSpinner_KEEP_SCREEN_ON 67108864L
#undef android_widget_AbsSpinner_SOUND_EFFECTS_ENABLED
#define android_widget_AbsSpinner_SOUND_EFFECTS_ENABLED 134217728L
#undef android_widget_AbsSpinner_HAPTIC_FEEDBACK_ENABLED
#define android_widget_AbsSpinner_HAPTIC_FEEDBACK_ENABLED 268435456L
#undef android_widget_AbsSpinner_PARENT_SAVE_DISABLED
#define android_widget_AbsSpinner_PARENT_SAVE_DISABLED 536870912L
#undef android_widget_AbsSpinner_PARENT_SAVE_DISABLED_MASK
#define android_widget_AbsSpinner_PARENT_SAVE_DISABLED_MASK 536870912L
#undef android_widget_AbsSpinner_FOCUSABLES_ALL
#define android_widget_AbsSpinner_FOCUSABLES_ALL 0L
#undef android_widget_AbsSpinner_FOCUSABLES_TOUCH_MODE
#define android_widget_AbsSpinner_FOCUSABLES_TOUCH_MODE 1L
#undef android_widget_AbsSpinner_FOCUS_BACKWARD
#define android_widget_AbsSpinner_FOCUS_BACKWARD 1L
#undef android_widget_AbsSpinner_FOCUS_FORWARD
#define android_widget_AbsSpinner_FOCUS_FORWARD 2L
#undef android_widget_AbsSpinner_FOCUS_LEFT
#define android_widget_AbsSpinner_FOCUS_LEFT 17L
#undef android_widget_AbsSpinner_FOCUS_UP
#define android_widget_AbsSpinner_FOCUS_UP 33L
#undef android_widget_AbsSpinner_FOCUS_RIGHT
#define android_widget_AbsSpinner_FOCUS_RIGHT 66L
#undef android_widget_AbsSpinner_FOCUS_DOWN
#define android_widget_AbsSpinner_FOCUS_DOWN 130L
#undef android_widget_AbsSpinner_MEASURED_SIZE_MASK
#define android_widget_AbsSpinner_MEASURED_SIZE_MASK 16777215L
#undef android_widget_AbsSpinner_MEASURED_STATE_MASK
#define android_widget_AbsSpinner_MEASURED_STATE_MASK -16777216L
#undef android_widget_AbsSpinner_MEASURED_HEIGHT_STATE_SHIFT
#define android_widget_AbsSpinner_MEASURED_HEIGHT_STATE_SHIFT 16L
#undef android_widget_AbsSpinner_MEASURED_STATE_TOO_SMALL
#define android_widget_AbsSpinner_MEASURED_STATE_TOO_SMALL 16777216L
#undef android_widget_AbsSpinner_PFLAG2_DRAG_CAN_ACCEPT
#define android_widget_AbsSpinner_PFLAG2_DRAG_CAN_ACCEPT 1L
#undef android_widget_AbsSpinner_PFLAG2_DRAG_HOVERED
#define android_widget_AbsSpinner_PFLAG2_DRAG_HOVERED 2L
#undef android_widget_AbsSpinner_LAYOUT_DIRECTION_LTR
#define android_widget_AbsSpinner_LAYOUT_DIRECTION_LTR 0L
#undef android_widget_AbsSpinner_LAYOUT_DIRECTION_RTL
#define android_widget_AbsSpinner_LAYOUT_DIRECTION_RTL 1L
#undef android_widget_AbsSpinner_LAYOUT_DIRECTION_INHERIT
#define android_widget_AbsSpinner_LAYOUT_DIRECTION_INHERIT 2L
#undef android_widget_AbsSpinner_LAYOUT_DIRECTION_LOCALE
#define android_widget_AbsSpinner_LAYOUT_DIRECTION_LOCALE 3L
#undef android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT
#define android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT 2L
#undef android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_MASK
#define android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_MASK 12L
#undef android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL
#define android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL 16L
#undef android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED
#define android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED 32L
#undef android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK
#define android_widget_AbsSpinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK 48L
#undef android_widget_AbsSpinner_STATUS_BAR_HIDDEN
#define android_widget_AbsSpinner_STATUS_BAR_HIDDEN 1L
#undef android_widget_AbsSpinner_STATUS_BAR_VISIBLE
#define android_widget_AbsSpinner_STATUS_BAR_VISIBLE 0L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_FULLSCREEN
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_FULLSCREEN 4L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_HIDE_NAVIGATION
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_HIDE_NAVIGATION 2L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_IMMERSIVE
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_IMMERSIVE 2048L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_IMMERSIVE_STICKY
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_IMMERSIVE_STICKY 4096L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 1024L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 512L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_LAYOUT_STABLE
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_LAYOUT_STABLE 256L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_LOW_PROFILE
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_LOW_PROFILE 1L
#undef android_widget_AbsSpinner_SYSTEM_UI_FLAG_VISIBLE
#define android_widget_AbsSpinner_SYSTEM_UI_FLAG_VISIBLE 0L
#undef android_widget_AbsSpinner_SYSTEM_UI_LAYOUT_FLAGS
#define android_widget_AbsSpinner_SYSTEM_UI_LAYOUT_FLAGS 1536L
#undef android_widget_AbsSpinner_TEXT_ALIGNMENT_CENTER
#define android_widget_AbsSpinner_TEXT_ALIGNMENT_CENTER 4L
#undef android_widget_AbsSpinner_TEXT_ALIGNMENT_GRAVITY
#define android_widget_AbsSpinner_TEXT_ALIGNMENT_GRAVITY 1L
#undef android_widget_AbsSpinner_TEXT_ALIGNMENT_INHERIT
#define android_widget_AbsSpinner_TEXT_ALIGNMENT_INHERIT 0L
#undef android_widget_AbsSpinner_TEXT_ALIGNMENT_TEXT_END
#define android_widget_AbsSpinner_TEXT_ALIGNMENT_TEXT_END 3L
#undef android_widget_AbsSpinner_TEXT_ALIGNMENT_TEXT_START
#define android_widget_AbsSpinner_TEXT_ALIGNMENT_TEXT_START 2L
#undef android_widget_AbsSpinner_TEXT_ALIGNMENT_VIEW_END
#define android_widget_AbsSpinner_TEXT_ALIGNMENT_VIEW_END 6L
#undef android_widget_AbsSpinner_TEXT_ALIGNMENT_VIEW_START
#define android_widget_AbsSpinner_TEXT_ALIGNMENT_VIEW_START 5L
#undef android_widget_AbsSpinner_TEXT_DIRECTION_ANY_RTL
#define android_widget_AbsSpinner_TEXT_DIRECTION_ANY_RTL 2L
#undef android_widget_AbsSpinner_TEXT_DIRECTION_FIRST_STRONG
#define android_widget_AbsSpinner_TEXT_DIRECTION_FIRST_STRONG 1L
#undef android_widget_AbsSpinner_TEXT_DIRECTION_INHERIT
#define android_widget_AbsSpinner_TEXT_DIRECTION_INHERIT 0L
#undef android_widget_AbsSpinner_TEXT_DIRECTION_LOCALE
#define android_widget_AbsSpinner_TEXT_DIRECTION_LOCALE 5L
#undef android_widget_AbsSpinner_TEXT_DIRECTION_LTR
#define android_widget_AbsSpinner_TEXT_DIRECTION_LTR 3L
#undef android_widget_AbsSpinner_TEXT_DIRECTION_RTL
#define android_widget_AbsSpinner_TEXT_DIRECTION_RTL 4L
/*
* Class: android_widget_AbsSpinner
* Method: native_constructor
* Signature: (Landroid/content/Context;Landroid/util/AttributeSet;)J
*/
JNIEXPORT jlong JNICALL Java_android_widget_AbsSpinner_native_1constructor
(JNIEnv *, jobject, jobject, jobject);
/*
* Class: android_widget_AbsSpinner
* Method: native_setAdapter
* Signature: (JLandroid/widget/SpinnerAdapter;)V
*/
JNIEXPORT void JNICALL Java_android_widget_AbsSpinner_native_1setAdapter
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: android_widget_AbsSpinner
* Method: setOnItemSelectedListener
* Signature: (Landroid/widget/AdapterView/OnItemSelectedListener;)V
*/
JNIEXPORT void JNICALL Java_android_widget_AbsSpinner_setOnItemSelectedListener
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,243 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class android_widget_Spinner */
#ifndef _Included_android_widget_Spinner
#define _Included_android_widget_Spinner
#ifdef __cplusplus
extern "C" {
#endif
#undef android_widget_Spinner_NO_ID
#define android_widget_Spinner_NO_ID -1L
#undef android_widget_Spinner_NOT_FOCUSABLE
#define android_widget_Spinner_NOT_FOCUSABLE 0L
#undef android_widget_Spinner_FOCUSABLE
#define android_widget_Spinner_FOCUSABLE 1L
#undef android_widget_Spinner_FOCUSABLE_MASK
#define android_widget_Spinner_FOCUSABLE_MASK 1L
#undef android_widget_Spinner_FITS_SYSTEM_WINDOWS
#define android_widget_Spinner_FITS_SYSTEM_WINDOWS 2L
#undef android_widget_Spinner_VISIBLE
#define android_widget_Spinner_VISIBLE 0L
#undef android_widget_Spinner_INVISIBLE
#define android_widget_Spinner_INVISIBLE 4L
#undef android_widget_Spinner_GONE
#define android_widget_Spinner_GONE 8L
#undef android_widget_Spinner_VISIBILITY_MASK
#define android_widget_Spinner_VISIBILITY_MASK 12L
#undef android_widget_Spinner_ENABLED
#define android_widget_Spinner_ENABLED 0L
#undef android_widget_Spinner_DISABLED
#define android_widget_Spinner_DISABLED 32L
#undef android_widget_Spinner_ENABLED_MASK
#define android_widget_Spinner_ENABLED_MASK 32L
#undef android_widget_Spinner_WILL_NOT_DRAW
#define android_widget_Spinner_WILL_NOT_DRAW 128L
#undef android_widget_Spinner_DRAW_MASK
#define android_widget_Spinner_DRAW_MASK 128L
#undef android_widget_Spinner_SCROLLBARS_NONE
#define android_widget_Spinner_SCROLLBARS_NONE 0L
#undef android_widget_Spinner_SCROLLBARS_HORIZONTAL
#define android_widget_Spinner_SCROLLBARS_HORIZONTAL 256L
#undef android_widget_Spinner_SCROLLBARS_VERTICAL
#define android_widget_Spinner_SCROLLBARS_VERTICAL 512L
#undef android_widget_Spinner_SCROLLBARS_MASK
#define android_widget_Spinner_SCROLLBARS_MASK 768L
#undef android_widget_Spinner_FILTER_TOUCHES_WHEN_OBSCURED
#define android_widget_Spinner_FILTER_TOUCHES_WHEN_OBSCURED 1024L
#undef android_widget_Spinner_OPTIONAL_FITS_SYSTEM_WINDOWS
#define android_widget_Spinner_OPTIONAL_FITS_SYSTEM_WINDOWS 2048L
#undef android_widget_Spinner_FADING_EDGE_NONE
#define android_widget_Spinner_FADING_EDGE_NONE 0L
#undef android_widget_Spinner_FADING_EDGE_HORIZONTAL
#define android_widget_Spinner_FADING_EDGE_HORIZONTAL 4096L
#undef android_widget_Spinner_FADING_EDGE_VERTICAL
#define android_widget_Spinner_FADING_EDGE_VERTICAL 8192L
#undef android_widget_Spinner_FADING_EDGE_MASK
#define android_widget_Spinner_FADING_EDGE_MASK 12288L
#undef android_widget_Spinner_CLICKABLE
#define android_widget_Spinner_CLICKABLE 16384L
#undef android_widget_Spinner_DRAWING_CACHE_ENABLED
#define android_widget_Spinner_DRAWING_CACHE_ENABLED 32768L
#undef android_widget_Spinner_SAVE_DISABLED
#define android_widget_Spinner_SAVE_DISABLED 65536L
#undef android_widget_Spinner_SAVE_DISABLED_MASK
#define android_widget_Spinner_SAVE_DISABLED_MASK 65536L
#undef android_widget_Spinner_WILL_NOT_CACHE_DRAWING
#define android_widget_Spinner_WILL_NOT_CACHE_DRAWING 131072L
#undef android_widget_Spinner_FOCUSABLE_IN_TOUCH_MODE
#define android_widget_Spinner_FOCUSABLE_IN_TOUCH_MODE 262144L
#undef android_widget_Spinner_DRAWING_CACHE_QUALITY_LOW
#define android_widget_Spinner_DRAWING_CACHE_QUALITY_LOW 524288L
#undef android_widget_Spinner_DRAWING_CACHE_QUALITY_HIGH
#define android_widget_Spinner_DRAWING_CACHE_QUALITY_HIGH 1048576L
#undef android_widget_Spinner_DRAWING_CACHE_QUALITY_AUTO
#define android_widget_Spinner_DRAWING_CACHE_QUALITY_AUTO 0L
#undef android_widget_Spinner_DRAWING_CACHE_QUALITY_MASK
#define android_widget_Spinner_DRAWING_CACHE_QUALITY_MASK 1572864L
#undef android_widget_Spinner_LONG_CLICKABLE
#define android_widget_Spinner_LONG_CLICKABLE 2097152L
#undef android_widget_Spinner_DUPLICATE_PARENT_STATE
#define android_widget_Spinner_DUPLICATE_PARENT_STATE 4194304L
#undef android_widget_Spinner_SCROLLBARS_INSIDE_OVERLAY
#define android_widget_Spinner_SCROLLBARS_INSIDE_OVERLAY 0L
#undef android_widget_Spinner_SCROLLBARS_INSIDE_INSET
#define android_widget_Spinner_SCROLLBARS_INSIDE_INSET 16777216L
#undef android_widget_Spinner_SCROLLBARS_OUTSIDE_OVERLAY
#define android_widget_Spinner_SCROLLBARS_OUTSIDE_OVERLAY 33554432L
#undef android_widget_Spinner_SCROLLBARS_OUTSIDE_INSET
#define android_widget_Spinner_SCROLLBARS_OUTSIDE_INSET 50331648L
#undef android_widget_Spinner_SCROLLBARS_INSET_MASK
#define android_widget_Spinner_SCROLLBARS_INSET_MASK 16777216L
#undef android_widget_Spinner_SCROLLBARS_OUTSIDE_MASK
#define android_widget_Spinner_SCROLLBARS_OUTSIDE_MASK 33554432L
#undef android_widget_Spinner_SCROLLBARS_STYLE_MASK
#define android_widget_Spinner_SCROLLBARS_STYLE_MASK 50331648L
#undef android_widget_Spinner_KEEP_SCREEN_ON
#define android_widget_Spinner_KEEP_SCREEN_ON 67108864L
#undef android_widget_Spinner_SOUND_EFFECTS_ENABLED
#define android_widget_Spinner_SOUND_EFFECTS_ENABLED 134217728L
#undef android_widget_Spinner_HAPTIC_FEEDBACK_ENABLED
#define android_widget_Spinner_HAPTIC_FEEDBACK_ENABLED 268435456L
#undef android_widget_Spinner_PARENT_SAVE_DISABLED
#define android_widget_Spinner_PARENT_SAVE_DISABLED 536870912L
#undef android_widget_Spinner_PARENT_SAVE_DISABLED_MASK
#define android_widget_Spinner_PARENT_SAVE_DISABLED_MASK 536870912L
#undef android_widget_Spinner_FOCUSABLES_ALL
#define android_widget_Spinner_FOCUSABLES_ALL 0L
#undef android_widget_Spinner_FOCUSABLES_TOUCH_MODE
#define android_widget_Spinner_FOCUSABLES_TOUCH_MODE 1L
#undef android_widget_Spinner_FOCUS_BACKWARD
#define android_widget_Spinner_FOCUS_BACKWARD 1L
#undef android_widget_Spinner_FOCUS_FORWARD
#define android_widget_Spinner_FOCUS_FORWARD 2L
#undef android_widget_Spinner_FOCUS_LEFT
#define android_widget_Spinner_FOCUS_LEFT 17L
#undef android_widget_Spinner_FOCUS_UP
#define android_widget_Spinner_FOCUS_UP 33L
#undef android_widget_Spinner_FOCUS_RIGHT
#define android_widget_Spinner_FOCUS_RIGHT 66L
#undef android_widget_Spinner_FOCUS_DOWN
#define android_widget_Spinner_FOCUS_DOWN 130L
#undef android_widget_Spinner_MEASURED_SIZE_MASK
#define android_widget_Spinner_MEASURED_SIZE_MASK 16777215L
#undef android_widget_Spinner_MEASURED_STATE_MASK
#define android_widget_Spinner_MEASURED_STATE_MASK -16777216L
#undef android_widget_Spinner_MEASURED_HEIGHT_STATE_SHIFT
#define android_widget_Spinner_MEASURED_HEIGHT_STATE_SHIFT 16L
#undef android_widget_Spinner_MEASURED_STATE_TOO_SMALL
#define android_widget_Spinner_MEASURED_STATE_TOO_SMALL 16777216L
#undef android_widget_Spinner_PFLAG2_DRAG_CAN_ACCEPT
#define android_widget_Spinner_PFLAG2_DRAG_CAN_ACCEPT 1L
#undef android_widget_Spinner_PFLAG2_DRAG_HOVERED
#define android_widget_Spinner_PFLAG2_DRAG_HOVERED 2L
#undef android_widget_Spinner_LAYOUT_DIRECTION_LTR
#define android_widget_Spinner_LAYOUT_DIRECTION_LTR 0L
#undef android_widget_Spinner_LAYOUT_DIRECTION_RTL
#define android_widget_Spinner_LAYOUT_DIRECTION_RTL 1L
#undef android_widget_Spinner_LAYOUT_DIRECTION_INHERIT
#define android_widget_Spinner_LAYOUT_DIRECTION_INHERIT 2L
#undef android_widget_Spinner_LAYOUT_DIRECTION_LOCALE
#define android_widget_Spinner_LAYOUT_DIRECTION_LOCALE 3L
#undef android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT
#define android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT 2L
#undef android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_MASK
#define android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_MASK 12L
#undef android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL
#define android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL 16L
#undef android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED
#define android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED 32L
#undef android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK
#define android_widget_Spinner_PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK 48L
#undef android_widget_Spinner_STATUS_BAR_HIDDEN
#define android_widget_Spinner_STATUS_BAR_HIDDEN 1L
#undef android_widget_Spinner_STATUS_BAR_VISIBLE
#define android_widget_Spinner_STATUS_BAR_VISIBLE 0L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_FULLSCREEN
#define android_widget_Spinner_SYSTEM_UI_FLAG_FULLSCREEN 4L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_HIDE_NAVIGATION
#define android_widget_Spinner_SYSTEM_UI_FLAG_HIDE_NAVIGATION 2L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_IMMERSIVE
#define android_widget_Spinner_SYSTEM_UI_FLAG_IMMERSIVE 2048L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_IMMERSIVE_STICKY
#define android_widget_Spinner_SYSTEM_UI_FLAG_IMMERSIVE_STICKY 4096L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
#define android_widget_Spinner_SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 1024L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
#define android_widget_Spinner_SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 512L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_LAYOUT_STABLE
#define android_widget_Spinner_SYSTEM_UI_FLAG_LAYOUT_STABLE 256L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_LOW_PROFILE
#define android_widget_Spinner_SYSTEM_UI_FLAG_LOW_PROFILE 1L
#undef android_widget_Spinner_SYSTEM_UI_FLAG_VISIBLE
#define android_widget_Spinner_SYSTEM_UI_FLAG_VISIBLE 0L
#undef android_widget_Spinner_SYSTEM_UI_LAYOUT_FLAGS
#define android_widget_Spinner_SYSTEM_UI_LAYOUT_FLAGS 1536L
#undef android_widget_Spinner_TEXT_ALIGNMENT_CENTER
#define android_widget_Spinner_TEXT_ALIGNMENT_CENTER 4L
#undef android_widget_Spinner_TEXT_ALIGNMENT_GRAVITY
#define android_widget_Spinner_TEXT_ALIGNMENT_GRAVITY 1L
#undef android_widget_Spinner_TEXT_ALIGNMENT_INHERIT
#define android_widget_Spinner_TEXT_ALIGNMENT_INHERIT 0L
#undef android_widget_Spinner_TEXT_ALIGNMENT_TEXT_END
#define android_widget_Spinner_TEXT_ALIGNMENT_TEXT_END 3L
#undef android_widget_Spinner_TEXT_ALIGNMENT_TEXT_START
#define android_widget_Spinner_TEXT_ALIGNMENT_TEXT_START 2L
#undef android_widget_Spinner_TEXT_ALIGNMENT_VIEW_END
#define android_widget_Spinner_TEXT_ALIGNMENT_VIEW_END 6L
#undef android_widget_Spinner_TEXT_ALIGNMENT_VIEW_START
#define android_widget_Spinner_TEXT_ALIGNMENT_VIEW_START 5L
#undef android_widget_Spinner_TEXT_DIRECTION_ANY_RTL
#define android_widget_Spinner_TEXT_DIRECTION_ANY_RTL 2L
#undef android_widget_Spinner_TEXT_DIRECTION_FIRST_STRONG
#define android_widget_Spinner_TEXT_DIRECTION_FIRST_STRONG 1L
#undef android_widget_Spinner_TEXT_DIRECTION_INHERIT
#define android_widget_Spinner_TEXT_DIRECTION_INHERIT 0L
#undef android_widget_Spinner_TEXT_DIRECTION_LOCALE
#define android_widget_Spinner_TEXT_DIRECTION_LOCALE 5L
#undef android_widget_Spinner_TEXT_DIRECTION_LTR
#define android_widget_Spinner_TEXT_DIRECTION_LTR 3L
#undef android_widget_Spinner_TEXT_DIRECTION_RTL
#define android_widget_Spinner_TEXT_DIRECTION_RTL 4L
#undef android_widget_Spinner_ITEM_VIEW_TYPE_IGNORE
#define android_widget_Spinner_ITEM_VIEW_TYPE_IGNORE -1L
#undef android_widget_Spinner_ITEM_VIEW_TYPE_HEADER_OR_FOOTER
#define android_widget_Spinner_ITEM_VIEW_TYPE_HEADER_OR_FOOTER -2L
#undef android_widget_Spinner_SYNC_SELECTED_POSITION
#define android_widget_Spinner_SYNC_SELECTED_POSITION 0L
#undef android_widget_Spinner_SYNC_FIRST_POSITION
#define android_widget_Spinner_SYNC_FIRST_POSITION 1L
#undef android_widget_Spinner_SYNC_MAX_DURATION_MILLIS
#define android_widget_Spinner_SYNC_MAX_DURATION_MILLIS 100L
#undef android_widget_Spinner_INVALID_POSITION
#define android_widget_Spinner_INVALID_POSITION -1L
#undef android_widget_Spinner_INVALID_ROW_ID
#define android_widget_Spinner_INVALID_ROW_ID -9223372036854775808LL
/*
* Class: android_widget_Spinner
* Method: native_constructor
* Signature: (Landroid/content/Context;Landroid/util/AttributeSet;)J
*/
JNIEXPORT jlong JNICALL Java_android_widget_Spinner_native_1constructor
(JNIEnv *, jobject, jobject, jobject);
/*
* Class: android_widget_Spinner
* Method: native_setAdapter
* Signature: (JLandroid/widget/SpinnerAdapter;)V
*/
JNIEXPORT void JNICALL Java_android_widget_Spinner_native_1setAdapter
(JNIEnv *, jobject, jlong, jobject);
/*
* Class: android_widget_Spinner
* Method: setOnItemSelectedListener
* Signature: (Landroid/widget/AdapterView/OnItemSelectedListener;)V
*/
JNIEXPORT void JNICALL Java_android_widget_Spinner_setOnItemSelectedListener
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -6,7 +6,7 @@
#include "WrapperWidget.h"
#include "AdapterView.h"
#include "../generated_headers/android_widget_AbsSpinner.h"
#include "../generated_headers/android_widget_Spinner.h"
static void bind_listitem_cb(GtkListItemFactory *factory, GtkListItem *list_item)
{
@ -27,7 +27,7 @@ static void bind_listitem_cb(GtkListItemFactory *factory, GtkListItem *list_item
gtk_list_item_set_child(list_item, child);
}
JNIEXPORT jlong JNICALL Java_android_widget_AbsSpinner_native_1constructor(JNIEnv *env, jobject this, jobject context, jobject attrs)
JNIEXPORT jlong JNICALL Java_android_widget_Spinner_native_1constructor(JNIEnv *env, jobject this, jobject context, jobject attrs)
{
GtkWidget *wrapper = g_object_ref(wrapper_widget_new());
GtkListItemFactory *factory = gtk_signal_list_item_factory_new();
@ -42,7 +42,7 @@ JNIEXPORT jlong JNICALL Java_android_widget_AbsSpinner_native_1constructor(JNIEn
return _INTPTR(dropdown);
}
JNIEXPORT void JNICALL Java_android_widget_AbsSpinner_native_1setAdapter(JNIEnv *env, jobject this, jlong widget_ptr, jobject adapter)
JNIEXPORT void JNICALL Java_android_widget_Spinner_native_1setAdapter(JNIEnv *env, jobject this, jlong widget_ptr, jobject adapter)
{
GtkDropDown *dropdown = GTK_DROP_DOWN(_PTR(widget_ptr));
RangeListModel *model = RANGE_LIST_MODEL(gtk_drop_down_get_model(dropdown));
@ -64,7 +64,7 @@ static void on_selected_changed(GtkDropDown *dropdown, GParamSpec *pspec, jobjec
(*env)->CallVoidMethod(env, listener, onItemSelected, model->jobject, NULL, index, (long)0);
}
JNIEXPORT void JNICALL Java_android_widget_AbsSpinner_setOnItemSelectedListener(JNIEnv *env, jobject this, jobject listener)
JNIEXPORT void JNICALL Java_android_widget_Spinner_setOnItemSelectedListener(JNIEnv *env, jobject this, jobject listener)
{
GtkDropDown *dropdown = GTK_DROP_DOWN(_PTR(_GET_LONG_FIELD(this, "widget")));
g_signal_connect(dropdown, "notify::selected", G_CALLBACK(on_selected_changed), _REF(listener));

View file

@ -127,7 +127,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
}
public void detachViewFromParent(int index) {
removeViewAt(index);
removeViewInternal(children.get(index));
}
public void attachViewToParent(View view, int index, LayoutParams params) {
@ -367,7 +367,7 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
public void setClipChildren(boolean clipChildren) {}
public void dispatchSetPressed(boolean pressed) {}
protected void dispatchSetPressed(boolean pressed) {}
@Override
public View findViewWithTag(Object tag) {

View file

@ -5,10 +5,11 @@ import android.database.DataSetObserver;
import android.util.AttributeSet;
import android.view.ViewGroup;
public abstract class AbsListView extends AdapterView {
public abstract class AbsListView extends AdapterView<ListAdapter> {
public boolean mIsChildViewEnabled = false; // this field gets directly accessed by androidx DropDownListView
protected Observer observer = new Observer();
private ListAdapter adapter;
public AbsListView(Context context) {
super(context);
@ -35,7 +36,7 @@ public abstract class AbsListView extends AdapterView {
ListAdapter oldAdapter = getAdapter();
if (oldAdapter != null)
oldAdapter.unregisterDataSetObserver(observer);
super.setAdapter(adapter);
this.adapter = adapter;
if (adapter != null)
adapter.registerDataSetObserver(observer);
native_setAdapter(this.widget, adapter);
@ -55,7 +56,7 @@ public abstract class AbsListView extends AdapterView {
public int getListPaddingBottom() {return paddingBottom;}
public ListAdapter getAdapter() {
return (ListAdapter) super.getAdapter();
return adapter;
}
public int pointToPosition(int x, int y) {
@ -79,9 +80,7 @@ public abstract class AbsListView extends AdapterView {
}
private int pendingSelection = -1;
@Override
public void setSelection(int position, boolean animate) {
super.setSelection(position, animate);
native_scrollTo(this.widget, position);
if (getWidth() > 0 && getHeight() > 0)
native_scrollTo(AbsListView.this.widget, position);

View file

@ -1,57 +1,391 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.widget;
import android.content.Context;
import android.database.DataSetObserver;
import android.util.AttributeSet;
import com.android.internal.R;
public abstract class AbsSpinner extends AdapterView {
private Observer observer = new Observer();
import android.content.Context;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
/**
* An abstract base class for spinner widgets. SDK users will probably not
* need to use this class.
*
* @attr ref android.R.styleable#AbsSpinner_entries
*/
public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
SpinnerAdapter mAdapter;
int mHeightMeasureSpec;
int mWidthMeasureSpec;
int mSelectionLeftPadding = 0;
int mSelectionTopPadding = 0;
int mSelectionRightPadding = 0;
int mSelectionBottomPadding = 0;
final Rect mSpinnerPadding = new Rect();
final RecycleBin mRecycler = new RecycleBin();
private DataSetObserver mDataSetObserver;
/** Temporary frame to hold a child View's frame rectangle */
private Rect mTouchFrame;
public AbsSpinner(Context context) {
super(context);
haveCustomMeasure = false;
initAbsSpinner();
}
public AbsSpinner(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
haveCustomMeasure = false;
public AbsSpinner(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public AbsSpinner(Context context, AttributeSet attributeSet, int defStyle) {
super(context, attributeSet, defStyle);
haveCustomMeasure = false;
public AbsSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
@Override
protected native long native_constructor(Context context, AttributeSet attrs);
protected native void native_setAdapter(long widget, SpinnerAdapter adapter);
public AbsSpinner(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
initAbsSpinner();
public void setAdapter(SpinnerAdapter adapter) {
SpinnerAdapter oldAdapter = getAdapter();
if (oldAdapter != null)
oldAdapter.unregisterDataSetObserver(observer);
super.setAdapter(adapter);
if (adapter != null)
adapter.registerDataSetObserver(observer);
native_setAdapter(this.widget, adapter);
}
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.AbsSpinner, defStyleAttr, defStyleRes);
public SpinnerAdapter getAdapter() {
return (SpinnerAdapter) super.getAdapter();
}
@Override
public native void setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener);
private class Observer extends DataSetObserver {
@Override
public void onChanged() {
AbsSpinner.this.native_setAdapter(widget, getAdapter());
final CharSequence[] entries = a.getTextArray(R.styleable.AbsSpinner_entries);
if (entries != null) {
final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(
context, R.layout.simple_spinner_item, entries);
adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
setAdapter(adapter);
}
@Override
public void onInvalidated() {
AbsSpinner.this.native_setAdapter(widget, getAdapter());
a.recycle();
}
/**
* Common code for different constructor flavors
*/
private void initAbsSpinner() {
setFocusable(true);
setWillNotDraw(false);
}
/**
* The Adapter is used to provide the data which backs this Spinner.
* It also provides methods to transform spinner items based on their position
* relative to the selected item.
* @param adapter The SpinnerAdapter to use for this Spinner
*/
@Override
public void setAdapter(SpinnerAdapter adapter) {
if (null != mAdapter) {
mAdapter.unregisterDataSetObserver(mDataSetObserver);
resetList();
}
mAdapter = adapter;
mOldSelectedPosition = INVALID_POSITION;
mOldSelectedRowId = INVALID_ROW_ID;
if (mAdapter != null) {
mOldItemCount = mItemCount;
mItemCount = mAdapter.getCount();
checkFocus();
mDataSetObserver = new AdapterDataSetObserver();
mAdapter.registerDataSetObserver(mDataSetObserver);
int position = mItemCount > 0 ? 0 : INVALID_POSITION;
setSelectedPositionInt(position);
setNextSelectedPositionInt(position);
if (mItemCount == 0) {
// Nothing selected
checkSelectionChanged();
}
} else {
checkFocus();
resetList();
// Nothing selected
checkSelectionChanged();
}
requestLayout();
}
/**
* Clear out all children from the list
*/
void resetList() {
mDataChanged = false;
mNeedSync = false;
// removeAllViewsInLayout();
for (int i = getChildCount() - 1; i >= 0; i--) {
removeViewInLayout(getChildAt(i));
}
mOldSelectedPosition = INVALID_POSITION;
mOldSelectedRowId = INVALID_ROW_ID;
setSelectedPositionInt(INVALID_POSITION);
setNextSelectedPositionInt(INVALID_POSITION);
invalidate();
}
/**
* @see android.view.View#measure(int, int)
*
* Figure out the dimensions of this Spinner. The width comes from
* the widthMeasureSpec as Spinnners can't have their width set to
* UNSPECIFIED. The height is based on the height of the selected item
* plus padding.
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int widthSize;
int heightSize;
mSpinnerPadding.left = paddingLeft > mSelectionLeftPadding ? paddingLeft
: mSelectionLeftPadding;
mSpinnerPadding.top = paddingTop > mSelectionTopPadding ? paddingTop
: mSelectionTopPadding;
mSpinnerPadding.right = paddingRight > mSelectionRightPadding ? paddingRight
: mSelectionRightPadding;
mSpinnerPadding.bottom = paddingBottom > mSelectionBottomPadding ? paddingBottom
: mSelectionBottomPadding;
if (mDataChanged) {
handleDataChanged();
}
int preferredHeight = 0;
int preferredWidth = 0;
boolean needsMeasuring = true;
int selectedPosition = getSelectedItemPosition();
if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) {
// Try looking in the recycler. (Maybe we were measured once already)
View view = mRecycler.get(selectedPosition);
if (view == null) {
// Make a new one
view = mAdapter.getView(selectedPosition, null, this);
}
if (view != null) {
// Put in recycler for re-measuring and/or layout
mRecycler.put(selectedPosition, view);
if (view.getLayoutParams() == null) {
mBlockLayoutRequests = true;
view.setLayoutParams(generateDefaultLayoutParams());
mBlockLayoutRequests = false;
}
measureChild(view, widthMeasureSpec, heightMeasureSpec);
preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom;
preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right;
needsMeasuring = false;
}
}
if (needsMeasuring) {
// No views -- just use padding
preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom;
if (widthMode == MeasureSpec.UNSPECIFIED) {
preferredWidth = mSpinnerPadding.left + mSpinnerPadding.right;
}
}
preferredHeight = Math.max(preferredHeight, getSuggestedMinimumHeight());
preferredWidth = Math.max(preferredWidth, getSuggestedMinimumWidth());
heightSize = resolveSizeAndState(preferredHeight, heightMeasureSpec, 0);
widthSize = resolveSizeAndState(preferredWidth, widthMeasureSpec, 0);
setMeasuredDimension(widthSize, heightSize);
mHeightMeasureSpec = heightMeasureSpec;
mWidthMeasureSpec = widthMeasureSpec;
}
int getChildHeight(View child) {
return child.getMeasuredHeight();
}
int getChildWidth(View child) {
return child.getMeasuredWidth();
}
@Override
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
return new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
}
void recycleAllViews() {
final int childCount = getChildCount();
final AbsSpinner.RecycleBin recycleBin = mRecycler;
final int position = mFirstPosition;
// All views go in recycler
for (int i = 0; i < childCount; i++) {
View v = getChildAt(i);
int index = position + i;
recycleBin.put(index, v);
}
}
/**
* Jump directly to a specific item in the adapter data.
*/
public void setSelection(int position, boolean animate) {
// Animate only if requested position is already on screen somewhere
boolean shouldAnimate = animate && mFirstPosition <= position &&
position <= mFirstPosition + getChildCount() - 1;
setSelectionInt(position, shouldAnimate);
}
@Override
public void setSelection(int position) {
setNextSelectedPositionInt(position);
requestLayout();
invalidate();
}
/**
* Makes the item at the supplied position selected.
*
* @param position Position to select
* @param animate Should the transition be animated
*
*/
void setSelectionInt(int position, boolean animate) {
if (position != mOldSelectedPosition) {
mBlockLayoutRequests = true;
int delta = position - mSelectedPosition;
setNextSelectedPositionInt(position);
layout(delta, animate);
mBlockLayoutRequests = false;
}
}
abstract void layout(int delta, boolean animate);
@Override
public View getSelectedView() {
if (mItemCount > 0 && mSelectedPosition >= 0) {
return getChildAt(mSelectedPosition - mFirstPosition);
} else {
return null;
}
}
/**
* Override to prevent spamming ourselves with layout requests
* as we place views
*
* @see android.view.View#requestLayout()
*/
@Override
public void requestLayout() {
if (!mBlockLayoutRequests) {
super.requestLayout();
}
}
@Override
public SpinnerAdapter getAdapter() {
return mAdapter;
}
@Override
public int getCount() {
return mItemCount;
}
/**
* Maps a point to a position in the list.
*
* @param x X in local coordinate
* @param y Y in local coordinate
* @return The position of the item which contains the specified point, or
* {@link #INVALID_POSITION} if the point does not intersect an item.
*/
public int pointToPosition(int x, int y) {
Rect frame = mTouchFrame;
if (frame == null) {
mTouchFrame = new Rect();
frame = mTouchFrame;
}
final int count = getChildCount();
for (int i = count - 1; i >= 0; i--) {
View child = getChildAt(i);
if (child.getVisibility() == View.VISIBLE) {
child.getHitRect(frame);
if (frame.contains(x, y)) {
return mFirstPosition + i;
}
}
}
return INVALID_POSITION;
}
class RecycleBin {
private final SparseArray<View> mScrapHeap = new SparseArray<View>();
public void put(int position, View v) {
mScrapHeap.put(position, v);
}
View get(int position) {
// System.out.print("Looking for " + position);
View result = mScrapHeap.get(position);
if (result != null) {
// System.out.println(" HIT");
mScrapHeap.delete(position);
} else {
// System.out.println(" MISS");
}
return result;
}
void clear() {
final SparseArray<View> scrapHeap = mScrapHeap;
final int count = scrapHeap.size();
for (int i = 0; i < count; i++) {
final View view = scrapHeap.valueAt(i);
if (view != null) {
removeDetachedView(view, true);
}
}
scrapHeap.clear();
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -104,4 +104,15 @@ public class ListView extends AbsListView {
public void setSelection(int position, boolean animate) {
super.setSelection(position + getHeaderViewsCount(), animate);
}
@Override
public View getSelectedView() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getSelectedView'");
}
@Override
public void setSelection(int position) {
setSelection(position, false);
}
}

View file

@ -1,16 +1,61 @@
package android.widget;
import android.content.Context;
import android.database.DataSetObserver;
import android.util.AttributeSet;
public class Spinner extends AbsSpinner {
private Observer observer = new Observer();
public Spinner(Context context) {
super(context);
haveCustomMeasure = false;
}
public Spinner(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
haveCustomMeasure = false;
}
public Spinner(Context context, AttributeSet attributeSet, int defStyle) {
super(context, attributeSet, defStyle);
haveCustomMeasure = false;
}
@Override
protected native long native_constructor(Context context, AttributeSet attrs);
protected native void native_setAdapter(long widget, SpinnerAdapter adapter);
public void setAdapter(SpinnerAdapter adapter) {
SpinnerAdapter oldAdapter = getAdapter();
if (oldAdapter != null)
oldAdapter.unregisterDataSetObserver(observer);
super.setAdapter(adapter);
if (adapter != null)
adapter.registerDataSetObserver(observer);
native_setAdapter(this.widget, adapter);
}
public SpinnerAdapter getAdapter() {
return (SpinnerAdapter) super.getAdapter();
}
@Override
public native void setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener);
private class Observer extends DataSetObserver {
@Override
public void onChanged() {
Spinner.this.native_setAdapter(widget, getAdapter());
}
@Override
public void onInvalidated() {
Spinner.this.native_setAdapter(widget, getAdapter());
}
}
@Override
void layout(int delta, boolean animate) {}
}