How xuningjack/drag_click_view works
1. Repository type and purpose
- This is a single Android application focused on a dual-GridView selection UI: users can tap or drag items to move them between “selected” and “unselected” states.
- The README frames the core feature clearly: two GridViews that support click-and-drag item toggling.
2. Top-level app structure
- The app is organized as a traditional Android project with AndroidManifest.xml, res/, assets/, libs/, and Java source under src/com/example/android_pra/.
- There is no backend, service layer, or multi-module structure visible; the architecture is primarily UI-driven and in-process.
3. Main entry point
- MainActivity.java is the application entry point and likely owns the screen layout, user interaction wiring, and data initialization.
- The main screen is defined in res/layout/activity_main.xml, which probably hosts the two custom GridViews and any surrounding controls.
4. Custom interaction widgets
- SubscribeDragGridView.java is the core custom UI component for the draggable/selected grid behavior.
- NoScrollGridView.java suggests a grid implementation adapted to fit inside another scrollable container without conflicting scroll handling.
- These custom views form the interaction boundary: they encapsulate gesture behavior and presentation mechanics separate from the activity.
5. Adapter layer
- SubScribeDragViewAdapter.java and UnSubScribeAdapter.java are the data-to-view bridges for the two grid states.
- This indicates a split between subscribed/selected items and unsubscribed/unselected items, with each grid using its own adapter or rendering path.
6. Data model
- SubScribeBean.java is the primary item model.
- The bean likely carries the fields needed for display and state transitions, such as label/title and selection status, and it is the unit moved between adapters when the user toggles an item.
7. Resource-driven UI
- The app uses standard Android resources for layout, styles, colors, and string assets under res/.
- Drawable selectors such as btn_bg_selector.xml and my_item_font_color_selector.xml indicate stateful visual feedback for pressed/selected items, which is important for the drag/click UX.
- Multiple style directories (values-v11, values-v14) suggest compatibility handling across Android versions.
8. Assets and bundled runtime artifacts
- assets/ contains web.html, classes.dex, and common.jar, which is unusual for a simple source-only app.
- This suggests the project bundles prebuilt code or a local asset-based component in addition to the Java source, possibly for demo content or embedded logic loaded at runtime.
9. Third-party dependencies
- libs/android-support-v4.jar provides backward-compatible Android support APIs.
- libs/gson-2.2.4.jar is available for JSON serialization/deserialization, though its exact use is not visible from the file tree alone.
- These libraries indicate the app targets older Android compatibility while possibly supporting structured data handling.
10. Build and compatibility boundaries
- project.properties and proguard-project.txt show a classic Eclipse/ADT-era Android build setup.
- The .settings/ files reinforce that this is an older Android project structure rather than a modern Gradle-based one.
11. How the pieces fit together
- MainActivity initializes data, creates/attaches the two adapters, and connects them to the custom grid views.
- User actions in the grids trigger item state changes, moving or reclassifying SubScribeBean objects between selected and unselected lists.
- The adapters then refresh the grids to reflect the new state, with selectors/styles providing the visual feedback.
12. Architecture diagram guidance
- The key boxes to draw are: Activity, two custom GridViews, two adapters, item bean/model, Android resources, and bundled assets/libs.
- The main data flow is user input → custom grid gesture handling → model/state update → adapter refresh → UI redraw.
Main entry points: MainActivity.java MainActivity · activity_main.xml Main screen · SubScribeDragViewAdapter.java Selected adapter · UnSubScribeAdapter.java Unselected adapter
Components 21
App core
Entry activity and primary UI flow
- MainActivity · App entry point; wires layout, data, and grid interactions
src/com/example/android_pra/MainActivity.java - Manifest · Declares the application and entry activity
AndroidManifest.xml
Custom UI
Grid widgets and adapters
- Drag grid · Custom grid that supports tap and drag selection changes
src/com/example/android_pra/ui/SubscribeDragGridView.java - No-scroll grid · Grid variant adapted for nested scrolling layouts
src/com/example/android_pra/ui/NoScrollGridView.java - Selected adapter · Binds subscribed items to the selected grid
src/com/example/android_pra/ui/adapter/SubScribeDragViewAdapter.java - Unselected adapter · Binds available items to the unselected grid
src/com/example/android_pra/ui/adapter/UnSubScribeAdapter.java
Data model
Item state used by the grids
- Item bean · Grid item state and display data
src/com/example/android_pra/ui/bean/SubScribeBean.java
Resources
Layouts, drawables, and values driving presentation
- Main screen · Hosts the dual-grid selection UI
res/layout/activity_main.xml - Item view · Row/cell layout for grid items
res/layout/subscribe_category_item.xml - Button state · Pressed/selected background styling for items
res/drawable/btn_bg_selector.xml - Text state · Stateful text color styling for item labels
res/drawable/my_item_font_color_selector.xml - Strings · User-facing text constants
res/values/strings.xml - Colors · Shared color palette
res/values/colors.xml - Styles · Theme and widget styling across versions
res/values/styles.xml - V11 styles · API-specific style overrides
res/values-v11/styles.xml - V14 styles · API-specific style overrides
res/values-v14/styles.xml
Bundled assets
Prebuilt assets and external libraries
- Web asset · Bundled HTML asset included with the app
assets/web.html - Dex asset · Prebuilt dex payload bundled in assets
assets/classes.dex - Common jar · Bundled precompiled jar asset
assets/common.jar - Support v4 · Backwards-compatible Android support library
libs/android-support-v4.jar - Gson · JSON serialization library available to the app
libs/gson-2.2.4.jar
Connections 26
- MainActivity → Main screen: inflates · Activity loads the main screen layout
- MainActivity → Drag grid: configures · Activity wires the draggable selected grid
- MainActivity → No-scroll grid: configures · Activity wires the companion grid
- MainActivity → Selected adapter: attaches · Selected items are rendered through the selected adapter
- MainActivity → Unselected adapter: attaches · Unselected items are rendered through the unselected adapter
- Selected adapter → Item bean: binds · Selected adapter reads item data and state
- Unselected adapter → Item bean: binds · Unselected adapter reads item data and state
- Drag grid → Selected adapter: renders · Custom grid displays the selected adapter contents
- No-scroll grid → Unselected adapter: renders · Companion grid displays the unselected adapter contents
- Drag grid → Item bean: toggles · Drag and tap interactions move or reclassify items
- No-scroll grid → Item bean: toggles · Tap interactions update item state for the other grid
- Selected adapter → Item view: inflates · Adapter uses the item cell layout
- Unselected adapter → Item view: inflates · Adapter uses the item cell layout
- Item view → Button state: styles · Cell background reacts to pressed/selected state
- Item view → Text state: styles · Cell label color reacts to state
- Main screen → Styles: uses · Main screen styling comes from shared styles
- Main screen → Strings: uses · Main screen text comes from string resources
- Main screen → Colors: uses · Main screen palette comes from color resources
- Styles → V11 styles: overridden by · Version-specific style variants extend the base theme
- Styles → V14 styles: overridden by · Version-specific style variants extend the base theme
- MainActivity → Manifest: declared in · Activity is registered as the app entry point
- MainActivity → Support v4: depends on · Activity code can use support library APIs
- MainActivity → Gson: depends on · JSON library is available for app data handling
- MainActivity → Web asset: may load · Bundled HTML asset is available at runtime
- MainActivity → Dex asset: bundles · Prebuilt dex is packaged with the app assets
- MainActivity → Common jar: bundles · Precompiled jar is packaged with the app assets