Coder Social home page Coder Social logo

sudhakar-r08 / progressstatusbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from baselhorany/progressstatusbar

0.0 1.0 0.0 280 KB

Another way to show progress. A progress View over the system StatusBar.

License: Apache License 2.0

Java 100.00%

progressstatusbar's Introduction

ProgressStatusBar

Another way to show progress. A progress View over the system StatusBar. in addition to showing a toast message.

The first form is suitable for showing that the activity is being loaded like fetching data from server, meanwhile the second form is better for real process and the third is for waiting.

Important Note

Due to Android O changes, this will not work on API 27 and above so you have to check:

if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
    // use this library 
} else { 
    // another progress way 
}

Setup

1- Add jitpack.io repositories to you project build.gradle

allprojects {
	repositories {
	    maven { url 'https://jitpack.io' }
	}
}

2- Add it as a dependency to your app build.gradle

dependencies {
  compile 'com.github.BaselHorany:ProgressStatusBar:1.1.4'
}

3- Add SYSTEM_ALERT_WINDOW permission

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

Usage

1- In your Activity class

public class MainActivity extends AppCompatActivity {

    ProgressStatusBar mProgressStatusBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.acitivity_main);
	
	//initialize
        mProgressStatusBar = new ProgressStatusBar(this); 
	
	//show progress
        mProgressStatusBar.setFakeProgress(3000,true); //make fake progress from 0 to 100 in 3 sec. true/false for display the percentage text.
	//or
        mProgressStatusBar.setProgress(60,false); //set progress value manually
	//or
        mProgressStatusBar.setWaiting(6000); //show waitting balls for 6 sec.
	
	//show toast message
	mProgressStatusBar.showToast("1 new message", 3000); //(Sting message, int duratoion)
		
	/*Addidional*/
	//options, anytime before you start a new progress 
	mProgressStatusBar.setProgressColor(COLOR);//default #40212121
	mProgressStatusBar.setProgressBackgroundColor(COLOR);//default transparent or colorPrimaryDark
	mProgressStatusBar.setBallsColor(COLOR);//default #ffffff
	mProgressStatusBar.setTextColor(COLOR);//default #ffffff

	//Listener
        mProgressStatusBar.setProgressListener(new ProgressStatusBar.OnProgressListener() {
            public void onStart() {
                //ex: lock the UI or tent it
            }
            public void onUpdate(int progress) {
                //ex: simulate with another progressView
            }
            public void onEnd() {
                //ex: continue the job
            }
        });
	
    }
    

    @Override
    protected void onPause() {
        mProgressStatusBar.remove(); //remove progress view in case user went out before the progress end
        super.onPause();
    }
    
}

Important Note

Due to Android O changes, this will not work on API 27 and above so you have to check:

if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
    // use this library 
} else { 
    // another progress way 
}

Author

Basel Horany http://baselhorany.com

progressstatusbar's People

Contributors

baselhorany avatar

Watchers

Sudhakar Raju avatar

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.