Skip to content

Commit 33333e5

Browse files
committed
Latest Commit
1 parent f67f5ab commit 33333e5

File tree

71 files changed

+3359
-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.

71 files changed

+3359
-0
lines changed

app/.gitignore

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

app/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.application'
2+
3+
apply plugin: 'kotlin-android'
4+
5+
apply plugin: 'kotlin-android-extensions'
6+
7+
android {
8+
compileSdkVersion 27
9+
defaultConfig {
10+
applicationId "com.yuvraj.livesmashbardemo"
11+
minSdkVersion 16
12+
targetSdkVersion 27
13+
versionCode 1
14+
versionName "1.0"
15+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
}
24+
25+
dependencies {
26+
implementation fileTree(dir: 'libs', include: ['*.jar'])
27+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
28+
implementation 'com.android.support:appcompat-v7:27.1.1'
29+
30+
implementation project(':library')
31+
implementation 'com.android.support:recyclerview-v7:27.1.1'
32+
implementation 'com.android.support:design:27.1.1'
33+
implementation "android.arch.lifecycle:livedata:1.1.1"
34+
}

app/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.yuvraj.livemessagebar
2+
3+
import android.support.test.InstrumentationRegistry
4+
import android.support.test.runner.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.getTargetContext()
22+
assertEquals("com.yuvraj.livemessagebar", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.yuvraj.livesmashbardemo">
3+
4+
<application
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:label="@string/app_name"
8+
android:roundIcon="@mipmap/ic_launcher_round"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity
12+
android:name="com.yuvraj.livesmashbardemo.SampleActivity"
13+
android:label="@string/app_name">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
</application>
21+
</manifest>
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
package com.yuvraj.livesmashbardemo
2+
3+
import android.arch.lifecycle.LifecycleOwner
4+
import android.arch.lifecycle.MutableLiveData
5+
import android.os.Bundle
6+
import android.os.Handler
7+
import android.support.v4.content.ContextCompat
8+
import android.support.v7.app.AppCompatActivity
9+
import android.support.v7.widget.LinearLayoutManager
10+
import com.yuvraj.livesmashbar.anim.AnimIconBuilder
11+
import com.yuvraj.livesmashbar.enums.BarStyle
12+
import com.yuvraj.livesmashbar.enums.DismissEvent
13+
import com.yuvraj.livesmashbar.enums.GravityView
14+
import com.yuvraj.livesmashbar.lintener.OnEventDismissListener
15+
import com.yuvraj.livesmashbar.lintener.OnEventListener
16+
import com.yuvraj.livesmashbar.lintener.OnEventShowListener
17+
import com.yuvraj.livesmashbar.lintener.OnEventTapListener
18+
import com.yuvraj.livesmashbar.view.LiveSmashBar
19+
import kotlinx.android.synthetic.main.activity_sample.*
20+
21+
class SampleActivity : AppCompatActivity(), OnEventTapListener,
22+
OnEventListener, OnEventDismissListener, OnEventShowListener,
23+
SampleRecyclerAdapter.OnItemClickListener, LifecycleOwner {
24+
25+
var listSamples = arrayListOf<String>();
26+
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
29+
setContentView(R.layout.activity_sample)
30+
31+
createSamplesList();
32+
33+
recycler_samples.layoutManager = LinearLayoutManager(this);
34+
recycler_samples.adapter = SampleRecyclerAdapter(this, listSamples, this);
35+
}
36+
37+
private fun createSamplesList() {
38+
listSamples.add("Simple LiveSmashBar")
39+
listSamples.add("Simple LiveSmashBar with Icon & Action button")
40+
listSamples.add("Simple Dialog LiveSmashBar with Icon & Action button")
41+
listSamples.add("Simple Overlay LiveSmashBar")
42+
listSamples.add("Simple LiveSmashBar using LiveData & LifecycleOwner")
43+
listSamples.add("Simple LiveSmashBar with Gravity Top")
44+
listSamples.add("Simple LiveSmashBar with Gravity Top , Icon & Action button")
45+
listSamples.add("Simple Dialog LiveSmashBar with Gravity Top , Icon & Action button")
46+
listSamples.add("Simple Dialog LiveSmashBar with Gravity Top")
47+
listSamples.add("Simple LiveSmashBar Pulse Animation effect")
48+
}
49+
50+
override fun onActionTapped(bar: LiveSmashBar) {
51+
52+
53+
}
54+
55+
override fun onTap(liveSmashBar: LiveSmashBar) {
56+
57+
}
58+
59+
override fun onDismissing(bar: LiveSmashBar, isSwiped: Boolean) {
60+
61+
}
62+
63+
override fun onDismissProgress(bar: LiveSmashBar, progress: Float) {
64+
65+
}
66+
67+
override fun onDismissed(bar: LiveSmashBar, event: DismissEvent) {
68+
69+
}
70+
71+
override fun onShowing(bar: LiveSmashBar) {
72+
73+
}
74+
75+
override fun onShowProgress(bar: LiveSmashBar, progress: Float) {
76+
77+
}
78+
79+
override fun onShown(bar: LiveSmashBar) {
80+
81+
}
82+
83+
override fun onItemClick(position: Int) {
84+
when (position) {
85+
0 ->
86+
LiveSmashBar.Builder(this)
87+
.title(getString(R.string.title))
88+
.titleColor(ContextCompat.getColor(this, R.color.white))
89+
.description(getString(R.string.description))
90+
.descriptionColor(ContextCompat.getColor(this, R.color.white))
91+
.gravity(GravityView.BOTTOM)
92+
.duration(3000)
93+
.show();
94+
95+
1 ->
96+
LiveSmashBar.Builder(this)
97+
.icon(R.mipmap.ic_launcher)
98+
.title(getString(R.string.title))
99+
.titleColor(ContextCompat.getColor(this, R.color.white))
100+
.description(getString(R.string.description))
101+
.descriptionColor(ContextCompat.getColor(this, R.color.white))
102+
.gravity(GravityView.BOTTOM)
103+
.duration(3000)
104+
.primaryActionText("DONE")
105+
.primaryActionTextColor(ContextCompat.getColor(this, R.color.white))
106+
.primaryActionEventListener(object : OnEventTapListener {
107+
override fun onActionTapped(bar: LiveSmashBar) {
108+
bar.dismiss()
109+
}
110+
})
111+
.show();
112+
113+
2 ->
114+
LiveSmashBar.Builder(this)
115+
.icon(R.mipmap.ic_launcher)
116+
.title(getString(R.string.title))
117+
.titleColor(ContextCompat.getColor(this, R.color.white))
118+
.description(getString(R.string.description))
119+
.descriptionColor(ContextCompat.getColor(this, R.color.white))
120+
.gravity(GravityView.BOTTOM)
121+
.backgroundColor(ContextCompat.getColor(this, R.color.colorPrimary))
122+
.setBarStyle(BarStyle.DIALOG)
123+
.positiveActionText("DONE")
124+
.positiveActionTextColor(ContextCompat.getColor(this, R.color.white))
125+
.positiveActionEventListener(object : OnEventTapListener {
126+
override fun onActionTapped(bar: LiveSmashBar) {
127+
bar.dismiss()
128+
}
129+
})
130+
.negativeActionText("CLOSE")
131+
.negativeActionTextColor(ContextCompat.getColor(this, R.color.white))
132+
.negativeActionEventListener(object : OnEventTapListener {
133+
override fun onActionTapped(bar: LiveSmashBar) {
134+
bar.dismiss()
135+
}
136+
})
137+
.show();
138+
3 ->
139+
LiveSmashBar.Builder(this)
140+
.showIcon()
141+
.icon(R.mipmap.ic_launcher)
142+
.title(getString(R.string.flutter_title))
143+
.titleColor(ContextCompat.getColor(this, R.color.slate_black))
144+
.description(getString(R.string.flutter_info))
145+
.descriptionColor(ContextCompat.getColor(this, R.color.slate_black))
146+
.gravity(GravityView.BOTTOM)
147+
.dismissOnTapOutside()
148+
.showOverlay()
149+
.overlayBlockable()
150+
.backgroundColor(ContextCompat.getColor(this, R.color.white))
151+
.show();
152+
153+
4 -> {
154+
155+
val liveData: MutableLiveData<Unit> = MutableLiveData()
156+
157+
LiveSmashBar.Builder(this)
158+
.showIcon()
159+
.icon(R.mipmap.ic_launcher)
160+
.title(getString(R.string.flutter_title))
161+
.titleColor(ContextCompat.getColor(this, R.color.white))
162+
.description(getString(R.string.flutter_info))
163+
.descriptionColor(ContextCompat.getColor(this, R.color.white))
164+
.gravity(GravityView.BOTTOM)
165+
.duration(3000)
166+
.liveDataCallback(this, liveData)
167+
168+
Handler().postDelayed({
169+
liveData.postValue(Unit)
170+
}, 2000)
171+
}
172+
173+
5 ->
174+
LiveSmashBar.Builder(this)
175+
.icon(R.mipmap.ic_launcher)
176+
.title(getString(R.string.description))
177+
.titleColor(ContextCompat.getColor(this, R.color.white))
178+
.gravity(GravityView.TOP)
179+
.duration(3000)
180+
.show()
181+
182+
6 ->
183+
LiveSmashBar.Builder(this)
184+
.showIcon()
185+
.icon(R.mipmap.ic_launcher)
186+
.title(getString(R.string.flutter_title))
187+
.titleColor(ContextCompat.getColor(this, R.color.white))
188+
.description(getString(R.string.flutter_info))
189+
.descriptionColor(ContextCompat.getColor(this, R.color.white))
190+
.gravity(GravityView.TOP)
191+
.duration(3000)
192+
.primaryActionText("DONE")
193+
.primaryActionTextColor(ContextCompat.getColor(this, R.color.white))
194+
.primaryActionEventListener(object : OnEventTapListener {
195+
override fun onActionTapped(bar: LiveSmashBar) {
196+
bar.dismiss()
197+
}
198+
})
199+
.show()
200+
201+
7 ->
202+
LiveSmashBar.Builder(this)
203+
.icon(R.mipmap.ic_launcher)
204+
.title(getString(R.string.title))
205+
.titleColor(ContextCompat.getColor(this, R.color.white))
206+
.description(getString(R.string.description))
207+
.descriptionColor(ContextCompat.getColor(this, R.color.white))
208+
.gravity(GravityView.TOP)
209+
.setBarStyle(BarStyle.DIALOG)
210+
.positiveActionText("DONE")
211+
.positiveActionTextColor(ContextCompat.getColor(this, R.color.white))
212+
.positiveActionEventListener(object : OnEventTapListener {
213+
override fun onActionTapped(bar: LiveSmashBar) {
214+
bar.dismiss()
215+
}
216+
})
217+
.negativeActionText("CLOSE")
218+
.negativeActionTextColor(ContextCompat.getColor(this, R.color.white))
219+
.negativeActionEventListener(object : OnEventTapListener {
220+
override fun onActionTapped(bar: LiveSmashBar) {
221+
bar.dismiss()
222+
}
223+
})
224+
.show();
225+
226+
8 ->
227+
LiveSmashBar.Builder(this)
228+
.showIcon()
229+
.icon(R.mipmap.ic_launcher)
230+
.title(getString(R.string.flutter_title))
231+
.titleColor(ContextCompat.getColor(this, R.color.slate_black))
232+
.description(getString(R.string.flutter_info))
233+
.descriptionColor(ContextCompat.getColor(this, R.color.slate_black))
234+
.gravity(GravityView.TOP)
235+
.dismissOnTapOutside()
236+
.showOverlay()
237+
.overlayBlockable()
238+
.backgroundColor(ContextCompat.getColor(this, R.color.white))
239+
.show();
240+
241+
9 ->
242+
LiveSmashBar.Builder(this)
243+
.icon(R.mipmap.ic_launcher)
244+
.iconAnimation(AnimIconBuilder(this).pulse())
245+
.title(getString(R.string.description))
246+
.titleColor(ContextCompat.getColor(this, R.color.white))
247+
.gravity(GravityView.TOP)
248+
.duration(3000)
249+
.show()
250+
}
251+
}
252+
}

0 commit comments

Comments
 (0)