Skip to content

Commit 2827da2

Browse files
committed
x
1 parent 7d07606 commit 2827da2

File tree

80 files changed

+2240
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2240
-14
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Configuration of build modules
3+
*/
4+
object BuildModules {
5+
const val app = ":app"
6+
const val core = ":core"
7+
8+
object Features {
9+
const val home = ":features:home"
10+
}
11+
12+
object Commons {
13+
const val testShared = ":common:testShared"
14+
const val androidShared = ":common:androidShared"
15+
}
16+
}

buildSrc/src/main/kotlin/commonscripts/android-library.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ android {
3131
jvmTarget = "1.8"
3232
}
3333

34+
compileOptions {
35+
sourceCompatibility = JavaVersion.VERSION_1_8
36+
targetCompatibility = JavaVersion.VERSION_1_8
37+
}
38+
3439
}
3540

3641
dependencies {

common/androidShared/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
plugins {
2+
androidLibrary
3+
}
4+
5+
dependencies {
6+
7+
implementation(Libs.kotlinx_coroutines_android)
8+
implementation (Libs.kotlinx_coroutines_core)
9+
10+
implementation (Libs.timber)
11+
implementation (Libs.core_ktx)
12+
implementation (Libs.appcompat)
13+
14+
implementation (Libs.material)
15+
implementation (Libs.constraintlayout)
16+
17+
implementation (Libs.fragment_ktx)
18+
19+
implementation (Libs.lifecycle_common_java8)
20+
21+
}

common/androidShared/consumer-rules.pro

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="com.kryptkode.commonandroid">
3+
4+
</manifest>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.ellalan.certifiedparent.app.utils
2+
3+
import android.content.Context
4+
import androidx.annotation.AttrRes
5+
import androidx.core.content.res.getColorOrThrow
6+
7+
object AttrUtils {
8+
9+
fun convertAttrToColor(@AttrRes attrResId: Int, context: Context): Int {
10+
val styledAttr = context.obtainStyledAttributes(null, intArrayOf(attrResId))
11+
val colorInt = styledAttr.getColorOrThrow(0)
12+
styledAttr.recycle()
13+
return colorInt
14+
}
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.kryptkode.commonandroid
2+
3+
import android.content.Context
4+
import android.widget.Toast
5+
6+
class ToastHelper constructor(private val context: Context) {
7+
fun showMessage(message: String) {
8+
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
9+
}
10+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.kryptkode.commonandroid.customviews
2+
3+
import android.content.Context
4+
import android.util.AttributeSet
5+
import android.view.View
6+
import androidx.recyclerview.widget.RecyclerView
7+
8+
class EmptyRecyclerView : RecyclerView {
9+
10+
private var emptyView: View? = null
11+
12+
private val observer = object : RecyclerView.AdapterDataObserver() {
13+
override fun onChanged() {
14+
checkIfEmpty()
15+
}
16+
17+
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
18+
checkIfEmpty()
19+
}
20+
21+
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
22+
checkIfEmpty()
23+
}
24+
}
25+
26+
constructor(context: Context) : super(context) {}
27+
28+
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
29+
30+
constructor(
31+
context: Context, attrs: AttributeSet,
32+
defStyle: Int
33+
) : super(context, attrs, defStyle) {
34+
}
35+
36+
fun checkIfEmpty() {
37+
if (emptyView != null && adapter != null) {
38+
val emptyViewVisible = adapter!!.itemCount == 0
39+
emptyView!!.visibility = if (emptyViewVisible) View.VISIBLE else View.GONE
40+
visibility = if (emptyViewVisible) View.GONE else View.VISIBLE
41+
}
42+
}
43+
44+
override fun setAdapter(adapter: Adapter<*>?) {
45+
val oldAdapter = getAdapter()
46+
oldAdapter?.unregisterAdapterDataObserver(observer)
47+
super.setAdapter(adapter)
48+
adapter?.registerAdapterDataObserver(observer)
49+
checkIfEmpty()
50+
}
51+
52+
fun setEmptyView(emptyView: View) {
53+
this.emptyView = emptyView
54+
checkIfEmpty()
55+
}
56+
57+
58+
}

0 commit comments

Comments
 (0)