Code Monkey home page Code Monkey logo

timerx's Introduction

TimerX

A simple timer & stowatch library for android which allows for building customizable timer or stopwatch, applying custom formats, scheduling actions and more.

TimerX provides a simple api to apply a different format to a timer or a stopwatch. For instance, you can create a stopwatch, specify format as HH:MM:SS or SS.LL and time in the stopwatch will be formatted accordingly.

See wiki for more detailed explanation.

Gradle Setup

Make sure you have jitpack added in your top-level build.gradle file:

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

And then, add following lines in your module-level build.gradle file:

dependencies {
    implementation 'com.github.arsvechkarev:TimerX:3.1.0'
}

Examples:

Stopwatch:

val stopwatch = buildStopwatch { 
    // Setting the start format of the stopwatch
    startFormat("SS:LL")
    // Setting a tick listener that gets notified when time changes
    onTick { millis: Long, time: CharSequence -> myTextView.text = time }
    // Running an action at a certain time
    actionWhen(10, TimeUnit.SECONDS) { showToast("10s passed") }
    // When the time is equal to one minute, change format to "MM:SS:LL"
    changeFormatWhen(1, TimeUnit.MINUTES, "MM:SS:LL")
}

// Starting the stopwatch
stopwatch.start();
...

Timer:

val timer = buildTimer {
    // Setting the start format of timer
    startFormat("MM:SS")
    // Setting the start time of the timer
    startTime(60, TimeUnit.SECONDS)
    // Setting a tick listener that gets notified when time changes
    onTick { millis: Long, time: CharSequence -> myTextView.text = time }
    // Run actions at a certain time
    actionWhen(40, TimeUnit.SECONDS) { showToast("40 seconds left") }
    actionWhen(20, TimeUnit.SECONDS) { showToast("20 seconds left") }
    // When the time is equal to ten seconds, change format to "SS:LL"
    changeFormatWhen(10, TimeUnit.SECONDS, "SS:LL")
}
    
// Starting the timer
timer.start();
...

timerx's People

Contributors

arsvechkarev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

timerx's Issues

Code is not Implementing on Android Studio

The Timerx code is not getting implemented on Android Studio. It's showing this error : Failed to resolve: com.arsvechkarev:timerx:2.0.0 please provide the information regarding how to implement this dependency or is there any new version available.

OnTick in 1 Second

When i am going to use this TimerX API its executing multiple time in a tick.
Can we make this timer to 1 second tick

Gradle dependency

Hi, can u provide how to add dependency to version 3.0.0 to gradle project?

Some java code how to use this library writen in kotlin will be nice.

Thank u.

Migrate to other Maven repository

Since the latest Gradle update I get the following message:

Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.
This repository is deprecated and it will be shut down in the future.
See http://developer.android.com/r/tools/jcenter-end-of-service for more information.

I think you will have to move your plugin in the near future.
Actually, you should be able to use GitHub for this.

The timer is not able to stay in background

I really like the timerx app but it is not able to stay in background .Multiple times when I set timer for more than 2 hours ,it didn't ring the timer .

I use Nothing Phone 2 (android 14)- Close to Stock android and I am able to set timer in other app for more than 5 hours and it still rang .for example

Alarmy app by Delightroom
Kitchen Multi Timer by Bunnybun studios- a simple timer app available in playstore .

I know this is opensource and you are doing this in your free time . but i really appreciate if you are able to fix this issue .

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.