How xuningjack/year_month_wheel_dialog works
1. Project type and purpose
- This is an Android UI component project centered on a year/month picker dialog with a double wheel/roller interaction.
- The README and package layout suggest it is both a sample app and a custom widget implementation.
2. Top-level app entry point
- com.example.android_year_month_wheel.MainActivity is the demo/activity entry point.
- Its role is likely to launch or showcase the custom year-month dialog rather than implement business logic.
3. Custom dialog layer
- com.wanmei.dospy.view.CustomDialog is the main UI container for the picker experience.
- PageHelper likely supports showing/hiding or managing the dialog/popup page behavior.
- The layout res/layout/layout_page_popup_view.xml indicates the picker is presented as a popup-style panel rather than a full screen page.
4. Wheel component subsystem
- The core reusable UI engine lives under com.wanmei.dospy.view.wheel.
- WheelView is the central visual component responsible for rendering a scrolling wheel and coordinating selection state.
5. Scrolling and interaction model
- WheelScroller handles the inertial scrolling / fling behavior.
- IWheelScrollListener, IWheelChangedListener, and IWheelClickedListener define the event boundaries for scroll, selection changes, and item clicks.
- This separates gesture handling from the rest of the UI logic.
6. Adapter-based data binding
- IWheelViewAdapter is the abstraction that feeds data into the wheel.
- AbstractWheelAdapter and AbstractWheelTextAdapter provide base implementations for adapter logic and text rendering.
- ArrayWheelAdapter and YearOrMonthAdapter supply concrete item sources, with YearOrMonthAdapter likely specializing the wheel for year/month values.
7. Rendering and recycling
- ItemsRange and WheelRecycle indicate the wheel uses view range management and recycling to keep scrolling efficient.
- This matters architecturally because the wheel is not just a static list; it maintains a moving visible window of items.
8. Resources and visual theming
- The drawable resources wheel_bg_day.xml, wheel_fg_day.xml, and wheel_val.xml define the wheel’s appearance and selection overlays.
- The layout files item_wheel_view.xml, item_wheel_view_align_left.xml, and item_wheel_view_align_right.xml suggest reusable item templates for different alignments.
- The res/anim folder contains slide-in/slide-out transitions used by the dialog or popup presentation.
9. Android compatibility and styling
- res/values-v11 and res/values-v14 styles indicate API-level-specific styling support.
- This implies the UI behavior or appearance is adapted for different Android platform versions.
- libs/android-support-v4.jar shows reliance on the legacy support library for backward compatibility.
10. Configuration and packaging
- AndroidManifest.xml, project.properties, and proguard-project.txt mark this as a classic Android project structure.
- There is no evidence of network, database, or backend dependencies; the architecture is primarily in-app UI and view logic.
11. Likely runtime data flow
- The activity triggers the custom dialog.
- The dialog/page helper inflates the popup layout.
- One or more wheel views are populated through adapters.
- Scrolling events update the selected year/month and notify listeners.
- The final selected value is returned to the hosting activity.
12. Architecture boundary summary
- The main boundary is between host app code (MainActivity) and the reusable picker widget (CustomDialog, PageHelper, and the wheel package).
- Inside the widget, the other key boundary is between presentation/gesture logic (WheelView, WheelScroller, layouts, drawables) and data provisioning (WheelViewAdapter implementations).
13. What to emphasize in an architecture diagram
- Show the app/activity on one side, the dialog/popup container in the middle, and two wheel components beneath it for year and month.
- Show adapter-driven data feeding into each wheel.
- Show listener callbacks returning the final selection to the activity.
Main entry points: WheelView.java WheelView · CustomDialog.java CustomDialog · AbstractWheelTextAdapter.java Text Adapter · MainActivity.java MainActivity
Components 21
App
Demo entry point and host activity
- MainActivity · Sample entry point that launches the picker dialog
src/com/example/android_year_month_wheel/MainActivity.java
Picker UI
Dialog and popup page that present the year/month selector
- CustomDialog · Main container for the year/month picker experience
src/com/wanmei/dospy/view/CustomDialog.java - PageHelper · Manages page/popup presentation behavior for the dialog
src/com/wanmei/dospy/view/PageHelper.java
Wheel Core
Reusable scrolling wheel engine, adapters, and selection logic
- WheelView · Core scrolling wheel and selection component
src/com/wanmei/dospy/view/wheel/WheelView.java - WheelScroller · Handles fling, inertia, and scroll motion
src/com/wanmei/dospy/view/wheel/WheelScroller.java - IWheelViewAdapter · Data source abstraction for wheel items
src/com/wanmei/dospy/view/wheel/IWheelViewAdapter.java - AbstractWheelAdapter · Base adapter implementation shared by wheel data sources
src/com/wanmei/dospy/view/wheel/AbstractWheelAdapter.java - Text Adapter · Base class for text-rendered wheel items
src/com/wanmei/dospy/view/wheel/AbstractWheelTextAdapter.java - ArrayWheelAdapter · Generic array-backed wheel data source
src/com/wanmei/dospy/view/wheel/ArrayWheelAdapter.java - YearOrMonthAdapter · Specialized data source for year/month values
src/com/wanmei/dospy/view/wheel/YearOrMonthAdapter.java - Changed Listener · Notifies selection changes from the wheel
src/com/wanmei/dospy/view/wheel/IWheelChangedListener.java - Scroll Listener · Observes scroll state and motion events
src/com/wanmei/dospy/view/wheel/IWheelScrollListener.java - Click Listener · Handles item click interactions on the wheel
src/com/wanmei/dospy/view/wheel/IWheelClickedListener.java - ItemsRange · Tracks the visible item window during scrolling
src/com/wanmei/dospy/view/wheel/ItemsRange.java - WheelRecycle · Reuses item views as the wheel moves
src/com/wanmei/dospy/view/wheel/WheelRecycle.java
Resources
Layouts, drawables, and animations that shape the picker UI
- Popup Layout · Popup-style shell that hosts the wheel picker
res/layout/layout_page_popup_view.xml - Wheel BG · Background skin for the wheel
res/drawable/wheel_bg_day.xml - Wheel FG · Foreground highlight/overlay for the wheel
res/drawable/wheel_fg_day.xml - Wheel Value · Selection indicator or value styling
res/drawable/wheel_val.xml - Item Layout · Template used to render wheel rows
res/layout/item_wheel_view.xml - Slide Anim · Popup enter/exit motion for the picker
res/anim/slide_in_from_bottom.xml
Connections 21
- MainActivity → CustomDialog: opens · Demo activity launches the picker dialog
- CustomDialog → PageHelper: uses · Dialog delegates popup/page behavior
- PageHelper → Popup Layout: inflates · Popup shell is built from the page layout
- CustomDialog → WheelView: hosts · Dialog contains the wheel picker widget
- WheelView → WheelScroller: scrolls via · Wheel view delegates inertial motion handling
- WheelView → IWheelViewAdapter: reads data · Wheel view consumes items through the adapter contract
- IWheelViewAdapter → AbstractWheelAdapter: base · Shared adapter functionality is implemented in the base class
- AbstractWheelAdapter → Text Adapter: specializes · Text rendering behavior is layered on top of the adapter base
- Text Adapter → ArrayWheelAdapter: backs · Array-backed adapter is one concrete data source
- Text Adapter → YearOrMonthAdapter: backs · Year/month adapter is the domain-specific data source
- WheelView → Changed Listener: notifies · Selection updates are emitted to listeners
- WheelView → Scroll Listener: emits · Scroll state changes are exposed through callbacks
- WheelView → Click Listener: emits · Item click interactions are exposed through callbacks
- WheelView → ItemsRange: tracks · Visible item window is managed during scroll
- WheelView → WheelRecycle: recycles · Offscreen views are reused while scrolling
- WheelView → Item Layout: renders with · Wheel rows are inflated from reusable item templates
- WheelView → Wheel BG: styled by · Wheel background skin defines appearance
- WheelView → Wheel FG: styled by · Foreground overlay defines selection emphasis
- WheelView → Wheel Value: styled by · Value/selection decoration is supplied by drawable resources
- CustomDialog → Slide Anim: animates with · Dialog/popup presentation uses slide transitions
- MainActivity → Changed Listener: receives result · Hosting activity consumes the chosen year/month value