# xuningjack/year_month_wheel_dialog architecture

> Architecture diagram of the GitHub repository xuningjack/year_month_wheel_dialog, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xuningjack/year_month_wheel_dialog
- Repository: https://github.com/xuningjack/year_month_wheel_dialog

## Overview

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: [`src/com/wanmei/dospy/view/wheel/WheelView.java`](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/WheelView.java) (WheelView), [`src/com/wanmei/dospy/view/CustomDialog.java`](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/CustomDialog.java) (CustomDialog), [`src/com/wanmei/dospy/view/wheel/AbstractWheelTextAdapter.java`](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/AbstractWheelTextAdapter.java) (Text Adapter), [`src/com/example/android_year_month_wheel/MainActivity.java`](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/example/android_year_month_wheel/MainActivity.java) (MainActivity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App"]
  node_main_activity["MainActivity<br/>[MainActivity.java]"]
end

subgraph group_popup["Picker UI"]
  node_custom_dialog["CustomDialog<br/>[CustomDialog.java]"]
  node_page_helper["PageHelper<br/>popup helper<br/>[PageHelper.java]"]
end

subgraph group_wheel["Wheel Core"]
  node_wheel_view(("WheelView<br/>wheel widget<br/>[WheelView.java]"))
  node_wheel_scroller(("WheelScroller<br/>scroll physics<br/>[WheelScroller.java]"))
  node_wheel_adapter["IWheelViewAdapter<br/>adapter contract"]
  node_abstract_adapter["AbstractWheelAdapter<br/>adapter base"]
  node_text_adapter["Text Adapter"]
  node_array_adapter["ArrayWheelAdapter"]
  node_ym_adapter["YearOrMonthAdapter"]
  node_changed_listener["Changed Listener<br/>event listener"]
  node_scroll_listener["Scroll Listener<br/>event listener"]
  node_click_listener["Click Listener<br/>event listener"]
  node_items_range["ItemsRange<br/>viewport range<br/>[ItemsRange.java]"]
  node_wheel_recycle["WheelRecycle<br/>recycling<br/>[WheelRecycle.java]"]
end

subgraph group_resources["Resources"]
  node_popup_layout["Popup Layout"]
  node_wheel_bg["Wheel BG<br/>drawable<br/>[wheel_bg_day.xml]"]
  node_wheel_fg["Wheel FG<br/>drawable<br/>[wheel_fg_day.xml]"]
  node_wheel_val["Wheel Value<br/>drawable<br/>[wheel_val.xml]"]
  node_item_layout["Item Layout"]
  node_slide_anim["Slide Anim<br/>animation"]
end

node_main_activity -->|"opens"| node_custom_dialog
node_custom_dialog -->|"uses"| node_page_helper
node_page_helper -->|"inflates"| node_popup_layout
node_custom_dialog -->|"hosts"| node_wheel_view
node_wheel_view -->|"scrolls via"| node_wheel_scroller
node_wheel_view -->|"reads data"| node_wheel_adapter
node_wheel_adapter -->|"base"| node_abstract_adapter
node_abstract_adapter -->|"specializes"| node_text_adapter
node_text_adapter -->|"backs"| node_array_adapter
node_text_adapter -->|"backs"| node_ym_adapter
node_wheel_view -->|"notifies"| node_changed_listener
node_wheel_view -->|"emits"| node_scroll_listener
node_wheel_view -->|"emits"| node_click_listener
node_wheel_view -->|"tracks"| node_items_range
node_wheel_view -->|"recycles"| node_wheel_recycle
node_wheel_view -->|"renders with"| node_item_layout
node_wheel_view -->|"styled by"| node_wheel_bg
node_wheel_view -->|"styled by"| node_wheel_fg
node_wheel_view -->|"styled by"| node_wheel_val
node_custom_dialog -->|"animates with"| node_slide_anim
node_main_activity -.->|"receives result"| node_changed_listener

click node_main_activity "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/example/android_year_month_wheel/MainActivity.java"
click node_custom_dialog "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/CustomDialog.java"
click node_page_helper "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/PageHelper.java"
click node_popup_layout "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/layout/layout_page_popup_view.xml"
click node_wheel_view "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/WheelView.java"
click node_wheel_scroller "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/WheelScroller.java"
click node_wheel_adapter "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/IWheelViewAdapter.java"
click node_abstract_adapter "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/AbstractWheelAdapter.java"
click node_text_adapter "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/AbstractWheelTextAdapter.java"
click node_array_adapter "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/ArrayWheelAdapter.java"
click node_ym_adapter "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/YearOrMonthAdapter.java"
click node_changed_listener "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/IWheelChangedListener.java"
click node_scroll_listener "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/IWheelScrollListener.java"
click node_click_listener "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/IWheelClickedListener.java"
click node_items_range "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/ItemsRange.java"
click node_wheel_recycle "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/WheelRecycle.java"
click node_wheel_bg "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/drawable/wheel_bg_day.xml"
click node_wheel_fg "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/drawable/wheel_fg_day.xml"
click node_wheel_val "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/drawable/wheel_val.xml"
click node_item_layout "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/layout/item_wheel_view.xml"
click node_slide_anim "https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/anim/slide_in_from_bottom.xml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_activity toneBlue
class node_custom_dialog,node_page_helper toneAmber
class node_wheel_view,node_wheel_scroller,node_wheel_adapter,node_abstract_adapter,node_text_adapter,node_array_adapter,node_ym_adapter,node_changed_listener,node_scroll_listener,node_click_listener,node_items_range,node_wheel_recycle toneMint
class node_popup_layout,node_wheel_bg,node_wheel_fg,node_wheel_val,node_item_layout,node_slide_anim toneRose
```

## Components

### App

Demo entry point and host activity

- [MainActivity](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/example/android_year_month_wheel/MainActivity.java): activity · 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](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/CustomDialog.java): dialog · Main container for the year/month picker experience · `src/com/wanmei/dospy/view/CustomDialog.java`
- [PageHelper](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/PageHelper.java): popup helper · 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](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/WheelView.java): wheel widget · Core scrolling wheel and selection component · `src/com/wanmei/dospy/view/wheel/WheelView.java`
- [WheelScroller](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/WheelScroller.java): scroll physics · Handles fling, inertia, and scroll motion · `src/com/wanmei/dospy/view/wheel/WheelScroller.java`
- [IWheelViewAdapter](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/IWheelViewAdapter.java): adapter contract · Data source abstraction for wheel items · `src/com/wanmei/dospy/view/wheel/IWheelViewAdapter.java`
- [AbstractWheelAdapter](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/AbstractWheelAdapter.java): adapter base · Base adapter implementation shared by wheel data sources · `src/com/wanmei/dospy/view/wheel/AbstractWheelAdapter.java`
- [Text Adapter](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/AbstractWheelTextAdapter.java): text adapter base · Base class for text-rendered wheel items · `src/com/wanmei/dospy/view/wheel/AbstractWheelTextAdapter.java`
- [ArrayWheelAdapter](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/ArrayWheelAdapter.java): adapter · Generic array-backed wheel data source · `src/com/wanmei/dospy/view/wheel/ArrayWheelAdapter.java`
- [YearOrMonthAdapter](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/YearOrMonthAdapter.java): adapter · Specialized data source for year/month values · `src/com/wanmei/dospy/view/wheel/YearOrMonthAdapter.java`
- [Changed Listener](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/IWheelChangedListener.java): event listener · Notifies selection changes from the wheel · `src/com/wanmei/dospy/view/wheel/IWheelChangedListener.java`
- [Scroll Listener](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/IWheelScrollListener.java): event listener · Observes scroll state and motion events · `src/com/wanmei/dospy/view/wheel/IWheelScrollListener.java`
- [Click Listener](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/IWheelClickedListener.java): event listener · Handles item click interactions on the wheel · `src/com/wanmei/dospy/view/wheel/IWheelClickedListener.java`
- [ItemsRange](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/ItemsRange.java): viewport range · Tracks the visible item window during scrolling · `src/com/wanmei/dospy/view/wheel/ItemsRange.java`
- [WheelRecycle](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/src/com/wanmei/dospy/view/wheel/WheelRecycle.java): recycling · 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](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/layout/layout_page_popup_view.xml): layout · Popup-style shell that hosts the wheel picker · `res/layout/layout_page_popup_view.xml`
- [Wheel BG](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/drawable/wheel_bg_day.xml): drawable · Background skin for the wheel · `res/drawable/wheel_bg_day.xml`
- [Wheel FG](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/drawable/wheel_fg_day.xml): drawable · Foreground highlight/overlay for the wheel · `res/drawable/wheel_fg_day.xml`
- [Wheel Value](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/drawable/wheel_val.xml): drawable · Selection indicator or value styling · `res/drawable/wheel_val.xml`
- [Item Layout](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/layout/item_wheel_view.xml): layout · Template used to render wheel rows · `res/layout/item_wheel_view.xml`
- [Slide Anim](https://github.com/xuningjack/year_month_wheel_dialog/blob/master/res/anim/slide_in_from_bottom.xml): animation · Popup enter/exit motion for the picker · `res/anim/slide_in_from_bottom.xml`

## Connections

- 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
