Awesome
Small library that contains common extensions for Android
- Provide the shortest way to do things.
- Reduce count of "Compat" and "Utils" classes.
- Remove boilerplate code.
Learn Kotlin development with:
- Kotlin Clean Architecture (MVVM And Project Setting)
- Advance level setup Gradle like (version, source, signature, flavour, buildType, dependencies, repositories).
- LiveData.
- ViewModel.
- DataBinding.
- Room.
- Lifecycle Architecture Components.
- Retrofit 2 with dynamic url change without create retrofit object and CallbackWrapper to customise response.
- Dagger 2.
- RxJava 2.
Also create so many extensions to use generally like
- ActivityExtensions to allow full-screen, toggle statusBar, show/hide toolbar and show/hide keyboard.
- AlertExtensions to allow alert, confirm and selector dialog.
- BitmapExtensions to allow cut rounded corner, save bitmap, download, resize etc.
- ClipboardExtensions to allow copy and get text in clipboard.
- ContactProviderExtensions to get phone contact.
- ContextExtensions to allow hide/show keyboard
- DateExtensions to allow convert date format.
- DimenExtensions to get and convert dime value in dip, px, sp.
- DrawableExtensions search and get image from resource.
- FileExtensions to get path, download, save and read file.
- FontExtensions to apply custom font.
- JsonExtensions to convert json to different type of data.
- KeyHashExtensions to get Facebook hash string.
- LayoutExtensions to inflate layout.
- LocationExtensions to get current location and address base on provider.
- LogExtensions to error, debug, shout, json, exception logical print in android console.
- ManagerExtensions to get system services.
- NavigationExtensions to use launch screen and manage fragment.
- NetworkExtensions to use get current network(WIFI/MOBILE) and check internet availability.
- PermissionExtensions to use runtime permission check in above Marshmallow.
- PhotoExtensions to allow get image width, height, mime-type, orientation etc.
- PickMediaExtensions to get image and video from gallery and camera.
- SharePreferenceExtensions to use store app data in locally.
- TimeExtensions to allow plus, minus time and scheduler set.
- ToastAndSnackBarExtensions to user acknowledgement purpose.
- VersionExtensions to get application version code and name.
- ValidationExtensions to validate EditText and TextInputEditText field like(email, noNumber, nonEmpty, allUpperCase, allLowerCase, atLeastOneLowerCase etc).
- RecyclerView adapter with support multiple view holder with data binding or without data binding, diffutils, loadmore listener with custom support and empty/error layout attach with custom support.
- Fastlane integration with auto increment build number with product flavors option and upload in fabric. build number pattern like 1.0.0(0) [major.minor.patch(build)], Also Rename and copy apk file in Settings/apk dir, so the every time of releasing to auto backup apk file.
You have just run fastlane command like below
fastlane devVariant versionChange:"build" isNote:false
fastlane qaVariant versionChange:"build" isNote:false
fastlane productionVariant versionChange:"build"
How to use Recycler Adapter?
How to user without data binding
RecyclerAdapter.create()
.register<User>(R.layout.recycler_item_user) { data, injector ->
injector.text(R.id.name, data.name)
.image(R.id.avatar, data.avatarRes)
.text(R.id.phone, data.phone)
.textColor(R.id.phone, Color.RED)
.textSize(R.id.phone, 12)
}
.register<SectionHeader>(R.layout.recycler_item_setion_header) { data, injector ->
injector.text(R.id.section_title, data.title)
.clicked(R.id.lny_main) {
context.shortToast("Section Header Clicked -> " + data.title)
}
}
.register<Image>(R.layout.recycler_item_image) { data, injector ->
injector.with<ImageView>(R.id.img_cover, object : IViewInjector.Action<ImageView> {
override fun action(view: ImageView?) {
view?.setImageResource(data.res)
}
})
.longClicked(R.id.img_cover) {
context.shortToast("Image LongClicked -> " + data.res)
true
}
}
.register<Music>(R.layout.recycler_item_music) { data, injector ->
injector.text(R.id.name, data.name)
.image(R.id.cover, data.coverRes)
.clicked(R.id.movie_item) {
context.shortToast("Music Clicked -> " + data.name)
}
}
.enableDiff()
.enableLoadMore(object: RecyclerMoreLoader(context, object: SimpleLoadMoreViewCreator(context){
override fun createNoMoreHint(): CharSequence = getString(R.string.txt_no_more_data)
}){
override fun onLoadMore(handler: Handler?) {
SystemClock.sleep(3_000L);
if (random.nextInt(10) > 7) {
handler!!.error()
} else {
handler!!.loadCompleted(data1)
loadTime++
}
}
override fun hasMore(): Boolean = loadTime < 3
})
.enableEmptyError(object: RecyclerEmptyErrorLoader(context, object: SimpleEmptyErrorViewCreator(context) {
}){
override fun onLoadEmptyError(handler: Handler?) {
SystemClock.sleep(3_000L);
if (random.nextInt(10) > 7) {
handler!!.error()
} else {
handler!!.loadCompleted(data)
}
}
override fun hasEmptyError(): Int {
return 0
}
})
.attachTo(recyclerView)
With data binding
RecyclerAdapter.create()
.register<NewsBean, RecyclerItemNewsBinding>(R.layout.recycler_item_news) { data, injector, binding ->
}
.enableDiff()
.attachTo(recyclerView)
Add Build.gradle file
//Add Dependencies for app level build.gradle
repositories {
jcenter()
}
dependencies {
implementation 'com.kevadiyakrunalk:kotlinextensions:1.0.0'
}
or Maven:
<dependency>
<groupId>com.kevadiyakrunalk</groupId>
<artifactId>kotlinextensions</artifactId>
<version>1.0.0</version>
<type>pom</type>
</dependency>