All Projects → yuvraj24 → Livesmashbar

yuvraj24 / Livesmashbar

Licence: apache-2.0
An elegant looking and easy to use informative library with LiveData integration for Android.

Programming Languages

kotlin
9241 projects
gravity
16 projects

Projects that are alternatives of or similar to Livesmashbar

media-picker
Easy customizable picker for all your needs in Android application
Stars: ✭ 167 (+56.07%)
Mutual labels:  android-sdk, android-development, android-application, android-studio, android-app
Mediapicker
Easy customizable picker for all your needs in Android application
Stars: ✭ 105 (-1.87%)
Mutual labels:  android-app, android-studio, android-application, android-development, android-sdk
Androidkex
Extensions for Kotlin. Use the power of Kotlin to make your code smaller and beautiful.
Stars: ✭ 35 (-67.29%)
Mutual labels:  android-app, android-studio, android-application, android-development, android-sdk
Modern Android Development
Modern Android Development tools & key points
Stars: ✭ 219 (+104.67%)
Mutual labels:  android-app, android-studio, android-application, android-development, android-sdk
Ibackdrop
A library to simply use Backdrop in your project (make it easy). Read more ->
Stars: ✭ 137 (+28.04%)
Mutual labels:  android-app, android-studio, android-application, android-development, android-sdk
Android-daily-read-tips
log for articles and info in android for every developer
Stars: ✭ 13 (-87.85%)
Mutual labels:  android-sdk, android-development, android-application, android-studio, android-app
Android Inappbilling
A sample which uses Google's Play Billing Library and it does InApp Purchases and Subscriptions.
Stars: ✭ 114 (+6.54%)
Mutual labels:  android-app, android-studio, android-application, android-development, android-sdk
Kotlin Android Scaffolding
An android project structure using kotlin and most common libraries.
Stars: ✭ 53 (-50.47%)
Mutual labels:  android-app, android-studio, android-application, android-development, android-sdk
Cameraxdemo
A sample camera app with CameraX API from Android Jetpack
Stars: ✭ 112 (+4.67%)
Mutual labels:  android-app, android-studio, android-application, android-development, android-sdk
Android-MonetizeApp
A sample which uses Google's Play Billing Library and it makes In-app Purchases and Subscriptions.
Stars: ✭ 149 (+39.25%)
Mutual labels:  android-sdk, android-development, android-studio, android-app
FireFiles
Powerful Android File Manager for everything that runs on Android OS (Android TV, Android Watch, Mobile, etc)
Stars: ✭ 37 (-65.42%)
Mutual labels:  android-development, android-application, android-studio, android-app
CustomFontView
Custom View classes for TextView, EditText & Buttons - to set custom fonts
Stars: ✭ 26 (-75.7%)
Mutual labels:  android-sdk, android-application, android-studio, android-app
android-jetpack
🚀 Road to Accelerate Android Development using Jetpack
Stars: ✭ 50 (-53.27%)
Mutual labels:  android-sdk, android-development, android-studio, android-app
Biometric-Authentication-Android
A sample implementation of AndroidX biometrics API using Kotlin. Authenticate using biometrics or PIN/Password if biometrics isn't available on device. Fully implemented in Jetpack compose using Material 3 dynamic theming and also has a separate implementation in xml with MDC 3.
Stars: ✭ 29 (-72.9%)
Mutual labels:  android-sdk, android-development, android-studio, android-app
Zoomrecylerlayout
🎢 Zoom Recycler Layout Manager For Android Kotlin
Stars: ✭ 618 (+477.57%)
Mutual labels:  android-app, android-studio, android-application, android-development
Android Arsenal.com
Source to android-arsenal.herokuapp.com
Stars: ✭ 541 (+405.61%)
Mutual labels:  android-app, android-application, android-development, android-sdk
Permissionsflow
A simple library to make it easy requesting permissions in Android using Kotlin Coroutines.
Stars: ✭ 49 (-54.21%)
Mutual labels:  android-app, android-application, android-development, android-sdk
Awesome Android Ui
😎 A curated list of awesome Android UI/UX libraries
Stars: ✭ 353 (+229.91%)
Mutual labels:  android-app, android-studio, android-development, android-sdk
Androidroom
Android example to show how to use Room to access SQLite database on device for reading and writing data. This example also shows how to use LiveData and ViewModel with Room to build reactive, well performing and easy to maintain applications.
Stars: ✭ 36 (-66.36%)
Mutual labels:  android-app, android-application, android-development, livedata
Dagger2 Sample
A sample app to demo how to implement dagger in Android using Dagger Android Support library
Stars: ✭ 72 (-32.71%)
Mutual labels:  android-studio, android-application, android-development, livedata

LiveSmashBar

Download API License

LiveSmashBar allows you a great alternative for native snackbar & toast in Android. It allows a great extent of customisation & flexibility in terms of usage & behaviour.

Also it has support for LiveData which can be beneficial for displaying repetitive messages just be single initialization.

Library has been designed & developed purely in Kotlin. ❤️

Alt text

Spread Your ❤️:

GitHub followers Twitter Follow

Samples

You can check the Demo Project developed in kotlin for better understanding of concepts & usage.

Get it on Google Play

Download

This library is available in maven & jcenter which can also be imported from source as a module.

maven

<dependency>
    <groupId>com.yuvraj.livesmashbar</groupId>
    <artifactId>smashbar</artifactId>
    <version>1.0.0</version>
    <type>pom</type>
</dependency>

gradle

dependencies {
    // other dependencies here
    implementation 'com.yuvraj.livesmashbar:smashbar:1.0.0'
}

Get Started

Basic

Alt text

Shows a simple LiveSmashBar with description & duration.

LiveSmashBar.Builder(this)
            .description(getString(R.string.description))
            .descriptionColor(ContextCompat.getColor(this, R.color.white))
            .gravity(GravityView.BOTTOM)
            .duration(3000)
            .show();

Also you can show both title & description along with duration in milliseconds. Duration is set to indefinite which means it won't dismiss until & unless specified for.Also you can use predefined parameters i.e DURATION_SHORT = 1000, DURATION_LONG = 2500 for specifying duration for LiveSmashBar.

LiveSmashBar.Builder(this)
            .title(getString(R.string.title))
            .titleColor(ContextCompat.getColor(this, R.color.white))
            .description(getString(R.string.description))
            .descriptionColor(ContextCompat.getColor(this, R.color.white))
            .gravity(GravityView.BOTTOM)
            .duration(DURATION_SHORT)
            .show();

Gravity

Gravity_top

You can show LiveSmashBar at both Bottom ae well as Top of the screen by specifying GravityView.BOTTOM / GravityView.TOP.

GravityView.BOTTOM :

LiveSmashBar.Builder(this)
            .title(getString(R.string.title))
            .description(getString(R.string.description))
            .gravity(GravityView.BOTTOM)
            .duration(DURATION_SHORT)
            .show();

GravityView.TOP :

LiveSmashBar.Builder(this)
            .title(getString(R.string.title))
            .description(getString(R.string.description))
            .gravity(GravityView.TOP)
            .duration(DURATION_SHORT)
            .show();

LiveData Support

LiveData

LiveSmashBar allows support for LiveData , which can be used for showing similar group of messages with single initialization thereby avoiding code redundancy. This can be achieved by simply creating a LiveSmashBar instance & passing the livedata object as parameter. So when ever you post anything to livedata, your LiveSmashBar will receive that call back and will display the same to the end user. Following is a sample demostrating the use of livedata,

val liveData: MutableLiveData<Unit> = MutableLiveData()

LiveSmashBar.Builder(this)
            .showIcon()
            .icon(R.mipmap.ic_launcher)
            .title(getString(R.string.flutter_title)) 
            .description(getString(R.string.flutter_info)) 
            .gravity(GravityView.BOTTOM)
            .liveDataCallback(this, liveData)

Icon

Gravity_top

You can add icons to make details displayed on LiveSmashBar more meaningful & intuitive.

LiveSmashBar.Builder(this)
            .icon(R.mipmap.ic_launcher)
            .title(getString(R.string.title))
            .titleColor(ContextCompat.getColor(this, R.color.white))
            .description(getString(R.string.description))
            .descriptionColor(ContextCompat.getColor(this, R.color.white))
            .gravity(GravityView.BOTTOM)
            .duration(DURATION_SHORT)
            .show();

Also you can apply animation to icons, with the following snippet,

LiveSmashBar.Builder(this)
            .icon(R.mipmap.ic_launcher)
            .iconAnimation(AnimIconBuilder(this).pulse())
            .title(getString(R.string.description))
            .titleColor(ContextCompat.getColor(this, R.color.white))
            .gravity(GravityView.TOP)
            .duration(3000)
            .show()

Primary Button

Primary_Action

Similar to Snackbar, a message can be accompanied by an action button which can be used to perform some functionality. Below example listens for action button click to dismiss LiveSmashBar displayed to user.

LiveSmashBar.Builder(this)
            .icon(R.mipmap.ic_launcher)
            .title(getString(R.string.title)) 
            .description(getString(R.string.description)) 
            .primaryActionText("DONE") 
            .primaryActionEventListener(object : OnEventTapListener {
                      override fun onActionTapped(bar: LiveSmashBar) {
                                bar.dismiss()
                       }
             })
            .show();

Dialog Style

Dialog_Style

LiveSmashBar can also be used to display a dialog view with a message & action buttons. By defalut the view type set is BarStyle.DEFAULT_MESSAGE which shows basic message with action button. For displaying dialog style LiveSmashBar use the following snippet,

LiveSmashBar.Builder(this)
            .icon(R.mipmap.ic_launcher)
            .title(getString(R.string.title)) 
            .description(getString(R.string.description)) 
            .backgroundColor(ContextCompat.getColor(this, R.color.orange))
            .setBarStyle(BarStyle.DIALOG)
            .positiveActionText("DONE")
            .positiveActionTextColor(ContextCompat.getColor(this, R.color.white))
            .positiveActionEventListener(object : OnEventTapListener {
                     override fun onActionTapped(bar: LiveSmashBar) {
                             bar.dismiss()
                     }
            })
            .negativeActionText("CLOSE")
            .negativeActionTextColor(ContextCompat.getColor(this, R.color.white))
            .negativeActionEventListener(object : OnEventTapListener {
                     override fun onActionTapped(bar: LiveSmashBar) {
                             bar.dismiss()
                     }
            })
            .show();

Overlay

Dialog_Style

LiveSmashBar allows to show modal overlay messages that dims the background & highlights the message to user. It blocks the UI if function overlayBlockable() is called thereby blocking user taps on the underlying content. You can dismiss the overlay by calling function dismissOnTapOutside() for dismissing the overlay.

LiveSmashBar.Builder(this)
            .showIcon()
            .icon(R.mipmap.ic_launcher)
            .title(getString(R.string.flutter_title))
            .description(getString(R.string.flutter_info))
            .gravity(GravityView.TOP)
            .dismissOnTapOutside()
            .showOverlay()
            .overlayBlockable()
            .backgroundColor(ContextCompat.getColor(this, R.color.white))
            .show();            

Event Listeners

You can subscribe to events like when the LiveSmashBar is showing, or dismissing. You can also subscribe to when the LiveSmashBar is being shown or dismissed to perform animations on other views if needed.

You can also subscribe to tap events inside or outside the bar.

Show Event

You can subscribe to events on OnEventShowListener as follows,

LiveSmashBar.Builder(this) 
        .title("Hello World!")
        .description("You can listen to events when the LiveSmashBar is shown")
        .barShowListener(object : LiveSmashBar.OnEventShowListener {
            override fun onShowing(bar: LiveSmashBar) {
                Log.d(TAG, "LiveSmashBar is showing")
            }

            override fun onShown(bar: LiveSmashBar) {
                Log.d(TAG, "LiveSmashBar is shown")
            }
        })
        .show()

Dismiss

You can listen to events on OnEventDismissListener for dismissing events. You can also specifically get to know the reason behind the bar dismiss action - TIMEOUT, MANUAL, TAP_OUTSIDE and SWIPE.

LiveSmashBar.Builder(this) 
        .title("Hello World!") 
        .description("You can listen to events when the LiveSmashBar is dismissed")
        .barDismissListener(object : LiveSmashBar.OnEventDismissListener {
            override fun onDismissing(bar: LiveSmashBar, isSwiped: Boolean) {
                Log.d(TAG, "LiveSmashBar is dismissing with $isSwiped")
            }

            override fun onDismissed(bar: LiveSmashBar, event: LiveSmashBar.DismissEvent) {
                Log.d(TAG, "LiveSmashBar is dismissed with event $event")
            }
        }) 
        .show()

Taps

You can listen to tap events inside or outside of the LiveSmashBar.

LiveSmashBar.Builder(this) 
        .title("Hello World!")
        .description("You can listen to tap events inside or outside the LiveSmashBar.")
        .listenBarTaps(object : LiveSmashBar.OnEventListener {
            override fun onTap(bar: LiveSmashBar) {
                Log.d(TAG, "Bar tapped")
            }
        })
        .listenOutsideTaps(object : LiveSmashBar.OnTapListener {
            override fun onTap(bar: LiveSmashBar) {
                Log.d(TAG, "Outside tapped")
            }
        })
        .show()

About Me

Yuvraj Pandey

I am a passionate Mobility Engineer which likes to push himself on various fronts of technologies.

For more exciting updates follow me,

                                    

License


Copyright 2018 Yuvraj Pandey 

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].