Coder Social home page Coder Social logo

yatindeokar / myloadingbutton Goto Github PK

View Code? Open in Web Editor NEW
47.0 4.0 5.0 147 KB

This is animated button which animate into three state Loading state, Done state and Error state.

License: MIT License

Java 100.00%
android animation button loading-animations loading-indicator animated-button success-view error-view-button morph morphing-animations

myloadingbutton's Introduction

MyLoadingButton

MyLoadingButton is a library that allows you to create a animated button which converts into loading, error and done state.

myloadingbuttondemon

Gradle Dependency

Repository

Add this in your root build.gradle file ( not your module build.gradle file):

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

Dependency

Add this to your module's build.gradle file:

dependencies {
		compile 'com.github.yatindeokar:MyLoadingButton:v1.0.1'
	}

Basic Usage

XML

To use this MyLoadingButton in your layout simply copy and paste the xml below. This provides the default MyLoadingButton.

<com.example.myloadingbutton.MyLoadingButton
        android:id="@+id/my_loading_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

MyLoadingButton Attr

       < ...
        app:mlb_labelSize="5sp"  // Set MyLoadingButton label size.
        app:mlb_label="Login Button"  // Set MyLoadingButton label text/name.
        app:mlb_backgroundColor="@color/view_color_gray"  // Set MyLoadingButton custom background color.
        app:mlb_labelColor="@color/colorAccent" // Set MyLoadingButton custom label color.
        app:mlb_loaderColor="@color/colorPrimaryDark" // Set MyLoadingButton loader color.
        app:mlb_setNormalAfterError="false" // Set MyLoadingButton to normal if its in error state, by default true.
        app:mlb_animationDuration="300" // Set MyLoadingButton animation duration.
        app:mlb_setErrorIcon="@drawable/ic_progress_cancel" // Set MyLoadingButton error icon.
        app:mlb_setDoneIcon="@drawable/ic_progress_done" // Set MyLoadingButton done icon.
        />

Init from Java

Implements to get MyLoadingButton click listener

implements MyLoadingButton.MyLoadingButtonClick

MyLoadingButton myLoadingButton = findViewById(R.id.my_loading_button);
myLoadingButton.setMyButtonClickListener(this); // Set MyLoadingButton click listener

myLoadingButton.setAnimationDuration(300)
                .setButtonColor(R.color.colorAccent) // Set MyLoadingButton custom background color.
                .setButtonLabel("Label") // Set MyLoadingButton button label text.
                .setButtonLabelSize(20) // Set button label size in integer.
                .setProgressLoaderColor(Color.WHITE) // Set Color att for loader color.
                .setButtonLabelColor(R.color.white) // Set button label/text color.
                .setProgressDoneIcon(getResources().getDrawable(R.drawable.ic_progress_done)) // Set MyLoadingButton done icon drawable.
                .setProgressErrorIcon(getResources().getDrawable(R.drawable.ic_progress_cancel)) //Set MyLoadingButton error icon drawable.
                .setNormalAfterError(false); // Button animate to normal state if its in error state ,by default true.
                

Change Button State

Change button state to LOADING

myLoadingButton.showLoadingButton();

Change button state to NORMAL

myLoadingButton.showNormalButton();

Change button state to ERROR

myLoadingButton.showErrorButton();

Change button state to DONE

myLoadingButton.showDoneButton();

MIT License

    Copyright (c) 2017 Yatin I Deokar.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

myloadingbutton's People

Contributors

yatindeokar 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

Watchers

 avatar  avatar  avatar  avatar

myloadingbutton's Issues

Crash app using this library.

When i use this library then app crash and get error :

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.xxxx.xxxxx, PID: 14907
    java.lang.NullPointerException: Attempt to invoke interface method 'void com.example.myloadingbutton.MyLoadingButton$MyLoadingButtonClick.onMyLoadingButtonClick()' on a null object reference
        at com.example.myloadingbutton.MyLoadingButton.onClick(MyLoadingButton.java:373)
        at android.view.View.performClick(View.java:7870)
        at android.view.View.performClickInternal(View.java:7839)
        at android.view.View.access$3600(View.java:886)
        at android.view.View$PerformClick.run(View.java:29363)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7807)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)

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.