# johanadam/android-searchview-recyclerview architecture

> Architecture diagram of the GitHub repository johanadam/android-searchview-recyclerview, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/johanadam/android-searchview-recyclerview
- Repository: https://github.com/johanadam/android-searchview-recyclerview

## Overview

##### Project Type & Purpose
- This is a beginner‐level Android mobile application demonstrating how to filter/search a list of items in a RecyclerView and how to navigate to a detail screen. There is no external service or database—everything runs in‐memory and uses Android’s Intent system for navigation.

##### Main Architectural Components
a. UI Layer
- MainActivity
- MainFragment (hosts the SearchView + RecyclerView)
- DetailActivity (displays selected item details)
- Layout XMLs (activity_main.xml, activity_detail.xml, cardview_detail.xml, recyclerview.xml, etc.)
b. Adapter Layer
- RecyclerViewAdapter (binds MemberData items to ViewHolders)
- RecyclerViewViewHolder (holds references to UI widgets for each row)
c. Data Layer
- MemberData.java (Serializable data model)
- In-memory List<MemberData> (holds all items and filtered subset)
d. Build & Config
- Gradle build scripts (app/build.gradle, settings.gradle, gradle wrapper)
- AndroidManifest.xml
- proguard-rules.pro

##### Relationships & Data Flow
1. User enters text into SearchView in MainFragment
→ MainFragment.onQueryTextChange(newText)
→ calls filter(datas, newText)
→ produces filteredModelList
→ adapter.setItems(filteredModelList); adapter.notifyDataSetChanged()
→ RecyclerView rebinds and redraws only matching items
2. User taps a row in RecyclerView
→ RecyclerViewAdapter’s ViewHolder.onClickListener
→ builds Intent with Bundle.putSerializable("DATA", selected MemberData)
→ context.startActivity(Intent → DetailActivity)
→ DetailActivity.onCreate(): retrieves MemberData and populates UI

##### Architectural Patterns & Principles
- MVC‐ish separation:
- View = XML layouts + RecyclerView
- Controller = MainFragment, DetailActivity, Adapter
- Model = MemberData + List storage
- Single Responsibility: Adapter only binds and handles click events; Fragment only handles filtering logic and delegates UI updates.
- Loose coupling via Serializable Intent extras.

1. Two large containers: MainActivity (contains MainFragment) and DetailActivity.
2. Inside MainFragment, place SearchView and RecyclerView side by side.
7. Inside DetailActivity, show retrieval of the Serializable “DATA” and population of TextViews.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Main Activity and Fragment
    subgraph "MainActivity" 
        direction TB
        MA["MainActivity"]:::ui
        subgraph "MainFragment"
            direction TB
            SV["SearchView"]:::ui
            FL["filter() logic"]:::logic
            RL["RecyclerView"]:::ui
        end
    end

    %% Adapter and ViewHolder
    RVA["RecyclerViewAdapter"]:::logic
    RVH["RecyclerViewViewHolder"]:::logic

    %% Data Layer
    MD["MemberData (Serializable)"]:::data
    DL["List<MemberData> (In-Memory)"]:::data
    FL2["FilteredList (subset)"]:::data

    %% Detail Activity
    subgraph "DetailActivity"
        direction TB
        RET["Retrieve Intent DATA"]:::logic
        TV["Populate TextViews"]:::ui
    end

    %% Config & Build
    subgraph "Build & Config"
        direction TB
        GM["app/build.gradle"]:::config
        SG["settings.gradle"]:::config
        GW["gradle-wrapper.properties"]:::config
        PM["proguard-rules.pro"]:::config
        AM["AndroidManifest.xml"]:::config
    end

    %% Layout Resources
    subgraph "Layouts" 
        direction TB
        LM1["activity_main.xml"]:::ui
        LM2["activity_detail.xml"]:::ui
        LM3["cardview_detail.xml"]:::ui
        LM4["recyclerview.xml"]:::ui
        LM5["activity_main_frame.xml"]:::ui
        LM6["activity_members_main.xml"]:::ui
        LM7["content_main.xml"]:::ui
    end

    %% Connections for filtering
    SV -->|"filter(text)"| FL
    FL -->|"produce subset"| FL2
    FL2 -->|"setItems() & notifyDataSetChanged()"| RVA

    %% RecyclerView binding flow
    DL -->|"initial data"| RVA
    RVA -->|"binds rows"| RVH
    RVH -->|"renders UI"| RL

    %% Click navigation to detail
    RVH -->|"onClick → Intent(Bundle: DATA) startActivity(Intent)"| DetailActivity

    %% DetailActivity logic
    DetailActivity --> RET
    RET --> TV

    %% Activity containment
    MA --> MainFragment
    MA --> LM1
    DetailActivity --> LM2

    %% Link other layouts
    MainFragment --> LM4
    MainActivity --> LM5
    MainActivity --> LM6
    MainActivity --> LM7
    RVH --> LM3

    %% Build & Config links
    MA --> AM
    MA --> GM
    MA --> SG
    MA --> GW
    MA --> PM

    %% Click events
    click MA "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/java/com/josh/example/searchviewnew/MainActivity.java"
    click MainFragment "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/java/com/josh/example/searchviewnew/MainFragment.java"
    click DetailActivity "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/java/com/josh/example/searchviewnew/DetailActivity.java"
    click MD "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/java/com/josh/example/searchviewnew/Data.java"
    click RVA "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/java/com/josh/example/searchviewnew/RecyclerViewAdapter.java"
    click RVH "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/java/com/josh/example/searchviewnew/RecyclerViewViewHolder.java"
    click LM1 "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/res/layout/activity_main.xml"
    click LM2 "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/res/layout/activity_detail.xml"
    click LM3 "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/res/layout/cardview_detail.xml"
    click LM4 "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/res/layout/recyclerview.xml"
    click LM5 "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/res/layout/activity_main_frame.xml"
    click LM6 "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/res/layout/activity_members_main.xml"
    click LM7 "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/res/layout/content_main.xml"
    click AM "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/src/main/AndroidManifest.xml"
    click GM "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/build.gradle"
    click SG "https://github.com/johanadam/android-searchview-recyclerview/blob/master/settings.gradle"
    click GW "https://github.com/johanadam/android-searchview-recyclerview/blob/master/gradle/wrapper/gradle-wrapper.properties"
    click PM "https://github.com/johanadam/android-searchview-recyclerview/blob/master/app/proguard-rules.pro"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFD700,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
```
