├── sample
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── font
│ │ │ │ ├── bold.ttf
│ │ │ │ ├── light.ttf
│ │ │ │ ├── medium.ttf
│ │ │ │ ├── extrabold.ttf
│ │ │ │ ├── regular.ttf
│ │ │ │ └── semibold.ttf
│ │ │ ├── drawable
│ │ │ │ ├── ic_logo.png
│ │ │ │ ├── ic_drag.xml
│ │ │ │ ├── ic_circle.xml
│ │ │ │ ├── ic_drag_handle.xml
│ │ │ │ ├── ic_circle_variant.xml
│ │ │ │ ├── ic_swipe_to_dismiss.xml
│ │ │ │ ├── ic_expand_less.xml
│ │ │ │ ├── ic_expand_more.xml
│ │ │ │ ├── ic_star.xml
│ │ │ │ ├── ic_diff_util.xml
│ │ │ │ ├── ic_expandable_mode.xml
│ │ │ │ ├── ic_tv.xml
│ │ │ │ ├── ic_check_box.xml
│ │ │ │ ├── ic_heart.xml
│ │ │ │ ├── ic_web.xml
│ │ │ │ ├── ic_shuffle.xml
│ │ │ │ ├── ic_span_count.xml
│ │ │ │ ├── ic_newspaper.xml
│ │ │ │ ├── ic_decoration.xml
│ │ │ │ ├── ic_offline_empty.xml
│ │ │ │ ├── ic_thumb_up.xml
│ │ │ │ ├── ic_extension.xml
│ │ │ │ ├── ic_fake_news.xml
│ │ │ │ ├── ic_umbrella.xml
│ │ │ │ ├── ic_emoticon.xml
│ │ │ │ ├── ic_data_binding.xml
│ │ │ │ ├── ic_topic.xml
│ │ │ │ ├── ic_infinite_loading.xml
│ │ │ │ ├── ic_configure.xml
│ │ │ │ ├── ic_language.xml
│ │ │ │ └── ic_patter.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ ├── ic_launcher_background.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ ├── ic_launcher_background.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ ├── ic_launcher_background.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ ├── ic_launcher_background.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ ├── ic_launcher_background.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── values-v27
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-v23
│ │ │ │ └── styles.xml
│ │ │ ├── values
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── colors.xml
│ │ │ ├── color
│ │ │ │ ├── text_color_body_primary1.xml
│ │ │ │ ├── text_color_body_primary2.xml
│ │ │ │ ├── text_color_body_primary3.xml
│ │ │ │ ├── text_color_title1.xml
│ │ │ │ ├── text_color_title2.xml
│ │ │ │ └── text_color_title3.xml
│ │ │ ├── layout
│ │ │ │ ├── item_progress.xml
│ │ │ │ ├── item_header_decorated.xml
│ │ │ │ ├── item_header.xml
│ │ │ │ ├── item_news_group.xml
│ │ │ │ ├── fragment_home.xml
│ │ │ │ ├── item_basic.xml
│ │ │ │ ├── item_news_header.xml
│ │ │ │ ├── item_number.xml
│ │ │ │ ├── item_feature.xml
│ │ │ │ ├── widget_feature_header.xml
│ │ │ │ ├── fragment_nested_section.xml
│ │ │ │ ├── fragment_basic.xml
│ │ │ │ ├── fragment_news_feed.xml
│ │ │ │ ├── fragment_expansion.xml
│ │ │ │ ├── fragment_decoration.xml
│ │ │ │ ├── fragment_selection.xml
│ │ │ │ ├── item_shuffling_header.xml
│ │ │ │ ├── fragment_advanced.xml
│ │ │ │ ├── include_config_button_panel.xml
│ │ │ │ ├── item_news_empty.xml
│ │ │ │ └── item_text.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_home.xml
│ │ │ │ └── menu_sample_fragment.xml
│ │ │ └── values-night
│ │ │ │ └── colors.xml
│ │ ├── java
│ │ │ └── dev
│ │ │ │ └── ahamed
│ │ │ │ └── mva
│ │ │ │ └── sample
│ │ │ │ ├── data
│ │ │ │ └── model
│ │ │ │ │ ├── Hint.java
│ │ │ │ │ ├── Person.java
│ │ │ │ │ ├── Comment.java
│ │ │ │ │ ├── TextItem.java
│ │ │ │ │ ├── Header.java
│ │ │ │ │ ├── NumberItem.java
│ │ │ │ │ ├── NewsHeader.java
│ │ │ │ │ ├── ShufflingHeader.java
│ │ │ │ │ ├── ColoredItem.java
│ │ │ │ │ ├── MoviePosterItem.java
│ │ │ │ │ ├── FaqItem.java
│ │ │ │ │ └── SelectableItem.java
│ │ │ │ └── view
│ │ │ │ ├── widget
│ │ │ │ ├── TopBar.java
│ │ │ │ ├── BottomBar.java
│ │ │ │ ├── InsetFrameLayout.java
│ │ │ │ └── WindowInsetsFrameLayout.java
│ │ │ │ ├── decoration
│ │ │ │ ├── HeaderBinder.java
│ │ │ │ └── PersonBinder.java
│ │ │ │ ├── advanced
│ │ │ │ └── NumberItemBinder.java
│ │ │ │ ├── home
│ │ │ │ ├── Feature.java
│ │ │ │ ├── IntroItemBinder.java
│ │ │ │ └── FeatureItemBinder.java
│ │ │ │ ├── newsfeed
│ │ │ │ ├── EmptyStateItemBinder.java
│ │ │ │ ├── NewsFeedDecorator.java
│ │ │ │ ├── NewsHeaderDecorator.java
│ │ │ │ ├── NewsSectionDecorator.java
│ │ │ │ ├── OfflineNewsFeedItemBinder.java
│ │ │ │ └── NewsHeaderItemBinder.java
│ │ │ │ ├── common
│ │ │ │ ├── HintBinder.java
│ │ │ │ └── HeaderItemBinder.java
│ │ │ │ ├── basic
│ │ │ │ ├── CustomLayoutManager.java
│ │ │ │ └── NumberItemBinder.java
│ │ │ │ ├── expansion
│ │ │ │ └── SectionSpaceDecorator.java
│ │ │ │ └── nested
│ │ │ │ ├── DividerDecorator.java
│ │ │ │ └── ThreadDecorator.java
│ │ └── AndroidManifest.xml
│ └── debug
│ │ ├── ic_launcher-web.png
│ │ └── res
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_launcher_background.png
│ │ └── ic_launcher_foreground.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_launcher_background.png
│ │ └── ic_launcher_foreground.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_launcher_background.png
│ │ └── ic_launcher_foreground.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_launcher_background.png
│ │ └── ic_launcher_foreground.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_round.png
│ │ ├── ic_launcher_background.png
│ │ └── ic_launcher_foreground.png
│ │ └── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
├── proguard-rules.pro
└── build.gradle
├── extensions
├── decorator
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── mva2
│ │ │ └── extension
│ │ │ └── decorator
│ │ │ └── InsetDecoration.java
│ └── proguard-rules.pro
├── databinding
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ └── java
│ │ │ └── mva2
│ │ │ └── extension
│ │ │ ├── BindingViewHolder.java
│ │ │ └── DBItemBinder.java
│ └── proguard-rules.pro
└── diffutil-rx
│ ├── .gitignore
│ ├── src
│ └── main
│ │ └── AndroidManifest.xml
│ └── proguard-rules.pro
├── multi-view-adapter
├── .gitignore
├── src
│ ├── test
│ │ ├── resources
│ │ │ └── mockito-extensions
│ │ │ │ └── org.mockito.plugins.MockMaker
│ │ └── java
│ │ │ └── mva2
│ │ │ └── adapter
│ │ │ ├── testconfig
│ │ │ ├── DecorationCapture.java
│ │ │ ├── Header.java
│ │ │ ├── TestItem.java
│ │ │ ├── AdapterDataObserver.java
│ │ │ ├── Comment.java
│ │ │ ├── HashMapCache.java
│ │ │ ├── HeaderBinder.java
│ │ │ ├── TestItemBinder.java
│ │ │ ├── CommentBinder.java
│ │ │ └── RectUtil.java
│ │ │ ├── SectionExpansionTest.java
│ │ │ └── TestAdapter.java
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── mva2
│ │ └── adapter
│ │ ├── internal
│ │ ├── Cache.java
│ │ ├── RecyclerItem.java
│ │ ├── Notifier.java
│ │ ├── ItemMetaData.java
│ │ └── SparseIntArrayCache.java
│ │ ├── util
│ │ ├── SwipeToDismissListener.java
│ │ ├── OnItemClickListener.java
│ │ ├── Mode.java
│ │ ├── OnSelectionChangedListener.java
│ │ └── MvaDiffUtil.java
│ │ └── decorator
│ │ └── SectionPositionType.java
└── proguard-rules.pro
├── images
├── cover.png
├── multi-view-min.gif
├── selection-min.gif
├── how-section-works.gif
├── item-expansion-min.gif
├── other-features-min.gif
└── section-expansion-min.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── .idea
└── codeStyles
│ └── codeStyleConfig.xml
├── .github
├── ISSUE_TEMPLATE
│ └── bug_report.md
├── CONTRIBUTING.md
├── PULL_REQUEST_TEMPLATE
│ └── pull_request_template.md
└── CODE_OF_CONDUCT.md
├── settings.gradle
└── gradle.properties
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /release
--------------------------------------------------------------------------------
/extensions/decorator/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/extensions/databinding/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/extensions/diffutil-rx/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/multi-view-adapter/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /javadocs
--------------------------------------------------------------------------------
/images/cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/images/cover.png
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker:
--------------------------------------------------------------------------------
1 | mock-maker-inline
--------------------------------------------------------------------------------
/images/multi-view-min.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/images/multi-view-min.gif
--------------------------------------------------------------------------------
/images/selection-min.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/images/selection-min.gif
--------------------------------------------------------------------------------
/images/how-section-works.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/images/how-section-works.gif
--------------------------------------------------------------------------------
/images/item-expansion-min.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/images/item-expansion-min.gif
--------------------------------------------------------------------------------
/images/other-features-min.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/images/other-features-min.gif
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/images/section-expansion-min.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/images/section-expansion-min.gif
--------------------------------------------------------------------------------
/sample/src/main/res/font/bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/font/bold.ttf
--------------------------------------------------------------------------------
/sample/src/main/res/font/light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/font/light.ttf
--------------------------------------------------------------------------------
/sample/src/main/res/font/medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/font/medium.ttf
--------------------------------------------------------------------------------
/sample/src/debug/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/ic_launcher-web.png
--------------------------------------------------------------------------------
/sample/src/main/res/font/extrabold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/font/extrabold.ttf
--------------------------------------------------------------------------------
/sample/src/main/res/font/regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/font/regular.ttf
--------------------------------------------------------------------------------
/sample/src/main/res/font/semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/font/semibold.ttf
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/drawable/ic_logo.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-hdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-hdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-mdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-mdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xhdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xhdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xxhdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xxhdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xxxhdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xxxhdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/debug/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevAhamed/MultiViewAdapter/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/*
5 | !/.idea/codeStyles/
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | developer.properties
11 | *.jks
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
6 |
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/debug/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: new
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Please complete the following information:**
11 | - Android API level: [e.g. 21]
12 | - Library Version: [e.g. 2.0.0]
13 | - Recyclerview Version [e.g. 2.0.0]
14 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/Hint.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.data.model;
2 |
3 | import android.support.annotation.StringRes;
4 |
5 | public class Hint {
6 |
7 | private final int description;
8 |
9 | public Hint(@StringRes int description) {
10 | this.description = description;
11 | }
12 |
13 | public @StringRes int getDescription() {
14 | return description;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | // Core Library
2 | include ':multi-view-adapter'
3 |
4 | // Sample
5 | include ':sample'
6 |
7 | // Extensions
8 | include ':mva-databinding', ':mva-decorator', ':mva-diffutil-rx'
9 |
10 | project(':mva-databinding').projectDir = new File(rootDir, 'extensions/databinding')
11 | project(':mva-decorator').projectDir = new File(rootDir, 'extensions/decorator')
12 | project(':mva-diffutil-rx').projectDir = new File(rootDir, 'extensions/diffutil-rx')
13 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/Person.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.data.model;
2 |
3 | public class Person {
4 |
5 | private final String name;
6 | private final String initials;
7 | private final String overline;
8 |
9 | public Person(String name, String initials, String overline) {
10 | this.name = name;
11 | this.initials = initials;
12 | this.overline = overline;
13 | }
14 |
15 | public String getInitials() {
16 | return initials;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public String getOverline() {
24 | return overline;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Enable daemon
2 | org.gradle.daemon=true
3 |
4 | # Try and findout the best heap size for your project build and system.
5 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
6 |
7 | # Modularise your project and enable parallel build
8 | org.gradle.parallel=true
9 |
10 | # Gradle Cache
11 | org.gradle.caching=true
12 |
13 | # Android Build Cache
14 | android.enableBuildCache=true
15 |
16 | # DataBinding
17 | android.databinding.enableV2=true
18 |
19 | # AndroidX
20 | android.useAndroidX=false
21 | android.enableJetifier=false
22 |
23 | # Experimental
24 | android.enableD8.desugaring=true
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
--------------------------------------------------------------------------------
/extensions/decorator/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/extensions/databinding/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/extensions/diffutil-rx/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-v27/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | #CCFFFFFF
20 |
21 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-v23/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/internal/Cache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.internal;
18 |
19 | public interface Cache {
20 |
21 | void append(int key, int value);
22 |
23 | int get(int key, int valueIfKeyNotFound);
24 |
25 | void clear();
26 | }
27 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/Comment.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.data.model;
2 |
3 | import java.util.List;
4 |
5 | public class Comment {
6 |
7 | private final String author;
8 | private final String comment;
9 | private final String postedTime;
10 | private final List childComments;
11 |
12 | public Comment(String author, String comment, String postedTime, List childComments) {
13 | this.author = author;
14 | this.comment = comment;
15 | this.postedTime = postedTime;
16 | this.childComments = childComments;
17 | }
18 |
19 | public String getAuthor() {
20 | return author;
21 | }
22 |
23 | public List getChildComments() {
24 | return childComments;
25 | }
26 |
27 | public String getComment() {
28 | return comment;
29 | }
30 |
31 | public String getPostedTime() {
32 | return postedTime;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/DecorationCapture.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | public interface DecorationCapture {
20 |
21 | void captureOffsets(int left, int top, int right, int bottom);
22 |
23 | void captureDrawing(int adapterPosition);
24 | }
25 |
--------------------------------------------------------------------------------
/sample/src/main/res/color/text_color_body_primary1.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-v27/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
24 |
--------------------------------------------------------------------------------
/sample/src/main/res/color/text_color_body_primary2.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/color/text_color_body_primary3.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/color/text_color_title1.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/color/text_color_title2.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/color/text_color_title3.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/Header.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | public class Header {
20 |
21 | private final String test;
22 |
23 | public Header(String test) {
24 | this.test = test;
25 | }
26 |
27 | public String getTest() {
28 | return test;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/TextItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class TextItem {
20 |
21 | private final String text;
22 |
23 | public TextItem(String text) {
24 | this.text = text;
25 | }
26 |
27 | public String getText() {
28 | return text;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/Header.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class Header {
20 |
21 | private final String header;
22 |
23 | public Header(String header) {
24 | this.header = header;
25 | }
26 |
27 | public String getHeader() {
28 | return header;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/NumberItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class NumberItem {
20 |
21 | private final int number;
22 |
23 | public NumberItem(int number) {
24 | this.number = number;
25 | }
26 |
27 | public int getNumber() {
28 | return number;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/NewsHeader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class NewsHeader {
20 |
21 | private final String header;
22 |
23 | public NewsHeader(String header) {
24 | this.header = header;
25 | }
26 |
27 | public String getHeader() {
28 | return header;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/ShufflingHeader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class ShufflingHeader {
20 |
21 | private final String header;
22 |
23 | public ShufflingHeader(String header) {
24 | this.header = header;
25 | }
26 |
27 | public String getHeader() {
28 | return header;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_drag.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/widget/TopBar.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.widget;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.util.AttributeSet;
6 | import android.widget.FrameLayout;
7 |
8 | public class TopBar extends FrameLayout {
9 |
10 | public TopBar(Context context) {
11 | super(context);
12 | setInsetsListener();
13 | }
14 |
15 | public TopBar(Context context, @Nullable AttributeSet attrs) {
16 | super(context, attrs);
17 | setInsetsListener();
18 | }
19 |
20 | public TopBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
21 | super(context, attrs, defStyleAttr);
22 | setInsetsListener();
23 | }
24 |
25 | public void setInsetsListener() {
26 | setOnApplyWindowInsetsListener((v, insets) -> {
27 | v.setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
28 | insets.getSystemWindowInsetRight(), 0);
29 | return insets;
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Ahamed/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/multi-view-adapter/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Ahamed/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/extensions/databinding/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Ahamed/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/extensions/decorator/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Ahamed/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/extensions/diffutil-rx/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Ahamed/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/widget/BottomBar.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.widget;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.util.AttributeSet;
6 | import android.widget.FrameLayout;
7 |
8 | public class BottomBar extends FrameLayout {
9 |
10 | public BottomBar(Context context) {
11 | super(context);
12 | setInsetsListener();
13 | }
14 |
15 | public BottomBar(Context context, @Nullable AttributeSet attrs) {
16 | super(context, attrs);
17 | setInsetsListener();
18 | }
19 |
20 | public BottomBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
21 | super(context, attrs, defStyleAttr);
22 | setInsetsListener();
23 | }
24 |
25 | public void setInsetsListener() {
26 | setOnApplyWindowInsetsListener((v, insets) -> {
27 | v.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(),
28 | insets.getSystemWindowInsetBottom());
29 | return insets;
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_circle.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_drag_handle.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_circle_variant.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_swipe_to_dismiss.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_expand_less.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_expand_more.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_star.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/TestItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | public class TestItem {
20 |
21 | private final int id;
22 | private final String text;
23 |
24 | public TestItem(int id, String text) {
25 | this.id = id;
26 | this.text = text;
27 | }
28 |
29 | public int getId() {
30 | return id;
31 | }
32 |
33 | public String getText() {
34 | return text;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_diff_util.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/AdapterDataObserver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | public interface AdapterDataObserver {
20 |
21 | void notifyItemMoved(int fromPosition, int toPosition);
22 |
23 | void notifyItemRangeChanged(int positionStart, int itemCount, Object payload);
24 |
25 | void notifyItemRangeInserted(int positionStart, int itemCount);
26 |
27 | void notifyItemRangeRemoved(int positionStart, int itemCount);
28 | }
29 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/ColoredItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class ColoredItem {
20 |
21 | private final int number;
22 | private final int color;
23 |
24 | public ColoredItem(int number, int color) {
25 | this.number = number;
26 | this.color = color;
27 | }
28 |
29 | public int getColor() {
30 | return color;
31 | }
32 |
33 | public int getNumber() {
34 | return number;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_expandable_mode.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/decoration/HeaderBinder.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.decoration;
2 |
3 | import android.view.View;
4 | import android.view.ViewGroup;
5 | import android.widget.TextView;
6 | import dev.ahamed.mva.sample.R;
7 | import dev.ahamed.mva.sample.data.model.Header;
8 | import mva2.adapter.ItemBinder;
9 | import mva2.adapter.ItemViewHolder;
10 |
11 | public class HeaderBinder extends ItemBinder {
12 |
13 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
14 | return new ViewHolder(inflate(parent, R.layout.item_header_decorated));
15 | }
16 |
17 | @Override public void bindViewHolder(ViewHolder holder, Header item) {
18 | holder.header.setText(item.getHeader());
19 | }
20 |
21 | @Override public boolean canBindData(Object item) {
22 | return item instanceof Header;
23 | }
24 |
25 | static class ViewHolder extends ItemViewHolder {
26 |
27 | private TextView header;
28 |
29 | ViewHolder(View itemView) {
30 | super(itemView);
31 | header = itemView.findViewById(R.id.tv_header);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_tv.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
22 |
23 |
29 |
30 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_check_box.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/internal/RecyclerItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.internal;
18 |
19 | public class RecyclerItem {
20 |
21 | private final M item;
22 | private ItemMetaData itemMetaData;
23 |
24 | public RecyclerItem(M item, ItemMetaData itemMetaData) {
25 | this.item = item;
26 | this.itemMetaData = itemMetaData;
27 | }
28 |
29 | public M getItem() {
30 | return item;
31 | }
32 |
33 | public ItemMetaData getItemMetaData() {
34 | return itemMetaData;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/MoviePosterItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class MoviePosterItem {
20 |
21 | private final String name;
22 | private final int posterColor;
23 |
24 | public MoviePosterItem(String name, int posterColor) {
25 | this.name = name;
26 | this.posterColor = posterColor;
27 | }
28 |
29 | public String getName() {
30 | return name;
31 | }
32 |
33 | public int getPosterColor() {
34 | return posterColor;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/advanced/NumberItemBinder.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.advanced;
2 |
3 | import android.view.View;
4 | import android.view.ViewGroup;
5 | import android.widget.TextView;
6 | import dev.ahamed.mva.sample.R;
7 | import dev.ahamed.mva.sample.data.model.NumberItem;
8 | import mva2.adapter.ItemBinder;
9 | import mva2.adapter.ItemViewHolder;
10 |
11 | public class NumberItemBinder extends ItemBinder {
12 |
13 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
14 | return new ViewHolder(inflate(parent, R.layout.item_number));
15 | }
16 |
17 | @Override public void bindViewHolder(ViewHolder holder, NumberItem item) {
18 | holder.textView.setText(String.valueOf(item.getNumber()));
19 | }
20 |
21 | @Override public boolean canBindData(Object item) {
22 | return item instanceof NumberItem;
23 | }
24 |
25 | static final class ViewHolder extends ItemViewHolder {
26 |
27 | TextView textView;
28 |
29 | ViewHolder(View itemView) {
30 | super(itemView);
31 | textView = itemView.findViewById(R.id.text_view);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_heart.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_header_decorated.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_web.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/FaqItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class FaqItem {
20 |
21 | private final String question;
22 |
23 | public FaqItem(String question) {
24 | this.question = question;
25 | }
26 |
27 | public String getAnswer() {
28 | return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor "
29 | + "incididunt ut labore et dolore magna aliqua.";
30 | }
31 |
32 | public String getQuestion() {
33 | return question;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_shuffle.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/internal/Notifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.internal;
18 |
19 | import mva2.adapter.Section;
20 |
21 | public interface Notifier {
22 |
23 | void notifySectionItemMoved(Section section, int fromPosition, int toPosition);
24 |
25 | void notifySectionRangeChanged(Section section, int positionStart, int itemCount, Object payload);
26 |
27 | void notifySectionRangeInserted(Section section, int positionStart, int itemCount);
28 |
29 | void notifySectionRangeRemoved(Section section, int positionStart, int itemCount);
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_span_count.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_newspaper.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_decoration.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/internal/ItemMetaData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.internal;
18 |
19 | public class ItemMetaData {
20 |
21 | private boolean isExpanded = false;
22 | private boolean isSelected = false;
23 |
24 | public boolean isExpanded() {
25 | return isExpanded;
26 | }
27 |
28 | public boolean isSelected() {
29 | return isSelected;
30 | }
31 |
32 | public void setExpanded(boolean expanded) {
33 | isExpanded = expanded;
34 | }
35 |
36 | public void setSelected(boolean selected) {
37 | isSelected = selected;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/util/SwipeToDismissListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.util;
18 |
19 | /**
20 | * Listener to listen when an item is dismissed by swipe gesture.
21 | *
22 | * @param Refers to the model class
23 | */
24 | public interface SwipeToDismissListener {
25 |
26 | /**
27 | * This method will be called when an item is dismissed using swipe gesture
28 | *
29 | * @param position Adapter position of the item being removed
30 | * @param item Object being removed
31 | */
32 | void onItemDismissed(int position, M item);
33 | }
34 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_offline_empty.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/internal/SparseIntArrayCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.internal;
18 |
19 | import android.util.SparseIntArray;
20 |
21 | public class SparseIntArrayCache implements Cache {
22 |
23 | private final SparseIntArray cache = new SparseIntArray();
24 |
25 | @Override public void append(int key, int value) {
26 | cache.append(key, value);
27 | }
28 |
29 | @Override public int get(int key, int valueIfKeyNotFound) {
30 | return cache.get(key, valueIfKeyNotFound);
31 | }
32 |
33 | @Override public void clear() {
34 | cache.clear();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/Comment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | public class Comment {
20 |
21 | private int id;
22 | private String author;
23 | private String comment;
24 |
25 | public Comment(int id, String author, String comment) {
26 | this.id = id;
27 | this.author = author;
28 | this.comment = comment;
29 | }
30 |
31 | public String getAuthor() {
32 | return author;
33 | }
34 |
35 | public String getComment() {
36 | return comment;
37 | }
38 |
39 | public int getId() {
40 | return id;
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/home/Feature.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.home;
18 |
19 | class Feature {
20 |
21 | private final String title;
22 | private final int icon;
23 | private final String description;
24 |
25 | Feature(String title, int icon, String description) {
26 | this.title = title;
27 | this.icon = icon;
28 | this.description = description;
29 | }
30 |
31 | String getDescription() {
32 | return description;
33 | }
34 |
35 | int getIcon() {
36 | return icon;
37 | }
38 |
39 | String getTitle() {
40 | return title;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_thumb_up.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contribution Guidelines
2 |
3 | When contributing to this repository, please discuss the change you wish to make via issue to the maintainers of this repository before making a change.
4 |
5 | Please note we have a code of conduct, follow it in all your interactions with the project.
6 |
7 | ## Reporting Bugs
8 |
9 | 1. Please provide a clear subject and description of the bug. Provide necessary information about the version of the library and recyclerview version.
10 | 2. If possible, create a failing test case and make a pull request.
11 | 3. Be nice to the contributors.
12 |
13 | ## Submitting changes
14 |
15 | 1. Make a clone of the repo, create a new branch for your changes.
16 | 2. Make sure the code is well formatted according to code style added in the repo.
17 | 3. After making changes, make sure you rebase with the base branch.
18 | 4. If possible squash your commits to single commit. Give a meaningful commit message.
19 | 5. If the public api methods are being changed, change the necessary documentation. Make sure changes are backward compatible.
20 | 6. If you want to deprecate a method, please have a discussion with maintainers.
21 | 7. Once the changes are done, make a pull request.
22 | 8. Engage with maintainers if further changes are requested.
23 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/decorator/SectionPositionType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.decorator;
18 |
19 | /**
20 | * SectionPositionType refers to position of section inside the adapter
21 | *
22 | *
23 | *
24 | *
25 | * SectionPositionType is an enum value, which has only possible three values.
26 | * 1. FIRST - Denotes that Section is first inside adapter
27 | * 2. MIDDLE - Denotes that Section is neither first nor last inside adapter
28 | * 3. LAST - Denotes that Section is last inside adapter
29 | */
30 | public enum SectionPositionType {
31 | FIRST, MIDDLE, LAST
32 | }
33 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_news_group.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Pull Request template
2 |
3 | Please, go through these steps before you submit a PR.
4 |
5 | 1. Make sure that your PR is not a duplicate.
6 | 2. If not, then make sure that:
7 |
8 | 2.1. You have done your changes in a separate branch. Branches MUST have descriptive names that start with either the `fix/` or `feature/` prefixes. Good examples are: `fix/span-issue` or `feature/multiple-viewtype`.
9 |
10 | 2.2. You have a descriptive commit message with a short title (first line).
11 |
12 | 2.3. You have only one commit (if not, squash them into one commit).
13 |
14 | 2.4. `./gradlew test` does not throw any error.
15 |
16 | 2.5. Code is formatted with code style included in the document.
17 |
18 | 2.6. Make sure that necessary changes in documentation is also done.
19 |
20 | 3. **After** these steps, you're ready to open a pull request.
21 |
22 | 3.1. Give a descriptive title to your PR.
23 |
24 | 3.2. Provide a description of your changes.
25 |
26 | 3.3. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such).
27 |
28 | IMPORTANT: Please review the [CONTRIBUTING.md](../.github/CONTRIBUTING.md) file for detailed contributing guidelines.
29 |
30 | **PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/data/model/SelectableItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.data.model;
18 |
19 | public class SelectableItem {
20 |
21 | private final int iconResource;
22 | private final int color;
23 | private final String text;
24 |
25 | public SelectableItem(int iconResource, int color, String text) {
26 | this.iconResource = iconResource;
27 | this.color = color;
28 | this.text = text;
29 | }
30 |
31 | public int getColor() {
32 | return color;
33 | }
34 |
35 | public int getIconResource() {
36 | return iconResource;
37 | }
38 |
39 | public String getText() {
40 | return text;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_extension.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_fake_news.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_umbrella.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/extensions/databinding/src/main/java/mva2/extension/BindingViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.extension;
18 |
19 | import android.databinding.ViewDataBinding;
20 | import mva2.adapter.ItemViewHolder;
21 |
22 | /**
23 | * ViewHolder which supports the DataBinding
24 | *
25 | * @param Refers to the model class
26 | * @param Refers to the DataBinding class of the model
27 | */
28 | abstract class BindingViewHolder extends ItemViewHolder {
29 |
30 | private final VDB binding;
31 |
32 | BindingViewHolder(VDB binding) {
33 | super(binding.getRoot());
34 | this.binding = binding;
35 | }
36 |
37 | public VDB getBinding() {
38 | return binding;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/extensions/decorator/src/main/java/mva2/extension/decorator/InsetDecoration.java:
--------------------------------------------------------------------------------
1 | package mva2.extension.decorator;
2 |
3 | import android.graphics.Rect;
4 | import android.view.View;
5 | import android.support.annotation.NonNull;
6 | import android.support.v7.widget.RecyclerView;
7 | import mva2.adapter.MultiViewAdapter;
8 | import mva2.adapter.decorator.Decorator;
9 |
10 | public class InsetDecoration extends Decorator {
11 |
12 | private final int insetSpace;
13 |
14 | public InsetDecoration(MultiViewAdapter adapter, int insetSpace) {
15 | super(adapter);
16 | this.insetSpace = insetSpace;
17 | }
18 |
19 | @Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
20 | @NonNull RecyclerView parent, @NonNull RecyclerView.State state, int adapterPosition) {
21 | int itemPositionType = getPositionType(adapterPosition, parent);
22 | addToRect(outRect, insetSpace, insetSpace, insetSpace, insetSpace);
23 |
24 | if (isItemOnLeftEdge(itemPositionType)) {
25 | outRect.left += insetSpace;
26 | }
27 | if (isItemOnRightEdge(itemPositionType)) {
28 | outRect.right += insetSpace;
29 | }
30 | if (isItemOnTopEdge(itemPositionType)) {
31 | outRect.top += insetSpace;
32 | }
33 | if (isItemOnBottomEdge(itemPositionType)) {
34 | outRect.bottom += insetSpace;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | 0dp
19 | 2dp
20 | 4dp
21 | 8dp
22 | 12dp
23 | 16dp
24 | 24dp
25 | 30dp
26 |
27 | 12sp
28 | 14sp
29 | 15sp
30 | 16sp
31 | 20sp
32 | 24sp
33 |
34 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_emoticon.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/widget/InsetFrameLayout.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.widget;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.util.AttributeSet;
6 | import android.util.TypedValue;
7 | import android.widget.FrameLayout;
8 | import dev.ahamed.mva.sample.R;
9 |
10 | public class InsetFrameLayout extends FrameLayout {
11 |
12 | public InsetFrameLayout(Context context) {
13 | super(context);
14 | setInsetsListener(context);
15 | }
16 |
17 | public InsetFrameLayout(Context context, @Nullable AttributeSet attrs) {
18 | super(context, attrs);
19 | setInsetsListener(context);
20 | }
21 |
22 | public InsetFrameLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
23 | super(context, attrs, defStyleAttr);
24 | setInsetsListener(context);
25 | }
26 |
27 | public void setInsetsListener(Context context) {
28 | TypedValue typedValue = new TypedValue();
29 | context.getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true);
30 | int actionBarSize = (int) getResources().getDimension(typedValue.resourceId);
31 | setOnApplyWindowInsetsListener((v, insets) -> {
32 | v.setPadding(insets.getSystemWindowInsetLeft(), 0,
33 | insets.getSystemWindowInsetRight(), 0);
34 | return insets;
35 | });
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
33 |
34 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/HashMapCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | import android.annotation.SuppressLint;
20 | import java.util.HashMap;
21 | import mva2.adapter.internal.Cache;
22 |
23 | public class HashMapCache implements Cache {
24 |
25 | @SuppressLint("UseSparseArrays") private final HashMap cache = new HashMap<>();
26 |
27 | @Override public void append(int key, int value) {
28 | cache.put(key, value);
29 | }
30 |
31 | @Override public int get(int key, int valueIfKeyNotFound) {
32 | Integer value = cache.get(key);
33 | return value == null ? valueIfKeyNotFound : value;
34 | }
35 |
36 | @Override public void clear() {
37 | cache.clear();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/decoration/PersonBinder.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.decoration;
2 |
3 | import android.view.View;
4 | import android.view.ViewGroup;
5 | import android.widget.TextView;
6 | import dev.ahamed.mva.sample.R;
7 | import dev.ahamed.mva.sample.data.model.Person;
8 | import mva2.adapter.ItemBinder;
9 | import mva2.adapter.ItemViewHolder;
10 |
11 | public class PersonBinder extends ItemBinder {
12 |
13 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
14 | return new ViewHolder(inflate(parent, R.layout.item_person));
15 | }
16 |
17 | @Override public void bindViewHolder(ViewHolder holder, Person item) {
18 | holder.name.setText(item.getName());
19 | holder.overline.setText(item.getOverline());
20 | holder.avatar.setText(item.getInitials());
21 | }
22 |
23 | @Override public boolean canBindData(Object item) {
24 | return item instanceof Person;
25 | }
26 |
27 | static class ViewHolder extends ItemViewHolder {
28 |
29 | private TextView name;
30 | private TextView overline;
31 | private TextView avatar;
32 |
33 | ViewHolder(View itemView) {
34 | super(itemView);
35 | name = itemView.findViewById(R.id.tv_name);
36 | overline = itemView.findViewById(R.id.tv_overline);
37 | avatar = itemView.findViewById(R.id.tv_avatar);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/home/IntroItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.home;
18 |
19 | import android.view.ViewGroup;
20 | import dev.ahamed.mva.sample.R;
21 | import mva2.adapter.ItemBinder;
22 | import mva2.adapter.ItemViewHolder;
23 |
24 | public class IntroItemBinder extends ItemBinder> {
25 |
26 | @Override public ItemViewHolder createViewHolder(ViewGroup parent) {
27 | return new ItemViewHolder<>(inflate(parent, R.layout.item_introduction));
28 | }
29 |
30 | @Override public void bindViewHolder(ItemViewHolder holder, String item) {
31 | // No-op
32 | }
33 |
34 | @Override public boolean canBindData(Object item) {
35 | return item instanceof String;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/widget/WindowInsetsFrameLayout.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.view.WindowInsets;
7 | import android.widget.FrameLayout;
8 |
9 | public class WindowInsetsFrameLayout extends FrameLayout {
10 |
11 | public WindowInsetsFrameLayout(Context context) {
12 | this(context, null);
13 | }
14 |
15 | public WindowInsetsFrameLayout(Context context, AttributeSet attrs) {
16 | this(context, attrs, 0);
17 | }
18 |
19 | public WindowInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
20 | super(context, attrs, defStyleAttr);
21 |
22 | // Look for replaced fragments and apply the insets again.
23 | setOnHierarchyChangeListener(new OnHierarchyChangeListener() {
24 | @Override public void onChildViewAdded(View parent, View child) {
25 | requestApplyInsets();
26 | }
27 |
28 | @Override public void onChildViewRemoved(View parent, View child) {
29 |
30 | }
31 | });
32 | }
33 |
34 | @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) {
35 | int childCount = getChildCount();
36 | for (int index = 0; index < childCount; index++) {
37 | getChildAt(index).dispatchApplyWindowInsets(insets);
38 | }
39 | return insets;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_data_binding.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/menu/menu_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_basic.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/newsfeed/EmptyStateItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.newsfeed;
18 |
19 | import android.view.ViewGroup;
20 | import dev.ahamed.mva.sample.R;
21 | import mva2.adapter.ItemBinder;
22 | import mva2.adapter.ItemViewHolder;
23 |
24 | public class EmptyStateItemBinder extends ItemBinder> {
25 |
26 | @Override public ItemViewHolder createViewHolder(ViewGroup parent) {
27 | return new ItemViewHolder<>(inflate(parent, R.layout.item_news_empty));
28 | }
29 |
30 | @Override public void bindViewHolder(ItemViewHolder holder, String item) {
31 | // Nothing to bindViewHolder
32 | }
33 |
34 | @Override public boolean canBindData(Object item) {
35 | return item instanceof String;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/common/HintBinder.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.common;
2 |
3 | import android.support.v7.widget.helper.ItemTouchHelper;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.TextView;
7 | import dev.ahamed.mva.sample.R;
8 | import dev.ahamed.mva.sample.data.model.Hint;
9 | import mva2.adapter.ItemBinder;
10 | import mva2.adapter.ItemViewHolder;
11 |
12 | public class HintBinder extends ItemBinder {
13 |
14 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
15 | return new ViewHolder(inflate(parent, R.layout.item_hint));
16 | }
17 |
18 | @Override public void bindViewHolder(ViewHolder holder, Hint item) {
19 | holder.tvDescription.setText(item.getDescription());
20 | }
21 |
22 | @Override public boolean canBindData(Object item) {
23 | return item instanceof Hint;
24 | }
25 |
26 | @Override public int getSpanSize(int maxSpanCount) {
27 | return maxSpanCount;
28 | }
29 |
30 | public static class ViewHolder extends ItemViewHolder {
31 |
32 | private final TextView tvDescription;
33 |
34 | public ViewHolder(View itemView) {
35 | super(itemView);
36 | tvDescription = itemView.findViewById(R.id.tv_hint_description);
37 | }
38 |
39 | @Override public int getSwipeDirections() {
40 | return ItemTouchHelper.START | ItemTouchHelper.END;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/util/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.util;
18 |
19 | import mva2.adapter.ItemSection;
20 | import mva2.adapter.ItemViewHolder;
21 | import mva2.adapter.ListSection;
22 |
23 | /**
24 | * This interface lets you listen to the click event of the items inside the ListSection or
25 | * ItemSection. You can attach this listener to the section and listen for click events. To pass
26 | * down the click events to this interface call {@link ItemViewHolder#onItemClick()} method.
27 | *
28 | * @param Model used in the {@link ListSection} or {@link ItemSection} where this listener is
29 | * attached.
30 | *
31 | * @see ItemViewHolder#onItemClick()
32 | */
33 | public interface OnItemClickListener {
34 |
35 | void onItemClicked(int position, M item);
36 | }
37 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/newsfeed/NewsFeedDecorator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.newsfeed;
18 |
19 | import android.graphics.Rect;
20 | import android.support.annotation.NonNull;
21 | import android.support.v7.widget.RecyclerView;
22 | import android.view.View;
23 | import mva2.adapter.MultiViewAdapter;
24 | import mva2.adapter.decorator.Decorator;
25 |
26 | public class NewsFeedDecorator extends Decorator {
27 |
28 | NewsFeedDecorator(MultiViewAdapter adapter) {
29 | super(adapter);
30 | }
31 |
32 | @Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
33 | @NonNull RecyclerView parent, @NonNull RecyclerView.State state, int adapterPosition) {
34 | if (!isLast(getPositionType(adapterPosition, parent))) addToRect(outRect, 0, 0, 0, 1);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_topic.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | #### Be nice and Be humble.
2 |
3 | #### Code of Conduct
4 |
5 | 1. **Be welcoming.** We welcome and support people of all backgrounds and identities.
6 | 2. **Respect all project contributors and maintainers** We all put our spare time into this project. The time we could have spent with our kids and family. So respect each other.
7 | 3. **Be nice towards non-native english speakers.** Understand people don't speak the same language as you. If you don't understand or the message is not clear, ask for clarification nicely.
8 | 4. **Don't abuse.** We don't accept discriminating, foul or slur words/graphic in any of our communication. Project maintainers reserve the right to remove any such contents.
9 | 5. **Be respectful.** Even if you disagree with someone, you can still be respectful.
10 | 6. **Be nice and Be humble.** It makes us human.
11 |
12 |
13 | #### For Maintainers and Contributors
14 |
15 | 1. **Treat all users same and respectful.** Just because we spend our spare time for this project, it does not give us any right to abuse or mistreat fellow users.
16 | 2. **Be clear when disagreeing.** We might come across users/contributors whose ideas we might disagree since it does not fit our project's roadmap. Be clear and respect when communicating the same.
17 | 3. **Don't reject ideas outright.** If you are unsure about an idea, ask for help. Engage in a conversation. Give it some time. Don't reject ideas outright.
18 | 4. **Be nice and Be humble.** It makes us human.
19 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/util/Mode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.util;
18 |
19 | import mva2.adapter.MultiViewAdapter;
20 |
21 | /**
22 | * Enum represents different types of mode which can be set as selection or expansion modes.
23 | *
24 | * @see MultiViewAdapter#setSelectionMode(Mode)
25 | * @see MultiViewAdapter#setExpansionMode(Mode) (Mode)
26 | */
27 | public enum Mode {
28 |
29 | /**
30 | * Removes the selection or expansion feature
31 | */
32 | NONE,
33 |
34 | /**
35 | * Applies to a single item ie., only one item can be selected or expanded at a time
36 | */
37 | SINGLE,
38 |
39 | /**
40 | * Applies to a multiple items ie., multiple items can be selected or expanded at a time
41 | */
42 | MULTIPLE,
43 |
44 | /**
45 | * Inherits the mode from its parent
46 | */
47 | INHERIT
48 | }
49 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/newsfeed/NewsHeaderDecorator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.newsfeed;
18 |
19 | import android.graphics.Rect;
20 | import android.support.annotation.NonNull;
21 | import android.support.v7.widget.RecyclerView;
22 | import android.view.View;
23 | import dev.ahamed.mva.sample.view.SampleActivity;
24 | import mva2.adapter.MultiViewAdapter;
25 | import mva2.adapter.decorator.Decorator;
26 |
27 | public class NewsHeaderDecorator extends Decorator {
28 |
29 | NewsHeaderDecorator(MultiViewAdapter adapter) {
30 | super(adapter);
31 | }
32 |
33 | @Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
34 | @NonNull RecyclerView parent, @NonNull RecyclerView.State state, int adapterPosition) {
35 | addToRect(outRect, 0, SampleActivity.EIGHT_DP * 2, 0, 0);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_news_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
27 |
28 |
36 |
37 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
21 |
22 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_infinite_loading.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/newsfeed/NewsSectionDecorator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.newsfeed;
18 |
19 | import android.graphics.Rect;
20 | import android.support.annotation.NonNull;
21 | import android.support.v7.widget.RecyclerView;
22 | import android.view.View;
23 | import dev.ahamed.mva.sample.view.SampleActivity;
24 | import mva2.adapter.MultiViewAdapter;
25 | import mva2.adapter.decorator.Decorator;
26 |
27 | public class NewsSectionDecorator extends Decorator {
28 |
29 | public NewsSectionDecorator(MultiViewAdapter adapter) {
30 | super(adapter);
31 | }
32 |
33 | @Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
34 | @NonNull RecyclerView parent, @NonNull RecyclerView.State state, int adapterPosition) {
35 | addToRect(outRect, SampleActivity.EIGHT_DP, SampleActivity.EIGHT_DP, SampleActivity.EIGHT_DP,
36 | SampleActivity.EIGHT_DP);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | #333333
20 | #000000
21 | #FFC107
22 |
23 | #EFEFEF
24 | #DFDFDF
25 | #606060
26 |
27 | #d94f4f
28 | #8367be
29 | #01b981
30 |
31 | #BB000000
32 | #1A202c
33 | #1e2533
34 | #222a3a
35 | #262f40
36 | #2a3446
37 | #2e394d
38 |
39 |
40 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_number.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
27 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/HeaderBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 | import mva2.adapter.ItemBinder;
22 | import mva2.adapter.ItemViewHolder;
23 |
24 | public class HeaderBinder extends ItemBinder {
25 |
26 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
27 | return new ViewHolder(parent);
28 | }
29 |
30 | @Override public void bindViewHolder(ViewHolder holder, Header item) {
31 | // No-op
32 | }
33 |
34 | @Override public boolean canBindData(Object item) {
35 | return item instanceof Header;
36 | }
37 |
38 | @Override public int getSpanSize(int maxSpanCount) {
39 | return maxSpanCount;
40 | }
41 |
42 | public static class ViewHolder extends ItemViewHolder {
43 |
44 | public ViewHolder(View itemView) {
45 | super(itemView);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/TestItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 | import mva2.adapter.ItemBinder;
22 | import mva2.adapter.ItemViewHolder;
23 |
24 | public class TestItemBinder extends ItemBinder {
25 |
26 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
27 | return new ViewHolder(parent);
28 | }
29 |
30 | @Override public void bindViewHolder(ViewHolder holder, TestItem item) {
31 | // No-op
32 | }
33 |
34 | @Override public boolean canBindData(Object item) {
35 | return item instanceof TestItem;
36 | }
37 |
38 | @Override public int getSpanSize(int maxSpanCount) {
39 | return 1;
40 | }
41 |
42 | public static class ViewHolder extends ItemViewHolder {
43 |
44 | public ViewHolder(View itemView) {
45 | super(itemView);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/CommentBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 | import mva2.adapter.ItemBinder;
22 | import mva2.adapter.ItemViewHolder;
23 |
24 | public class CommentBinder extends ItemBinder {
25 |
26 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
27 | return new ViewHolder(parent);
28 | }
29 |
30 | @Override public void bindViewHolder(ViewHolder holder, Comment item) {
31 | // No-op
32 | }
33 |
34 | @Override public boolean canBindData(Object item) {
35 | return item instanceof Comment;
36 | }
37 |
38 | @Override public int getSpanSize(int maxSpanCount) {
39 | return maxSpanCount;
40 | }
41 |
42 | public static class ViewHolder extends ItemViewHolder {
43 |
44 | public ViewHolder(View itemView) {
45 | super(itemView);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/basic/CustomLayoutManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.basic;
18 |
19 | import android.content.Context;
20 | import android.support.v7.widget.GridLayoutManager;
21 | import android.support.v7.widget.LinearLayoutManager;
22 | import android.support.v7.widget.RecyclerView;
23 | import android.view.ViewGroup;
24 |
25 | public class CustomLayoutManager extends LinearLayoutManager {
26 |
27 | CustomLayoutManager(Context context) {
28 | super(context);
29 | }
30 |
31 | @Override public RecyclerView.LayoutParams generateDefaultLayoutParams() {
32 | if (getOrientation() == HORIZONTAL) {
33 | return new GridLayoutManager.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
34 | ViewGroup.LayoutParams.MATCH_PARENT);
35 | } else {
36 | return new GridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
37 | ViewGroup.LayoutParams.WRAP_CONTENT);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/sample/src/main/res/menu/menu_sample_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/expansion/SectionSpaceDecorator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.expansion;
18 |
19 | import android.graphics.Rect;
20 | import android.support.annotation.NonNull;
21 | import android.support.v7.widget.RecyclerView;
22 | import android.view.View;
23 | import mva2.adapter.MultiViewAdapter;
24 | import mva2.adapter.decorator.Decorator;
25 |
26 | import static dev.ahamed.mva.sample.view.SampleActivity.EIGHT_DP;
27 |
28 | public class SectionSpaceDecorator extends Decorator {
29 |
30 | SectionSpaceDecorator(MultiViewAdapter adapter) {
31 | super(adapter);
32 | }
33 |
34 | @Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
35 | @NonNull RecyclerView parent, @NonNull RecyclerView.State state, int adapterPosition) {
36 | if (isFirst(getPositionType(adapterPosition, parent))) {
37 | addToRect(outRect, 0, EIGHT_DP * 2, 0, 0);
38 | }
39 | addToRect(outRect, 0, 0, 0, 1);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_feature.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
25 |
26 |
31 |
32 |
41 |
42 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_configure.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/util/OnSelectionChangedListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.util;
18 |
19 | import java.util.List;
20 |
21 | /**
22 | * Listener to listen for changes if an item is selected or un-selected. This can be used if the
23 | * adapter has the selection mode as {@link Mode#SINGLE}
24 | *
25 | * @param Refers to the model class
26 | *
27 | * @see Mode for possible values
28 | */
29 | public interface OnSelectionChangedListener {
30 |
31 | /**
32 | * Called when the selection is changed. Even if you are using {@link Mode#SINGLE}, selected items
33 | * will be provided as a list. If no item is selected, it will provide an empty list.
34 | *
35 | * @param item Item which is currently selected / unselected
36 | * @param isSelected Denotes whether the item was selected or unselected
37 | * @param selectedItems List of selected items. It will be empty if no items are selected
38 | */
39 | void onSelectionChanged(M item, boolean isSelected, List selectedItems);
40 | }
41 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/newsfeed/OfflineNewsFeedItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.newsfeed;
18 |
19 | import android.support.v7.widget.helper.ItemTouchHelper;
20 | import android.view.View;
21 | import android.view.ViewGroup;
22 | import dev.ahamed.mva.sample.R;
23 | import dev.ahamed.mva.sample.data.model.NewsItem;
24 |
25 | public class OfflineNewsFeedItemBinder extends NewsFeedItemBinder {
26 |
27 | @Override public NewsFeedItemBinder.ViewHolder createViewHolder(ViewGroup parent) {
28 | return new ViewHolder(inflate(parent, R.layout.item_news));
29 | }
30 |
31 | @Override public boolean canBindData(Object item) {
32 | return item instanceof NewsItem && ((NewsItem) item).isOffline();
33 | }
34 |
35 | static class ViewHolder extends NewsFeedItemBinder.ViewHolder {
36 |
37 | public ViewHolder(View itemView) {
38 | super(itemView);
39 | }
40 |
41 | @Override public int getSwipeDirections() {
42 | return ItemTouchHelper.START | ItemTouchHelper.END;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/widget_feature_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
21 |
22 |
31 |
32 |
43 |
44 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_nested_section.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
25 |
26 |
34 |
35 |
42 |
43 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_basic.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
25 |
26 |
34 |
35 |
43 |
44 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_news_feed.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
25 |
26 |
34 |
35 |
43 |
44 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_expansion.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
25 |
26 |
34 |
35 |
43 |
44 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_decoration.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
25 |
26 |
34 |
35 |
43 |
44 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | #FFFFFF
20 | #EFEFEF
21 | #FFC107
22 | #FFB305
23 |
24 | #202020
25 | #333333
26 | #AA606060
27 | #333333
28 |
29 | #EF9A9A
30 | #B39DDB
31 | #80e6ce
32 | #B39DDB
33 | #FFCC80
34 |
35 | #CCDFDFDF
36 | #ffffff
37 | #f8f9fa
38 | #f1f3f5
39 | #e9ecef
40 | #dee2e6
41 | #ced4da
42 |
43 |
44 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/main/java/mva2/adapter/util/MvaDiffUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.util;
18 |
19 | import android.support.v7.util.ListUpdateCallback;
20 | import java.util.List;
21 | import mva2.adapter.ListSection;
22 |
23 | /**
24 | * MvaDiffUtil lets the client to calculate the diff between old & new list and apply the changes.
25 | * By default the diff happens on the main thread. With the help of MvaDiffUtil the client can
26 | * totally take over how the diff is calculated.
27 | *
28 | * @param Model class for which the diff is calculated
29 | *
30 | * @see ListSection#setDiffUtil(MvaDiffUtil)
31 | * @see ListSection#setDiffUtil(MvaDiffUtil)
32 | */
33 | public interface MvaDiffUtil {
34 |
35 | /**
36 | * Lets you calculate the diff between oldList and newList, after that apply the changes to
37 | * listUpdateCallback
38 | *
39 | * @param listUpdateCallback Callback where the updates has to be posted
40 | * @param oldList List of old items
41 | * @param newList List of new items
42 | */
43 | void calculateDiff(ListUpdateCallback listUpdateCallback, List oldList, List newList);
44 | }
45 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/testconfig/RectUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter.testconfig;
18 |
19 | import android.graphics.Rect;
20 | import java.util.Objects;
21 |
22 | public class RectUtil {
23 |
24 | private final int left;
25 | private final int top;
26 | private final int right;
27 | private final int bottom;
28 |
29 | public RectUtil(Rect outRect) {
30 | this.left = outRect.left;
31 | this.top = outRect.top;
32 | this.right = outRect.right;
33 | this.bottom = outRect.bottom;
34 | }
35 |
36 | public RectUtil(int left, int top, int right, int bottom) {
37 | this.left = left;
38 | this.top = top;
39 | this.right = right;
40 | this.bottom = bottom;
41 | }
42 |
43 | @Override public boolean equals(Object o) {
44 | if (this == o) return true;
45 | if (!(o instanceof RectUtil)) return false;
46 | RectUtil rectUtil = (RectUtil) o;
47 | return left == rectUtil.left
48 | && top == rectUtil.top
49 | && right == rectUtil.right
50 | && bottom == rectUtil.bottom;
51 | }
52 |
53 | @Override public int hashCode() {
54 | return Objects.hash(left, top, right, bottom);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/nested/DividerDecorator.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.nested;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 | import android.support.annotation.NonNull;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.View;
11 | import dev.ahamed.mva.sample.R;
12 | import mva2.adapter.MultiViewAdapter;
13 | import mva2.adapter.decorator.Decorator;
14 |
15 | public class DividerDecorator extends Decorator {
16 |
17 | private Paint dividerPaint = new Paint();
18 | private Rect bounds = new Rect();
19 |
20 | DividerDecorator(MultiViewAdapter adapter, Context context) {
21 | super(adapter);
22 | dividerPaint.setColor(ContextCompat.getColor(context, R.color.grey_300));
23 | }
24 |
25 | @Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
26 | @NonNull RecyclerView parent, @NonNull RecyclerView.State state, int adapterPosition) {
27 | // No-op
28 | }
29 |
30 | @Override public void onDrawOver(@NonNull Canvas canvas, @NonNull RecyclerView parent,
31 | @NonNull RecyclerView.State state, View child, int adapterPosition) {
32 | //if(isLast(getPositionType(adapterPosition, parent))) {
33 | // return;
34 | //}
35 | RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
36 | if (null == layoutManager) {
37 | return;
38 | }
39 | canvas.save();
40 | int decoratedWidth = layoutManager.getLeftDecorationWidth(child);
41 |
42 | parent.getDecoratedBoundsWithMargins(child, bounds);
43 | canvas.drawRect(decoratedWidth, bounds.bottom - 2, bounds.right, bounds.bottom, dividerPaint);
44 | canvas.restore();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_selection.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
25 |
26 |
35 |
36 |
44 |
45 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/nested/ThreadDecorator.java:
--------------------------------------------------------------------------------
1 | package dev.ahamed.mva.sample.view.nested;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 | import android.support.annotation.NonNull;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.View;
11 | import dev.ahamed.mva.sample.R;
12 | import dev.ahamed.mva.sample.view.SampleActivity;
13 | import mva2.adapter.MultiViewAdapter;
14 | import mva2.adapter.decorator.Decorator;
15 |
16 | public class ThreadDecorator extends Decorator {
17 |
18 | private Paint paint = new Paint();
19 | private Rect bounds = new Rect();
20 |
21 | ThreadDecorator(MultiViewAdapter adapter, Context context) {
22 | super(adapter);
23 | paint.setColor(ContextCompat.getColor(context, R.color.colorAccent));
24 | }
25 |
26 | @Override public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
27 | @NonNull RecyclerView parent, @NonNull RecyclerView.State state, int adapterPosition) {
28 | addToRect(outRect, SampleActivity.EIGHT_DP, 0, 0, 0);
29 | }
30 |
31 | @Override public void onDraw(@NonNull Canvas canvas, @NonNull RecyclerView parent,
32 | @NonNull RecyclerView.State state, View child, int adapterPosition) {
33 | canvas.save();
34 | int decoratedWidth = parent.getLayoutManager().getLeftDecorationWidth(child);
35 | int level = decoratedWidth / SampleActivity.EIGHT_DP;
36 |
37 | parent.getDecoratedBoundsWithMargins(child, bounds);
38 | for (int i = 0; i < level; i++) {
39 | final int left = (i + 1) * SampleActivity.EIGHT_DP;
40 | canvas.drawRect(left - SampleActivity.TWO_DP, bounds.top, left, bounds.bottom, paint);
41 | }
42 | canvas.restore();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_shuffling_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
24 |
35 |
36 |
46 |
47 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_advanced.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
25 |
26 |
36 |
37 |
45 |
46 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/common/HeaderItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.common;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 | import android.widget.TextView;
22 | import dev.ahamed.mva.sample.R;
23 | import dev.ahamed.mva.sample.data.model.Header;
24 | import mva2.adapter.ItemBinder;
25 | import mva2.adapter.ItemViewHolder;
26 |
27 | public class HeaderItemBinder extends ItemBinder {
28 |
29 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
30 | return new ViewHolder(inflate(parent, R.layout.item_header));
31 | }
32 |
33 | @Override public void bindViewHolder(ViewHolder holder, Header item) {
34 | holder.header.setText(item.getHeader());
35 | }
36 |
37 | @Override public boolean canBindData(Object item) {
38 | return item instanceof Header;
39 | }
40 |
41 | @Override public int getSpanSize(int maxSpanCount) {
42 | return maxSpanCount;
43 | }
44 |
45 | static class ViewHolder extends ItemViewHolder {
46 |
47 | private TextView header;
48 |
49 | ViewHolder(View itemView) {
50 | super(itemView);
51 | header = itemView.findViewById(R.id.tv_header);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_language.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | import gradle.Config
18 |
19 | apply plugin: 'com.android.application'
20 |
21 | android {
22 | compileSdkVersion Config.TARGET_SDK
23 | defaultConfig {
24 | applicationId "dev.ahamed.mva.sample"
25 | minSdkVersion 21
26 | targetSdkVersion Config.TARGET_SDK
27 | versionCode Config.VERSION_CODE
28 | versionName Config.APP_VERSION
29 | }
30 | buildTypes {
31 | debug {
32 | applicationIdSuffix ".debug"
33 | }
34 | release {
35 | minifyEnabled false
36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
37 | }
38 | }
39 | // dataBinding {
40 | // enabled = true
41 | // }
42 | compileOptions {
43 | targetCompatibility 1.8
44 | sourceCompatibility 1.8
45 | }
46 | }
47 |
48 | dependencies {
49 | implementation project(':multi-view-adapter')
50 | implementation project(':mva-decorator')
51 | implementation project(':mva-diffutil-rx')
52 |
53 | implementation Config.APP_COMPAT
54 | implementation Config.RECYCLER_VIEW
55 | implementation Config.CARD_VIEW
56 | implementation Config.DESIGN
57 | implementation Config.RX_JAVA
58 | implementation Config.RX_ANDROID
59 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
60 | implementation 'com.mikepenz:itemanimators:1.0.2'
61 | }
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/SectionExpansionTest.java:
--------------------------------------------------------------------------------
1 | package mva2.adapter;
2 |
3 | import mva2.adapter.util.Mode;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.mockito.junit.MockitoJUnitRunner;
7 |
8 | import static junit.framework.Assert.assertEquals;
9 |
10 | @RunWith(MockitoJUnitRunner.class) public class SectionExpansionTest extends BaseTest {
11 |
12 | @Test public void sectionExpansionModeTest_Single() {
13 | adapter.removeAllSections();
14 | adapter.addSection(itemSection1);
15 | adapter.addSection(listSection1);
16 | adapter.addSection(headerSection1);
17 | adapter.addSection(nestedSection1);
18 |
19 | adapter.setSectionExpansionMode(Mode.SINGLE);
20 |
21 | adapter.collapseAllSections();
22 |
23 | adapter.onSectionExpansionToggled(19);
24 | assertEquals(adapter.getItemCount(), 40);
25 |
26 | adapter.onSectionExpansionToggled(19);
27 | assertEquals(adapter.getItemCount(), 31);
28 |
29 | adapter.onSectionExpansionToggled(30);
30 | assertEquals(adapter.getItemCount(), 40);
31 |
32 | adapter.onSectionExpansionToggled(19);
33 | assertEquals(adapter.getItemCount(), 40);
34 | }
35 |
36 | @Test public void sectionExpansionModeTest_Multiple() {
37 | adapter.removeAllSections();
38 | adapter.addSection(itemSection1);
39 | adapter.addSection(listSection1);
40 | adapter.addSection(headerSection1);
41 | adapter.addSection(nestedSection1);
42 |
43 | adapter.setSectionExpansionMode(Mode.MULTIPLE);
44 |
45 | adapter.collapseAllSections();
46 |
47 | adapter.onSectionExpansionToggled(19);
48 | assertEquals(adapter.getItemCount(), 40);
49 |
50 | adapter.onSectionExpansionToggled(19);
51 | assertEquals(adapter.getItemCount(), 31);
52 |
53 | adapter.onSectionExpansionToggled(30);
54 | assertEquals(adapter.getItemCount(), 40);
55 |
56 | adapter.onSectionExpansionToggled(19);
57 | assertEquals(adapter.getItemCount(), 49);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/newsfeed/NewsHeaderItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.newsfeed;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 | import android.widget.TextView;
22 | import dev.ahamed.mva.sample.R;
23 | import dev.ahamed.mva.sample.data.model.NewsHeader;
24 | import mva2.adapter.ItemBinder;
25 | import mva2.adapter.ItemViewHolder;
26 | import mva2.adapter.decorator.Decorator;
27 |
28 | public class NewsHeaderItemBinder extends ItemBinder {
29 |
30 | public NewsHeaderItemBinder(Decorator decorator) {
31 | super(decorator);
32 | }
33 |
34 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
35 | return new ViewHolder(inflate(parent, R.layout.item_news_header));
36 | }
37 |
38 | @Override public void bindViewHolder(ViewHolder holder, NewsHeader item) {
39 | holder.header.setText(item.getHeader());
40 | }
41 |
42 | @Override public boolean canBindData(Object item) {
43 | return item instanceof NewsHeader;
44 | }
45 |
46 | static class ViewHolder extends ItemViewHolder {
47 |
48 | private TextView header;
49 |
50 | public ViewHolder(View itemView) {
51 | super(itemView);
52 | header = itemView.findViewById(R.id.tv_news_header);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/extensions/databinding/src/main/java/mva2/extension/DBItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.extension;
18 |
19 | import android.databinding.ViewDataBinding;
20 | import android.view.ViewGroup;
21 | import mva2.adapter.ItemBinder;
22 |
23 | /**
24 | * ItemBinder which supports the DataBinding
25 | *
26 | * @param Refers to the model class
27 | * @param Refers to the view binding of the model class
28 | */
29 | public abstract class DBItemBinder
30 | extends ItemBinder> {
31 |
32 | @Override public final ViewHolder createViewHolder(ViewGroup parent) {
33 | return createViewHolder(createBinding(parent));
34 | }
35 |
36 | @Override public final void bindViewHolder(ViewHolder holder, M item) {
37 | bindModel(item, holder.getBinding());
38 | holder.getBinding().executePendingBindings();
39 | }
40 |
41 | protected ViewHolder createViewHolder(VDB binding) {
42 | return new ViewHolder<>(binding);
43 | }
44 |
45 | protected abstract void bindModel(M item, VDB binding);
46 |
47 | protected abstract VDB createBinding(ViewGroup parent);
48 |
49 | protected static class ViewHolder
50 | extends BindingViewHolder {
51 |
52 | public ViewHolder(VDB binding) {
53 | super(binding);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/include_config_button_panel.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
27 |
28 |
39 |
40 |
51 |
52 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/basic/NumberItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.basic;
18 |
19 | import android.view.LayoutInflater;
20 | import android.view.View;
21 | import android.view.ViewGroup;
22 | import android.widget.TextView;
23 | import dev.ahamed.mva.sample.R;
24 | import dev.ahamed.mva.sample.data.model.NumberItem;
25 | import mva2.adapter.ItemBinder;
26 | import mva2.adapter.ItemViewHolder;
27 | import mva2.adapter.decorator.Decorator;
28 |
29 | class NumberItemBinder extends ItemBinder {
30 |
31 | NumberItemBinder(Decorator itemDecorator) {
32 | super(itemDecorator);
33 | }
34 |
35 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
36 | return new ViewHolder(
37 | LayoutInflater.from(parent.getContext()).inflate(R.layout.item_basic, null, false));
38 | }
39 |
40 | @Override public void bindViewHolder(ViewHolder holder, NumberItem item) {
41 | holder.textView.setText(String.valueOf(item.getNumber()));
42 | }
43 |
44 | @Override public boolean canBindData(Object item) {
45 | return item instanceof NumberItem;
46 | }
47 |
48 | static final class ViewHolder extends ItemViewHolder {
49 |
50 | TextView textView;
51 |
52 | ViewHolder(View itemView) {
53 | super(itemView);
54 | textView = itemView.findViewById(R.id.text_view);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_news_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
27 |
28 |
34 |
35 |
43 |
44 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/multi-view-adapter/src/test/java/mva2/adapter/TestAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package mva2.adapter;
18 |
19 | import android.support.v7.widget.SpanSizeLookup;
20 | import mva2.adapter.testconfig.AdapterDataObserver;
21 | import mva2.adapter.testconfig.HashMapCache;
22 |
23 | public class TestAdapter extends MultiViewAdapter {
24 |
25 | private final AdapterDataObserver adapterDataObserver;
26 |
27 | public TestAdapter(AdapterDataObserver adapterDataObserver, SpanSizeLookup spanSizeLookup) {
28 | super(spanSizeLookup, new HashMapCache(), new HashMapCache(), new HashMapCache());
29 | this.adapterDataObserver = adapterDataObserver;
30 | }
31 |
32 | @Override void notifyAdapterItemMoved(int fromPosition, int toPosition) {
33 | onDataSetChanged();
34 | adapterDataObserver.notifyItemMoved(fromPosition, toPosition);
35 | }
36 |
37 | @Override void notifyAdapterRangeChanged(int positionStart, int itemCount, Object payload) {
38 | onDataSetChanged();
39 | adapterDataObserver.notifyItemRangeChanged(positionStart, itemCount, payload);
40 | }
41 |
42 | @Override void notifyAdapterRangeInserted(int positionStart, int itemCount) {
43 | onDataSetChanged();
44 | adapterDataObserver.notifyItemRangeInserted(positionStart, itemCount);
45 | }
46 |
47 | @Override void notifyAdapterRangeRemoved(int positionStart, int itemCount) {
48 | onDataSetChanged();
49 | adapterDataObserver.notifyItemRangeRemoved(positionStart, itemCount);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/sample/src/main/java/dev/ahamed/mva/sample/view/home/FeatureItemBinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Riyaz Ahamed
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.ahamed.mva.sample.view.home;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 | import android.widget.TextView;
22 | import dev.ahamed.mva.sample.R;
23 | import dev.ahamed.mva.sample.widget.FeatureHeader;
24 | import mva2.adapter.ItemBinder;
25 | import mva2.adapter.ItemViewHolder;
26 | import mva2.adapter.decorator.Decorator;
27 |
28 | public class FeatureItemBinder extends ItemBinder {
29 |
30 | FeatureItemBinder(Decorator decorator) {
31 | super(decorator);
32 | }
33 |
34 | @Override public ViewHolder createViewHolder(ViewGroup parent) {
35 | return new ViewHolder(inflate(parent, R.layout.item_feature));
36 | }
37 |
38 | @Override public void bindViewHolder(ViewHolder holder, Feature item) {
39 | holder.featureHeader.setTitle(item.getTitle());
40 | holder.featureHeader.setIcon(item.getIcon());
41 | holder.description.setText(item.getDescription());
42 | }
43 |
44 | @Override public boolean canBindData(Object item) {
45 | return item instanceof Feature;
46 | }
47 |
48 | static class ViewHolder extends ItemViewHolder {
49 |
50 | FeatureHeader featureHeader;
51 | TextView description;
52 |
53 | ViewHolder(View itemView) {
54 | super(itemView);
55 | featureHeader = itemView.findViewById(R.id.feature_header);
56 | description = itemView.findViewById(R.id.tv_description);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
27 |
33 |
34 |
43 |
44 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_patter.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
27 |
30 |
34 |
38 |
42 |
46 |
50 |
54 |
58 |
62 |
63 |
--------------------------------------------------------------------------------