Coder Social home page Coder Social logo

countdownview's Introduction

Android Gems Android Arsenal @iwgang

CountdownView

Android countdown view,use canvas draw,supports multiple styles

Download demo apk

Screenshot

Gradle

compile 'com.github.iwgang:countdownview:2.1.6'

Code

CountdownView mCvCountdownView = (CountdownView)findViewById(R.id.cv_countdownViewTest1);
mCvCountdownView.start(995550000); // Millisecond

// or
for (int time=0; time<1000; time++) {
    mCvCountdownView.updateShow(time);
}

Layout

<cn.iwgang.countdownview.CountdownView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:isHideTimeBackground="true"
    app:isShowDay="true"
    app:isShowHour="true"
    app:isShowMinute="true"
    app:isShowSecond="true"
    app:isShowMillisecond="true"
    app:timeTextColor="#000000"
    app:timeTextSize="22sp"
    app:isTimeTextBold="true"
    app:suffixGravity="bottom"
    app:suffixTextColor="#000000"
    app:suffixTextSize="12sp"
    app:suffixHour=""
    app:suffixMinute=""
    app:suffixSecond=""
    app:suffixMillisecond="毫秒" />

Customization

attr type default
isHideTimeBackground boolean true
timeBgColor color #444444
timeBgSize dimension timeSize + 2dp * 4
timeBgRadius dimension 0
isShowTimeBgDivisionLine boolean true
timeBgDivisionLineColor color #30FFFFFF
timeBgDivisionLineSize dimension 0.5dp
timeTextSize dimension 12sp
timeTextColor color #000000
isTimeTextBold boolean false
isShowDay boolean auto show (has value show if not hide)
isShowHour boolean auto show (has value show if not hide)
isShowMinute boolean true
isShowSecond boolean true
isShowMillisecond boolean false
isConvertDaysToHours boolean false
suffixTextSize dimension 12sp
suffixTextColor color #000000
isSuffixTextBold boolean false
suffixGravity 'top' or 'center' or 'bottom' 'center'
suffix string ':'
suffixDay string null
suffixHour string null
suffixMinute string null
suffixSecond string null
suffixMillisecond string null
suffixLRMargin dimension left 3dp right 3dp
suffixDayLeftMargin dimension 0
suffixDayRightMargin dimension 0
suffixHourLeftMargin dimension 0
suffixHourRightMargin dimension 0
suffixMinuteLeftMargin dimension 0
suffixMinuteRightMargin dimension 0
suffixSecondLeftMargin dimension 0
suffixSecondRightMargin dimension 0
suffixMillisecondLeftMargin dimension 0
isShowTimeBgBorder boolean false
timeBgBorderColor color #000000
timeBgBorderSize dimension 1dp
timeBgBorderRadius dimension 0

Other

  • Multiple countdownView specified value
    // step 1
    mCvCountdownView.setTag(R.id.name, uid);
    // step 2
    @Override
    public void onEnd(CountdownView cv) {
        Object nameTag = cv.getTag(R.id.uid);
        if (null != nameTag) {
            Log.i(TAG, "name = " + nameTag.toString());
        }
    }
  • Dynamic show
    dynamicShow(DynamicConfig dynamicConfig)
  • Countdown complete callback
    setOnCountdownEndListener(OnCountdownEndListener onCountdownEndListener);
  • Interval callback
    setOnCountdownIntervalListener(long interval, OnCountdownIntervalListener onCountdownIntervalListener);

countdownview's People

Contributors

imknown avatar iwgang avatar liaohuqiu avatar quentin-st 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  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  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

countdownview's Issues

RecyclerView页面复用有问题

1.当我在RecyclerView页面的第一个item有一个定时器的时候(其他item没有),我滑动到下面不可视的状态,定时器会停止走动!!!(当然因为你这边都是有定时器的,所以你这边的demo会出现复用的问题!!)

wrong calculate

please check your project with value : 1486987061090
this return 17209 days! I mean is 12 days !

有点问题需要请教

您好作者,在RecyclerView中使用倒计时的时候,上下滑动 倒计时会暂停 ,多滑动几次就,变成0了,下拉刷新 时间又重置了,怎么解决这个问题啊 ,我Adapter继承的是BaseQuickAdapter com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.15这个里面的BaseAdapter

Custom Font

Hello,

Thank you for this great job keep it up.
I would like to ask if there is a way to change the font without adding the library to my project and thx.

Best.

请教两个问题

1,背景支持渐变的颜色吗?或者用个图片
2,倒计时中间那条横线怎么去掉?

请大神赐教

底下这段代码不太懂

看代码 不写for循环 或者只写mCvCountdownView.updateShow(1);
没有任何影响也会倒计时。
请问这个倒计时逻辑是否是必须的还是试用某种情形。

CountdownView mCvCountdownView = (CountdownView)findViewById(R.id.cv_countdownViewTest1);
mCvCountdownView.start(995550000); // 毫秒

// 或者自己编写倒计时逻辑,然后调用updateShow来更新UI
for (int time=0; time<1000; time++) {
mCvCountdownView.updateShow(time);
}

出现负时间

出现负时间的问题。。。出现负时间UI错乱不好看。。

RecyclerView的问题

如果我设置了RecyclerView的第一个item有个定时器,当我下滑到第二页的时候,第一个item的定时器时间结束了不会调用setOnCountdownEndListener方法么 ??

convert a date to a countdown

How it's possible to convert a date dd/MM/yyyy to set it into a countdown

i tried several examples with converting the date to milliseconds and make it as input for this method
but it returns a randomly generated number while the milliseconds are 1000% correct

Please give me a way to solve this problem asap

DynamicConfig

DynamicConfig constructor is a private access , so I can't get a instance , I want to config DynamicShow , due to countDownView.dynamicShow() method need a DynamicConfig type parameter,can you update DynamicConfig constructor permission modifier is public ?

关于第二次stop()以后再次start()的bug

假设已经为mCvCountdownView设置了OnCountdownIntervalListener的间隔时间监听器。mCvCountdownView在调用stop()以后,再次调用start()方法启动的话,很可能不会回调onInterval()方法,因为对象的成员变量mPreviouIntervalCallbackTime在stop()以后并没有被置零。解决办法是在stop()以后将之置零;或者增加一个set方法,在再次start之前置零。
另外这个倒计时很好用,谢谢!

Setting isHideTimeBackground dynamically

Is there a way to set isHideTimeBackground as false dynamically other than setting the same via xml ????
My requirement is to dynamically create the Countdown view. Figured out everything dynamically except isHideTimeBackground.

Countdowns stop in a recycler view when items scroll out of view

My recycler view items each contain countdowns.
When an item goes out of view, the countdowns pause at the exact time they went from visible to not visible.
My recycler view doesn't always retrigger my onBind's depending on how many list items it caches.
It looks like this library stops the countdown on detachment, but doesn't restart it on re-attachment.

See: CountdownView.java#L95

@Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        stop();
    }

About Handler

Since this Handler is declared as an inner class, it may prevent the outer class from being garbage collected. If the Handler is using a Looper or MessageQueue for a thread other than the main thread, then there is no issue. If the Handler is using the Looper or MessageQueue of the main thread, you need to fix your Handler declaration, as follows: Declare the Handler as a static class; In the outer class, instantiate a WeakReference to the outer class and pass this object to your Handler when you instantiate the Handler; Make all references to members of the outer class using the WeakReference object.

Typeface

Nice work !
Please provide an option for setting the custom typeface

Thanks In Advance

How to use Interval

Hi, thanks for your great library.
I want show some time in my application and i want when lasted 5s show me toast.
For example : I want how 17s countTimer, when this timer receive to 5s show me toast "just 5s".

how can i it? please help me

跳两秒问题

我项目中就一个textview需要一个倒计时,之前自己用写的转换成天时分秒后也会跳两秒,就是一次性会减掉两秒,我设置的是1秒,后来把你项目中的CustomCountDownTimer拷过来之后还是一样会跳两秒,这个怎么解决?

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.