├── .bundle
└── config
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE.md
├── ci-gradle.properties
├── config
│ └── configuration.json
└── workflows
│ └── ci.yml
├── .gitignore
├── .idea
└── dictionaries
│ └── benji.xml
├── CHANGELOG.md
├── CONTRIBUTORS.md
├── DEV
├── code-style.xml
├── default-detekt-config.yml
├── functiongraphic
│ └── functiongraphic.png
├── github
│ ├── screenshots1.jpg
│ └── screenshots1.png
├── ic_launcher
│ ├── res
│ │ ├── drawable-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_launcher.png
│ │ └── drawable-xxxhdpi
│ │ │ └── ic_launcher.png
│ └── web_hi_res_512.png
├── inspections.xml
└── screenshots
│ ├── Screenshot_20160119-231900.png
│ ├── Screenshot_20160119-231905.png
│ ├── Screenshot_20160119-231914.png
│ ├── Screenshot_20160119-231928.png
│ ├── Screenshot_20160119-231945.png
│ ├── Screenshot_20160119-231952.png
│ └── Screenshot_20160119-231959.png
├── Dangerfile
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── MIGRATION.md
├── README.md
├── _config.yml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-web.png
│ ├── java
│ └── com
│ │ └── mikepenz
│ │ └── fastadapter
│ │ └── app
│ │ ├── AdvancedSampleActivity.kt
│ │ ├── CheckBoxSampleActivity.kt
│ │ ├── CustomApplication.kt
│ │ ├── DiffUtilActivity.kt
│ │ ├── DragAndDropActivity.kt
│ │ ├── EndlessScrollListActivity.kt
│ │ ├── ExpandableMultiselectDeleteSampleActivity.kt
│ │ ├── ExpandableSampleActivity.kt
│ │ ├── IconGridActivity.kt
│ │ ├── ImageListActivity.kt
│ │ ├── ModelItemActivity.kt
│ │ ├── MultiTypeModelItemActivity.kt
│ │ ├── MultiselectSampleActivity.kt
│ │ ├── PagedActivity.kt
│ │ ├── RadioButtonSampleActivity.kt
│ │ ├── RealmActivity.kt
│ │ ├── SampleActivity.kt
│ │ ├── SimpleItemListActivity.kt
│ │ ├── SortActivity.kt
│ │ ├── StickyHeaderSampleActivity.kt
│ │ ├── SwipeDrawerListActivity.kt
│ │ ├── SwipeListActivity.kt
│ │ ├── adapters
│ │ ├── FastScrollIndicatorAdapter.kt
│ │ ├── IDraggableViewHolder.java
│ │ ├── SampleWrapAdapter.kt
│ │ └── StickyHeaderAdapter.kt
│ │ ├── binding
│ │ └── BindingIconItem.kt
│ │ ├── dummy
│ │ └── ImageDummyData.kt
│ │ ├── items
│ │ ├── CheckBoxSampleItem.kt
│ │ ├── DraggableSingleLineItem.kt
│ │ ├── HeaderSelectionItem.kt
│ │ ├── IconItem.kt
│ │ ├── ImageItem.kt
│ │ ├── LetterItem.kt
│ │ ├── RadioButtonSampleItem.kt
│ │ ├── RealmSampleUserItem.kt
│ │ ├── SectionHeaderItem.kt
│ │ ├── SimpleImageItem.kt
│ │ ├── SimpleItem.kt
│ │ ├── SmallIconSingleLineItem.kt
│ │ ├── SwipeableDrawerItem.kt
│ │ ├── SwipeableItem.kt
│ │ └── expandable
│ │ │ ├── SimpleSubExpandableItem.kt
│ │ │ └── SimpleSubItem.kt
│ │ ├── model
│ │ ├── IconModel.kt
│ │ ├── ModelIconItem.kt
│ │ ├── RightIconModel.kt
│ │ └── RightModelIconItem.kt
│ │ ├── paged
│ │ ├── DemoEntitiesDB.kt
│ │ ├── DemoEntity.kt
│ │ ├── DemoEntityLocalDAO.kt
│ │ ├── DemoEntityViewModel.kt
│ │ └── LocalRepository.kt
│ │ ├── utils
│ │ └── Utils.kt
│ │ └── view
│ │ ├── DraggableFrameLayout.kt
│ │ └── RecyclerViewBackgroundDrawable.kt
│ └── res
│ ├── anim
│ └── alpha_on.xml
│ ├── animator
│ └── draggable_state_list_anim.xml
│ ├── drawable-v21
│ └── button_rect_list_normal.xml
│ ├── drawable
│ ├── button_rect_list_normal.xml
│ ├── gradient.xml
│ └── ic_drag_handle.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_sample.xml
│ ├── checkbox_sample_item.xml
│ ├── draggable_single_line_item.xml
│ ├── expandable_item.xml
│ ├── icon_item.xml
│ ├── image_item.xml
│ ├── letter_item.xml
│ ├── native_ad_item.xml
│ ├── radiobutton_sample_item.xml
│ ├── right_icon_item.xml
│ ├── sample_item.xml
│ ├── section_header_item.xml
│ ├── simple_image_item.xml
│ ├── small_single_line_item.xml
│ ├── swipeable_drawer_item.xml
│ ├── swipeable_item.xml
│ └── view_header.xml
│ ├── menu
│ ├── cab.xml
│ ├── menu.xml
│ ├── menu_add.xml
│ ├── refresh.xml
│ ├── search.xml
│ └── sort.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── values-land
│ └── integers.xml
│ ├── values-night
│ └── colors.xml
│ └── values
│ ├── colors.xml
│ ├── ic_launcher_background.xml
│ ├── ids.xml
│ ├── integers.xml
│ ├── strings.xml
│ ├── styles.xml
│ └── themes.xml
├── build.gradle
├── configurations.gradle
├── detekt.gradle
├── fastadapter-extensions-binding
├── .gitignore
├── build.gradle
├── consumer-proguard-rules.pro
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── mikepenz
│ └── fastadapter
│ └── binding
│ ├── AbstractBindingItem.kt
│ ├── BaseBindingItemVHFactory.kt
│ ├── BindingViewHolder.kt
│ ├── ModelAbstractBindingItem.kt
│ └── listeners
│ └── BindingEventHookExtensions.kt
├── fastadapter-extensions-diff
├── .gitignore
├── build.gradle
├── consumer-proguard-rules.pro
├── gradle.properties
├── proguard-rules.pro
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── mikepenz
│ │ └── fastadapter
│ │ └── diff
│ │ ├── DiffCallback.kt
│ │ ├── DiffCallbackImpl.kt
│ │ └── FastAdapterDiffUtil.kt
│ └── test
│ ├── java
│ └── com
│ │ └── mikepenz
│ │ └── fastadapter
│ │ └── diff
│ │ ├── FastAdapterDiffUtilTest.java
│ │ ├── TestDataGenerator.java
│ │ └── TestItem.java
│ └── resources
│ └── robolectric.properties
├── fastadapter-extensions-drag
├── .gitignore
├── build.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── mikepenz
│ └── fastadapter
│ └── drag
│ ├── IDraggable.kt
│ ├── IExtendedDraggable.kt
│ ├── ItemTouchCallback.kt
│ └── SimpleDragCallback.kt
├── fastadapter-extensions-expandable
├── .gitignore
├── build.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── mikepenz
│ │ └── fastadapter
│ │ ├── expandable
│ │ ├── ExpandableExtension.kt
│ │ ├── ExpandableExtensionFactory.kt
│ │ └── items
│ │ │ ├── AbstractExpandableItem.kt
│ │ │ └── ModelAbstractExpandableItem.kt
│ │ └── utils
│ │ ├── AdapterUtil.kt
│ │ └── SubItemUtil.kt
│ └── test
│ └── java
│ └── com
│ └── mikepenz
│ └── fastadapter
│ ├── ExpandableFastAdapterTest.kt
│ ├── ExpandableTestDataGenerator.java
│ ├── ExpandableTestItem.java
│ └── NoneExpandableTestItem.java
├── fastadapter-extensions-paged
├── .gitignore
├── build.gradle
├── consumer-proguard-rules.pro
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── mikepenz
│ └── fastadapter
│ └── paged
│ ├── PagedItemListImpl.kt
│ └── PagedModelAdapter.kt
├── fastadapter-extensions-scroll
├── .gitignore
├── build.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ ├── androidx
│ └── recyclerview
│ │ └── widget
│ │ └── com_mikepenz_fastadapter_extensions_scroll.kt
│ └── com
│ └── mikepenz
│ └── fastadapter
│ └── scroll
│ ├── EndlessRecyclerOnScrollListener.kt
│ ├── EndlessRecyclerOnTopScrollListener.kt
│ └── EndlessScrollHelper.kt
├── fastadapter-extensions-swipe
├── .gitignore
├── build.gradle
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── mikepenz
│ └── fastadapter
│ └── swipe
│ ├── Extensions.kt
│ ├── IDrawerSwipeableViewHolder.kt
│ ├── ISwipeable.kt
│ ├── SimpleSwipeCallback.kt
│ └── SimpleSwipeDrawerCallback.kt
├── fastadapter-extensions-ui
├── .gitignore
├── build.gradle
├── consumer-proguard-rules.pro
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── mikepenz
│ │ └── fastadapter
│ │ └── ui
│ │ ├── dialog
│ │ ├── FastAdapterBottomSheetDialog.kt
│ │ └── FastAdapterDialog.kt
│ │ ├── items
│ │ ├── ProgressItem.kt
│ │ ├── SingleLineItem.kt
│ │ ├── ThreeLineItem.kt
│ │ └── TwoLineItem.kt
│ │ └── utils
│ │ ├── FastAdapterUIUtils.kt
│ │ ├── FixStateListDrawable.kt
│ │ ├── ImageHolder.kt
│ │ └── StringHolder.kt
│ └── res
│ ├── layout
│ ├── progress_item.xml
│ ├── single_line_item.xml
│ ├── three_line_item.xml
│ └── two_line_item.xml
│ └── values
│ └── ids.xml
├── fastadapter-extensions-utils
├── .gitignore
├── build.gradle
├── consumer-proguard-rules.pro
├── gradle.properties
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── mikepenz
│ └── fastadapter
│ ├── adapters
│ ├── AbstractWrapAdapter.kt
│ ├── FastItemAdapter.kt
│ └── WrapAdapter.kt
│ ├── helpers
│ ├── ActionModeHelper.kt
│ ├── HeaderHelper.kt
│ ├── RangeSelectorHelper.kt
│ └── UndoHelper.kt
│ ├── swipe_drag
│ ├── SimpleSwipeDragCallback.kt
│ └── SimpleSwipeDrawerDragCallback.kt
│ └── utils
│ └── DragDropUtil.kt
├── fastadapter
├── .gitignore
├── build.gradle
├── consumer-proguard-rules.pro
├── gradle.properties
├── proguard-rules.txt
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── mikepenz
│ │ │ └── fastadapter
│ │ │ ├── AbstractAdapter.kt
│ │ │ ├── FastAdapter.kt
│ │ │ ├── IAdapter.kt
│ │ │ ├── IAdapterExtension.kt
│ │ │ ├── IAdapterNotifier.kt
│ │ │ ├── IClickable.kt
│ │ │ ├── IExpandable.kt
│ │ │ ├── IHookable.kt
│ │ │ ├── IIdDistributor.kt
│ │ │ ├── IIdentifyable.kt
│ │ │ ├── IItem.kt
│ │ │ ├── IItemAdapter.kt
│ │ │ ├── IItemList.kt
│ │ │ ├── IItemVHFactory.kt
│ │ │ ├── IItemVHFactoryCache.kt
│ │ │ ├── IItemViewGenerator.kt
│ │ │ ├── IModelItem.kt
│ │ │ ├── IParentItem.kt
│ │ │ ├── ISelectionListener.kt
│ │ │ ├── ISubItem.kt
│ │ │ ├── MutableSubItemList.kt
│ │ │ ├── VerboseLogger.kt
│ │ │ ├── adapters
│ │ │ ├── ItemAdapter.kt
│ │ │ ├── ItemFilter.kt
│ │ │ └── ModelAdapter.kt
│ │ │ ├── dsl
│ │ │ └── FastAdapterDsl.kt
│ │ │ ├── extensions
│ │ │ ├── ExtensionFactory.kt
│ │ │ └── ExtensionsFactories.kt
│ │ │ ├── items
│ │ │ ├── AbstractItem.kt
│ │ │ ├── BaseItem.kt
│ │ │ ├── ModelAbstractItem.kt
│ │ │ └── ModelBaseItem.kt
│ │ │ ├── listeners
│ │ │ ├── ClickEventHook.kt
│ │ │ ├── CustomEventHook.kt
│ │ │ ├── EventHook.kt
│ │ │ ├── ItemFilterListener.kt
│ │ │ ├── LongClickEventHook.kt
│ │ │ ├── OnBindViewHolderListener.kt
│ │ │ ├── OnBindViewHolderListenerImpl.kt
│ │ │ ├── OnCreateViewHolderListener.kt
│ │ │ ├── OnCreateViewHolderListenerImpl.kt
│ │ │ └── TouchEventHook.kt
│ │ │ ├── select
│ │ │ ├── SelectExtension.kt
│ │ │ └── SelectExtensionFactory.kt
│ │ │ └── utils
│ │ │ ├── AdapterPredicate.kt
│ │ │ ├── ComparableItemListImpl.kt
│ │ │ ├── DefaultIdDistributor.kt
│ │ │ ├── DefaultIdDistributorImpl.kt
│ │ │ ├── DefaultItemList.kt
│ │ │ ├── DefaultItemListImpl.kt
│ │ │ ├── DefaultItemVHFactoryCache.kt
│ │ │ ├── EventHookUtil.kt
│ │ │ ├── InterceptorUtil.kt
│ │ │ ├── Sort.kt
│ │ │ └── Triple.kt
│ └── res
│ │ └── values
│ │ ├── ids.xml
│ │ └── library_fastadapter_strings.xml
│ └── test
│ ├── java
│ └── com
│ │ └── mikepenz
│ │ └── fastadapter
│ │ ├── FastAdapterTest.java
│ │ ├── TestDataGenerator.java
│ │ └── TestItem.java
│ └── resources
│ └── robolectric.properties
├── gradle-release.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── release.sh
└── settings.gradle
/.bundle/config:
--------------------------------------------------------------------------------
1 | ---
2 | BUNDLE_PATH: "vendor/bundle"
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [mikepenz]
4 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## About this issue
2 |
3 | - Briefly describe the issue
4 | - How can the issue be reproduced / sample code
5 |
6 | ## Details
7 | - [ ] Used library version
8 | - [ ] Used support library version
9 | - [ ] Used gradle build tools version
10 | - [ ] Used tooling / Android Studio version
11 | - [ ] Other used libraries, potential conflicting libraries
12 |
13 | ## Checklist
14 |
15 | - [ ] Searched for [similar issues](https://github.com/mikepenz/FastAdapter/issues)
16 | - [ ] Checked out the [sample application](https://github.com/mikepenz/FastAdapter/tree/develop/app)
17 | - [ ] Read the [README](https://github.com/mikepenz/FastAdapter/blob/develop/README.md)
18 | - [ ] Checked out the [CHANGELOG](https://github.com/mikepenz/FastAdapter/releases)
19 | - [ ] Checked out the [MIGRATION GUIDE](https://github.com/mikepenz/FastAdapter/blob/develop/MIGRATION.md)
20 |
--------------------------------------------------------------------------------
/.github/ci-gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.daemon=true
2 | org.gradle.parallel=true
3 | org.gradle.workers.max=2
4 | org.gradle.jvmargs=-Xmx6G
5 | org.gradle.caching=true
6 | org.gradle.configureondemand=true
7 | # parallel kapt
8 | kapt.use.worker.api=true
9 |
--------------------------------------------------------------------------------
/.github/config/configuration.json:
--------------------------------------------------------------------------------
1 | {
2 | "categories": [
3 | {
4 | "title": "## 🚀 Features",
5 | "labels": [
6 | "feature"
7 | ]
8 | },
9 | {
10 | "title": "## 🐛 Fixes",
11 | "labels": [
12 | "fix"
13 | ]
14 | },
15 | {
16 | "title": "## 🧪 Tests",
17 | "labels": [
18 | "test"
19 | ]
20 | },
21 | {
22 | "title": "## 💬 Other",
23 | "labels": [
24 | "other"
25 | ]
26 | }
27 | ]
28 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 | /*/build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | #IntelliJ files
30 | *.iml
31 | .idea/*
32 | !.idea/dictionaries
33 |
34 | *.DS_STORE
35 | /vendor/*
36 |
--------------------------------------------------------------------------------
/.idea/dictionaries/benji.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | aleksander
5 | alireza
6 | bergander
7 | chaudhary
8 | claide
9 | configureondemand
10 | ctor
11 | descr
12 | detekt
13 | expandables
14 | fabianterhorst
15 | fastadapter
16 | flisar
17 | gagan
18 | gulko
19 | hookable
20 | iconics
21 | identifiables
22 | isegran
23 | jasonsparc
24 | jetpack
25 | jvmargs
26 | kapt
27 | kramdown
28 | mielczarek
29 | mikepenz
30 | mopub
31 | multiselect
32 | octokit
33 | paypal
34 | penz
35 | performant
36 | rchardet
37 | rects
38 | rexml
39 | rubengees
40 | shubham
41 | snackbar
42 | spek
43 | stickyheadersrecyclerview
44 | subitem
45 | subitems
46 | sublists
47 | swipeable
48 | terhorst
49 | timehop
50 | unselect
51 | unswipe
52 | unswiped
53 | usecases
54 | viewholder
55 |
56 |
57 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | You can find a detailed change log in the [release section](https://github.com/mikepenz/FastAdapter/releases)
2 |
--------------------------------------------------------------------------------
/CONTRIBUTORS.md:
--------------------------------------------------------------------------------
1 | FastAdapter contributors (sorted alphabetically)
2 | ============================================
3 |
4 | * **[Fabian Terhorst](https://github.com/FabianTerhorst)**
5 |
6 | * EndlessScroll-Listener (EndlessScroll Sample)
7 | * Improvements to the `SimpleDragCallback`
8 | * Add additional tests
9 | * Add `FastAdapterDialog`
10 | * Add additional default `Items`
11 |
12 | * **[MFlisar](https://github.com/MFlisar)**
13 |
14 | * Improvements to the Expandable / SubItems implementation
15 |
16 | * **[Mattias Isegran Bergander](https://github.com/mattiasbe)**
17 |
18 | * "Leave-Behind"-Pattern (SwipeList Sample)
19 |
20 | * **[Rainer Lang](https://github.com/Rainer-Lang)**
21 |
22 | * CheckBoxSample
23 | * RadioButtonSample
24 |
25 | * **[rubengees](https://github.com/rubengees)**
26 |
27 | * SortSample with comparator
28 |
29 | * **[Shubham Chaudhary](https://github.com/shubhamchaudhary)**
30 |
31 | * Basic Unit-Tests
32 |
33 | * **[Alireza](https://github.com/meNESS)**
34 |
35 | * EndlessRecyclerOnTopScrollListener
36 |
37 | * **[jasonsparc](https://github.com/jasonsparc)**
38 |
39 | * Added `EndlessScrollHelper`
--------------------------------------------------------------------------------
/DEV/functiongraphic/functiongraphic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/functiongraphic/functiongraphic.png
--------------------------------------------------------------------------------
/DEV/github/screenshots1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/github/screenshots1.jpg
--------------------------------------------------------------------------------
/DEV/github/screenshots1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/github/screenshots1.png
--------------------------------------------------------------------------------
/DEV/ic_launcher/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/ic_launcher/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DEV/ic_launcher/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/ic_launcher/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DEV/ic_launcher/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/ic_launcher/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DEV/ic_launcher/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/ic_launcher/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DEV/ic_launcher/res/drawable-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/ic_launcher/res/drawable-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/DEV/ic_launcher/web_hi_res_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/ic_launcher/web_hi_res_512.png
--------------------------------------------------------------------------------
/DEV/inspections.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/DEV/screenshots/Screenshot_20160119-231900.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/screenshots/Screenshot_20160119-231900.png
--------------------------------------------------------------------------------
/DEV/screenshots/Screenshot_20160119-231905.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/screenshots/Screenshot_20160119-231905.png
--------------------------------------------------------------------------------
/DEV/screenshots/Screenshot_20160119-231914.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/screenshots/Screenshot_20160119-231914.png
--------------------------------------------------------------------------------
/DEV/screenshots/Screenshot_20160119-231928.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/screenshots/Screenshot_20160119-231928.png
--------------------------------------------------------------------------------
/DEV/screenshots/Screenshot_20160119-231945.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/screenshots/Screenshot_20160119-231945.png
--------------------------------------------------------------------------------
/DEV/screenshots/Screenshot_20160119-231952.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/screenshots/Screenshot_20160119-231952.png
--------------------------------------------------------------------------------
/DEV/screenshots/Screenshot_20160119-231959.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/DEV/screenshots/Screenshot_20160119-231959.png
--------------------------------------------------------------------------------
/Dangerfile:
--------------------------------------------------------------------------------
1 | github.dismiss_out_of_range_messages
2 |
3 | # Make it more obvious that a PR is a work in progress and shouldn't be merged yet.
4 | has_wip_label = github.pr_labels.any? { |label| label.include? "Engineers at work" }
5 | has_wip_title = github.pr_title.include? "[WIP]"
6 |
7 | if has_wip_label || has_wip_title
8 | warn("PR is marked as Work in Progress")
9 | end
10 |
11 | # Ensure the PR is not marked as DO NOT MERGE
12 | fail("PR specifies label DO NOT MERGE") if github.pr_labels.any? { |label| label.include? "DO NOT MERGE" }
13 |
14 | # Warn when there is a big PR
15 | warn("Big PR") if git.lines_of_code > 5000
16 |
17 | File.open("settings.gradle", "r") do |file_handle|
18 | file_handle.each_line do |setting|
19 | if setting.include? "include"
20 | gradleModule = setting[10, setting.length-12]
21 |
22 | # AndroidLint
23 | androidLintFile = String.new(gradleModule + "/build/reports/lint-results.xml")
24 | androidLintDebugFile = String.new(gradleModule + "/build/reports/lint-results-debug.xml")
25 | if File.file?(androidLintFile) || File.file?(androidLintDebugFile)
26 | android_lint.skip_gradle_task = true
27 | android_lint.severity = "Warning"
28 | if File.file?(androidLintFile)
29 | android_lint.report_file = androidLintFile
30 | else
31 | android_lint.report_file = androidLintDebugFile
32 | end
33 | android_lint.filtering = true
34 | android_lint.lint(inline_mode: true)
35 | end
36 |
37 | # Detekt
38 | detektFile = String.new(gradleModule + "/build/reports/detekt.xml")
39 | if File.file?(detektFile)
40 | kotlin_detekt.report_file = detektFile
41 | kotlin_detekt.skip_gradle_task = true
42 | kotlin_detekt.severity = "warning"
43 | kotlin_detekt.filtering = true
44 | kotlin_detekt.detekt(inline_mode: true)
45 | end
46 | end
47 | end
48 | end
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | source "https://rubygems.org"
4 |
5 | git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6 |
7 | gem 'danger'
8 | gem 'danger-android_lint'
9 | gem 'danger-kotlin_detekt'
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | title: FastAdapter
2 | description: The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
3 | show_downloads: true
4 | theme: jekyll-theme-minimal
5 |
6 | gems:
7 | - jekyll-mentions
8 | - jekyll-readme-index
9 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/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 /Entwicklung/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 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/CustomApplication.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app
2 |
3 | import androidx.multidex.MultiDexApplication
4 | import io.realm.Realm
5 | import io.realm.RealmConfiguration
6 |
7 | /**
8 | * Created by mikepenz on 04.07.16.
9 | */
10 |
11 | class CustomApplication : MultiDexApplication() {
12 | override fun onCreate() {
13 | super.onCreate()
14 | // The Realm file will be located in Context.getFilesDir() with name "default.realm"
15 | Realm.init(this)
16 | val config = RealmConfiguration.Builder().build()
17 | Realm.setDefaultConfiguration(config)
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/adapters/IDraggableViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.adapters;
2 |
3 | /**
4 | * Helper interface to allow a viewHolder to react to drag events.
5 | */
6 | public interface IDraggableViewHolder {
7 | /**
8 | * Called when an item enters drag state
9 | */
10 | void onDragged();
11 |
12 | /**
13 | * Called when an item has been dropped
14 | */
15 | void onDropped();
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/adapters/SampleWrapAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.adapters
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | import com.mikepenz.fastadapter.IItem
6 | import com.mikepenz.fastadapter.adapters.AbstractWrapAdapter
7 |
8 | /**
9 | * Created by mikepenz on 03.03.16.
10 | */
11 | class SampleWrapAdapter- , VH : RecyclerView.ViewHolder>(list: List
- ) : AbstractWrapAdapter
- (list) {
12 |
13 | override fun shouldInsertItemAtPosition(position: Int): Boolean {
14 | return position == 10
15 | }
16 |
17 | override fun itemInsertedBeforeCount(position: Int): Int {
18 | return if (position > 10) {
19 | 1
20 | } else 0
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/binding/BindingIconItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.binding
2 |
3 | import android.view.LayoutInflater
4 | import android.view.ViewGroup
5 | import com.mikepenz.fastadapter.IExpandable
6 | import com.mikepenz.fastadapter.IParentItem
7 | import com.mikepenz.fastadapter.ISubItem
8 | import com.mikepenz.fastadapter.app.R
9 | import com.mikepenz.fastadapter.app.databinding.IconItemBinding
10 | import com.mikepenz.fastadapter.app.utils.getThemeColor
11 | import com.mikepenz.fastadapter.binding.AbstractBindingItem
12 | import com.mikepenz.fastadapter.binding.BindingViewHolder
13 | import com.mikepenz.iconics.IconicsDrawable
14 | import com.mikepenz.iconics.typeface.IIcon
15 | import com.mikepenz.iconics.utils.colorInt
16 |
17 | /**
18 | * Created by mikepenz on 28.12.15.
19 | */
20 | class BindingIconItem : AbstractBindingItem(), IExpandable> {
21 | var icon: IIcon? = null
22 |
23 | override var parent: IParentItem<*>? = null
24 | override var isExpanded: Boolean = false
25 |
26 | override var subItems: MutableList>
27 | get() = mutableListOf()
28 | set(_) {
29 | }
30 |
31 | override val isAutoExpanding: Boolean
32 | get() = true
33 |
34 | /**
35 | * defines the type defining this item. must be unique. preferably an id
36 | *
37 | * @return the type
38 | */
39 | override val type: Int
40 | get() = R.id.fastadapter_icon_item_id
41 |
42 | /**
43 | * setter method for the Icon
44 | *
45 | * @param icon the icon
46 | * @return this
47 | */
48 | fun withIcon(icon: IIcon): BindingIconItem {
49 | this.icon = icon
50 | return this
51 | }
52 |
53 | /**
54 | * binds the data of this item onto the viewHolder
55 | */
56 | override fun bindView(binding: IconItemBinding, payloads: List) {
57 | //define our data for the view
58 | icon?.let {
59 | binding.icon.icon = IconicsDrawable(binding.icon.context, it).apply {
60 | colorInt = binding.root.context.getThemeColor(R.attr.colorOnSurface)
61 | }
62 | }
63 | binding.name.text = icon?.name
64 | }
65 |
66 | override fun unbindView(binding: IconItemBinding) {
67 | binding.icon.setImageDrawable(null)
68 | }
69 |
70 | override fun createBinding(inflater: LayoutInflater, parent: ViewGroup?): IconItemBinding {
71 | return IconItemBinding.inflate(inflater, parent, false)
72 | }
73 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/items/DraggableSingleLineItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.items
2 |
3 | import android.graphics.drawable.Drawable
4 | import android.view.MotionEvent
5 | import android.view.View
6 | import android.widget.ImageView
7 | import android.widget.TextView
8 | import androidx.recyclerview.widget.RecyclerView
9 | import com.mikepenz.fastadapter.FastAdapter
10 | import com.mikepenz.fastadapter.app.R
11 | import com.mikepenz.fastadapter.drag.IDraggable
12 | import com.mikepenz.fastadapter.items.AbstractItem
13 | import com.mikepenz.fastadapter.listeners.TouchEventHook
14 | import com.mikepenz.fastadapter.ui.utils.ImageHolder
15 | import com.mikepenz.fastadapter.ui.utils.StringHolder
16 |
17 | class DraggableSingleLineItem(icon: Drawable, name: String) : AbstractItem(), IDraggable {
18 | val icon: ImageHolder = ImageHolder(icon)
19 | val name: StringHolder = StringHolder(name)
20 |
21 | override val isDraggable: Boolean = true
22 |
23 | override val type: Int
24 | get() = R.id.fastadapter_draggable_single_line_item
25 |
26 | override val layoutRes: Int
27 | get() = R.layout.draggable_single_line_item
28 |
29 | override fun bindView(holder: ViewHolder, payloads: List) {
30 | super.bindView(holder, payloads)
31 | ImageHolder.applyToOrSetGone(icon, holder.icon)
32 | name.applyTo(holder.name)
33 | }
34 |
35 | override fun unbindView(holder: ViewHolder) {
36 | holder.icon.setImageDrawable(null)
37 | holder.name.text = null
38 | }
39 |
40 | override fun getViewHolder(v: View): ViewHolder = ViewHolder(v)
41 |
42 | class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
43 | var icon: ImageView = view.findViewById(R.id.icon)
44 | var name: TextView = view.findViewById(R.id.name)
45 | var dragHandle: View = view.findViewById(R.id.drag_handle)
46 | }
47 | }
48 |
49 | class DragHandleTouchEvent(val action: (position: Int) -> Unit) : TouchEventHook() {
50 | override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {
51 | return if (viewHolder is DraggableSingleLineItem.ViewHolder) viewHolder.dragHandle else null
52 | }
53 |
54 | override fun onTouch(
55 | v: View,
56 | event: MotionEvent,
57 | position: Int,
58 | fastAdapter: FastAdapter,
59 | item: DraggableSingleLineItem
60 | ): Boolean {
61 | return if (event.action == MotionEvent.ACTION_DOWN) {
62 | action(position)
63 | true
64 | } else {
65 | false
66 | }
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/items/HeaderSelectionItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.items
2 |
3 | import android.graphics.Color
4 | import androidx.core.view.ViewCompat
5 | import com.mikepenz.fastadapter.app.items.expandable.SimpleSubExpandableItem
6 | import com.mikepenz.fastadapter.ui.utils.FastAdapterUIUtils
7 | import com.mikepenz.materialdrawer.holder.StringHolder
8 |
9 | /**
10 | * Created by flisar on 21.09.2016.
11 | */
12 |
13 | open class HeaderSelectionItem : SimpleSubExpandableItem() {
14 |
15 | var mSubSelectionProvider: (() -> Int)? = null
16 |
17 | fun withSubSelectionProvider(subSelectionProvider: () -> Int) {
18 | this.mSubSelectionProvider = subSelectionProvider
19 | }
20 |
21 | override fun bindView(holder: ViewHolder, payloads: List) {
22 | super.bindView(holder, payloads)
23 |
24 | //get the context
25 | val ctx = holder.itemView.context
26 |
27 | //set the background for the item
28 | holder.view.clearAnimation()
29 | ViewCompat.setBackground(holder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true))
30 | //set the text for the name
31 | StringHolder.applyTo(name, holder.name)
32 | //set the text for the description or hide
33 |
34 | var selectedSubItems = 0
35 | if (mSubSelectionProvider != null)
36 | selectedSubItems = mSubSelectionProvider?.invoke() ?: 0
37 | val descr = StringHolder(if (selectedSubItems > 0) description?.textString else "Selected children: " + selectedSubItems + "/" + subItems.size)
38 | StringHolder.applyToOrHide(descr, holder.description)
39 |
40 | holder.description.setTextColor(if (selectedSubItems == 0) Color.BLACK else Color.RED)
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/items/LetterItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.items
2 |
3 | import android.view.View
4 | import android.widget.TextView
5 | import androidx.recyclerview.widget.RecyclerView
6 | import com.mikepenz.fastadapter.app.R
7 | import com.mikepenz.fastadapter.items.AbstractItem
8 |
9 | class LetterItem(var letter: String) : AbstractItem() {
10 |
11 | override val type: Int
12 | get() = R.id.fastadapter_letter_item_id
13 |
14 | override val layoutRes: Int
15 | get() = R.layout.letter_item
16 |
17 | override fun bindView(holder: ViewHolder, payloads: List) {
18 | super.bindView(holder, payloads)
19 | holder.text.text = letter
20 | }
21 |
22 | override fun unbindView(holder: ViewHolder) {
23 | super.unbindView(holder)
24 | holder.text.text = null
25 | }
26 |
27 | override fun getViewHolder(v: View): ViewHolder {
28 | return ViewHolder(v)
29 | }
30 |
31 | class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
32 | var text: TextView = view.findViewById(R.id.text)
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/items/SectionHeaderItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.items
2 |
3 | import android.view.View
4 | import android.widget.TextView
5 | import androidx.recyclerview.widget.RecyclerView
6 | import com.mikepenz.fastadapter.app.R
7 | import com.mikepenz.fastadapter.items.AbstractItem
8 | import com.mikepenz.fastadapter.ui.utils.StringHolder
9 |
10 | class SectionHeaderItem(text: String) : AbstractItem() {
11 | val text: StringHolder = StringHolder(text)
12 |
13 | override val type: Int
14 | get() = R.id.fastadapter_section_header_item
15 |
16 | override val layoutRes: Int
17 | get() = R.layout.section_header_item
18 |
19 | override fun bindView(holder: ViewHolder, payloads: List) {
20 | super.bindView(holder, payloads)
21 | text.applyTo(holder.text)
22 | }
23 |
24 | override fun unbindView(holder: ViewHolder) {
25 | holder.text.text = null
26 | }
27 |
28 | override fun getViewHolder(v: View): ViewHolder = ViewHolder(v)
29 |
30 | class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
31 | var text: TextView = view.findViewById(R.id.text)
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/items/SmallIconSingleLineItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.items
2 |
3 | import android.graphics.drawable.Drawable
4 | import android.view.View
5 | import android.widget.ImageView
6 | import android.widget.TextView
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.mikepenz.fastadapter.app.R
9 | import com.mikepenz.fastadapter.items.AbstractItem
10 | import com.mikepenz.fastadapter.ui.utils.ImageHolder
11 | import com.mikepenz.fastadapter.ui.utils.StringHolder
12 |
13 | class SmallIconSingleLineItem(icon: Drawable, name: String) : AbstractItem() {
14 | val icon: ImageHolder = ImageHolder(icon)
15 | val name: StringHolder = StringHolder(name)
16 |
17 | override val type: Int
18 | get() = R.id.fastadapter_small_icon_single_line_item
19 |
20 | override val layoutRes: Int
21 | get() = R.layout.small_single_line_item
22 |
23 | override fun bindView(holder: ViewHolder, payloads: List) {
24 | super.bindView(holder, payloads)
25 | ImageHolder.applyToOrSetGone(icon, holder.icon)
26 | name.applyTo(holder.name)
27 | }
28 |
29 | override fun unbindView(holder: ViewHolder) {
30 | holder.icon.setImageDrawable(null)
31 | holder.name.text = null
32 | }
33 |
34 | override fun getViewHolder(v: View): ViewHolder = ViewHolder(v)
35 |
36 | class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
37 | var icon: ImageView = view.findViewById(R.id.icon)
38 | var name: TextView = view.findViewById(R.id.name)
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/model/IconModel.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.model
2 |
3 | import com.mikepenz.iconics.typeface.IIcon
4 |
5 | /**
6 | * Created by mikepenz on 18.01.16.
7 | */
8 | open class IconModel(var icon: IIcon)
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/model/ModelIconItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.model
2 |
3 | import android.view.View
4 | import android.widget.TextView
5 | import androidx.recyclerview.widget.RecyclerView
6 | import com.mikepenz.fastadapter.app.R
7 | import com.mikepenz.fastadapter.app.utils.getThemeColor
8 | import com.mikepenz.fastadapter.items.ModelAbstractItem
9 | import com.mikepenz.iconics.IconicsDrawable
10 | import com.mikepenz.iconics.utils.colorInt
11 | import com.mikepenz.iconics.view.IconicsImageView
12 |
13 | /**
14 | * Created by mikepenz on 28.12.15.
15 | */
16 | open class ModelIconItem(icon: IconModel) : ModelAbstractItem(icon) {
17 |
18 | /**
19 | * defines the type defining this item. must be unique. preferably an id
20 | *
21 | * @return the type
22 | */
23 | override val type: Int
24 | get() = R.id.fastadapter_model_icon_item_id
25 |
26 | /**
27 | * defines the layout which will be used for this item in the list
28 | *
29 | * @return the layout for this item
30 | */
31 | override val layoutRes: Int
32 | get() = R.layout.icon_item
33 |
34 | /**
35 | * binds the data of this item onto the viewHolder
36 | *
37 | * @param holder the viewHolder of this item
38 | */
39 | override fun bindView(holder: ViewHolder, payloads: List) {
40 | super.bindView(holder, payloads)
41 |
42 | //define our data for the view
43 | holder.image.icon = IconicsDrawable(holder.image.context, model.icon).apply {
44 | colorInt = holder.view.context.getThemeColor(R.attr.colorOnSurface)
45 | }
46 | holder.name.text = model.icon.name
47 | }
48 |
49 | override fun unbindView(holder: ViewHolder) {
50 | super.unbindView(holder)
51 | holder.image.setImageDrawable(null)
52 | holder.name.text = null
53 | }
54 |
55 | override fun getViewHolder(v: View): ViewHolder {
56 | return ViewHolder(v)
57 | }
58 |
59 | /**
60 | * our ViewHolder
61 | */
62 | class ViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
63 | var name: TextView = view.findViewById(R.id.name)
64 | var image: IconicsImageView = view.findViewById(R.id.icon)
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/model/RightIconModel.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.model
2 |
3 | import com.mikepenz.iconics.typeface.IIcon
4 |
5 | /**
6 | * Created by mikepenz on 18.01.16.
7 | */
8 | class RightIconModel(icon: IIcon) : IconModel(icon)
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/model/RightModelIconItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.model
2 |
3 | import com.mikepenz.fastadapter.app.R
4 |
5 | /**
6 | * Created by mikepenz on 28.12.15.
7 | */
8 | class RightModelIconItem(icon: IconModel) : ModelIconItem(icon) {
9 |
10 | /**
11 | * defines the type defining this item. must be unique. preferably an id
12 | *
13 | * @return the type
14 | */
15 | override val type: Int
16 | get() = R.id.fastadapter_right_Model_icon_item_id
17 |
18 | /**
19 | * defines the layout which will be used for this item in the list
20 | *
21 | * @return the layout for this item
22 | */
23 | override val layoutRes: Int
24 | get() = R.layout.right_icon_item
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/paged/DemoEntitiesDB.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.paged
2 |
3 | import androidx.room.Database
4 | import androidx.room.RoomDatabase
5 |
6 | /**
7 | * https://www.zoftino.com/pagination-in-android-using-paging-library
8 | */
9 | @Database(entities = [DemoEntity::class], version = 1)
10 | abstract class DemoEntitiesDB : RoomDatabase() {
11 | abstract fun demoEntityDAO(): DemoEntityLocalDAO
12 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/paged/DemoEntity.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.paged
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 |
6 | /**
7 | * https://www.zoftino.com/pagination-in-android-using-paging-library
8 | */
9 | @Entity
10 | class DemoEntity() {
11 | @PrimaryKey(autoGenerate = true)
12 | var identifier: Int = 0
13 | var data1: String? = null
14 | var data2: String? = null
15 |
16 | constructor(data1: String, data2: String) : this() {
17 | this.data1 = data1
18 | this.data2 = data2
19 | }
20 |
21 | override fun equals(other: Any?): Boolean {
22 | if (other === this)
23 | return true
24 | val demoEntity = other as DemoEntity?
25 | return demoEntity!!.identifier == this.identifier &&
26 | demoEntity.data1 === demoEntity.data1 &&
27 | demoEntity.data2 === demoEntity.data2
28 | }
29 |
30 | override fun hashCode(): Int {
31 | var result = identifier
32 | result = 31 * result + (data1?.hashCode() ?: 0)
33 | result = 31 * result + (data2?.hashCode() ?: 0)
34 | return result
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/paged/DemoEntityLocalDAO.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.paged
2 |
3 | import androidx.paging.DataSource
4 | import androidx.room.Dao
5 | import androidx.room.Insert
6 | import androidx.room.Query
7 |
8 |
9 | /**
10 | * https://www.zoftino.com/pagination-in-android-using-paging-library
11 | */
12 | @Dao
13 | interface DemoEntityLocalDAO {
14 | //to fetch data required to display in each page
15 | @Query("SELECT * FROM DemoEntity")
16 | fun getAll(): DataSource.Factory
17 |
18 | //this is used to populate db
19 | @Insert
20 | fun insertDemoEntities(demoEntities: List)
21 |
22 | @Query("UPDATE DemoEntity SET data1 = -data1")
23 | fun updateDemoEntities()
24 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/paged/DemoEntityViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.paged
2 |
3 | import android.app.Application
4 | import androidx.lifecycle.LiveData
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.ViewModelProvider
7 | import androidx.paging.LivePagedListBuilder
8 | import androidx.paging.PagedList
9 | import io.reactivex.Completable
10 | import io.reactivex.android.schedulers.AndroidSchedulers
11 | import io.reactivex.schedulers.Schedulers
12 |
13 |
14 | /**
15 | * https://www.zoftino.com/pagination-in-android-using-paging-library
16 | */
17 | class DemoEntityViewModel(val application: Application) : ViewModel() {
18 | //PagedList controls data loading using data source
19 | private val dao: DemoEntityLocalDAO =
20 | LocalRepository.getDemoEntityDB(application).demoEntityDAO()
21 | var demoEntitiesList: LiveData>
22 |
23 | init {
24 | val pagedListConfig = PagedList.Config.Builder()
25 | .setPageSize(20)
26 | .setPrefetchDistance(20)
27 | .setEnablePlaceholders(true)
28 | .build()
29 |
30 | demoEntitiesList = LivePagedListBuilder(dao.getAll(), pagedListConfig).build()
31 | }
32 |
33 | fun updateEntities() {
34 | Completable.fromRunnable { dao.updateDemoEntities() }
35 | .subscribeOn(Schedulers.io())
36 | .observeOn(AndroidSchedulers.mainThread())
37 | .subscribe()
38 | }
39 |
40 | //factory for creating view model,
41 | // required because we need to pass Application to view model object
42 | class DemoEntityViewModelFactory(private val mApplication: Application) :
43 | ViewModelProvider.NewInstanceFactory() {
44 | override fun create(viewModel: Class): T {
45 | return DemoEntityViewModel(mApplication) as T
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/utils/Utils.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.utils
2 |
3 | import android.content.Context
4 | import android.util.TypedValue
5 | import androidx.annotation.AttrRes
6 | import androidx.annotation.ColorInt
7 | import androidx.annotation.RestrictTo
8 | import androidx.core.content.ContextCompat
9 | import androidx.core.content.res.ResourcesCompat
10 |
11 | internal fun Context.getThemeColor(attr: Int): Int {
12 | val tv = TypedValue()
13 | return if (this.theme.resolveAttribute(attr, tv, true)) {
14 | if (tv.resourceId != 0) {
15 | ContextCompat.getColor(this, tv.resourceId)
16 | } else {
17 | tv.data
18 | }
19 | } else {
20 | 0
21 | }
22 | }
23 |
24 |
25 | /**
26 | * a helper method to get the color from an attribute
27 | * @hide
28 | */
29 | @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
30 | fun Context.getThemeColor(@AttrRes attr: Int, @ColorInt def: Int = 0): Int {
31 | val tv = TypedValue()
32 | return if (theme.resolveAttribute(attr, tv, true)) {
33 | if (tv.resourceId != 0) ResourcesCompat.getColor(resources, tv.resourceId, theme) else tv.data
34 | } else def
35 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/view/DraggableFrameLayout.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.view
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import android.widget.FrameLayout
6 | import com.google.android.material.R
7 |
8 |
9 | private val DRAGGED_STATE_SET = intArrayOf(
10 | R.attr.state_dragged,
11 | // When the item is dragged we also set the 'pressed' state so the item background is changed
12 | android.R.attr.state_pressed
13 | )
14 |
15 | class DraggableFrameLayout : FrameLayout {
16 | constructor(context: Context) : super(context)
17 | constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
18 | constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
19 |
20 | var isDragged: Boolean = false
21 | set(value) {
22 | field = value
23 | refreshDrawableState()
24 | invalidate()
25 | }
26 |
27 | override fun onCreateDrawableState(extraSpace: Int): IntArray? {
28 | val drawableState = super.onCreateDrawableState(extraSpace + DRAGGED_STATE_SET.size)
29 | if (isDragged) {
30 | mergeDrawableStates(drawableState, DRAGGED_STATE_SET)
31 | }
32 | return drawableState
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mikepenz/fastadapter/app/view/RecyclerViewBackgroundDrawable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.app.view
2 |
3 | import android.graphics.Canvas
4 | import android.graphics.ColorFilter
5 | import android.graphics.Paint
6 | import android.graphics.PixelFormat
7 | import android.graphics.drawable.Drawable
8 | import androidx.recyclerview.widget.RecyclerView
9 |
10 | // Based on https://stackoverflow.com/a/49825927/1800174
11 | class RecyclerViewBackgroundDrawable internal constructor(private val color: Int) : Drawable() {
12 | private var recyclerView: RecyclerView? = null
13 | private val paint: Paint = Paint().apply {
14 | color = this@RecyclerViewBackgroundDrawable.color
15 | }
16 |
17 | fun attachTo(recyclerView: RecyclerView?) {
18 | this.recyclerView = recyclerView
19 | recyclerView?.background = this
20 | }
21 |
22 | override fun draw(canvas: Canvas) {
23 | val recyclerView = recyclerView ?: return
24 | if (recyclerView.childCount == 0) {
25 | return
26 | }
27 |
28 | var bottom = recyclerView.getChildAt(recyclerView.childCount - 1).bottom
29 | if (bottom >= recyclerView.bottom) {
30 | bottom = recyclerView.bottom
31 | }
32 |
33 | canvas.drawRect(
34 | recyclerView.left.toFloat(),
35 | recyclerView.top.toFloat(),
36 | recyclerView.right.toFloat(),
37 | bottom.toFloat(),
38 | paint
39 | )
40 | }
41 |
42 | override fun setAlpha(alpha: Int) = Unit
43 |
44 | override fun setColorFilter(colorFilter: ColorFilter?) = Unit
45 |
46 | override fun getOpacity(): Int = PixelFormat.OPAQUE
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/alpha_on.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/draggable_state_list_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
-
9 |
10 |
18 |
19 |
20 |
21 | -
22 |
23 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/button_rect_list_normal.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/button_rect_list_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gradient.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_drag_handle.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
22 |
23 |
33 |
34 |
35 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_sample.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
18 |
19 |
27 |
28 |
32 |
33 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/checkbox_sample_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
24 |
25 |
36 |
37 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/draggable_single_line_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
31 |
32 |
41 |
42 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/expandable_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
19 |
20 |
31 |
32 |
43 |
44 |
45 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/icon_item.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
28 |
29 |
40 |
41 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/letter_item.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/native_ad_item.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
15 |
16 |
26 |
27 |
36 |
37 |
51 |
52 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/radiobutton_sample_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
24 |
25 |
36 |
37 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/right_icon_item.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
24 |
35 |
36 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/sample_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
24 |
25 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/section_header_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/simple_image_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
24 |
25 |
26 |
35 |
36 |
49 |
50 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/small_single_line_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
29 |
30 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/cab.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_add.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/refresh.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/search.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/sort.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikepenz/FastAdapter/77761873d8f5c469a3dcc49766e2960826bbe62b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-land/integers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #202020
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 | #FFEB3B
10 | #FDD835
11 | #FFEE58
12 | #8BC34A
13 |
14 |
15 | #F2F2F2
16 |
17 | #FCFCFC
18 |
19 | #F0F0F0
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #03A9F4
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/integers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 300
4 |
5 |
6 | 1
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
14 |
15 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | apply from: 'configurations.gradle'
4 |
5 | ext {
6 | release = [
7 | versionName: "5.7.0",
8 | versionCode: 5070
9 | ]
10 |
11 | setup = [
12 | gradleTools: '7.3.0',
13 | compileSdk : 33,
14 | buildTools : "33.0.0",
15 | minSdk : 16,
16 | targetSdk : 33
17 | ]
18 |
19 | versions = [
20 | recyclerView : '1.2.1',
21 | material : '1.6.1',
22 | appcompat : '1.5.1',
23 | drawerlayout : '1.1.0',
24 | constraintLayout: '2.1.0',
25 | cardview : '1.0.0',
26 | kotlin : '1.7.20',
27 | iconics : '5.2.8',
28 | materialdrawer : '9.0.1',
29 | aboutlib : '10.5.0',
30 | roboelectric : '4.8.2',
31 | detekt : '1.18.1',
32 | paging : "2.1.2",
33 | room : "2.4.3",
34 | lifecycle : "2.3.1"
35 | ]
36 | }
37 |
38 | repositories {
39 | gradlePluginPortal()
40 | mavenCentral()
41 | google()
42 | }
43 | dependencies {
44 | classpath "com.android.tools.build:gradle:${setup.gradleTools}"
45 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
46 | classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${versions.detekt}"
47 | classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${versions.aboutlib}"
48 | }
49 | }
50 |
51 | allprojects {
52 | group "com.mikepenz"
53 |
54 | repositories {
55 | mavenCentral()
56 | google()
57 | }
58 | }
59 |
60 | subprojects {
61 | apply from: "$rootDir/detekt.gradle"
62 |
63 | dependencies {
64 | detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:${versions.detekt}"
65 | }
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/detekt.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "io.gitlab.arturbosch.detekt"
2 |
3 | detekt {
4 | toolVersion = "${versions.detekt}"
5 | //input = files("src/main/kotlin")
6 | config = files(buildscript.sourceFile.getParent().toString() + "/DEV/default-detekt-config.yml")
7 |
8 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | version release.versionName
5 |
6 | android {
7 | compileSdkVersion setup.compileSdk
8 | buildToolsVersion setup.buildTools
9 |
10 | defaultConfig {
11 | minSdkVersion setup.minSdk
12 | targetSdkVersion setup.targetSdk
13 | versionCode release.versionCode
14 | versionName release.versionName
15 |
16 | consumerProguardFiles 'consumer-proguard-rules.pro'
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
22 | }
23 | }
24 | productFlavors {
25 | }
26 | lintOptions {
27 | abortOnError false
28 | }
29 | testOptions {
30 | unitTests {
31 | includeAndroidResources = true
32 | }
33 | }
34 | // specify the artifactId as module-name for kotlin
35 | kotlinOptions.freeCompilerArgs += ["-module-name", POM_ARTIFACT_ID]
36 | }
37 |
38 | dependencies {
39 | implementation project(':fastadapter')
40 |
41 | compileOnly "androidx.databinding:viewbinding:${setup.gradleTools}"
42 | }
43 |
44 | if (project.hasProperty('pushall') || project.hasProperty('library_extensions_binding_only')) {
45 | apply from: '../gradle-release.gradle'
46 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/consumer-proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.mikepenz.fastadapter.binding.**
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-Binding
2 | POM_DESCRIPTION=Binding extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-binding
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/src/main/java/com/mikepenz/fastadapter/binding/AbstractBindingItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.binding
2 |
3 | import android.view.LayoutInflater
4 | import android.view.ViewGroup
5 | import androidx.annotation.CallSuper
6 | import androidx.viewbinding.ViewBinding
7 | import com.mikepenz.fastadapter.IItemVHFactory
8 | import com.mikepenz.fastadapter.items.BaseItem
9 |
10 | /**
11 | * Implements an abstract item simplifying usage with ViewBinding as much as possible.
12 | */
13 | abstract class AbstractBindingItem : BaseItem>(), IItemVHFactory> {
14 |
15 | @CallSuper
16 | override fun bindView(holder: BindingViewHolder, payloads: List) {
17 | super.bindView(holder, payloads)
18 | bindView(holder.binding, payloads)
19 | }
20 |
21 | open fun bindView(binding: Binding, payloads: List) {}
22 |
23 | override fun unbindView(holder: BindingViewHolder) {
24 | super.unbindView(holder)
25 | unbindView(holder.binding)
26 | }
27 |
28 | open fun unbindView(binding: Binding) {}
29 |
30 | override fun attachToWindow(holder: BindingViewHolder) {
31 | super.attachToWindow(holder)
32 | attachToWindow(holder.binding)
33 | }
34 |
35 | open fun attachToWindow(binding: Binding) {}
36 |
37 | override fun detachFromWindow(holder: BindingViewHolder) {
38 | super.detachFromWindow(holder)
39 | detachFromWindow(holder.binding)
40 | }
41 |
42 | open fun detachFromWindow(binding: Binding) {}
43 |
44 | /**
45 | * This method is called by generateView(Context ctx), generateView(Context ctx, ViewGroup parent) and getViewHolder(ViewGroup parent)
46 | * it will generate the ViewBinding. You have to provide the correct binding class.
47 | */
48 | abstract fun createBinding(inflater: LayoutInflater, parent: ViewGroup? = null): Binding
49 |
50 | /** Generates a ViewHolder from this Item with the given parent */
51 | override fun getViewHolder(parent: ViewGroup): BindingViewHolder {
52 | return getViewHolder(createBinding(LayoutInflater.from(parent.context), parent))
53 | }
54 |
55 | /** Generates a ViewHolder from this Item with the given ViewBinding */
56 | open fun getViewHolder(viewBinding: Binding): BindingViewHolder {
57 | return BindingViewHolder(viewBinding)
58 | }
59 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/src/main/java/com/mikepenz/fastadapter/binding/BaseBindingItemVHFactory.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.binding
2 |
3 | import android.view.LayoutInflater
4 | import android.view.ViewGroup
5 | import androidx.viewbinding.ViewBinding
6 | import com.mikepenz.fastadapter.IItemVHFactory
7 |
8 | /**
9 | * Implements an abstract item simplifying usage with ViewBinding.
10 | */
11 | abstract class BaseBindingItemVHFactory> : IItemVHFactory {
12 | /**
13 | * This method is called by generateView(Context ctx), generateView(Context ctx, ViewGroup parent) and getViewHolder(ViewGroup parent)
14 | * it will generate the ViewBinding. You have to provide the correct binding class.
15 | */
16 | abstract fun createBinding(inflater: LayoutInflater, parent: ViewGroup? = null): VB
17 |
18 | /** Generates a ViewHolder from this Item with the given parent */
19 | override fun getViewHolder(parent: ViewGroup): VH {
20 | return getViewHolder(createBinding(LayoutInflater.from(parent.context), parent))
21 | }
22 |
23 | /** Generates a ViewHolder from this Item with the given ViewBinding */
24 | abstract fun getViewHolder(viewBinding: VB): VH
25 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/src/main/java/com/mikepenz/fastadapter/binding/BindingViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.binding
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 | import androidx.viewbinding.ViewBinding
5 |
6 | /**
7 | * A Simple [ViewHolder] providing easier support for ViewBinding
8 | */
9 | open class BindingViewHolder(val binding: VB) : RecyclerView.ViewHolder(binding.root)
--------------------------------------------------------------------------------
/fastadapter-extensions-binding/src/main/java/com/mikepenz/fastadapter/binding/ModelAbstractBindingItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.binding
2 |
3 | import androidx.viewbinding.ViewBinding
4 | import com.mikepenz.fastadapter.IModelItem
5 |
6 | /**
7 | * Provides a convenient abstract class for having a split model and item (with binding)
8 | */
9 | abstract class ModelAbstractBindingItem(override var model: Model) :
10 | AbstractBindingItem(), IModelItem>
11 |
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/consumer-proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.mikepenz.fastadapter.diff.**
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-Diff
2 | POM_DESCRIPTION=Commons extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-diff
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/src/main/java/com/mikepenz/fastadapter/diff/DiffCallback.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.diff
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | /**
6 | * DiffCallback used to efficiently update the items inside the list with the new DiffUtils
7 | */
8 | interface DiffCallback- {
9 | /**
10 | * Called by the DiffUtil to decide whether two object represent the same Item.
11 | * For example, if your items have unique ids, this method should check their id equality.
12 | *
13 | * @param oldItem the item in the old list
14 | * @param newItem the item in the new list
15 | * @return True if the two items represent the same object or false if they are different.
16 | */
17 | fun areItemsTheSame(oldItem: Item, newItem: Item): Boolean
18 |
19 | /**
20 | * Called by the DiffUtil when it wants to check whether two items have the same data.
21 | * DiffUtil uses this information to detect if the contents of an item has changed.
22 | * DiffUtil uses this method to check equality instead of [Object.equals]
23 | * so that you can change its behavior depending on your UI.
24 | * For example, if you are using DiffUtil with a
25 | * [RecyclerView.Adapter], you should
26 | * return whether the items' visual representations are the same.
27 | * This method is called only if #areItemsTheSame(Item, Item) returns
28 | * `true` for these items.
29 | *
30 | * @param oldItem the item in the old list
31 | * @param newItem the item in the new list
32 | * @return True if the contents of the items are the same or false if they are different.
33 | */
34 | fun areContentsTheSame(oldItem: Item, newItem: Item): Boolean
35 |
36 | /**
37 | * When {#areItemsTheSame(Item, Item)} returns `true` for two items and
38 | * {#areContentsTheSame(Item, Item)} returns false for them, DiffUtil
39 | * calls this method to get a payload about the change.
40 | * For example, if you are using DiffUtil with [RecyclerView], you can return the
41 | * particular field that changed in the item and your
42 | * [ItemAnimator][RecyclerView.ItemAnimator] can use that
43 | * information to run the correct animation.
44 | * Default implementation returns `null`.
45 | *
46 | * @param oldItemPosition The position of the item in the old list
47 | * @param newItemPosition The position of the item in the new list
48 | * @return A payload object that represents the change between the two items.
49 | */
50 | fun getChangePayload(oldItem: Item, oldItemPosition: Int, newItem: Item, newItemPosition: Int): Any?
51 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/src/main/java/com/mikepenz/fastadapter/diff/DiffCallbackImpl.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.diff
2 |
3 | import com.mikepenz.fastadapter.IItem
4 |
5 | /**
6 | * Created by mikepenz on 24.08.16.
7 | */
8 | internal class DiffCallbackImpl
- > : DiffCallback
- {
9 | override fun areItemsTheSame(oldItem: Item, newItem: Item): Boolean {
10 | return oldItem.identifier == newItem.identifier
11 | }
12 |
13 | override fun areContentsTheSame(oldItem: Item, newItem: Item): Boolean {
14 | return oldItem == newItem
15 | }
16 |
17 | override fun getChangePayload(oldItem: Item, oldItemPosition: Int, newItem: Item, newItemPosition: Int): Any? {
18 | return null
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/src/test/java/com/mikepenz/fastadapter/diff/TestDataGenerator.java:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.diff;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by fabianterhorst on 29.03.16.
10 | */
11 | public class TestDataGenerator {
12 | public static List genTestItemList(int size) {
13 | List list = new ArrayList<>();
14 | for (int i = 0; i < size; i++) {
15 | TestItem testItem = genTestItem(i);
16 | list.add(testItem);
17 | }
18 | return list;
19 | }
20 |
21 | @NonNull
22 | public static TestItem genTestItem(int i) {
23 | TestItem item = new TestItem(i + "");
24 | item.setIdentifier(i);
25 | return item;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/src/test/java/com/mikepenz/fastadapter/diff/TestItem.java:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.diff;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.FrameLayout;
7 |
8 | import androidx.annotation.Nullable;
9 | import androidx.recyclerview.widget.RecyclerView;
10 |
11 | import com.mikepenz.fastadapter.items.AbstractItem;
12 |
13 | import java.util.Objects;
14 |
15 | /**
16 | * Created by fabianterhorst on 29.03.16.
17 | */
18 | public class TestItem extends AbstractItem {
19 |
20 | private String name;
21 |
22 | public TestItem(String name) {
23 | this.name = name;
24 | }
25 |
26 | @Override
27 | public int getLayoutRes() {
28 | return -1;
29 | }
30 |
31 | @Override
32 | public int getType() {
33 | return -1;
34 | }
35 |
36 | @Override
37 | public View createView(final Context ctx, @Nullable final ViewGroup parent) {
38 | return new FrameLayout(ctx);
39 | }
40 |
41 | @Override
42 | public ViewHolder getViewHolder(View v) {
43 | return new ViewHolder(v);
44 | }
45 |
46 | public static class ViewHolder extends RecyclerView.ViewHolder {
47 | public ViewHolder(View view) {
48 | super(view);
49 | }
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return "TestItem{" +
55 | "name='" + name + '\'' +
56 | '}';
57 | }
58 |
59 | @Override
60 | public boolean equals(Object o) {
61 | if (this == o) return true;
62 | if (o == null || getClass() != o.getClass()) return false;
63 | if (!super.equals(o)) return false;
64 | TestItem testItem = (TestItem) o;
65 | return Objects.equals(name, testItem.name);
66 | }
67 |
68 | @Override
69 | public int hashCode() {
70 | return Objects.hash(super.hashCode(), name);
71 | }
72 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-diff/src/test/resources/robolectric.properties:
--------------------------------------------------------------------------------
1 | constants=com.mikepenz.fastadapter.BuildConfig
2 | packageName=com.mikepenz.fastadapter
3 | sdk=21
4 |
--------------------------------------------------------------------------------
/fastadapter-extensions-drag/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-drag/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | version release.versionName
5 |
6 | android {
7 | compileSdkVersion setup.compileSdk
8 | buildToolsVersion setup.buildTools
9 |
10 | defaultConfig {
11 | minSdkVersion setup.minSdk
12 | targetSdkVersion setup.targetSdk
13 | versionCode release.versionCode
14 | versionName release.versionName
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
20 | }
21 | }
22 | productFlavors {
23 | }
24 | lintOptions {
25 | abortOnError false
26 | }
27 | testOptions {
28 | unitTests {
29 | includeAndroidResources = true
30 | }
31 | }
32 | // specify the artifactId as module-name for kotlin
33 | kotlinOptions.freeCompilerArgs += ["-module-name", POM_ARTIFACT_ID]
34 | }
35 |
36 | dependencies {
37 | implementation project(':fastadapter')
38 | }
39 |
40 | if (project.hasProperty('pushall') || project.hasProperty('library_extensions_drag_only')) {
41 | apply from: '../gradle-release.gradle'
42 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-drag/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-Drag
2 | POM_DESCRIPTION=Commons extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-drag
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-drag/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-drag/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-drag/src/main/java/com/mikepenz/fastadapter/drag/IDraggable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.drag
2 |
3 | /**
4 | * Created by mikepenz on 30.12.15.
5 | */
6 | interface IDraggable {
7 | /** @return true if draggable */
8 | val isDraggable: Boolean
9 | }
10 |
--------------------------------------------------------------------------------
/fastadapter-extensions-drag/src/main/java/com/mikepenz/fastadapter/drag/IExtendedDraggable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.drag
2 |
3 | import android.view.View
4 | import androidx.recyclerview.widget.ItemTouchHelper
5 | import androidx.recyclerview.widget.RecyclerView
6 |
7 | /**
8 | * Created by mikepenz on 30.12.15.
9 | */
10 | interface IExtendedDraggable : IDraggable {
11 |
12 | /**
13 | * This returns the ItemTouchHelper
14 | *
15 | * @return the ItemTouchHelper if item has one or null
16 | */
17 | val touchHelper: ItemTouchHelper?
18 |
19 | /**
20 | * This method returns the drag view inside the item
21 | * use this with (@withTouchHelper) to start dragging when this view is touched
22 | *
23 | * @param viewHolder the ViewHolder
24 | * @return the view that should start the dragging or null
25 | */
26 | fun getDragView(viewHolder: VH): View?
27 | }
28 |
--------------------------------------------------------------------------------
/fastadapter-extensions-drag/src/main/java/com/mikepenz/fastadapter/drag/ItemTouchCallback.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.drag
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | interface ItemTouchCallback {
6 |
7 | /**
8 | * Called when an item enters drag state
9 | *
10 | * @param viewHolder dragged ViewHolder
11 | */
12 | fun itemTouchStartDrag(viewHolder: RecyclerView.ViewHolder) {}
13 |
14 | /**
15 | * Called when an item leaves drag state
16 | *
17 | * @param viewHolder dropped ViewHolder
18 | */
19 | fun itemTouchStopDrag(viewHolder: RecyclerView.ViewHolder) {}
20 |
21 | /**
22 | * Called when an item has been dragged
23 | * This event is called on every item in a dragging chain
24 | *
25 | * @param oldPosition start position
26 | * @param newPosition end position
27 | * @return true if moved otherwise false
28 | */
29 | fun itemTouchOnMove(oldPosition: Int, newPosition: Int): Boolean
30 |
31 | /**
32 | * Called when an item has been dropped
33 | * This event is only called :
34 | * - Once when the user stopped dragging the item
35 | * - If the corresponding AbstractItem implements {@link IDraggable}
36 | *
37 | * @param oldPosition start position
38 | * @param newPosition end position
39 | */
40 | fun itemTouchDropped(oldPosition: Int, newPosition: Int) {}
41 | }
42 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-Expandable
2 | POM_DESCRIPTION=Commons extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-expandable
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/src/main/java/com/mikepenz/fastadapter/expandable/ExpandableExtensionFactory.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.expandable
2 |
3 | import com.mikepenz.fastadapter.FastAdapter
4 | import com.mikepenz.fastadapter.GenericItem
5 | import com.mikepenz.fastadapter.extensions.ExtensionFactory
6 |
7 | class ExpandableExtensionFactory : ExtensionFactory> {
8 |
9 | override val clazz = ExpandableExtension::class.java
10 |
11 | override fun create(fastAdapter: FastAdapter): ExpandableExtension<*>? {
12 | return ExpandableExtension(fastAdapter)
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/src/main/java/com/mikepenz/fastadapter/expandable/items/AbstractExpandableItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.expandable.items
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 | import com.mikepenz.fastadapter.*
5 | import com.mikepenz.fastadapter.items.AbstractItem
6 |
7 | abstract class AbstractExpandableItem :
8 | AbstractItem(),
9 | IItem,
10 | IExpandable {
11 | private val _subItems = MutableSubItemList>(this)
12 |
13 | override var isExpanded: Boolean = false
14 | override var parent: IParentItem<*>? = null
15 | override var subItems: MutableList>
16 | set(value) = _subItems.setNewList(value)
17 | get() = _subItems
18 |
19 | override val isAutoExpanding: Boolean = true
20 | override var isSelectable: Boolean
21 | get() = subItems.isEmpty()
22 | set(_) {}
23 | }
24 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/src/main/java/com/mikepenz/fastadapter/expandable/items/ModelAbstractExpandableItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.expandable.items
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 | import com.mikepenz.fastadapter.IExpandable
5 | import com.mikepenz.fastadapter.IParentItem
6 | import com.mikepenz.fastadapter.ISubItem
7 | import com.mikepenz.fastadapter.MutableSubItemList
8 | import com.mikepenz.fastadapter.items.ModelAbstractItem
9 |
10 | abstract class ModelAbstractExpandableItem(model: Model) :
11 | ModelAbstractItem(model),
12 | IExpandable {
13 | private val _subItems = MutableSubItemList>(this)
14 |
15 | override var isExpanded: Boolean = false
16 | override var parent: IParentItem<*>? = null
17 | override var subItems: MutableList>
18 | set(value) = _subItems.setNewList(value)
19 | get() = _subItems
20 |
21 | override val isAutoExpanding: Boolean = true
22 | override var isSelectable: Boolean
23 | get() = _subItems.isEmpty()
24 | set(_) {}
25 | }
26 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/src/test/java/com/mikepenz/fastadapter/ExpandableTestItem.java:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter;
2 |
3 | import android.view.View;
4 |
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | import com.mikepenz.fastadapter.items.AbstractItem;
8 |
9 | import org.jetbrains.annotations.NotNull;
10 | import org.jetbrains.annotations.Nullable;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | /**
16 | * Created by fabianterhorst on 29.03.16.
17 | */
18 | public class ExpandableTestItem extends AbstractItem implements IExpandable {
19 |
20 | private List> mSubItems = new ArrayList<>();
21 | private IParentItem> mParent;
22 | private boolean mExpanded = false;
23 |
24 | @Override
25 | public int getLayoutRes() {
26 | return -1;
27 | }
28 |
29 | @Override
30 | public int getType() {
31 | return -1;
32 | }
33 |
34 | @Override
35 | public boolean isExpanded() {
36 | return mExpanded;
37 | }
38 |
39 | @Override
40 | public void setExpanded(boolean expanded) {
41 | mExpanded = expanded;
42 | }
43 |
44 | @NotNull
45 | @Override
46 | public List> getSubItems() {
47 | return mSubItems;
48 | }
49 |
50 | @Override
51 | public void setSubItems(@NotNull List> list) {
52 | this.mSubItems = list;
53 | }
54 |
55 | @Override
56 | public boolean isAutoExpanding() {
57 | return true;
58 | }
59 |
60 | @Override
61 | public void setParent(@Nullable IParentItem> parent) {
62 | this.mParent = parent;
63 | }
64 |
65 | @Nullable
66 | @Override
67 | public IParentItem> getParent() {
68 | return mParent;
69 | }
70 |
71 | @Override
72 | public ViewHolder getViewHolder(View v) {
73 | return new ViewHolder(v);
74 | }
75 |
76 |
77 | public static class ViewHolder extends RecyclerView.ViewHolder {
78 | public ViewHolder(View view) {
79 | super(view);
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/fastadapter-extensions-expandable/src/test/java/com/mikepenz/fastadapter/NoneExpandableTestItem.java:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter;
2 |
3 | import android.view.View;
4 |
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | import com.mikepenz.fastadapter.items.AbstractItem;
8 |
9 | /**
10 | * Created by fabianterhorst on 29.03.16.
11 | */
12 | public class NoneExpandableTestItem extends AbstractItem {
13 |
14 | @Override
15 | public int getLayoutRes() {
16 | return -1;
17 | }
18 |
19 | @Override
20 | public int getType() {
21 | return -1;
22 | }
23 |
24 | @Override
25 | public ViewHolder getViewHolder(View v) {
26 | return new ViewHolder(v);
27 | }
28 |
29 | public static class ViewHolder extends RecyclerView.ViewHolder {
30 | public ViewHolder(View view) {
31 | super(view);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/fastadapter-extensions-paged/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-paged/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | version release.versionName
5 |
6 | android {
7 | compileSdkVersion setup.compileSdk
8 | buildToolsVersion setup.buildTools
9 |
10 | defaultConfig {
11 | minSdkVersion setup.minSdk
12 | targetSdkVersion setup.targetSdk
13 | versionCode release.versionCode
14 | versionName release.versionName
15 |
16 | consumerProguardFiles 'consumer-proguard-rules.pro'
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
22 | }
23 | }
24 | productFlavors {
25 | }
26 | lintOptions {
27 | abortOnError false
28 | }
29 | testOptions {
30 | unitTests {
31 | includeAndroidResources = true
32 | }
33 | }
34 | // specify the artifactId as module-name for kotlin
35 | kotlinOptions.freeCompilerArgs += ["-module-name", POM_ARTIFACT_ID]
36 | }
37 |
38 | dependencies {
39 | implementation project(':fastadapter')
40 |
41 | api "androidx.paging:paging-runtime-ktx:${versions.paging}"
42 | }
43 |
44 | if (project.hasProperty('pushall') || project.hasProperty('library_extensions_paged_only')) {
45 | apply from: '../gradle-release.gradle'
46 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-paged/consumer-proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.mikepenz.fastadapter.paged.**
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-paged/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-Paged
2 | POM_DESCRIPTION=Commons extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-paged
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-paged/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-paged/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-scroll/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-scroll/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | version release.versionName
5 |
6 | android {
7 | compileSdkVersion setup.compileSdk
8 | buildToolsVersion setup.buildTools
9 |
10 | defaultConfig {
11 | minSdkVersion setup.minSdk
12 | targetSdkVersion setup.targetSdk
13 | versionCode release.versionCode
14 | versionName release.versionName
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
20 | }
21 | }
22 | productFlavors {
23 | }
24 | lintOptions {
25 | abortOnError false
26 | }
27 | testOptions {
28 | unitTests {
29 | includeAndroidResources = true
30 | }
31 | }
32 | // specify the artifactId as module-name for kotlin
33 | kotlinOptions.freeCompilerArgs += ["-module-name", POM_ARTIFACT_ID]
34 | }
35 |
36 | dependencies {
37 | implementation project(':fastadapter')
38 | }
39 |
40 | if (project.hasProperty('pushall') || project.hasProperty('library_extensions_scroll_only')) {
41 | apply from: '../gradle-release.gradle'
42 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-scroll/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-Scroll
2 | POM_DESCRIPTION=Commons extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-scroll
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-scroll/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-scroll/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-scroll/src/main/java/androidx/recyclerview/widget/com_mikepenz_fastadapter_extensions_scroll.kt:
--------------------------------------------------------------------------------
1 | package androidx.recyclerview.widget
2 |
3 | import androidx.recyclerview.widget.RecyclerView.LayoutManager
4 |
5 | /**
6 | * Why the class name? Because it guarantees zero naming conflicts!
7 | *
8 | * With this really long name, I recommend `import static *.*` !
9 | *
10 | * Created by jayson on 3/27/2016.
11 | */
12 | @Suppress("all")
13 | object com_mikepenz_fastadapter_extensions_scroll {
14 |
15 | @JvmStatic fun postOnRecyclerView(layoutManager: LayoutManager, action: Runnable): Boolean {
16 | if (layoutManager.mRecyclerView != null) {
17 | layoutManager.mRecyclerView.post(action)
18 | return true
19 | }
20 | return false
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/fastadapter-extensions-swipe/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-swipe/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | version release.versionName
5 |
6 | android {
7 | compileSdkVersion setup.compileSdk
8 | buildToolsVersion setup.buildTools
9 |
10 | defaultConfig {
11 | minSdkVersion setup.minSdk
12 | targetSdkVersion setup.targetSdk
13 | versionCode release.versionCode
14 | versionName release.versionName
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
20 | }
21 | }
22 | productFlavors {
23 | }
24 | lintOptions {
25 | abortOnError false
26 | }
27 | testOptions {
28 | unitTests {
29 | includeAndroidResources = true
30 | }
31 | }
32 | // specify the artifactId as module-name for kotlin
33 | kotlinOptions.freeCompilerArgs += ["-module-name", POM_ARTIFACT_ID]
34 | }
35 |
36 | dependencies {
37 | implementation project(':fastadapter')
38 | }
39 |
40 | if (project.hasProperty('pushall') || project.hasProperty('library_extensions_swipe_only')) {
41 | apply from: '../gradle-release.gradle'
42 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-swipe/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-Swipe
2 | POM_DESCRIPTION=Commons extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-swipe
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-swipe/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-swipe/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-swipe/src/main/java/com/mikepenz/fastadapter/swipe/Extensions.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.swipe
2 |
3 | import androidx.recyclerview.widget.ItemTouchHelper
4 |
5 | /**
6 | * Retrieve the swipe directions allowed for this [ISwipeable] element.
7 | */
8 | internal fun ISwipeable.getSwipeDirs(dirs: Int): Int {
9 | var directions = dirs
10 | if (!isDirectionSupported(ItemTouchHelper.LEFT)) {
11 | directions = directions and ItemTouchHelper.LEFT.inv()
12 | }
13 | if (!isDirectionSupported(ItemTouchHelper.RIGHT)) {
14 | directions = directions and ItemTouchHelper.RIGHT.inv()
15 | }
16 | return directions
17 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-swipe/src/main/java/com/mikepenz/fastadapter/swipe/IDrawerSwipeableViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.swipe
2 |
3 | import android.view.View
4 |
5 | /**
6 | * Created by Robb on 03.07.20.
7 | */
8 | interface IDrawerSwipeableViewHolder {
9 | /** @return View that will move with the swipe gesture inside the ViewHolder */
10 | val swipeableView: View
11 | }
12 |
--------------------------------------------------------------------------------
/fastadapter-extensions-swipe/src/main/java/com/mikepenz/fastadapter/swipe/ISwipeable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.swipe
2 |
3 | /**
4 | * Created by mikepenz on 30.12.15.
5 | */
6 | interface ISwipeable {
7 | /** @return true if swipeable */
8 | val isSwipeable: Boolean
9 |
10 | /**
11 | * @return true if the provided direction is supported
12 | *
13 | * This function will only be called if [isSwipeable] returns true
14 | */
15 | fun isDirectionSupported(direction: Int): Boolean = true
16 | }
17 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | version release.versionName
5 |
6 | android {
7 | compileSdkVersion setup.compileSdk
8 | buildToolsVersion setup.buildTools
9 |
10 | defaultConfig {
11 | minSdkVersion setup.minSdk
12 | targetSdkVersion setup.targetSdk
13 | versionCode release.versionCode
14 | versionName release.versionName
15 |
16 | consumerProguardFiles 'consumer-proguard-rules.pro'
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
22 | }
23 | }
24 | productFlavors {
25 | }
26 | lintOptions {
27 | abortOnError false
28 | }
29 | // specify the artifactId as module-name for kotlin
30 | kotlinOptions.freeCompilerArgs += ["-module-name", POM_ARTIFACT_ID]
31 | }
32 |
33 | dependencies {
34 | implementation project(':fastadapter')
35 |
36 | implementation "com.google.android.material:material:${versions.material}"
37 | }
38 |
39 | if (project.hasProperty('pushall') || project.hasProperty('library_extensions_ui_only')) {
40 | apply from: '../gradle-release.gradle'
41 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/consumer-proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.mikepenz.fastadapter.commons.utils.**
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-UI
2 | POM_DESCRIPTION=Commons extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-ui
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/src/main/java/com/mikepenz/fastadapter/ui/items/ProgressItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.ui.items
2 |
3 | import android.view.View
4 | import android.widget.ProgressBar
5 | import androidx.recyclerview.widget.RecyclerView
6 | import com.mikepenz.fastadapter.items.AbstractItem
7 | import com.mikepenz.fastadapter.ui.R
8 | import com.mikepenz.fastadapter.ui.utils.FastAdapterUIUtils
9 |
10 | class ProgressItem : AbstractItem() {
11 |
12 | override val type: Int
13 | get() = R.id.progress_item_id
14 |
15 | override val layoutRes: Int
16 | get() = R.layout.progress_item
17 |
18 | override fun bindView(holder: ViewHolder, payloads: List) {
19 | super.bindView(holder, payloads)
20 | if (isEnabled) {
21 | holder.itemView.setBackgroundResource(FastAdapterUIUtils.getSelectableBackground(holder.itemView.context))
22 | }
23 | }
24 |
25 | override fun getViewHolder(v: View): ViewHolder = ViewHolder(v)
26 |
27 | class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
28 | private var progressBar: ProgressBar = view.findViewById(R.id.progress_bar)
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/src/main/java/com/mikepenz/fastadapter/ui/utils/FixStateListDrawable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.ui.utils
2 |
3 | import android.R
4 | import android.annotation.SuppressLint
5 | import android.content.res.ColorStateList
6 | import android.graphics.PorterDuff
7 | import android.graphics.drawable.Drawable
8 | import android.graphics.drawable.StateListDrawable
9 |
10 | /**
11 | * http://stackoverflow.com/questions/7979440/android-cloning-a-drawable-in-order-to-make-a-statelistdrawable-with-filters
12 | * http://stackoverflow.com/users/2075875/malachiasz
13 | */
14 | @SuppressLint("InlinedApi")
15 | class FixStateListDrawable : StateListDrawable {
16 | var color: ColorStateList?
17 |
18 | constructor(drawable: Drawable, color: ColorStateList?) : super() {
19 | var drawable = drawable
20 | drawable = drawable.mutate()
21 | addState(intArrayOf(R.attr.state_selected), drawable)
22 | addState(intArrayOf(), drawable)
23 | this.color = color
24 | }
25 |
26 | constructor(drawable: Drawable, selectedDrawable: Drawable, color: ColorStateList?) : super() {
27 | var drawable = drawable
28 | var selectedDrawable = selectedDrawable
29 | drawable = drawable.mutate()
30 | selectedDrawable = selectedDrawable.mutate()
31 | addState(intArrayOf(R.attr.state_selected), selectedDrawable)
32 | addState(intArrayOf(), drawable)
33 | this.color = color
34 | }
35 |
36 | override fun onStateChange(states: IntArray): Boolean {
37 | val color = color
38 | if (color != null) {
39 | super.setColorFilter(color.getColorForState(states, color.defaultColor), PorterDuff.Mode.SRC_IN)
40 | }
41 | return super.onStateChange(states)
42 | }
43 |
44 | override fun isStateful(): Boolean {
45 | return true
46 | }
47 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/src/main/res/layout/progress_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/src/main/res/layout/single_line_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
32 |
33 |
41 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/src/main/res/layout/three_line_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
26 |
27 |
36 |
37 |
47 |
48 |
49 |
57 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/src/main/res/layout/two_line_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
29 |
30 |
38 |
39 |
49 |
50 |
51 |
59 |
--------------------------------------------------------------------------------
/fastadapter-extensions-ui/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | version release.versionName
5 |
6 | android {
7 | compileSdkVersion setup.compileSdk
8 | buildToolsVersion setup.buildTools
9 |
10 | defaultConfig {
11 | minSdkVersion setup.minSdk
12 | targetSdkVersion setup.targetSdk
13 | versionCode release.versionCode
14 | versionName release.versionName
15 |
16 | consumerProguardFiles 'consumer-proguard-rules.pro'
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
22 | }
23 | }
24 | productFlavors {
25 | }
26 | lintOptions {
27 | abortOnError false
28 | }
29 | // specify the artifactId as module-name for kotlin
30 | kotlinOptions.freeCompilerArgs += ["-module-name", POM_ARTIFACT_ID]
31 | }
32 |
33 | dependencies {
34 | implementation project(':fastadapter')
35 | implementation project(':fastadapter-extensions-expandable')
36 | implementation project(':fastadapter-extensions-swipe')
37 | implementation project(':fastadapter-extensions-drag')
38 |
39 | implementation "com.google.android.material:material:${versions.material}"
40 | }
41 |
42 | if (project.hasProperty('pushall') || project.hasProperty('library_extensions_utils_only')) {
43 | apply from: '../gradle-release.gradle'
44 | }
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/consumer-proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.mikepenz.fastadapter.commons.utils.**
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library-Extensions-Utils
2 | POM_DESCRIPTION=Commons extension for the FastAdapter library. The bullet proof, fast and easy to use adapter library.
3 | POM_ARTIFACT_ID=fastadapter-extensions-utils
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/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 /Development/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 |
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/src/main/java/com/mikepenz/fastadapter/adapters/FastItemAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.adapters
2 |
3 | import com.mikepenz.fastadapter.FastAdapter
4 | import com.mikepenz.fastadapter.GenericItem
5 | import com.mikepenz.fastadapter.IAdapter
6 | import com.mikepenz.fastadapter.IItemAdapter
7 | import com.mikepenz.fastadapter.adapters.ItemAdapter.Companion.items
8 |
9 | /**
10 | * Kotlin type alias to simplify usage for an all accepting FastItemAdapter
11 | */
12 | typealias GenericFastItemAdapter = FastItemAdapter
13 |
14 | /**
15 | * Created by mikepenz on 18.01.16.
16 | */
17 | open class FastItemAdapter- (
18 | /** @return the internal created [ItemAdapter] */
19 | val itemAdapter: ItemAdapter
- = items()
20 | ) : IItemAdapter
- by itemAdapter, FastAdapter
- () {
21 |
22 | /** @return the filter used to filter items */
23 | val itemFilter: ItemFilter<*, Item>
24 | get() = itemAdapter.itemFilter
25 |
26 | /** ctor */
27 | init {
28 | addAdapter>(0, itemAdapter)
29 | cacheSizes()
30 | }
31 |
32 | /**
33 | * Defines if the IdDistributor is used to provide an ID to all added items which do not yet define an id
34 | *
35 | * @param useIdDistributor false if the IdDistributor shouldn't be used
36 | * @return this
37 | */
38 | @Deprecated(message = "Use the isUseIdDistributor property getter", replaceWith = ReplaceWith("isUseIdDistributor"), level = DeprecationLevel.WARNING)
39 | open fun withUseIdDistributor(useIdDistributor: Boolean): FastItemAdapter
- {
40 | itemAdapter.isUseIdDistributor = useIdDistributor
41 | return this
42 | }
43 |
44 | /**
45 | * Removes a range of items starting with the given position within the existing icons
46 | *
47 | * @param position the global position
48 | * @param itemCount the count of items removed
49 | */
50 | @Deprecated(message = "removeItemRange is deprecated", replaceWith = ReplaceWith("removeRange"), level = DeprecationLevel.WARNING)
51 | open fun removeItemRange(position: Int, itemCount: Int): FastItemAdapter
- {
52 | removeRange(position, itemCount)
53 | return this
54 | }
55 |
56 | /** Convenient open functions, to force to remap all possible types for the RecyclerView */
57 | open fun remapMappedTypes() {
58 | itemAdapter.remapMappedTypes()
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/src/main/java/com/mikepenz/fastadapter/adapters/WrapAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.adapters
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 | import com.mikepenz.fastadapter.IItem
5 |
6 | /**
7 | * Created by mikepenz on 03.03.16.
8 | */
9 | class WrapAdapter
- , VH : RecyclerView.ViewHolder>(items: List
- ) : AbstractWrapAdapter
- (items) {
10 |
11 | override var items: List
- = emptyList()
12 | set(items) {
13 | field = items
14 | notifyDataSetChanged()
15 | }
16 |
17 | override fun shouldInsertItemAtPosition(position: Int): Boolean {
18 | if (adapter?.itemCount ?: 0 > 0 && items.isNotEmpty()) {
19 | val itemsInBetween = (adapter?.itemCount ?: 0 + items.size) / (items.size + 1) + 1
20 | return (position + 1) % itemsInBetween == 0
21 | }
22 | return false
23 | }
24 |
25 | override fun itemInsertedBeforeCount(position: Int): Int {
26 | if (adapter?.itemCount ?: 0 > 0 && items.isNotEmpty()) {
27 | val itemsInBetween = (adapter?.itemCount ?: 0 + items.size) / (items.size + 1) + 1
28 | return position / itemsInBetween
29 | }
30 | return 0
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/fastadapter-extensions-utils/src/main/java/com/mikepenz/fastadapter/utils/DragDropUtil.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.utils
2 |
3 | import android.view.MotionEvent
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.mikepenz.fastadapter.IItemAdapter
6 | import com.mikepenz.fastadapter.drag.IExtendedDraggable
7 |
8 | /**
9 | * Created by flisar on 30.09.2016.
10 | */
11 | object DragDropUtil {
12 | /**
13 | * This functions binds the view's touch listener to start the drag via the touch helper…
14 | *
15 | * @param holder the view holder
16 | * @param holder the item
17 | */
18 | @JvmStatic fun bindDragHandle(holder: RecyclerView.ViewHolder, item: IExtendedDraggable) {
19 | // if necessary, init the drag handle, which will start the drag when touched
20 | if (item.touchHelper != null) {
21 | item.getDragView(holder)?.setOnTouchListener { _, event ->
22 | if (event.actionMasked == MotionEvent.ACTION_DOWN) {
23 | if (item.isDraggable)
24 | item.touchHelper!!.startDrag(holder)
25 | }
26 | false
27 | }
28 | }
29 | }
30 |
31 | /**
32 | * This functions handles the default drag and drop move event
33 | * It takes care to move all items one by one within the passed in positions
34 | *
35 | * @param itemAdapter the adapter
36 | * @param oldPosition the start position of the move
37 | * @param newPosition the end position of the move
38 | */
39 | @JvmStatic fun onMove(itemAdapter: IItemAdapter<*, *>, oldPosition: Int, newPosition: Int) {
40 | // necessary, because the positions passed to this function may be jumping in case of
41 | // that the recycler view is scrolled while holding an item outside of the recycler view
42 | if (oldPosition < newPosition) {
43 | for (i in oldPosition + 1..newPosition) {
44 | itemAdapter.move(i, i - 1)
45 | }
46 | } else {
47 | for (i in oldPosition - 1 downTo newPosition) {
48 | itemAdapter.move(i, i + 1)
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/fastadapter/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/fastadapter/consumer-proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn javax.annotation.Nullable
2 | -dontwarn javax.annotation.ParametersAreNonnullByDefault
3 |
--------------------------------------------------------------------------------
/fastadapter/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=FastAdapter Library
2 | POM_DESCRIPTION=The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
3 | POM_ARTIFACT_ID=fastadapter
4 | POM_PACKAGING=aar
5 |
--------------------------------------------------------------------------------
/fastadapter/proguard-rules.txt:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Entwicklung/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the ProGuard
5 | # include property in project.properties.
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 | #}
--------------------------------------------------------------------------------
/fastadapter/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/AbstractAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | /**
4 | * Created by mikepenz on 27.12.15.
5 | */
6 | abstract class AbstractAdapter
- : IAdapter
- {
7 | override var fastAdapter: FastAdapter
- ? = null
8 |
9 | /** The position of this Adapter in the FastAdapter */
10 | override var order: Int = -1
11 | }
12 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | /**
4 | * Kotlin type alias to simplify usage for an all accepting IAdapter
5 | */
6 | typealias GenericAdapter = IAdapter
7 |
8 | /**
9 | * Created by mikepenz on 27.12.15.
10 | */
11 | interface IAdapter
- {
12 |
13 | /** Defines the FastAdapter which manages all the core logic */
14 | var fastAdapter: FastAdapter
- ?
15 |
16 | /** Defines the position of this Adapter in the FastAdapter */
17 | var order: Int
18 |
19 | /** Defines the count of items of THIS adapter */
20 | val adapterItemCount: Int
21 |
22 | /** Defines the list of defined items within THIS adapter */
23 | val adapterItems: List
-
24 |
25 | /**
26 | * @param position the relative position
27 | * @return the item at the given relative position within this adapter
28 | */
29 | fun getAdapterItem(position: Int): Item
30 |
31 | /**
32 | * @param position the relative position
33 | * @return the item at the given relative position within this adapter if it has been loaded
34 | */
35 | fun peekAdapterItem(position: Int): Item? {
36 | return getAdapterItem(position)
37 | }
38 |
39 | /**
40 | * Searches for the given item and calculates its relative position
41 | *
42 | * @param item the item which is searched for
43 | * @return the relative position
44 | */
45 | fun getAdapterPosition(item: Item): Int
46 |
47 | /**
48 | * Searches for the given item and calculates its relative position
49 | *
50 | * @param identifier the identifier of an item which is searched for
51 | * @return the relative position
52 | */
53 | fun getAdapterPosition(identifier: Long): Int
54 |
55 |
56 | /**
57 | * Returns the global position based on the relative position given
58 | *
59 | * @param position the relative position within this adapter
60 | * @return the global position used for all methods
61 | */
62 | fun getGlobalPosition(position: Int): Int
63 | }
64 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IAdapterExtension.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import android.os.Bundle
4 | import android.view.MotionEvent
5 | import android.view.View
6 |
7 | /**
8 | * Kotlin type alias to simplify usage for an all accepting AdapterExtension
9 | */
10 | typealias GenericAdapterExtension = IAdapterExtension
11 |
12 | /**
13 | * Created by mikepenz on 04/06/2017.
14 | */
15 | interface IAdapterExtension
- {
16 | fun withSavedInstanceState(savedInstanceState: Bundle?, prefix: String)
17 |
18 | fun saveInstanceState(savedInstanceState: Bundle?, prefix: String)
19 |
20 | fun onClick(v: View, pos: Int, fastAdapter: FastAdapter
- , item: Item): Boolean
21 |
22 | fun onLongClick(v: View, pos: Int, fastAdapter: FastAdapter
- , item: Item): Boolean
23 |
24 | fun onTouch(v: View, event: MotionEvent, position: Int, fastAdapter: FastAdapter
- , item: Item): Boolean
25 |
26 | fun notifyAdapterDataSetChanged()
27 |
28 | fun notifyAdapterItemRangeInserted(position: Int, itemCount: Int)
29 |
30 | fun notifyAdapterItemRangeRemoved(position: Int, itemCount: Int)
31 |
32 | fun notifyAdapterItemMoved(fromPosition: Int, toPosition: Int)
33 |
34 | fun notifyAdapterItemRangeChanged(position: Int, itemCount: Int, payload: Any?)
35 |
36 | operator fun set(items: List
- , resetFilter: Boolean)
37 |
38 | fun performFiltering(constraint: CharSequence?)
39 | }
40 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IClickable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import android.view.View
4 |
5 | /**
6 | * Created by mikepenz on 25.02.16.
7 | */
8 | typealias ClickListener
- = (v: View?, adapter: IAdapter
- , item: Item, position: Int) -> Boolean
9 |
10 | typealias LongClickListener
- = (v: View, adapter: IAdapter
- , item: Item, position: Int) -> Boolean
11 |
12 | interface IClickable
- {
13 |
14 | /**
15 | * Provide a listener which is called before any processing is done within the adapter
16 | * return true if you want to consume the event
17 | */
18 | var onPreItemClickListener: ClickListener
- ?
19 |
20 | /**
21 | * Provide a listener which is called before the click listener is called within the adapter
22 | * return true if you want to consume the event
23 | */
24 | var onItemClickListener: ClickListener
- ?
25 | }
26 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IExpandable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | /**
6 | * Created by mikepenz on 30.12.15.
7 | */
8 | interface IExpandable : IParentItem, ISubItem {
9 | /**
10 | * True if expanded (opened)
11 | */
12 | var isExpanded: Boolean
13 |
14 | /**
15 | * True if the item should auto expand on click, false if you want to disable this
16 | */
17 | val isAutoExpanding: Boolean
18 | }
19 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IHookable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import com.mikepenz.fastadapter.listeners.EventHook
4 |
5 | /**
6 | * Created by fabianterhorst on 01.03.17.
7 | */
8 | interface IHookable
- {
9 | /**
10 | * @return the event hooks for the item
11 | */
12 | val eventHooks: List>?
13 | }
14 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IIdDistributor.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import com.mikepenz.fastadapter.utils.DefaultIdDistributorImpl
4 |
5 | /**
6 | * Created by fabianterhorst on 16.07.17.
7 | */
8 | interface IIdDistributor {
9 |
10 | fun checkIds(identifiables: List): List
11 |
12 | fun checkIds(vararg identifiables: Identifiable): Array
13 |
14 | fun checkId(identifiable: Identifiable): Identifiable
15 |
16 | fun nextId(identifiable: Identifiable): Long
17 |
18 | companion object {
19 | @JvmField
20 | val DEFAULT: IIdDistributor = DefaultIdDistributorImpl()
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IIdentifyable.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | /**
4 | * Created by mikepenz on 03.02.15.
5 | */
6 | interface IIdentifyable {
7 | var identifier: Long
8 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import androidx.annotation.IdRes
4 | import androidx.recyclerview.widget.RecyclerView
5 |
6 | /**
7 | * Kotlin type alias to simplify usage for an all accepting item
8 | */
9 | typealias GenericItem = IItem
10 |
11 | /**
12 | * Created by mikepenz on 03.02.15.
13 | */
14 | interface IItem : IIdentifyable {
15 |
16 | /** A Tag of the Item */
17 | var tag: Any?
18 |
19 | /** If the item is enabled */
20 | var isEnabled: Boolean
21 |
22 | /** If the item is selected */
23 | var isSelected: Boolean
24 |
25 | /** If the item is selectable */
26 | var isSelectable: Boolean
27 |
28 | /** The type of the Item. Can be a hardcoded INT, but preferred is a defined id */
29 | @get:IdRes
30 | val type: Int
31 |
32 | /** The factory to use for creating this item, this does not have to be provided if the IItemFactory is implemented by this item too */
33 | val factory: IItemVHFactory?
34 |
35 | /** Binds the data of this item to the given holder */
36 | fun bindView(holder: VH, payloads: List)
37 |
38 | /** View needs to release resources when its recycled */
39 | fun unbindView(holder: VH)
40 |
41 | /** View got attached to the window */
42 | fun attachToWindow(holder: VH)
43 |
44 | /** View got detached from the window */
45 | fun detachFromWindow(holder: VH)
46 |
47 | /**
48 | * View is in a transient state and could not be recycled
49 | *
50 | * @param holder
51 | * @return return true if you want to recycle anyways (after clearing animations or so)
52 | */
53 | fun failedToRecycle(holder: VH): Boolean
54 |
55 | /** If this item equals to the given identifier */
56 | fun equals(id: Int): Boolean
57 | }
58 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IItemList.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | /**
4 | * The Item list interface
5 | */
6 |
7 | interface IItemList
- {
8 |
9 | var active: Boolean
10 |
11 | val isEmpty: Boolean
12 |
13 | val items: MutableList
-
14 |
15 | fun getAdapterPosition(identifier: Long): Int
16 |
17 | fun remove(position: Int, preItemCount: Int)
18 |
19 | fun removeRange(position: Int, itemCount: Int, preItemCount: Int)
20 |
21 | fun move(fromPosition: Int, toPosition: Int, preItemCount: Int)
22 |
23 | fun size(): Int
24 |
25 | fun clear(preItemCount: Int)
26 |
27 | fun addAll(items: List
- , preItemCount: Int)
28 |
29 | operator fun set(position: Int, item: Item, preItemCount: Int)
30 |
31 | operator fun set(items: List
- , preItemCount: Int, adapterNotifier: IAdapterNotifier?)
32 |
33 | fun setNewList(items: List
- , notify: Boolean)
34 |
35 | fun addAll(position: Int, items: List
- , preItemCount: Int)
36 |
37 | operator fun get(position: Int): Item?
38 |
39 | fun peek(position: Int): Item? {
40 | return get(position)
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IItemVHFactory.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.RecyclerView
5 |
6 | /**
7 | * Kotlin type alias to simplify usage for an all accepting item
8 | */
9 | typealias GenericItemVHFactory = IItemVHFactory
10 |
11 | /**
12 | * Defines the factory which is capable of creating the ViewHolder for a given Item
13 | */
14 | interface IItemVHFactory {
15 | /** Generates a ViewHolder from this Item with the given parent */
16 | fun getViewHolder(parent: ViewGroup): VH
17 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IItemVHFactoryCache.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | /**
4 | * Defines the factory logic to generate ViewHolders for an item
5 | */
6 | interface IItemVHFactoryCache {
7 |
8 | fun register(type: Int, item: ItemVHFactory): Boolean
9 |
10 | operator fun get(type: Int): ItemVHFactory
11 |
12 | fun contains(type: Int): Boolean
13 |
14 | fun clear()
15 | }
16 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IItemViewGenerator.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import android.content.Context
4 | import android.view.View
5 | import android.view.ViewGroup
6 |
7 | /**
8 | * Defines an additional interface to more conveniently generate the view of an item if not used in a RV
9 | */
10 | interface IItemViewGenerator {
11 | /** Generates a view by the defined LayoutRes */
12 | fun generateView(ctx: Context): View
13 |
14 | /** Generates a view by the defined LayoutRes and pass the LayoutParams from the parent */
15 | fun generateView(ctx: Context, parent: ViewGroup): View
16 | }
17 |
18 | /**
19 | NOTE This may be implemented as the following code showcases:
20 |
21 | /** Generates a view by the defined LayoutRes */
22 | override fun generateView(ctx: Context): View {
23 | val viewHolder = getViewHolder(createView(ctx, null))
24 |
25 | //as we already know the type of our ViewHolder cast it to our type
26 | bindView(viewHolder, Collections.emptyList())
27 |
28 | //return the bound view
29 | return viewHolder.itemView
30 | }
31 |
32 | /** Generates a view by the defined LayoutRes and pass the LayoutParams from the parent */
33 | override fun generateView(ctx: Context, parent: ViewGroup): View {
34 | val viewHolder = getViewHolder(createView(ctx, parent))
35 |
36 | //as we already know the type of our ViewHolder cast it to our type
37 | bindView(viewHolder, Collections.emptyList())
38 | //return the bound and generatedView
39 | return viewHolder.itemView
40 | }
41 | */
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IModelItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | /**
6 | * Created by mikepenz on 03.02.15.
7 | */
8 | interface IModelItem : IItem {
9 |
10 | /** The model of the item */
11 | var model: Model
12 | }
13 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/IParentItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | interface IParentItem : IItem {
6 |
7 | /** The list of subItems */
8 | var subItems: MutableList>
9 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/ISelectionListener.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | /**
4 | * Created by flisar on 21.09.2016.
5 | */
6 |
7 | interface ISelectionListener
- {
8 | /**
9 | * Is called, whenever the provided item is selected or deselected
10 | *
11 | * @param item the item who's selection state changed
12 | * @param selected the new selection state of the item
13 | */
14 | fun onSelectionChanged(item: Item, selected: Boolean)
15 | }
16 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/ISubItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | interface ISubItem : IItem {
6 |
7 | /**
8 | * Use this to get the parent of this sub item
9 | * the parent should also contain this sub item in its sub items list
10 | */
11 | var parent: IParentItem<*>?
12 | }
13 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/MutableSubItemList.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | /**
4 | * MutableList proxy which will properly set and remove the parent for items added/set/removed.
5 | * This is important as otherwise collapsing will not work properly (does not resolve parent relationships)
6 | */
7 | class MutableSubItemList>(val parent: IParentItem<*>, val list: MutableList = mutableListOf()) : MutableList by list {
8 |
9 | override fun remove(element: E): Boolean {
10 | return list.remove(element).also { removed -> if (removed) element.parent = null }
11 | }
12 |
13 | override fun removeAt(index: Int): E {
14 | return list.removeAt(index).also { element -> element.parent = null }
15 | }
16 |
17 | override fun removeAll(elements: Collection): Boolean {
18 | elements.filter { list.contains(it) }.forEach { it.parent = null }
19 | return list.removeAll(elements)
20 | }
21 |
22 | override fun add(element: E): Boolean {
23 | element.parent = parent
24 | return list.add(element)
25 | }
26 |
27 | override fun add(index: Int, element: E) {
28 | element.parent = parent
29 | return list.add(index, element)
30 | }
31 |
32 | override fun addAll(index: Int, elements: Collection): Boolean {
33 | elements.forEach { it.parent = parent }
34 | return list.addAll(index, elements)
35 | }
36 |
37 | override fun addAll(elements: Collection): Boolean {
38 | elements.forEach { it.parent = parent }
39 | return list.addAll(elements)
40 | }
41 |
42 | override fun set(index: Int, element: E): E {
43 | element.parent = parent
44 | return list.set(index, element).also { oldElement -> oldElement.parent = null }
45 | }
46 |
47 | override fun clear() {
48 | list.forEach { it.parent = null }
49 | list.clear()
50 | }
51 |
52 | fun setNewList(newList: List) {
53 | clear()
54 | addAll(newList)
55 | }
56 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/VerboseLogger.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter
2 |
3 | import android.util.Log
4 |
5 | /**
6 | * @author pa.gulko zTrap (16.10.2019)
7 | */
8 | internal class VerboseLogger(private val tag: String) {
9 |
10 | var isEnabled = false
11 |
12 | fun log(message: String) {
13 | if (isEnabled) {
14 | Log.v(tag, message)
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/adapters/ItemAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.adapters
2 |
3 | import com.mikepenz.fastadapter.GenericItem
4 | import com.mikepenz.fastadapter.IItemList
5 | import com.mikepenz.fastadapter.dsl.FastAdapterDsl
6 | import com.mikepenz.fastadapter.utils.InterceptorUtil
7 |
8 | /**
9 | * Kotlin type alias to simplify usage for an all accepting ItemAdapter
10 | */
11 | typealias GenericItemAdapter = ItemAdapter
12 |
13 | /**
14 | * Created by mikepenz on 27.12.15.
15 | * A general ItemAdapter implementation based on the AbstractAdapter to speed up development for general items
16 | */
17 | @FastAdapterDsl
18 | open class ItemAdapter
- : ModelAdapter
- {
19 |
20 | constructor() : super(InterceptorUtil.DEFAULT as (element: Item) -> Item?)
21 |
22 | constructor(itemList: IItemList
- ) : super(itemList, InterceptorUtil.DEFAULT as (element: Item) -> Item?)
23 |
24 | companion object {
25 |
26 | /**
27 | * Static method to retrieve a new `ItemAdapter`
28 | *
29 | * @return a new ItemAdapter
30 | */
31 | @JvmStatic
32 | fun
- items(): ItemAdapter
- {
33 | return ItemAdapter()
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/dsl/FastAdapterDsl.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.dsl
2 |
3 | import com.mikepenz.fastadapter.*
4 | import com.mikepenz.fastadapter.adapters.ItemAdapter
5 | import com.mikepenz.fastadapter.adapters.ModelAdapter
6 |
7 | // Notify user that the DSL is currently experimental
8 | @RequiresOptIn(level = RequiresOptIn.Level.WARNING)
9 | annotation class ExperimentalFADSL
10 |
11 | @DslMarker
12 | annotation class FastAdapterDsl
13 |
14 | @FastAdapterDsl
15 | @ExperimentalFADSL
16 | inline fun genericFastAdapter(block: (GenericFastAdapter).() -> Unit): GenericFastAdapter {
17 | return GenericFastAdapter().apply(block)
18 | }
19 |
20 | @FastAdapterDsl
21 | @ExperimentalFADSL
22 | inline operator fun
- FastAdapter.Companion.invoke(block: (FastAdapter
- ).() -> Unit): FastAdapter
- {
23 | return FastAdapter
- ().apply(block)
24 | }
25 |
26 | inline fun FastAdapter.itemAdapter(block: ItemAdapter.() -> Unit) {
27 | addAdapters(listOf(ItemAdapter().apply(block) as IAdapter))
28 | }
29 |
30 | fun FastAdapter.modelAdapter(interceptor: (element: Model) -> ChildItem?, block: ModelAdapter.() -> Unit) {
31 | addAdapters(listOf(ModelAdapter(interceptor).apply(block) as ModelAdapter))
32 | }
33 |
34 | fun FastAdapter.modelAdapter(itemList: IItemList, interceptor: (element: Model) -> ChildItem?, block: ModelAdapter.() -> Unit) {
35 | addAdapters(listOf(ModelAdapter(itemList, interceptor).apply(block) as ModelAdapter))
36 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/extensions/ExtensionFactory.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.extensions
2 |
3 | import com.mikepenz.fastadapter.FastAdapter
4 | import com.mikepenz.fastadapter.GenericItem
5 | import com.mikepenz.fastadapter.IAdapterExtension
6 |
7 | interface ExtensionFactory> {
8 |
9 | val clazz: Class
10 |
11 | fun create(fastAdapter: FastAdapter): T?
12 | }
13 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/extensions/ExtensionsFactories.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.extensions
2 |
3 | import com.mikepenz.fastadapter.FastAdapter
4 | import com.mikepenz.fastadapter.GenericItem
5 | import com.mikepenz.fastadapter.IAdapterExtension
6 |
7 | object ExtensionsFactories {
8 |
9 | private val factories = LinkedHashMap>, ExtensionFactory<*>>()
10 |
11 | fun register(factory: ExtensionFactory<*>) {
12 | factories[factory.clazz] = factory
13 | }
14 |
15 | fun create(
16 | fastAdapter: FastAdapter,
17 | clazz: Class>
18 | ): IAdapterExtension? =
19 | factories[clazz]?.create(fastAdapter)
20 |
21 | inline fun >
22 | create(fastAdapter: FastAdapter): IAdapterExtension? =
23 | create(fastAdapter, T::class.java)
24 | }
25 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/items/AbstractItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.items
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.annotation.LayoutRes
8 | import androidx.recyclerview.widget.RecyclerView
9 | import com.mikepenz.fastadapter.IItemVHFactory
10 | import com.mikepenz.fastadapter.IItemViewGenerator
11 | import java.util.*
12 |
13 | /**
14 | * Implements the general methods of the IItem interface to speed up development.
15 | */
16 | abstract class AbstractItem : BaseItem(), IItemVHFactory, IItemViewGenerator {
17 |
18 | /** The layout for the given item */
19 | @get:LayoutRes
20 | abstract val layoutRes: Int
21 |
22 | /**
23 | * This method is called by generateView(Context ctx), generateView(Context ctx, ViewGroup parent) and getViewHolder(ViewGroup parent)
24 | * it will generate the View from the layout, overwrite this if you want to implement your view creation programmatically
25 | */
26 | open fun createView(ctx: Context, parent: ViewGroup?): View {
27 | return LayoutInflater.from(ctx).inflate(layoutRes, parent, false)
28 | }
29 |
30 | /** Generates a view by the defined LayoutRes */
31 | override fun generateView(ctx: Context): View {
32 | val viewHolder = getViewHolder(createView(ctx, null))
33 |
34 | //as we already know the type of our ViewHolder cast it to our type
35 | bindView(viewHolder, Collections.emptyList())
36 |
37 | //return the bound view
38 | return viewHolder.itemView
39 | }
40 |
41 | /** Generates a view by the defined LayoutRes and pass the LayoutParams from the parent */
42 | override fun generateView(ctx: Context, parent: ViewGroup): View {
43 | val viewHolder = getViewHolder(createView(ctx, parent))
44 |
45 | //as we already know the type of our ViewHolder cast it to our type
46 | bindView(viewHolder, Collections.emptyList())
47 | //return the bound and generatedView
48 | return viewHolder.itemView
49 | }
50 |
51 | /** Generates a ViewHolder from this Item with the given parent */
52 | override fun getViewHolder(parent: ViewGroup): VH {
53 | return getViewHolder(createView(parent.context, parent))
54 | }
55 |
56 | /**
57 | * This method returns the ViewHolder for our item, using the provided View.
58 | *
59 | * @return the ViewHolder for this Item
60 | */
61 | abstract fun getViewHolder(v: View): VH
62 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/items/ModelAbstractItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.items
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | import com.mikepenz.fastadapter.IModelItem
6 |
7 | /**
8 | * Implements the general methods of the IItem interface to speed up development.
9 | */
10 | abstract class ModelAbstractItem(override var model: Model) :
11 | AbstractItem(), IModelItem
12 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/items/ModelBaseItem.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.items
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | import com.mikepenz.fastadapter.IModelItem
6 |
7 | /**
8 | * Implements the general methods of the IItem interface to speed up development.
9 | */
10 | abstract class ModelBaseItem(override var model: Model) :
11 | BaseItem(), IModelItem
12 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/ClickEventHook.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import android.view.View
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.mikepenz.fastadapter.FastAdapter
6 | import com.mikepenz.fastadapter.GenericItem
7 |
8 | abstract class ClickEventHook
- : EventHook
- {
9 | abstract fun onClick(v: View, position: Int, fastAdapter: FastAdapter
- , item: Item)
10 | }
11 |
12 | /**
13 | * Convenient extension function to simplify adding a [ClickEventHook] to the [FastAdapter]
14 | *
15 | * A sample implementation may look like:
16 | * ```
17 | * fastAdapter.addClickListener({ vh: SimpleImageItem.ViewHolder -> vh.imageView }) { _, _, _, _ ->
18 | * // do something
19 | * }
20 | * ```
21 | */
22 | inline fun FastAdapter
- .addClickListener(crossinline resolveView: (VH) -> View?, crossinline resolveViews: ((VH) -> List?) = { null }, crossinline onClick: (v: View, position: Int, fastAdapter: FastAdapter
- , item: Item) -> Unit) {
23 | addEventHook(object : ClickEventHook
- () {
24 | override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {
25 | return if (viewHolder is VH) resolveView.invoke(viewHolder) else super.onBind(viewHolder)
26 | }
27 |
28 | override fun onBindMany(viewHolder: RecyclerView.ViewHolder): List? {
29 | return if (viewHolder is VH) resolveViews.invoke(viewHolder) else super.onBindMany(viewHolder)
30 | }
31 |
32 | override fun onClick(v: View, position: Int, fastAdapter: FastAdapter
- , item: Item) {
33 | onClick.invoke(v, position, fastAdapter, item)
34 | }
35 | })
36 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/CustomEventHook.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import android.view.View
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.mikepenz.fastadapter.FastAdapter
6 | import com.mikepenz.fastadapter.GenericItem
7 |
8 | abstract class CustomEventHook
- : EventHook
- {
9 | /**
10 | * This method is called by the `FastAdapter` during ViewHolder creation ONCE.
11 | */
12 | abstract fun attachEvent(view: View, viewHolder: RecyclerView.ViewHolder)
13 |
14 | /**
15 | * Helper method to get the FastAdapter from this ViewHolder
16 | */
17 | @Deprecated("Replaced with the new helper inside the FastAdapter class", ReplaceWith("FastAdapter.getFromHolderTag(viewHolder)", "com.mikepenz.fastadapter.FastAdapter"))
18 | fun getFastAdapter(viewHolder: RecyclerView.ViewHolder): FastAdapter
- ? =
19 | FastAdapter.getFromHolderTag(viewHolder)
20 |
21 | /**
22 | * Helper method to get the item for this ViewHolder
23 | */
24 | @Deprecated("Replaced with the new helper inside the FastAdapter class", ReplaceWith("FastAdapter.getHolderAdapterItem(viewHolder)", "com.mikepenz.fastadapter.FastAdapter"))
25 | fun getItem(viewHolder: RecyclerView.ViewHolder): Item? =
26 | FastAdapter.getHolderAdapterItem(viewHolder)
27 | }
28 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/EventHook.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import android.view.View
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.mikepenz.fastadapter.GenericItem
6 |
7 | interface EventHook
- {
8 |
9 | /**
10 | * Return the view for this hook that the listener should be bound to
11 | *
12 | * @return null, if the provided ViewHolder should not be bound to the event hook; return the view responsible for the event otherwise
13 | */
14 | fun onBind(viewHolder: RecyclerView.ViewHolder): View? = null
15 |
16 | /**
17 | * Return the views for this hook that the listener should be bound to
18 | *
19 | * @return null, if the provided ViewHolder should not be bound to the event hook; return the views responsible for the event otherwise
20 | */
21 | fun onBindMany(viewHolder: RecyclerView.ViewHolder): List? = null
22 | }
23 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/ItemFilterListener.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import com.mikepenz.fastadapter.GenericItem
4 |
5 | /**
6 | * Interface for the ItemFilterListener
7 | */
8 | interface ItemFilterListener
- {
9 | fun itemsFiltered(constraint: CharSequence?, results: List
- ?)
10 |
11 | fun onReset()
12 | }
13 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/LongClickEventHook.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import android.view.View
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.mikepenz.fastadapter.FastAdapter
6 | import com.mikepenz.fastadapter.GenericItem
7 |
8 | abstract class LongClickEventHook
- : EventHook
- {
9 | abstract fun onLongClick(v: View, position: Int, fastAdapter: FastAdapter
- , item: Item): Boolean
10 | }
11 |
12 | /**
13 | * Convenient extension function to simplify adding a [LongClickEventHook] to the [FastAdapter]
14 | *
15 | * A sample implementation may look like:
16 | * ```
17 | * fastAdapter.addLongClickListener({ vh: SimpleImageItem.ViewHolder -> vh.imageView }) { _, _, _, _ ->
18 | * // do something
19 | * true
20 | * }
21 | * ```
22 | */
23 | inline fun FastAdapter
- .addLongClickListener(crossinline resolveView: (VH) -> View?, crossinline resolveViews: ((VH) -> List?) = { null }, crossinline onLongClick: (v: View, position: Int, fastAdapter: FastAdapter
- , item: Item) -> Boolean) {
24 | addEventHook(object : LongClickEventHook
- () {
25 | override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {
26 | return if (viewHolder is VH) resolveView.invoke(viewHolder) else null
27 | }
28 |
29 | override fun onBindMany(viewHolder: RecyclerView.ViewHolder): List? {
30 | return if (viewHolder is VH) resolveViews.invoke(viewHolder) else super.onBindMany(viewHolder)
31 | }
32 |
33 | override fun onLongClick(v: View, position: Int, fastAdapter: FastAdapter
- , item: Item): Boolean {
34 | return onLongClick.invoke(v, position, fastAdapter, item)
35 | }
36 | })
37 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/OnBindViewHolderListener.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import androidx.recyclerview.widget.RecyclerView
4 |
5 | interface OnBindViewHolderListener {
6 | /**
7 | * Is called in onBindViewHolder to bind the data on the ViewHolder
8 | *
9 | * @param viewHolder the viewHolder for the type at this position
10 | * @param position the position of this viewHolder
11 | * @param payloads the payloads provided by the adapter
12 | */
13 | fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int, payloads: List)
14 |
15 | /**
16 | * Is called in onViewRecycled to unbind the data on the ViewHolder
17 | *
18 | * @param viewHolder the viewHolder for the type at this position
19 | * @param position the position of this viewHolder
20 | */
21 | fun unBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int)
22 |
23 | /**
24 | * Is called in onViewAttachedToWindow when the view is detached from the window
25 | *
26 | * @param viewHolder the viewHolder for the type at this position
27 | * @param position the position of this viewHolder
28 | */
29 | fun onViewAttachedToWindow(viewHolder: RecyclerView.ViewHolder, position: Int)
30 |
31 | /**
32 | * Is called in onViewDetachedFromWindow when the view is detached from the window
33 | *
34 | * @param viewHolder the viewHolder for the type at this position
35 | * @param position the position of this viewHolder
36 | */
37 | fun onViewDetachedFromWindow(viewHolder: RecyclerView.ViewHolder, position: Int)
38 |
39 | /**
40 | * Is called when the ViewHolder is in a transient state. return true if you want to reuse
41 | * that view anyways
42 | *
43 | * @param viewHolder the viewHolder for the view which failed to recycle
44 | * @return true if we want to recycle anyways (false - it get's destroyed)
45 | */
46 | fun onFailedToRecycleView(viewHolder: RecyclerView.ViewHolder, position: Int): Boolean
47 | }
48 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/OnCreateViewHolderListener.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.mikepenz.fastadapter.FastAdapter
6 | import com.mikepenz.fastadapter.GenericItem
7 | import com.mikepenz.fastadapter.IItemVHFactory
8 |
9 | interface OnCreateViewHolderListener
- {
10 | /**
11 | * Is called inside the onCreateViewHolder method and creates the viewHolder based on the provided viewTyp
12 | *
13 | * @param fastAdapter the fastAdapter which handles the creation of this viewHolder
14 | * @param parent the parent which will host the View
15 | * @param viewType the type of the ViewHolder we want to create
16 | * @return the generated ViewHolder based on the given viewType
17 | */
18 | fun onPreCreateViewHolder(fastAdapter: FastAdapter
- , parent: ViewGroup, viewType: Int, itemVHFactory: IItemVHFactory<*>): RecyclerView.ViewHolder
19 |
20 | /**
21 | * Is called after the viewHolder was created and the default listeners were added
22 | *
23 | * @param fastAdapter the fastAdapter which handles the creation of this viewHolder
24 | * @param viewHolder the created viewHolder after all listeners were set
25 | * @return the viewHolder given as param
26 | */
27 | fun onPostCreateViewHolder(fastAdapter: FastAdapter
- , viewHolder: RecyclerView.ViewHolder, itemVHFactory: IItemVHFactory<*>): RecyclerView.ViewHolder
28 | }
29 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/OnCreateViewHolderListenerImpl.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.mikepenz.fastadapter.FastAdapter
6 | import com.mikepenz.fastadapter.GenericItem
7 | import com.mikepenz.fastadapter.IHookable
8 | import com.mikepenz.fastadapter.IItemVHFactory
9 | import com.mikepenz.fastadapter.utils.bind
10 |
11 | /**
12 | * Default implementation of the OnCreateViewHolderListener
13 | */
14 | open class OnCreateViewHolderListenerImpl
- : OnCreateViewHolderListener
- {
15 | /**
16 | * Is called inside the onCreateViewHolder method and creates the viewHolder based on the provided viewTyp
17 | *
18 | * @param parent the parent which will host the View
19 | * @param viewType the type of the ViewHolder we want to create
20 | * @return the generated ViewHolder based on the given viewType
21 | */
22 | override fun onPreCreateViewHolder(fastAdapter: FastAdapter
- , parent: ViewGroup, viewType: Int, itemVHFactory: IItemVHFactory<*>): RecyclerView.ViewHolder {
23 | return itemVHFactory.getViewHolder(parent)
24 | }
25 |
26 | /**
27 | * Is called after the viewHolder was created and the default listeners were added
28 | *
29 | * @param viewHolder the created viewHolder after all listeners were set
30 | * @return the viewHolder given as param
31 | */
32 | override fun onPostCreateViewHolder(fastAdapter: FastAdapter
- , viewHolder: RecyclerView.ViewHolder, itemVHFactory: IItemVHFactory<*>): RecyclerView.ViewHolder {
33 | fastAdapter.eventHooks.bind(viewHolder)
34 | //check if the item implements hookable and contains event hooks
35 | (itemVHFactory as? IHookable<*>)?.eventHooks?.bind(viewHolder)
36 | return viewHolder
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/listeners/TouchEventHook.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.listeners
2 |
3 | import android.view.MotionEvent
4 | import android.view.View
5 | import androidx.recyclerview.widget.RecyclerView
6 | import com.mikepenz.fastadapter.FastAdapter
7 | import com.mikepenz.fastadapter.GenericItem
8 | import com.mikepenz.fastadapter.IAdapter
9 |
10 | typealias TouchListener
- = (v: View, event: MotionEvent, adapter: IAdapter
- , item: Item, position: Int) -> Boolean
11 |
12 | abstract class TouchEventHook
- : EventHook
- {
13 | abstract fun onTouch(v: View, event: MotionEvent, position: Int, fastAdapter: FastAdapter
- , item: Item): Boolean
14 | }
15 |
16 | /**
17 | * Convenient extension function to simplify adding a [TouchEventHook] to the [FastAdapter]
18 | *
19 | * A sample implementation may look like:
20 | * ```
21 | * fastAdapter.addTouchListener({ vh: SimpleImageItem.ViewHolder -> vh.imageView }) { _, _, _, _ ->
22 | * // do something
23 | * true
24 | * }
25 | * ```
26 | */
27 | inline fun FastAdapter
- .addTouchListener(crossinline resolveView: (VH) -> View?, crossinline resolveViews: ((VH) -> List?) = { null }, crossinline onTouch: (v: View, event: MotionEvent, position: Int, fastAdapter: FastAdapter
- , item: Item) -> Boolean) {
28 | addEventHook(object : TouchEventHook
- () {
29 | override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {
30 | return if (viewHolder is VH) resolveView.invoke(viewHolder) else null
31 | }
32 |
33 | override fun onBindMany(viewHolder: RecyclerView.ViewHolder): List? {
34 | return if (viewHolder is VH) resolveViews.invoke(viewHolder) else super.onBindMany(viewHolder)
35 | }
36 |
37 | override fun onTouch(v: View, event: MotionEvent, position: Int, fastAdapter: FastAdapter
- , item: Item): Boolean {
38 | return onTouch.invoke(v, event, position, fastAdapter, item)
39 | }
40 | })
41 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/select/SelectExtensionFactory.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.select
2 |
3 | import com.mikepenz.fastadapter.FastAdapter
4 | import com.mikepenz.fastadapter.GenericItem
5 | import com.mikepenz.fastadapter.extensions.ExtensionFactory
6 |
7 | class SelectExtensionFactory : ExtensionFactory> {
8 |
9 | override val clazz = SelectExtension::class.java
10 |
11 | override fun create(fastAdapter: FastAdapter): SelectExtension<*>? {
12 | return SelectExtension(fastAdapter)
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/utils/AdapterPredicate.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.utils
2 |
3 | import com.mikepenz.fastadapter.GenericItem
4 | import com.mikepenz.fastadapter.IAdapter
5 |
6 | /**
7 | * AdapterPredicate interface to be used with the recursive method.
8 | */
9 | interface AdapterPredicate
- {
10 | /**
11 | * `apply` is called for every single item in the `recursive` method.
12 | *
13 | * @param lastParentAdapter the last `IAdapter` managing the last (visible) parent item (that might also be a parent of a parent, ..)
14 | * @param lastParentPosition the global position of the last (visible) parent item, holding this sub item (that might also be a parent of a parent, ..)
15 | * @param item the item to check
16 | * @param position the global position of the item, or [androidx.recyclerview.widget.RecyclerView.NO_POSITION] (-1) if it is a non displayed sub item
17 | * @return true if we matched and no longer want to continue (will be ignored if `stopOnMatch` of the recursive function is false)
18 | */
19 | fun apply(lastParentAdapter: IAdapter
- , lastParentPosition: Int, item: Item, position: Int): Boolean
20 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/utils/ComparableItemListImpl.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.utils
2 |
3 | import com.mikepenz.fastadapter.GenericItem
4 | import java.util.*
5 |
6 | /**
7 | * The default item list implementation
8 | */
9 | class ComparableItemListImpl
- @JvmOverloads constructor(
10 | comparator: Comparator
- ?,
11 | items: MutableList
- = ArrayList()
12 | ) : DefaultItemListImpl
- (items) {
13 |
14 | /** @return the defined Comparator used for this ItemAdapter */
15 | var comparator: Comparator
- ? = comparator
16 | private set
17 |
18 | /**
19 | * Define a comparator which will be used to sort the list "every time" it is altered
20 | * NOTE this will only sort if you "set" a new list or "add" new items (not if you provide a position for the add function)
21 | *
22 | * @param comparator used to sort the list
23 | * @param sortNow specifies if we use the provided comparator to sort now
24 | * @return this
25 | */
26 | @JvmOverloads
27 | fun withComparator(
28 | comparator: Comparator
- ?,
29 | sortNow: Boolean = true
30 | ): ComparableItemListImpl
- {
31 | this.comparator = comparator
32 |
33 | //we directly sort the list with the defined comparator
34 | if (this.comparator != null && sortNow) {
35 | Collections.sort(_items, this.comparator)
36 | fastAdapter?.notifyAdapterDataSetChanged()
37 | }
38 |
39 | return this
40 | }
41 |
42 | override fun move(fromPosition: Int, toPosition: Int, preItemCount: Int) {
43 | val item = _items[fromPosition - preItemCount]
44 | _items.removeAt(fromPosition - preItemCount)
45 | _items.add(toPosition - preItemCount, item)
46 | _items.trySortWith(comparator)
47 | fastAdapter?.notifyAdapterDataSetChanged()
48 | }
49 |
50 | override fun addAll(items: List
- , preItemCount: Int) {
51 | _items.addAll(items)
52 | _items.trySortWith(comparator)
53 | fastAdapter?.notifyAdapterDataSetChanged()
54 | }
55 |
56 | override fun addAll(position: Int, items: List
- , preItemCount: Int) {
57 | _items.addAll(position - preItemCount, items)
58 | _items.trySortWith(comparator)
59 | fastAdapter?.notifyAdapterDataSetChanged()
60 | }
61 |
62 | override fun setNewList(items: List
- , notify: Boolean) {
63 | _items = ArrayList(items)
64 | _items.trySortWith(comparator)
65 | if (notify) {
66 | fastAdapter?.notifyAdapterDataSetChanged()
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/utils/DefaultIdDistributor.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.utils
2 |
3 | import com.mikepenz.fastadapter.IIdDistributor
4 | import com.mikepenz.fastadapter.IIdentifyable
5 |
6 | /**
7 | * Created by mikepenz on 19.09.15.
8 | */
9 | abstract class DefaultIdDistributor : IIdDistributor {
10 |
11 | /**
12 | * Set an unique identifier for all identifiables which do not have one set already
13 | */
14 | override fun checkIds(identifiables: List): List {
15 | var i = 0
16 | val size = identifiables.size
17 | while (i < size) {
18 | checkId(identifiables[i])
19 | i++
20 | }
21 | return identifiables
22 | }
23 |
24 | /**
25 | * Set an unique identifier for all items which do not have one set already
26 | */
27 | override fun checkIds(vararg identifiables: Identifiable): Array {
28 | for (identifiable in identifiables) {
29 | checkId(identifiable)
30 | }
31 | return identifiables
32 | }
33 |
34 | /**
35 | * Set an unique identifier for the identifiable which do not have one set already
36 | */
37 | override fun checkId(identifiable: Identifiable): Identifiable {
38 | if (identifiable.identifier == -1L) {
39 | identifiable.identifier = nextId(identifiable)
40 | }
41 | return identifiable
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/utils/DefaultIdDistributorImpl.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.utils
2 |
3 | import com.mikepenz.fastadapter.IIdentifyable
4 | import java.util.concurrent.atomic.AtomicLong
5 |
6 | /**
7 | * Created by mikepenz on 19.09.15.
8 | */
9 | class DefaultIdDistributorImpl :
10 | DefaultIdDistributor() {
11 | private val idDistributor = AtomicLong(-2L)
12 |
13 | override fun nextId(identifiable: Identifiable): Long {
14 | return idDistributor.decrementAndGet()
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/fastadapter/src/main/java/com/mikepenz/fastadapter/utils/DefaultItemList.kt:
--------------------------------------------------------------------------------
1 | package com.mikepenz.fastadapter.utils
2 |
3 | import com.mikepenz.fastadapter.FastAdapter
4 | import com.mikepenz.fastadapter.GenericItem
5 | import com.mikepenz.fastadapter.IItemList
6 |
7 | /**
8 | * The default item list
9 | */
10 |
11 | abstract class DefaultItemList
- : IItemList