Giter VIP home page Giter VIP logo

statusbaralert's Introduction

Android Arsenal

What is this?

This is a small library inspired by Telegram X status bar new alert written in Kotlin. It can show custom message with optional indeterminate progress in status bar area. Optional autohide feature can be tweaked with custom duration. When showing, status bar alert kindly hides status bar's icon with SYSTEM_UI_FLAG_LOW_PROFILE flag mode, if available from os.

Supported devices

This lib is supported by every device with a SDK level of at least 14 (Android 4+. On Android 4.x the alert will be drawn below the status).

Android X required for v1.1.0 and above, otherwise use old version v1.0.2.

Quick walkthrough

Gradle

Step 1. Add the JitPack repository to your build file

gradle: add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
	maven { url 'https://jitpack.io' }
    }
}
Step 2. Add this line to your app's dependencies:
implementation 'com.github.fede87:StatusBarAlert:2.0.0'

Quick Sample

Create a new StatusBarAlert in activities and fragments.

Using Kotlin DSL:

statusBarAlert {
    autoHide()
    duration(2, TimeUnit.SECONDS)
    showProgress()
    text("Kotlin DSL")
    alertColor(android.R.color.red)
    textColor(android.R.color.white)
    progressBarColor(android.R.color.white)
}.show()

Using Java way:

val statusBarAlertview: StatusBarAlert = StatusBarAlert.Builder(this@MainActivity)
                       .autoHide()
                       .withDuration(100)
                       .showProgress()
                       .text("autohide!")
                       .alertColor(R.color.colorPrimaryDark)
                       .textColor(R.color.colorAccent)
                       .progressBarColor(R.color.colorAccent)
                       .typeface(typeface)
                       .build().show()
                       
                       
//update status bar alert view text at any time:
statusBarAlertView.setText("UPDATED!!")
//or:
statusBarAlertView.setText(R.string.updated)
 
 
// show indeterminate progress:
statusBarAlertView.showProgress()
 
// hide indeterminate progress:
statusBarAlertView.hideProgress()

License

Copyright 2018 Federico Marin

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.

statusbaralert's People

Contributors

datl4g avatar fede87 avatar nestoleh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

statusbaralert's Issues

Problem with Recyclerview after show message

Hey mate, first of all I want to say congrats to the work that you have made here.

Its a really good library, to be honest.

But I'm facing a issue that is making me really crazy.

I'm calling the StatusBarAlert message and, after that, I call the setAdapter to populate my RecyclerView.

But, the onBindViewHolder its not called. Not until I scroll the empty Recycler, who is setted to "match_parent".

I tried to change the StatusBarAlert to a simple SnackBar, and it made my recycler work again.

Do you imagine what is causing this trouble with Recycleview?

Current status of alert

How do I know if the status bard alert is already attached to the window or basically get the current status of the alert to see if it is attached/removed/ dismissing etc? Couldn't find the same in the documentation.

Fatal Exception: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:5341)
at android.view.ViewGroup.addView(ViewGroup.java:5162)
at android.view.ViewGroup.addView(ViewGroup.java:5102)
at android.view.ViewGroup.addView(ViewGroup.java:5074)
at com.fede987.statusbaralert.StatusBarAlert$showInternal$2.run(StatusBarAlert.kt:189)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:240)
at android.os.Looper.loop(Looper.java:351)
at android.app.ActivityThread.main(ActivityThread.java:8381)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.