Linear Timer


Source link: https://github.com/krtkush/LinearTimer

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 -

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

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.

Resources

Android buttons in various styles.

Gradle plugin for Spoon. Allows you to run spoon with almost no effort under new Android build system.

Helium is a DSL for REST API specifications and also a Java API for processing descriptions written in this language. The main goal of this project is to create a single source of truth about some REST API. Taking a spec as an input, Helium generates a lot of useful staff that can be used to rapidly develop REST clients.

Goro performs asynchronous operations in a queue. You may ask Goro to perform some task with schedule method invocation.

Android Lollipop Palette is now easy to use with Glide.

This Gradle plugin adds a new task to print out the dex method count of your Android projects without having to install separate tools.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes