Skip to content

Commit 7d84e49

Browse files
committed
Initial commit
0 parents  commit 7d84e49

File tree

107 files changed

+3516
-0
lines changed

Some content is hidden

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

107 files changed

+3516
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SmartDialog/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

SmartDialog/build.gradle

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'org.jetbrains.kotlin.android'
4+
id 'maven-publish'
5+
}
6+
7+
android {
8+
9+
namespace 'com.gtech.smartdialog'
10+
11+
compileSdk 33
12+
13+
defaultConfig {
14+
15+
minSdk 16
16+
targetSdk 33
17+
18+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19+
consumerProguardFiles "consumer-rules.pro"
20+
}
21+
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
29+
compileOptions {
30+
sourceCompatibility JavaVersion.VERSION_1_8
31+
targetCompatibility JavaVersion.VERSION_1_8
32+
}
33+
34+
kotlinOptions {
35+
jvmTarget = '1.8'
36+
}
37+
38+
buildFeatures {
39+
viewBinding true
40+
}
41+
42+
}
43+
44+
dependencies {
45+
46+
implementation 'androidx.core:core-ktx:1.9.0'
47+
implementation 'androidx.appcompat:appcompat:1.5.1'
48+
implementation 'com.google.android.material:material:1.6.1'
49+
testImplementation 'junit:junit:4.13.2'
50+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
51+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
52+
53+
// GIF
54+
implementation 'com.github.bumptech.glide:glide:4.11.0'
55+
56+
}
57+
58+
afterEvaluate {
59+
publishing {
60+
publications {
61+
release(MavenPublication) {
62+
from components.release
63+
groupId = 'com.github.GtechGovind'
64+
artifactId == 'SmartDialog'
65+
version = '1.0'
66+
}
67+
}
68+
}
69+
}

SmartDialog/consumer-rules.pro

Whitespace-only changes.

SmartDialog/proguard-rules.pro

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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.gtech.smartdialog
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.gtech.smartdialog.test", appContext.packageName)
23+
}
24+
}
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 xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
</manifest>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.gtech.smartdialog.app
2+
3+
import android.app.Application
4+
5+
class GtechApp: Application() {
6+
7+
companion object {
8+
lateinit var instance: GtechApp
9+
}
10+
11+
override fun onCreate() {
12+
super.onCreate()
13+
instance = this
14+
}
15+
16+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.gtech.smartdialog.domain
2+
3+
import android.app.AlertDialog
4+
import android.app.Dialog
5+
import android.os.Bundle
6+
import androidx.fragment.app.DialogFragment
7+
import com.bumptech.glide.Glide
8+
import com.gtech.smartdialog.R
9+
import com.gtech.smartdialog.app.GtechApp
10+
import com.gtech.smartdialog.databinding.CustomeAlertDialogBinding
11+
import com.gtech.smartdialog.utils.DialogType
12+
13+
class AlertDialogBuilder(private val message: String, private val type: DialogType, private val listener: DialogListeners? = null) : DialogFragment() {
14+
15+
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
16+
17+
val binding = CustomeAlertDialogBinding.inflate(requireActivity().layoutInflater)
18+
19+
val builder = AlertDialog.Builder(requireActivity())
20+
builder.setCancelable(false)
21+
builder.setView(binding.root)
22+
23+
when (type) {
24+
DialogType.SUCCESS -> Glide.with(GtechApp.instance).load(R.drawable.success).into(binding.image)
25+
DialogType.INFO -> Glide.with(GtechApp.instance).load(R.drawable.info).into(binding.image)
26+
else -> Glide.with(GtechApp.instance).load(R.drawable.error).into(binding.image)
27+
}
28+
29+
binding.message.text = message
30+
31+
if (listener != null) {
32+
binding.button.setOnClickListener {
33+
listener.onDialogClick(dialog, type)
34+
}
35+
} else {
36+
binding.button.setOnClickListener {
37+
dialog?.dismiss()
38+
}
39+
}
40+
41+
return builder.create()
42+
43+
}
44+
45+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.gtech.smartdialog.domain
2+
3+
import android.app.Dialog
4+
import com.gtech.smartdialog.utils.DialogType
5+
6+
interface DialogListeners {
7+
fun onDialogClick(dialog: Dialog?, type: DialogType)
8+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.gtech.smartdialog.domain
2+
3+
import android.app.AlertDialog
4+
import androidx.appcompat.app.AppCompatActivity
5+
import com.bumptech.glide.Glide
6+
import com.gtech.smartdialog.R
7+
import com.gtech.smartdialog.app.GtechApp
8+
import com.gtech.smartdialog.databinding.CustomLoadingDialogBinding
9+
10+
class LoadingDialogBuilder(private val activity: AppCompatActivity) {
11+
12+
private lateinit var binding: CustomLoadingDialogBinding
13+
private lateinit var dialog: AlertDialog
14+
15+
fun start(message: String = "Loading please wait ...") {
16+
17+
binding = CustomLoadingDialogBinding.inflate(activity.layoutInflater)
18+
val builder = AlertDialog.Builder(activity)
19+
builder.setView(binding.root)
20+
builder.setCancelable(false)
21+
dialog = builder.create()
22+
23+
Glide.with(GtechApp.instance).load(R.drawable.loading).into(binding.image)
24+
binding.message.text = message
25+
26+
dialog.show()
27+
}
28+
29+
fun stop() {
30+
if (this::dialog.isInitialized) {
31+
dialog.dismiss()
32+
}
33+
}
34+
35+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.gtech.smartdialog.utils
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import androidx.fragment.app.Fragment
5+
import com.gtech.smartdialog.domain.DialogListeners
6+
import com.gtech.smartdialog.domain.LoadingDialogBuilder
7+
import com.gtech.smartdialog.domain.AlertDialogBuilder
8+
9+
// Loading dialog
10+
lateinit var loadingDialogBuilder: LoadingDialogBuilder
11+
12+
fun AppCompatActivity.startLoader(message: String) {
13+
try {
14+
this.runOnUiThread {
15+
loadingDialogBuilder = LoadingDialogBuilder(this)
16+
loadingDialogBuilder.start(message)
17+
}
18+
} catch (e: Exception) {
19+
e.printStackTrace()
20+
}
21+
}
22+
23+
fun AppCompatActivity.stopLoader() {
24+
try {
25+
this.runOnUiThread {
26+
loadingDialogBuilder.stop()
27+
}
28+
} catch (e: Exception) {
29+
e.printStackTrace()
30+
}
31+
}
32+
33+
fun Fragment.startLoader(message: String) {
34+
try {
35+
this.requireActivity().runOnUiThread {
36+
loadingDialogBuilder = LoadingDialogBuilder(requireActivity() as AppCompatActivity)
37+
loadingDialogBuilder.start(message)
38+
}
39+
} catch (e: Exception) {
40+
e.printStackTrace()
41+
}
42+
}
43+
44+
fun Fragment.stopLoader() {
45+
try {
46+
this.requireActivity().runOnUiThread {
47+
loadingDialogBuilder.stop()
48+
}
49+
} catch (e: Exception) {
50+
e.printStackTrace()
51+
}
52+
}
53+
54+
fun Fragment.showAlert(
55+
message: String, type: DialogType, dialogListeners: DialogListeners? = null
56+
) {
57+
try {
58+
requireActivity().runOnUiThread {
59+
AlertDialogBuilder(
60+
message, type, dialogListeners
61+
).show(requireActivity().supportFragmentManager, null)
62+
}
63+
} catch (e: Exception) {
64+
e.printStackTrace()
65+
}
66+
}
67+
68+
fun AppCompatActivity.showAlert(
69+
message: String, type: DialogType, dialogListeners: DialogListeners? = null
70+
) {
71+
try {
72+
this.runOnUiThread {
73+
AlertDialogBuilder(message, type, dialogListeners).show(
74+
this.supportFragmentManager, null
75+
)
76+
}
77+
} catch (e: Exception) {
78+
e.printStackTrace()
79+
}
80+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.gtech.smartdialog.utils
2+
3+
enum class DialogType {
4+
SUCCESS,
5+
INFO,
6+
ERROR
7+
}

0 commit comments

Comments
 (0)