PlaceHolderRecyclerView¶
A RecyclerView that can switch between items and placeholders.
This libs doesn’t force a placehoder type, the developer is responsible for creating one, checkout the sample module and see how simple it is.
You can use the best beloved Shimmer-Android, a Lottie animation or even Property Animation. Use your imagination, it’s your placeholder 😊
Installation¶
PlaceHolderRecyclerView is distributed through Maven Central and Jitpack.
implementation 'com.github.guilhe:placeholder-recyclerview:${LATEST_VERSION}'
Usage¶
<com.github.guilhe.views.PlaceHolderRecyclerView
android:id="@+id/my_RecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
class MyItemsPlaceHolderAdapter : ..., PlaceHolderAdapter { ... }
private val itemsAdapter = MyItemsAdapter()
...
with(binding.myRecyclerView) {
adapter = itemsAdapter
holdersAdapter = MyItemsPlaceHolderAdapter()
holdersItemDecoration = MyItemsDecoration() //if needed
}
...
viewModel.items.observe(this, { itemsAdapter.update(it) })
viewModel.isLoading.observe(this, { isLoading -> binding.myRecyclerView.toggleHoldersAdapter(isLoading) })
Don’t recognise those chinese characters? They’re from an awesome game called Mahjong
Lottie animation by puput Santoso
Dependencies¶
Bugs and Feedback¶
For bugs, questions and discussions please use the Github Issues.
LICENSE¶
Copyright © 2020-present GuilhE
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.