# liangfeidotme/androidrubberindicator architecture

> Architecture diagram of the GitHub repository liangfeidotme/androidrubberindicator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/liangfeidotme/androidrubberindicator
- Repository: https://github.com/liangfeidotme/androidrubberindicator

## Overview

##### Main Components
- Library Module:
- Contains all the source code for the custom view. Under the Java package (me.liangfei.indicator), you have key classes such as:
- RubberIndicator – the main UI component providing APIs like setCount(), setFocusPosition(), moveToLeft(), etc.
- CircleView – responsible for drawing the indicator’s circular elements.
- Configuration files specific to the module (build.gradle, proguard rules).
- Sample Module:
- An Android application demonstrating usage. It includes the MainActivity which instantiates and interacts with the RubberIndicator.
- Its own set of resources and configuration files, which indicate how the library is integrated into a running Android app.
- Build & Dependency Components:
- Gradle build scripts and wrappers that define how both modules are built together.
- Project-level files (such as settings.gradle) establishing the multi-module project structure.

##### Establish Relationships and Interactions
- The Sample application depends on the Library module:
- API Invocations:
- Within the Library module, indicate that the RubberIndicator calls internal helper classes like CircleView to render the indicator.
- Data flow from user interactions (touch events on the indicator, page changes) to API calls (for instance, calling moveToLeft() or moveToRight()), which may trigger the OnMoveListener callbacks.
- Resource Usage:
- Linkage between resource files (XML layouts, drawable definitions) and how they are applied within the custom UI components.

##### Architectural Principles and Patterns
- Modular Design: Two clearly separated modules which promote reusability — the library can be integrated into any Android project.
- Separation of Concerns:
- Library module is solely responsible for the UI component and its behavior.
- Sample module demonstrates usage and integration, keeping the demo application separate from core functionality.
- Use of Callbacks:
- The OnMoveListener interface provided in the library is critical for notifying external listeners when the rubber indicator animation has finished moving.
- Integration with Standard Android Components:

- How the Sample module communicates with the Library module (e.g., MainActivity → RubberIndicator API calls).
- How the RubberIndicator uses internal elements like CircleView, resource files, and callbacks.
- Relevant Technologies and Tools:
- That Gradle is used for building, and indicate any specific Android dependencies or frameworks (the project uses standard Android SDK components).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Build & Dependency Components"
        A["settings.gradle"]:::config
    end

    subgraph "Library Module"
        subgraph "Library - Source Code"
            LI["RubberIndicator (UI Component)"]:::java
            LC["CircleView (Helper)"]:::java
            LI -->|"calls"| LC
        end
        subgraph "Library - Resources"
            LR1["Layout XML"]:::resource
            LR2["Drawable XML"]:::resource
            LR3["Attributes XML"]:::resource
            LR4["Colors XML"]:::resource
            LR5["Styles XML"]:::resource
        end
        subgraph "Library - Configuration"
            LC1["Gradle Build Script"]:::config
            LC2["Proguard Rules"]:::config
        end
        LR1 -->|"binds"| LI
        LR2 -->|"binds"| LI
        LR3 -->|"configures"| LI
        LR4 -->|"styles"| LI
        LR5 -->|"styles"| LI
    end

    subgraph "Sample Module"
        subgraph "Sample - Source Code"
            SA["MainActivity"]:::java
        end
        subgraph "Sample - Resources"
            SR1["Layout XML"]:::resource
            SR2["Drawable & Others"]:::resource
        end
        subgraph "Sample - Configuration"
            SC1["Gradle Build Script"]:::config
            SC2["Proguard Rules"]:::config
        end
        SR1 -->|"uses"| SA
    end

    SA -->|"API_call"| LI

    subgraph "User Interaction Flow"
        U["User Action"]:::interaction
        M["API_call(e.g.moveToLeft())"]:::interaction
        V["Visual_Update via CircleView"]:::interaction
        C["Callback(onMoved)"]:::interaction
        U -->|"triggers"| M
        M -->|"delegates_to"| V
        V -->|"feedback"| C
    end

    A -->|"builds"| LI
    A -->|"builds"| SA

    click LI "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/src/main/java/me/liangfei/indicator/RubberIndicator.java"
    click LC "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/src/main/java/me/liangfei/indicator/CircleView.java"
    click LR1 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/src/main/res/layout/rubber_indicator.xml"
    click LR2 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/src/main/res/drawable/indicator_background.xml"
    click LR3 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/src/main/res/values/attrs_rubberindicator.xml"
    click LR4 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/src/main/res/values/colors.xml"
    click LR5 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/src/main/res/values/styles.xml"
    click LC1 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/build.gradle"
    click LC2 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/library/proguard-rules.pro"
    click SA "https://github.com/liangfeidotme/androidrubberindicator/blob/master/sample/src/main/java/me/liangfei/rubberindicator/MainActivity.java"
    click SR1 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/sample/src/main/res/layout/activity_main.xml"
    click SR2 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/sample/src/main/res/drawable/indicator_background.xml"
    click SC1 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/sample/build.gradle"
    click SC2 "https://github.com/liangfeidotme/androidrubberindicator/blob/master/sample/proguard-rules.pro"
    click A "https://github.com/liangfeidotme/androidrubberindicator/blob/master/settings.gradle"

    classDef java fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef resource fill:#ABEBC6,stroke:#1E8449,stroke-width:2px;
    classDef config fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef interaction fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef default fill:#D5DBDB,stroke:#566573,stroke-width:1px;
```
