A simple and easy to use stopwatch and timer library for android

Overview

TimeIt

Now with Timer support!

Download Android Arsenal

A simple and easy to use stopwatch and timer library for android

Introduction

A stopwatch can be a very important widget in an app and yet creating it has been very difficult. Creating a stopwatch requires you to create a separate thread to keep track of the time and then post the updates on the UI thread. This process becomes complicated very quickly. Especially if you plan on adding features like pause and split.

Similarly, a timer is another important addon an app may need without going through all the hassle of running threads or handlers.

With TimeIt, you can create a stopwatch or a timer app with very few lines of code!

For example, to create and start a stopwatch and display it with a textView :

Stopwatch stopwatch = new Stopwatch();
stopwatch.setTextView(myTextView);
stopwatch.start();

Pausing a stopwatch and resuming it is as simple as calling stopwatch.pause(); and resume() respectively.

TimeIt also allows you to keep track of splits with the stopwatch by simply calling stopwatch.split();

Similarly, to set a timer:

Timer timer = new Timer(time_in_ms);
timer.setTextView(myTextView);
timer.start();

The timer provides utility functions to check the current time and current status (running, paused, stopped etc.). Please check the current status of the timer before actually starting/pausing/resuming the timer.

The Timer class provides an OnTickListener interface which you can register to, to listen for updates every clock cycle and receive a callback when the timer completes.

Features

  • NEW : Create Timers with pause and resume support!
  • Easy to use stopwatch library
  • No need to use separate threads. Multithreading is handled by the library itself
  • Supports pause/resume and split methods.
  • Supports an OnTickListener to listen for updates in clock.
  • Set the TextView directly with TimeIt (Automatically formats the time).
  • Set custom clock delay to update the time more or less frequently!
  • Much more to come!

Documentation

TimeIt is very easy to use. If you face any trouble, you can see the javadocs available here. A demo app is included here for your reference. It implements the basic features of the library.

Download

TimeIt is available on jcenter, jitpack and bintray. To download, use the badges above or follow these instructions:

Jcenter

Step 1. Add the JCenter repository to your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jcenter.bintray.com' }
		}
	}

Step 2 : Add the dependency in your app level build.gradle

implementation 'com.yashovardhan99.timeit:timeit:1.2.0'

Jitpack

Step 1. Add the JitPack repository to your root build.gradle at the end of repositories:

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

Step 2 : Add the dependency in your app level build.gradle

	dependencies {
	        implementation 'com.github.yashovardhan99:TimeIt:1.2.0'
	}

Bintray

Step 1 : Download or copy the Gradle configuration in your project level build.gradle:

repositories {
    maven {
        url  "https://dl.bintray.com/yashovardhan99/TimeIt" 
    }
}
        

Step 2 : Add the dependency in your app level build.gradle

implementation 'com.yashovardhan99.timeit:timeit:1.2.0'

Contributing

Contributing guidelines are available here. Feel free to report any issues or make new pull requests! TimeIt is an open source project and is free for all to use and improve!

License

Copyright 2018 Yashovardhan Dhanania

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You might also like...
Simple-Claim-Form - Android App for creating a simple dynamic form with MVVM architecture

Simple-Claim-Form Android App for creating a simple dynamic form with MVVM archi

Use Android as Rubber Ducky against another Android device
Use Android as Rubber Ducky against another Android device

Use Android as Rubber Ducky against another Android device

Multi-module, Kotlin, MVI, Compose, Hilt, Navigation Component, Use-cases, Room, Retrofit

Work in progress Multi-module demo app that gets data from dota2 api. API https://docs.opendota.com/ Players by rank (GET) https://api.opendota.com/ap

Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platform the code is running.

Trail Trail is a simple logging system for Java and Android. Create logs using the same API and the library will detect automatically in which platfor

A simple Android utils library to write any type of data into cache files and read them later.

CacheUtilsLibrary This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize

A Simple Android Library for Kenyan Counties

A Simple Android Library for Kenyan Counties

A small library which will save you from writing the same intent creation code again and again for the most simple tasks

Android Intents A small library which will save you from writing the same intent creation code again and again for the most simple tasks. I found myse

A simple library for validating user input in forms using annotations.
A simple library for validating user input in forms using annotations.

ValidationKomensky for Android A simple library for validating user input in forms using annotations. Features: Validate all views at once and show fe

A helper library to ease the most repetitive codes with simple reusable attributes.

ak-universal-android-helper A helper library to ease the most repetitive codes with simple reusable attributes. AKUAH can help you with many repetitiv

Comments
  • Timer should check if TextView is null

    Timer should check if TextView is null

    Thanks for this library.

    I believe Timer should check if textview is null before displaying the text. Similar to Stopwatch.

    This way it's not possible to use Timer without the textview and it also makes it hard to use the Timer in different scenarios.

    Thanks.

    opened by dirkam 1
  • Timer should have a finished state

    Timer should have a finished state

    Timer should have a finished state. Right now it's only possible to check this with a few checks, including the remaining time, which can go below zero (probably it should set itself to 0 instead of going below zero).

    enhancement 
    opened by dirkam 3
Releases(1.2.0)
Owner
Yashovardhan Dhanania
Student at Manipal University Jaipur Founder @AndroidDevJaipur; Android intern at Trell; Also check out @allisto
Yashovardhan Dhanania
An easy-to-use, cross-platform measurement tool that pulls data out of CD pipelines and analysis the four key metrics for you.

Maintained by SEA team, ThoughtWorks Inc. Read this in other languages: English, 简体中文 Table of Contents About the Project Usage How to Compute Contrib

Thoughtworks 277 Jan 7, 2023
Android library which makes it easy to handle the different obstacles while calling an API (Web Service) in Android App.

API Calling Flow API Calling Flow is a Android library which can help you to simplify handling different conditions while calling an API (Web Service)

Rohit Surwase 19 Nov 9, 2021
:iphone: [Android Library] Get device information in a super easy way.

EasyDeviceInfo Android library to get device information in a super easy way. The library is built for simplicity and approachability. It not only eli

Nishant Srivastava 1.7k Dec 22, 2022
Compose easy forms validation library

Compose EasyForms Focus on building your form UI while the library do the heavy work for you. Features Built in support for most of the Form widgets i

Kosh Sergani 24 Jul 18, 2022
Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.

PrivacyStreams PrivacyStreams is an Android library for easy and privacy-friendly personal data access and processing. It offers a functional programm

null 269 Dec 1, 2022
[] Easy async loading for Android's ListView/GridView

NOTE: Smoothie's API is not final yet. Although the library is fairly funcional, this is still beta-quality code. Do not rely on it for production cod

Lucas Rocha 988 Dec 22, 2022
Easy SharedPreference Engine foR ANDROid

esperandro Easy SharedPreference Engine foR ANDROid What? esperandro makes it simple to use SharedPreferences in a nicer and less error-prone way. Wit

David Kunzler 184 Nov 25, 2022
It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android.

Shutter-Android It's finally easy to take photos/videos via camera or get photos/videos from gallery on Android. What is Shutter? Shutter is an Androi

Levi Bostian 56 Oct 3, 2022
This is a easy way to publish MQTT message and receive MQTT message

SMQ-CLIENT This is a easy way to publish MQTT message and receive MQTT message This is provider a spring stater for quick use Recive message form the

SUDA 1 Apr 25, 2022
Interactive prompts made easy!

Interactive prompts made easy!

David Simon 1 Nov 1, 2021