Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evant/android-shard
'Fragments' with a simpler api built on top of the android architecture components
https://github.com/evant/android-shard
Last synced: about 1 month ago
JSON representation
'Fragments' with a simpler api built on top of the android architecture components
- Host: GitHub
- URL: https://github.com/evant/android-shard
- Owner: evant
- License: apache-2.0
- Created: 2018-08-17T12:26:08.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2020-06-14T22:55:25.000Z (over 4 years ago)
- Last Synced: 2023-07-05T08:08:50.747Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 959 KB
- Stars: 29
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Shard
Shards are 'Fragments' with a simpler api built on top of the android architecture components.
**Stability**: All important features are implemented but there may be some api changes before `1.0.0`.
## Download
[![Maven Central](https://img.shields.io/maven-central/v/me.tatarka.shard/shard.svg)](https://search.maven.org/search?q=g:me.tatarka.shard)
[![Sonatype Snapshot](https://img.shields.io/nexus/s/https/oss.sonatype.org/me.tatarka.shard/shard.svg)](https://oss.sonatype.org/content/repositories/snapshots/me/tatarka/shard/)```groovy
def shard_version = '1.0.0-beta03'
// The core lib
implementation "me.tatarka.shard:shard:$shard_version"
// For use with appcompat
implementation "me.tatarka.shard:shard-appcompat:$shard_version"
// For use with the material design lib
implementation "me.tatarka.shard:shard-host-ui:$shard_version"
// For use with the android architecture navigation component
implementation "me.tatarka.shard:shard-nav:$shard_version"
// For use in a ViewPager
implementation "me.tatarka.shard:shard-pager:$shard_version"
// For use in a ViewPager2
implementation "me.tatarka.shard:shard-pager2:$shard_version"
// For using androidx.transition
implementation "me.tatarka.shard:shard-transition:$shard_version"
// For interop with fragments
implementation "me.tatarka.shard:shard-fragment-interop:$shard_version"
```### Kotlin
There's a few additional artifacts for kotlin extensions.
```groovy
implementation "me.tatarka.shard:shard-ktx:$shard_version"
implementation "me.tatarka.shard:shard-host-ui-ktx:$shard_version"
```### SNAPSHOT
You can also follow the bleeding-edge with SNAPSHOT releases.
```groovy
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
def shard_version = '1.0.0-beta03-SNAPSHOT'
```## Usage
Creating a shard is as simple as
```kotlin
class MyShard: Shard() {
const val REQUEST_CODE = 1// get a ViewModel
val vm by viewModels()override fun onCreate() {
setContentView(R.layout.my_shard)
// find a view
val name: TextView = requireViewById(R.id.name)
// listen with LiveData
vm.name.observe(this, Observer { value -> name.text = value })
// handle back presses
onBackPressedDispatcher.addCallback(this, enabled = true) {
remove()
}
// start an activity for result
activityCallbacks.addOnActivityResultCallback(REQUEST_CODE) { resultCode, data -> }
requireViewById(R.id.button).setOnClickListener {
activityCallbacks.startActivityForResult(Intent(context, MyActivity::class.java), REQUEST_CODE)
}
}
}
``````xml
```
## Full Documentation
- [Getting Started](/docs/getting-started.md)
- [Implementing Shards](/docs/implementing-shards.md)
- [Hosting Shards](/docs/hosting-shards.md)
- [Transition Animations](/docs/transition-animations.md)
- [Migrating from Fragments](/docs/migrating-from-fragments.md)