π Genos makes it very easy to build better mobile apps more quickly and with less code. For more information please see the website.
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
implementation 'com.nyssance.genos:genos:2.0.2'
allprojects {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
dependencies {
implementation("com.nyssance.genos:genos:2.0.2")
}
Genos integrate google architecture. just use. if your need learn more info about how genos work, and mvvm, repository , viewmodel etc., see link
1.Rules
- Activity just as an container, include app bar and drawer/bottom navigation, and one fragment or more.
- Fragment have two type: list and detail.
- list for REST list api, like https://www.yourdomain.com/api/v1/users/, list include default
listView
,adapter
- detail for REST detail api, like https://www.yourdomain,com/api/v1/users/{:id}/
- call in fragment is a call of it, it's a Retrofit call
- list for REST list api, like https://www.yourdomain.com/api/v1/users/, list include default
- Repository is for load data.
- ViewModel is for bind data and view.
2.How to use
Create a list fragment, override three methods, 15 lines code, that's all you need to do.
import genos.ui.fragment.generic.List
import genos.ui.viewholder.Holder
class UserList : List<User, Holder>() {
override fun onCreate() {
call = API.userList(page) // A retrofit call of this fragment.
}
override fun onDisplayItem(item: User, viewHolder: Holder, viewType: Int) {
with(viewHoloder) {
icon?.setImage(item.avatarUrl)
title?.text = item.username
}
}
override fun onOpenItem(item: User) {
// StartActivity or do anything when click item.
}
}
class UserListActivity : AppBarActivity() {
override fun onCreateFragment() = UserList()
}
Create a bottom navigation with four buttons, 10 lines.
// If you need a drawer navigation, use `MainActivity : DrawerActivity`
class MainActivity : TabBarActivity(mapOf(
R.id.navigation_1 to UserList(),
R.id.navigation_2 to PlaceholderFragment.instance("2"),
R.id.navigation_3 to PlaceholderFragment.instance("3"),
R.id.navigation_4 to PlaceholderFragment.instance("4")
)) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
with(Global) { // Config
APP_SCHEME = "genos-sample"
}
router() // Set router
}
}
genos
βββ Global.kt Global config.
βββ Helper.kt
βββ extension
β βββ Fragment+Extension.kt
β βββ ImageView+Extension.kt
β βββ String+Extension.kt
βββ model
β βββ BaseItem.kt
β βββ Item.kt
βββ repository
β βββ HttpRepository.kt Default http repository.
β βββ HttpUtil.kt
β βββ IRepository.kt
β βββ NetworkState.kt
β βββ Status.kt
βββ ui
β βββ BaseAdapter.kt Default Adapter for list fragment.
β βββ BaseViewModel.kt Default ViewModel for list and detail fragment.
β βββ activity
β β βββ AppBarActivity.kt Activity with an app bar.
β β βββ CollapsingActivity.kt Activity with a collapsing app bar.
β β βββ DrawerActivity.kt Activity with drawer.
β β βββ TabBarActivity.kt Activity with bottom navigation.
β β βββ WebActivity.kt
β β βββ base Design your activity by extends activity in base.
β β β βββ BaseActivity.kt
β β β βββ ContainerActivity.kt
β β β βββ NavigationActivity.kt
β βββ fragment
β β βββ ActionSheet.kt
β β βββ Dialog.kt
β β βββ PlaceholderFragment.kt
β β βββ ViewPagerFragment.kt Fragment with a view pager.
β β βββ base Design your fragment by extends fragment in base.
β β β βββ BaseFragment.kt
β β β βββ ListFragment.kt
β β β βββ LoaderFragment.kt
β β β βββ ObjectFragment.kt
β β β βββ RecyclerViewFragment.kt
β β βββ generic
β β βββ Detail.kt Fragment for detail.
β β βββ GridViewList.kt Fragment with a grid layout, user for grid list.
β β βββ List.kt Fragment with a linear layout, use for stand list, one item per line.
β β βββ StaggeredGridViewList.kt Fragment with a staggered grid layout, use for waterfall list.
β β βββ TableViewDetail.kt
β βββ viewholder
β βββ BaseHolder.kt Base holder.
β βββ Holder.kt A holder with icon, title, subtitle, accessory.
βββ vendor
βββ Retrofit.kt
ifBlank
, orEmpty
Genos is released under the GPLv3 license. See LICENSE for details.