GithubHelp home page GithubHelp logo

max4aters / lineartimer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krtkush/lineartimer

0.0 0.0 0.0 938 KB

A custom view for circular progress animation on Android.

Home Page: https://play.google.com/store/apps/details?id=io.github.krtkush.lineartimeproject

License: GNU General Public License v3.0

Java 100.00%

lineartimer's Introduction

Android Arsenal

Linear Timer

Linear Timer is a custom view for Android that enables circular progress animation with respect to given duration.

Linear Timer supports following features -

  1. Progress animation in clock-wise or counter clock-wise direction.
  2. Get time elapsed since timer started or time left for the counter to complete.
  3. Provide Start and finish points for the animation.
  4. Pre-fill the progress up-till certain point.
  5. Resume the animation on the basis of duration elapsed from total duration.

...and much more.

Download the demo app -

Get it on Google Play

If you're using this library, please let me know; I'll feature your app in the wiki.

Screenshots

Versioning

Linear Timer follows the Semantic Versioning System.

Summery - MAJOR.MINOR.PATCH

Setup

Release

Setup is pretty straight forward. In your project's build.gradle add the following -

allprojects {
  repositories {
      jcenter()
      maven { url "https://jitpack.io" }
  }
}

And, in your app's build.gradle add this under dependencies block -

compile 'com.github.krtkush:LinearTimer:<version_available_on_jitpack>'

example - compile 'com.github.krtkush:LinearTimer:v2.1.1'

Usage

First, you need to add LinearTimerView into your XML layout -

xmlns:timer="http://schemas.android.com/apk/res-auto"

<io.github.krtkush.lineartimer.LinearTimerView
    android:id="@+id/linearTimer"
    android:layout_centerHorizontal="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    timer:radius="20dp"
    timer:strokeWidth="3dp"/>

Note that "wrap_content" for height and width is recommended. Using other values might not lead correct rendering of the view.

After adding the view, here is how it is initialized and used -

LinearTimerView linearTimerView = (LinearTimerView)
                                    findViewById(R.id.linearTimer);

LinearTimer linearTimer = new LinearTimer.Builder()
            .linearTimerView(linearTimerView)
            .duration(10 * 1000)
            .build();

// Start the timer.
findViewById(R.id.startTimer).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      linearTimer.startTimer();
    }
});

// Restart the timer.
findViewById(R.id.restartTimer).setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View view) {
        linearTimer.restartTimer();
      }
});

// Pause the timer
findViewById(R.id.pauseTimer).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
         try {
            linearTimer.pauseTimer();
         } catch (IllegalStateException e) {
            e.printStackTrace();
            Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
         }
      }
 });

// Resume the timer
findViewById(R.id.resumeTimer).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
          try {
            linearTimer.resumeTimer();
          } catch (IllegalStateException e) {
              e.printStackTrace();
              Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
          }
      }
 });

// Reset the timer
findViewById(R.id.resetTimer).setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
       try {
           linearTimer.resetTimer();
       } catch (IllegalStateException e) {
           e.printStackTrace();
           Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
       }
   }
});

List of methods available to control the timer -

Method Description Exception
1. startTimer() Start the timer. IllegalStateException
2. pauseTimer() Pause the timer. IllegalStateException
3. resumeTimer() Resume the timer from its pause position. IllegalStateException
4. resetTimer() Reset the timer to the starting angle; the timer will not start after reset. IllegalStateException
5. restartTimer() Restart the timer from the starting angle; the timer will start again. None
5. getState() Get current state of the timer. None

For detailed documentation and on how to customise and use LinearTimer please refer to the wiki.

Refer here for Java Docs. General URL for Java Docs is https://jitpack.io/com/github/krtkush/lineartimer/<insert_version_of_choice>/javadoc/

Contribution

Any kind of contribution will be appreciated; feel free to create a pull request or file issues on the issue tracker.

List of current contributors can be found here.

lineartimer's People

Contributors

krtkush avatar archern9 avatar dakshsrivastava 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.