GithubHelp home page GithubHelp logo

morristech / timer-button Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dhruvtaneja/timer-button

0.0 1.0 0.0 144 KB

Timer button is a countdown enabled button which can be used to disable user interactions while showing a timer on top of it.

Java 100.00%

timer-button's Introduction

Timer Button

Android Arsenal

Timer button is a countdown enabled button which can be used to disable user interactions while showing a timer on top of it.

Gradle

To include this library in your gradle project

dependencies {
	// ... other dependencies here
    implementation 'com.dt:timerbutton:0.1'
}

Maven

To include this library in your maven project

<dependency>
  <groupId>com.dt</groupId>
  <artifactId>timerbutton</artifactId>
  <version>0.1</version>
  <type>pom</type>
</dependency>

Usage

Put this button in your layout file like this

<com.dhruv.timerbutton.TimerButton
        android:id="@+id/timer_button"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        app:animationBackground="@color/colorAccentTrans"
        app:animationCompleteText="@string/resend_otp"
        app:buttonBackground="@drawable/selector_button"
        app:defaultText="@string/send_otp"
        app:dynamicString="@string/resend_otp_formatted"
        app:textColor="@color/colorPrimaryDark"/>

The various attributes that are available are

<declare-styleable name="TimerButton">
        <!--text to be displayed after animation is complete-->
        <attr name="animationCompleteText" format="string|reference"/>
        <!--text to be displayed in pre-animation state-->
        <attr name="defaultText" format="string|reference"/>
        <!--text to be displayed during animation-->
        <attr name="dynamicString" format="reference"/>
        <!--the overlay that animates over the button. Can be a drawable, a gradient, etc-->
        <attr name="animationBackground" format="reference"/>
        <!--the background of the button-->
        <attr name="buttonBackground" format="reference"/>
        <!--color of the text-->
        <attr name="textColor" format="reference|color"/>
        <!--size of the text-->
        <attr name="textSize" format="reference|dimension"/>
    </declare-styleable>

Now in your java code, start, stop or reset the animation with something like this

TimerButton timerButton = findViewById(R.id.timer_button);
timerButton.setDuration(6000L);

//  Start the animation
timerButton.start();

//  Stop the animation
timerButton.stop();

//  Reset the animation
timerButton.reset();

Issues and pull requests are most welcome

timer-button's People

Contributors

dhruvtaneja avatar

Watchers

 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.