Giter VIP home page Giter VIP logo

easycountdowntimer's Introduction

easyCountDownTimer

A simple android library to countdown timer textview for api 14+

Screan shot

screan_shot

screan_shot

Setup

The simplest way to use easyCountDownTimer is to add the library as aar dependency to your build.

Maven

<dependency>
  <groupId>ir.samanjafari.easycountdowntimer</groupId>
  <artifactId>easycountdowntimer</artifactId>
  <version>2.5.0</version>
  <type>aar</type>
</dependency>

Gradle

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral() // Add this Line
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.3"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral() // Add this line
    }
}

dependencies {
    implementation 'ir.samanjafari.easycountdowntimer:easycountdowntimer:2.5.0'
}

Usage

Add the following code to your view

<ir.samanjafari.easycountdowntimer.EasyCountDownTextview
        android:id="@+id/easyCountDownTextview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        app:hours="0"
        app:minute="1"
        app:second="10"
        app:showHours="true"
        app:textSize="12sp"
        app:digitBackground="@android:color/transparent"
        app:textColor="#9c9c9c"
        app:setAnimation="true"
        app:colonColor="#000"
        app:showDays="true"
        app:daysLabel="D"
        app:days="1"
        app:start_automatically="false"
        app:useFarsiNumeral="true"
        />

whit the following code you can listen to onFinish or onTick timer

EasyCountDownTextview countDownTextview = (EasyCountDownTextview) findViewById(R.id.easyCountDownTextview);
easyCountDownTextview.setTime(1, 1, 1, 1);
        easyCountDownTextview.setOnTick(new CountDownInterface() {
            @Override
            public void onTick(long time) {
                
            }

            @Override
            public void onFinish() {

            }
        });

how to set time programmatically ?

EasyCountDownTextview easyCountDownTextview = (EasyCountDownTextview) findViewById(R.id.easyCountDownTextview);
easyCountDownTextview.setTime(1,1, 30, 15);// setTime(days, hours, minute, second)

how to set custom font

Typeface typeface = ResourcesCompat.getFont(this, R.font.my_font);
easyCountDownTextview.setTypeFace(typeface);

how to pause and resume timer

easyCountDownTextview.pause();

easyCountDownTextview.resume();

Licence

Copyright 2017 Saman Jafari

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.

Author

Saman Jafari

email: [email protected]

github: https://github.com/jsaman19

site : http://samanjafari.ir

easycountdowntimer's People

Contributors

joykishansharma avatar jsaman19 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  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

easycountdowntimer's Issues

improvement and flexibility

Hi,
your library is very nice. I would really like to use it in my app but there is a few things that prevents me from doing so.

  • When i put app:showDays="false" in my xml file, the days still show up with "00". It only removes the label. I have to programmatically setShowDays(false) to remove the "00".
  • I also went through your code to see the logic because i came to realize that you call startTimer() when we setTime and in the constructor. Would it be possible to not start the timer in these functions. I'd like to start the timer myself when the user press a button.
  • Maybe it's just me but i can't center horizontally the textView inside the EasyCountDownTimer in my xml. It's placed inside a constrainLayout with other elements. It's always align to the left side.
    image

Thank you very much :)

Please add pause() and resume() methods

Hi @jsaman19 , It would be very helpful if we had pause() and resume() methods for this easyCountDownTimer library. ๐Ÿ˜Š We could do that by having a custom CountDownTimer abstract class with pause() and resume() mthods. I have tried to add those in this Pull Request, ๐Ÿ˜… please have a look.
Awesome Library by the way. ๐Ÿ‘

Memory leak and counter off by a second

Hi sorry for bodering you again,

The issue with days showing is back. The counter is also off by a second, ex(it displays 59 seconds but the minutes aren't going down, when it hits 0, the last number is 59).
displaybugs
displaybug2

While looking at the code, i came accross a memory leak when you have startAutomatically set to true.
image

Thank you for updating the library, it's really appreciated :D

Show/Hide Minutes

Is there a way like showDays or showHours we can also define showMinutes?

Display issues

Hi again,

i'm having issues with the display of the text.

  • The text doesn't update when i call setTime();
  • When i start the timer, the first second display a random number before the actual time i set.
  • For the last second of the timer, something weird is happening.

Here is a gif to help you better understand
displaybugs

Thank you again :)

Bug using minutes/seconds

Hi thank you for this repository.
This view does not work if I call setTime using only minutes or only minutes with seconds.
Ex:
countDownTextview.setTime(0, 0, 1,0);
countDownTextview.setTime(0, 0, 0,30);
Widget is stuck between 0 : 0 : 0 : 0 and 0 : 0 : 0 : 1 in loop.

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.