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

A progress view. It is similar to the Fitbit application's progress bar.

Create a simple button to play a media source.

An Android permission library extending Google's EasyPermissions with convenient additions.

Why EffortlessPermissions?

  • Used as a drop-in replacement for Google's EasyPermissions and based on its battle-tested implementation.
  • Added an @AfterPermissionDenied annotation for methods to run automatically after denial.
  • Included consumer ProGuard rules which fixes your release build.
  • Added more method overloads which make coding easier.
  • Added another DialogFragment to open app detail settings which you have more control upon, e.g. dialog title can be hidden now.

In a word, just start with EffortlessPermissions instead of EasyPermissions.

An infinite card switching UI for Android, support custom animation.

This is a library for odometer in an android. Odometer mainly used for measuring distance.

A library to help android developer working easly with activities and fragments

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