Giter Site home page Giter Site logo

androidbuttonprogress's Introduction

AndroidButtonProgress

Android Arsenal

This is a combination of button and progress bar. There are 4 states in this view first Idle, Indeterminate, Determinate and Finish. it makes you easy to manage download button state in your app ui.

In a download case you can use this as.

  • 1st show download button to the user
  • 2nd show indeterminate progress bar, it tells the user that the download is connecting.
  • 3rd show determinate progress bar, which tells the user that the download is progressing
  • 4th show finish button/icon

Demo

demo

Usage

Use jitpack

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

Gradle

dependencies {
        implementation 'com.github.abdularis:androidbuttonprogress:1.0.2'
}

Please always use same width and height for this button progress view

<com.github.abdularis.buttonprogress.DownloadButtonProgress
	android:layout_width="45dp"
	android:layout_height="45dp"/>

sc1

You can also

<com.github.abdularis.buttonprogress.DownloadButtonProgress
	android:layout_width="72dp"
	android:layout_height="72dp"
	app:progressIndeterminateSweepAngle="1"
	app:state="INDETERMINATE"/>

demo1

Use custom drawable for every state

<com.github.abdularis.buttonprogress.DownloadButtonProgress
	android:id="@+id/button_progress_2"
	android:layout_width="64dp"
	android:layout_height="64dp"
	android:layout_marginTop="20dp"
	app:idleIconDrawable="@drawable/ic_download"
	app:idleBackgroundDrawable="@drawable/bg_button_progress"
	app:cancelIconDrawable="@drawable/ic_cancel"
	app:indeterminateBackgroundDrawable="@drawable/bg_button_progress"
	app:progressIndeterminateColor="#828282"
	app:determinateBackgroundDrawable="@drawable/bg_button_progress"
	app:progressDeterminateColor="#ef2241"
	app:finishIconDrawable="@drawable/ic_finish"
	app:finishBackgroundDrawable="@drawable/bg_button_progress"/>

sc1

Note: you can use DownloadButtonProgress as upload button too just replace the idle download icon with upload icon! :)

Click listener

DownloadButtonProgress btn = findViewById(R.id.button_progress_id);

btn.addOnClickListener(new DownloadButtonProgress.OnClickListener() {
	@Override
	public void onIdleButtonClick(View view) {
		// called when download button/icon is clicked
	}

	@Override
	public void onCancelButtonClick(View view) {
		// called when cancel button/icon is clicked
	}

	@Override
	public void onFinishButtonClick(View view) {
		// called when finish button/icon is clicked
	}
});

Attributes

attrs for DownloadButtonProgress

<declare-styleable name="DownloadButtonProgress">
	<attr name="state" format="enum">
		<enum name="IDLE" value="1"/>
		<enum name="INDETERMINATE" value="2"/>
		<enum name="DETERMINATE" value="3"/>
		<enum name="FINISHED" value="4"/>			
	</attr>
	<attr name="cancelable" format="boolean"/>
	<attr name="hideOnFinish" format="boolean"/>
	<attr name="progressIndeterminateSweepAngle" format="integer"/>

	<attr name="idleBackgroundColor" format="color"/>
	<attr name="finishBackgroundColor" format="color"/>
	<attr name="indeterminateBackgroundColor" format="color"/>
	<attr name="determinateBackgroundColor" format="color"/>

	<attr name="idleBackgroundDrawable" format="reference"/>
	<attr name="finishBackgroundDrawable" format="reference"/>
	<attr name="indeterminateBackgroundDrawable" format="reference"/>
	<attr name="determinateBackgroundDrawable" format="reference"/>

	<attr name="progress" format="integer"/>
	<attr name="maxProgress" format="integer"/>
	<attr name="progressWidth" format="dimension"/>
	<attr name="progressMargin" format="dimension"/>
	<attr name="progressDeterminateColor" format="color"/>
	<attr name="progressIndeterminateColor" format="color"/>

	<attr name="idleIconDrawable" format="reference"/>
	<attr name="idleIconWidth" format="dimension"/>
	<attr name="idleIconHeight" format="dimension"/>

	<attr name="cancelIconDrawable" format="reference"/>
	<attr name="cancelIconWidth" format="dimension"/>
	<attr name="cancelIconHeight" format="dimension"/>

	<attr name="finishIconDrawable" format="reference"/>
	<attr name="finishIconWidth" format="dimension"/>
	<attr name="finishIconHeight" format="dimension"/>
</declare-styleable>

License

Apache License 2.0

androidbuttonprogress's People

Contributors

abdularis avatar

Watchers

James Cloos 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.