FlipTimerView library for Android

Overview

FlipTimerView

License API Android Arsenal

Preview

FlipTimerView library for Android

Getting started

Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

dependencies {
        implementation 'com.github.anugotta:FlipTimerView:v1.5'
}

Usage

Add the CountDownClock in your layout

  <com.asp.fliptimerviewlibrary.CountDownClock
            android:id="@+id/timerProgramCountdown"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:clipChildren="false"
            android:clipToPadding="false"
            flipTimer:almostFinishedCallbackTimeInSeconds="5"
            flipTimer:animationDuration="850"
            flipTimer:countdownTickInterval="1000"
            flipTimer:digitBottomDrawable="@drawable/background_bottom"
            flipTimer:digitDividerColor="@color/transparent"
            flipTimer:digitPadding="2dp"
            flipTimer:digitTextColor="@color/black"
            flipTimer:digitTextSize="24sp"
            flipTimer:digitTopDrawable="@drawable/background_top"
            flipTimer:digitWidth="28dp"
            flipTimer:halfDigitHeight="22dp"
            flipTimer:resetSymbol="8"
            flipTimer:splitterPadding="0dp"
    />

API

 timerProgramCountdown.startCountDown(99999999)
        timerProgramCountdown.setCountdownListener(object : CountDownClock.CountdownCallBack {
            override fun countdownAboutToFinish() {
                //TODO Add your code here
            }

            override fun countdownFinished() {
                Toast.makeText(this@MainActivity, "Finished", Toast.LENGTH_SHORT).show()
                timerProgramCountdown.resetCountdownTimer()
            }
        })

Designed by:

GadgetCheck: https://github.com/GadgetCheck

Contribution

If you are interested to contribute, feel free to send pull requests (to development branch) or issues.

Note: All your pull requests should be written in kotlin

Questions?

Hit me on twitter Twitter

License

MIT License

Copyright (c) 2019 Anu S Pillai

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You might also like...
A Material design back port of Android's CalendarView
A Material design back port of Android's CalendarView

Material Calendar View A Material design back port of Android's CalendarView. The goal is to have a Material look and feel, rather than 100% parity wi

Standalone Android widget for picking a single date from a calendar view.
Standalone Android widget for picking a single date from a calendar view.

TimesSquare for Android Standalone Android widget for picking a single date from a calendar view. Usage Include CalendarPickerView in your layout XML.

Pick a date or time on Android in style
Pick a date or time on Android in style

Material DateTime Picker - Select a time/date in style Material DateTime Picker tries to offer you the date and time pickers as shown in the Material

A better calendar for Android
A better calendar for Android

Caldroid Caldroid is a fragment that display calendar with dates in a month. Caldroid can be used as embedded fragment, or as dialog fragment. User ca

Wheel-like spinner widget for Android

Update Dec 2016 Library is discontinued There's still a lot of wheel libraries out there. Update Oct 2014 I am thinking of rewriting this control. Upd

Android calendar view (like card)
Android calendar view (like card)

android-calendar-card (Google Play Demo) Android calendar view (like card) Simple and easy to modify Author: Michał Szwarc #CalendarCardPager License

An calender widget for your Android home screen.
An calender widget for your Android home screen.

Todo Agenda - Calendar and Task widgets for Android Todo Agenda is home screen widgets for your Android device. Each widget has its own settings and d

Android time range picker

TimeRangePicker TimeRangePicker is a library which can be used to select a time range. WARNING Requires android-support-v4 Description This library pr

Android calendar view inspired by Sunrise calendar and iOS7 stock calendar
Android calendar view inspired by Sunrise calendar and iOS7 stock calendar

SilkCal Android calendar view inspired by Sunrise calendar and iOS7 stock calendar. Usage Add compile 'me.nlmartian.silkcal:library:0.1.1' to your dep

Comments
  • add attribute to set greatest visible digits

    add attribute to set greatest visible digits

    Currently FlipTimerViewis able to show timers in this format: dd:hh:mm:ss By accepting this PR, FlipTimerViewwill also be able to show shorter formats: hh:mm:ss, mm:ss and ss

    opened by ftabashir 0
  • Issue Implementing this with view binding

    Issue Implementing this with view binding

    Hey, I'm implementing this by using view binding but I can't figure out where I go wrong as background isn't visible on every text view. Basically I think I won't able to access both views in "CountDownClock". I m showing the script of how I access the multiple view using view binding. Please Can you provide me any direction where I go wrong? Thanks. Here is what my code is

    class CountDownClock : LinearLayout {
        private var countDownTimer: CountDownTimer? = null
        private var countdownListener: CountdownCallBack? = null
        private var countdownTickInterval = 1000
        private lateinit var bindingCountDownClock: ViewCountdownClockDigitBinding
        private lateinit var bindingSimpleClock: ViewSimpleClockBinding
    
        private var almostFinishedCallbackTimeInSeconds: Int = 5
    
        private var resetSymbol: String = "8"
    
        constructor(context: Context?) : this(context, null)
        constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
        constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
            context,
            attrs,
            defStyleAttr
        ) {
    
            bindingCountDownClock =
                ViewCountdownClockDigitBinding.inflate(LayoutInflater.from(context), this, true)
    
            bindingSimpleClock =
                ViewSimpleClockBinding.inflate(LayoutInflater.from(context), this, true)
    
            attrs?.let {
                val typedArray =
                    context?.obtainStyledAttributes(attrs, R.styleable.CountDownClock, defStyleAttr, 0)
                val resetSymbol = typedArray?.getString(R.styleable.CountDownClock_resetSymbol)
                if (resetSymbol != null) {
                    setResetSymbol(resetSymbol)
                }
    
                val digitTopDrawable =
                    typedArray?.getDrawable(R.styleable.CountDownClock_digitTopDrawable)
                setDigitTopDrawable(digitTopDrawable)
                val digitBottomDrawable =
                    typedArray?.getDrawable(R.styleable.CountDownClock_digitBottomDrawable)
                setDigitBottomDrawable(digitBottomDrawable)
                val digitDividerColor =
                    typedArray?.getColor(R.styleable.CountDownClock_digitDividerColor, 0)
                setDigitDividerColor(digitDividerColor ?: 0)
                val digitSplitterColor =
                    typedArray?.getColor(R.styleable.CountDownClock_digitSplitterColor, 0)
                setDigitSplitterColor(digitSplitterColor ?: 0)
    
                val digitTextColor = typedArray?.getColor(R.styleable.CountDownClock_digitTextColor, 0)
                setDigitTextColor(digitTextColor ?: 0)
    
                val digitTextSize =
                    typedArray?.getDimension(R.styleable.CountDownClock_digitTextSize, 0f)
                setDigitTextSize(digitTextSize ?: 0f)
                setSplitterDigitTextSize(digitTextSize ?: 0f)
    
                /*   val digitPadding = typedArray?.getDimension(R.styleable.CountDownClock_digitPadding, 0f)
                   setDigitPadding(digitPadding?.toInt() ?: 0)*/
    
                val splitterPadding =
                    typedArray?.getDimension(R.styleable.CountDownClock_splitterPadding, 0f)
                setSplitterPadding(splitterPadding?.toInt() ?: 0)
    
                val halfDigitHeight =
                    typedArray?.getDimensionPixelSize(R.styleable.CountDownClock_halfDigitHeight, 0)
                val digitWidth =
                    typedArray?.getDimensionPixelSize(R.styleable.CountDownClock_digitWidth, 0)
                setHalfDigitHeightAndDigitWidth(halfDigitHeight ?: 0, digitWidth ?: 0)
    
                val animationDuration =
                    typedArray?.getInt(R.styleable.CountDownClock_animationDuration, 0)
                setAnimationDuration(animationDuration ?: 600)
    
                val almostFinishedCallbackTimeInSeconds = typedArray?.getInt(
                    R.styleable.CountDownClock_almostFinishedCallbackTimeInSeconds,
                    5
                )
                setAlmostFinishedCallbackTimeInSeconds(almostFinishedCallbackTimeInSeconds ?: 5)
    
                val countdownTickInterval =
                    typedArray?.getInt(R.styleable.CountDownClock_countdownTickInterval, 1000)
                this.countdownTickInterval = countdownTickInterval ?: 1000
    
                invalidate()
                typedArray?.recycle()
            }
        }
    
        ////////////////
        // Public methods
        ////////////////
    
        private var milliLeft: Long = 0
    
        fun startCountDown(timeToNextEvent: Long) {
            countDownTimer?.cancel()
            var hasCalledAlmostFinished = false
            countDownTimer = object : CountDownTimer(timeToNextEvent, countdownTickInterval.toLong()) {
                override fun onTick(millisUntilFinished: Long) {
                    milliLeft = millisUntilFinished
                    if (millisUntilFinished / 1000 <= almostFinishedCallbackTimeInSeconds && !hasCalledAlmostFinished) {
                        hasCalledAlmostFinished = true
                        countdownListener?.countdownAboutToFinish()
                    }
                    setCountDownTime(millisUntilFinished)
                }
    
                override fun onFinish() {
                    hasCalledAlmostFinished = false
                    countdownListener?.countdownFinished()
                }
            }
            countDownTimer?.start()
        }
    
        fun resetCountdownTimer() {
            countDownTimer?.cancel()
            bindingSimpleClock.apply {
                firstDigitDays.setNewText(resetSymbol)
                secondDigitDays.setNewText(resetSymbol)
                firstDigitHours.setNewText(resetSymbol)
                secondDigitHours.setNewText(resetSymbol)
                firstDigitMinute.setNewText(resetSymbol)
                secondDigitMinute.setNewText(resetSymbol)
                firstDigitSecond.setNewText(resetSymbol)
                secondDigitSecond.setNewText(resetSymbol)
            }
    
        }
    
        ////////////////
        // Private methods
        ////////////////
    
        private fun setCountDownTime(timeToStart: Long) {
    
            val days = TimeUnit.MILLISECONDS.toDays(timeToStart)
            val hours = TimeUnit.MILLISECONDS.toHours(timeToStart - TimeUnit.DAYS.toMillis(days))
            val minutes = TimeUnit.MILLISECONDS.toMinutes(
                timeToStart - (TimeUnit.DAYS.toMillis(days) + TimeUnit.HOURS.toMillis(hours))
            )
            val seconds = TimeUnit.MILLISECONDS.toSeconds(
                timeToStart - (TimeUnit.DAYS.toMillis(days) + TimeUnit.HOURS.toMillis(hours) + TimeUnit.MINUTES.toMillis(
                    minutes
                ))
            )
    
            val daysString = days.toString()
            val hoursString = hours.toString()
            val minutesString = minutes.toString()
            val secondsString = seconds.toString()
            bindingSimpleClock.apply {
                when {
                    daysString.length == 2 -> {
                        firstDigitDays.animateTextChange((daysString[0].toString()))
                        secondDigitDays.animateTextChange((daysString[1].toString()))
                    }
                    daysString.length == 1 -> {
                        firstDigitDays.animateTextChange(("0"))
                        secondDigitDays.animateTextChange((daysString[0].toString()))
                    }
                    else -> {
                        firstDigitDays.animateTextChange(("3"))
                        secondDigitDays.animateTextChange(("0"))
                    }
                }
    
                when {
                    hoursString.length == 2 -> {
                        firstDigitHours.animateTextChange((hoursString[0].toString()))
                        secondDigitHours.animateTextChange((hoursString[1].toString()))
                    }
                    hoursString.length == 1 -> {
                        firstDigitHours.animateTextChange(("0"))
                        secondDigitHours.animateTextChange((hoursString[0].toString()))
                    }
                    else -> {
                        firstDigitHours.animateTextChange(("1"))
                        secondDigitHours.animateTextChange(("1"))
                    }
                }
    
                when {
                    minutesString.length == 2 -> {
                        firstDigitMinute.animateTextChange((minutesString[0].toString()))
                        secondDigitMinute.animateTextChange((minutesString[1].toString()))
                    }
                    minutesString.length == 1 -> {
                        firstDigitMinute.animateTextChange(("0"))
                        secondDigitMinute.animateTextChange((minutesString[0].toString()))
                    }
                    else -> {
                        firstDigitMinute.animateTextChange(("5"))
                        secondDigitMinute.animateTextChange(("9"))
                    }
                }
                when {
                    secondsString.length == 2 -> {
                        firstDigitSecond.animateTextChange((secondsString[0].toString()))
                        secondDigitSecond.animateTextChange((secondsString[1].toString()))
                    }
                    secondsString.length == 1 -> {
                        firstDigitSecond.animateTextChange(("0"))
                        secondDigitSecond.animateTextChange((secondsString[0].toString()))
                    }
                    else -> {
                        firstDigitSecond.animateTextChange((secondsString[secondsString.length - 2].toString()))
                        secondDigitSecond.animateTextChange((secondsString[secondsString.length - 1].toString()))
                    }
                }
            }
    
        }
    
        private fun setResetSymbol(resetSymbol: String?) {
            resetSymbol?.let {
                if (it.isNotEmpty()) {
                    this.resetSymbol = resetSymbol
                } else {
                    this.resetSymbol = ""
                }
            } ?: kotlin.run {
                this.resetSymbol = ""
            }
        }
    
        private fun setDigitTopDrawable(digitTopDrawable: Drawable?) {
    
            if (digitTopDrawable != null) {
                bindingSimpleClock.firstDigitDays.also {
                    bindingCountDownClock.frontUpper.background = digitTopDrawable
                    bindingCountDownClock.backUpper.background = digitTopDrawable
    
                }
                bindingSimpleClock.secondDigitDays.also {
                    bindingCountDownClock.frontUpper.background = digitTopDrawable
                    bindingCountDownClock.backUpper.background = digitTopDrawable
                }
                bindingSimpleClock.firstDigitHours.also {
                    bindingCountDownClock.frontUpper.background = digitTopDrawable
                    bindingCountDownClock.backUpper.background = digitTopDrawable
                }
                bindingSimpleClock.secondDigitHours.also {
                    bindingCountDownClock.frontUpper.background = digitTopDrawable
                    bindingCountDownClock.backUpper.background = digitTopDrawable
                }
                bindingSimpleClock.firstDigitMinute.also {
                    bindingCountDownClock.frontUpper.background = digitTopDrawable
                    bindingCountDownClock.backUpper.background = digitTopDrawable
                }
                bindingSimpleClock.secondDigitMinute.also {
                    bindingCountDownClock.frontUpper.background = digitTopDrawable
                    bindingCountDownClock.backUpper.background = digitTopDrawable
                }
                bindingSimpleClock.firstDigitSecond.also {
                    bindingCountDownClock.frontUpper.background = digitTopDrawable
                    bindingCountDownClock.backUpper.background = digitTopDrawable
                }
                bindingSimpleClock.secondDigitSecond.also {
                    bindingCountDownClock.frontUpper.background = digitTopDrawable
                    bindingCountDownClock.backUpper.background = digitTopDrawable
                }
    
            } else {
                setTransparentBackgroundColor()
            }
    
    
        }
    
        private fun setDigitBottomDrawable(digitBottomDrawable: Drawable?) {
    
                if (digitBottomDrawable != null) {
                    bindingSimpleClock.firstDigitDays.also {
                        bindingCountDownClock.frontUpper.background = digitBottomDrawable
                        bindingCountDownClock.backUpper.background = digitBottomDrawable
    
                    }
                    bindingSimpleClock.secondDigitDays.also {
                        bindingCountDownClock.frontUpper.background = digitBottomDrawable
                        bindingCountDownClock.backUpper.background = digitBottomDrawable
                    }
                    bindingSimpleClock.firstDigitHours.also {
                        bindingCountDownClock.frontUpper.background = digitBottomDrawable
                        bindingCountDownClock.backUpper.background = digitBottomDrawable
                    }
                    bindingSimpleClock.secondDigitHours.also {
                        bindingCountDownClock.frontUpper.background = digitBottomDrawable
                        bindingCountDownClock.backUpper.background = digitBottomDrawable
                    }
                    bindingSimpleClock.firstDigitMinute.also {
                        bindingCountDownClock.frontUpper.background = digitBottomDrawable
                        bindingCountDownClock.backUpper.background = digitBottomDrawable
                    }
                    bindingSimpleClock.secondDigitMinute.also {
                        bindingCountDownClock.frontUpper.background = digitBottomDrawable
                        bindingCountDownClock.backUpper.background = digitBottomDrawable
                    }
                    bindingSimpleClock.firstDigitSecond.also {
                        bindingCountDownClock.frontUpper.background = digitBottomDrawable
                        bindingCountDownClock.backUpper.background = digitBottomDrawable
                    }
                    bindingSimpleClock.secondDigitSecond.also {
                        bindingCountDownClock.frontUpper.background = digitBottomDrawable
                        bindingCountDownClock.backUpper.background = digitBottomDrawable
                    }
                   /* frontLower.background = digitBottomDrawable
                    backLower.background = digitBottomDrawable
                    frontLower.background = digitBottomDrawable
                    backLower.background = digitBottomDrawable
                    frontLower.background = digitBottomDrawable
                    backLower.background = digitBottomDrawable
                    frontLower.background = digitBottomDrawable
                    backLower.background = digitBottomDrawable
                     frontLower.background = digitBottomDrawable
                     backLower.background = digitBottomDrawable
                     frontLower.background = digitBottomDrawable
                     backLower.background = digitBottomDrawable
                     frontLower.background = digitBottomDrawable
                     backLower.background = digitBottomDrawable
                     frontLower.background = digitBottomDrawable
                     backLower.background = digitBottomDrawable*/
                } else {
                    setTransparentBackgroundColor()
                }
    
        }
    
        private fun setDigitDividerColor(digitDividerColor: Int) {
            var dividerColor = digitDividerColor
            if (dividerColor == 0) {
                dividerColor = ContextCompat.getColor(context, R.color.transparent)
            }
    
        }
    
        private fun setDigitSplitterColor(digitsSplitterColor: Int) {
            if (digitsSplitterColor != 0) {
            } else {
            }
        }
    
        private fun setSplitterDigitTextSize(digitsTextSize: Float) {
        }
    
        private fun setDigitPadding(digitPadding: Int) {
            bindingSimpleClock.apply {
                firstDigitDays.setPadding(digitPadding, digitPadding, digitPadding, digitPadding)
                secondDigitDays.setPadding(digitPadding, digitPadding, digitPadding, digitPadding)
                firstDigitHours.setPadding(digitPadding, digitPadding, digitPadding, digitPadding)
                secondDigitHours.setPadding(digitPadding, digitPadding, digitPadding, digitPadding)
                firstDigitMinute.setPadding(digitPadding, digitPadding, digitPadding, digitPadding)
                secondDigitMinute.setPadding(digitPadding, digitPadding, digitPadding, digitPadding)
                firstDigitSecond.setPadding(digitPadding, digitPadding, digitPadding, digitPadding)
                secondDigitSecond.setPadding(digitPadding, digitPadding, digitPadding, digitPadding)
            }
        }
    
        private fun setSplitterPadding(splitterPadding: Int) {
        }
    
        private fun setDigitTextColor(digitsTextColor: Int) {
            var textColor = digitsTextColor
            if (textColor == 0) {
                textColor = ContextCompat.getColor(context, R.color.transparent)
            }
            bindingSimpleClock.firstDigitDays.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextColor(textColor)
                    backUpperText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.firstDigitHours .also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextColor(textColor)
                    backUpperText.setTextColor(textColor)
                }
            }
    
            bindingSimpleClock.secondDigitDays.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextColor(textColor)
                    backUpperText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.secondDigitHours.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextColor(textColor)
                    backUpperText.setTextColor(textColor)
                }
            }
    
    
            bindingSimpleClock.firstDigitMinute.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextColor(textColor)
                    backUpperText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.secondDigitMinute.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextColor(textColor)
                    backUpperText.setTextColor(textColor)
                }
            }
    
            bindingSimpleClock.firstDigitSecond.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextColor(textColor)
                    backUpperText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.secondDigitSecond.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextColor(textColor)
                    backUpperText.setTextColor(textColor)
                }
            }
    
            bindingSimpleClock.firstDigitDays.also {
                bindingCountDownClock.apply {
                    frontLowerText.setTextColor(textColor)
                    backLowerText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.secondDigitDays.also {
                bindingCountDownClock.apply {
                    frontLowerText.setTextColor(textColor)
                    backLowerText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.firstDigitHours.also {
                bindingCountDownClock.apply {
                    frontLowerText.setTextColor(textColor)
                    backLowerText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.secondDigitHours.also {
                bindingCountDownClock.apply {
                    frontLowerText.setTextColor(textColor)
                    backLowerText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.firstDigitMinute.also {
                bindingCountDownClock.apply {
                    frontLowerText.setTextColor(textColor)
                    backLowerText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.secondDigitMinute.also {
                bindingCountDownClock.apply {
                    frontLowerText.setTextColor(textColor)
                    backLowerText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.firstDigitSecond.also {
                bindingCountDownClock.apply {
                    frontLowerText.setTextColor(textColor)
                    backLowerText.setTextColor(textColor)
                }
            }
            bindingSimpleClock.secondDigitSecond.also {
                bindingCountDownClock.apply {
                    frontLowerText.setTextColor(textColor)
                    backLowerText.setTextColor(textColor)
                }
            }
    
        }
    
        private fun setDigitTextSize(digitsTextSize: Float) {
            bindingSimpleClock.firstDigitDays.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    frontLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                }
            }
            bindingSimpleClock.secondDigitDays.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    frontLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                }
            }
            bindingSimpleClock.firstDigitHours.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    frontLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                }
            }
            bindingSimpleClock.secondDigitHours.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    frontLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                }
            }
            bindingSimpleClock.firstDigitMinute.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    frontLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                }
            }
            bindingSimpleClock.secondDigitMinute.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    frontLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                }
            }
            bindingSimpleClock.firstDigitSecond.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    frontLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                }
            }
            bindingSimpleClock.secondDigitSecond.also {
                bindingCountDownClock.apply {
                    frontUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backUpperText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    frontLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                    backLowerText.setTextSize(TypedValue.COMPLEX_UNIT_PX, digitsTextSize)
                }
            }
    
        }
    
        private fun setHalfDigitHeightAndDigitWidth(halfDigitHeight: Int, digitWidth: Int) {
            bindingSimpleClock.firstDigitDays.also {
                bindingCountDownClock.apply {
                    setHeightAndWidthToView(frontUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(frontLower, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backLower, halfDigitHeight, digitWidth)
                }
            }
            bindingSimpleClock.secondDigitDays.also {
                bindingCountDownClock.apply {
                    setHeightAndWidthToView(frontUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(frontLower, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backLower, halfDigitHeight, digitWidth)
                }
            }
            bindingSimpleClock.firstDigitHours.also {
                bindingCountDownClock.apply {
                    setHeightAndWidthToView(frontUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(frontLower, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backLower, halfDigitHeight, digitWidth)
                }
            }
            bindingSimpleClock.secondDigitHours.also {
                bindingCountDownClock.apply {
                    setHeightAndWidthToView(frontUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(frontLower, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backLower, halfDigitHeight, digitWidth)
                }
            }
            bindingSimpleClock.firstDigitMinute.also {
                bindingCountDownClock.apply {
                    setHeightAndWidthToView(frontUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(frontLower, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backLower, halfDigitHeight, digitWidth)
                }
            }
            bindingSimpleClock.secondDigitMinute.also {
                bindingCountDownClock.apply {
                    setHeightAndWidthToView(frontUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(frontLower, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backLower, halfDigitHeight, digitWidth)
                }
            }
            bindingSimpleClock.firstDigitSecond.also {
                bindingCountDownClock.apply {
                    setHeightAndWidthToView(frontUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(frontLower, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backLower, halfDigitHeight, digitWidth)
                }
            }
            bindingSimpleClock.secondDigitSecond.also {
                bindingCountDownClock.apply {
                    setHeightAndWidthToView(frontUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backUpper, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(frontLower, halfDigitHeight, digitWidth)
                    setHeightAndWidthToView(backLower, halfDigitHeight, digitWidth)
                }
            }
    
        }
    
        private fun setHeightAndWidthToView(view: View, halfDigitHeight: Int, digitWidth: Int) {
            val firstDigitMinuteFrontUpperLayoutParams = view.layoutParams
            firstDigitMinuteFrontUpperLayoutParams.height = halfDigitHeight
            firstDigitMinuteFrontUpperLayoutParams.width = digitWidth
            bindingSimpleClock.firstDigitDays.also {
                bindingCountDownClock.frontUpper.layoutParams = firstDigitMinuteFrontUpperLayoutParams
            }
        }
    
        private fun setAnimationDuration(animationDuration: Int) {
            bindingSimpleClock.apply {
                firstDigitDays.setAnimationDuration(animationDuration.toLong())
                secondDigitDays.setAnimationDuration(animationDuration.toLong())
                firstDigitHours.setAnimationDuration(animationDuration.toLong())
                secondDigitHours.setAnimationDuration(animationDuration.toLong())
                firstDigitMinute.setAnimationDuration(animationDuration.toLong())
                secondDigitMinute.setAnimationDuration(animationDuration.toLong())
                firstDigitSecond.setAnimationDuration(animationDuration.toLong())
                secondDigitSecond.setAnimationDuration(animationDuration.toLong())
            }
        }
    
        private fun setAlmostFinishedCallbackTimeInSeconds(almostFinishedCallbackTimeInSeconds: Int) {
            this.almostFinishedCallbackTimeInSeconds = almostFinishedCallbackTimeInSeconds
        }
    
        private fun setTransparentBackgroundColor() {
            val transparent = ContextCompat.getColor(context, R.color.transparent)
            bindingSimpleClock.firstDigitDays.apply {
                bindingCountDownClock.apply {
                    frontLower.setBackgroundColor(transparent)
                    backLower.setBackgroundColor(transparent)
                }
            }
            bindingSimpleClock.secondDigitDays.apply {
                bindingCountDownClock.apply {
                    frontLower.setBackgroundColor(transparent)
                    backLower.setBackgroundColor(transparent)
                }
            }
            bindingSimpleClock.firstDigitHours.apply {
                bindingCountDownClock.apply {
                    frontLower.setBackgroundColor(transparent)
                    backLower.setBackgroundColor(transparent)
                }
            }
            bindingSimpleClock.firstDigitHours.apply {
                bindingCountDownClock.apply {
                    frontLower.setBackgroundColor(transparent)
                    backLower.setBackgroundColor(transparent)
                }
            }
            bindingSimpleClock.firstDigitMinute.apply {
                bindingCountDownClock.apply {
                    frontLower.setBackgroundColor(transparent)
                    backLower.setBackgroundColor(transparent)
                }
            }
            bindingSimpleClock.secondDigitMinute.apply {
                bindingCountDownClock.apply {
                    frontLower.setBackgroundColor(transparent)
                    backLower.setBackgroundColor(transparent)
                }
            }
            bindingSimpleClock.firstDigitSecond.apply {
                bindingCountDownClock.apply {
                    frontLower.setBackgroundColor(transparent)
                    backLower.setBackgroundColor(transparent)
                }
            }
            bindingSimpleClock.secondDigitSecond.apply {
                bindingCountDownClock.apply {
                    frontLower.setBackgroundColor(transparent)
                    backLower.setBackgroundColor(transparent)
                }
            }
    
    
        }
    
        ////////////////
        // Listeners
        ////////////////
    
        fun setCountdownListener(countdownListener: CountdownCallBack) {
            this.countdownListener = countdownListener
        }
    
        interface CountdownCallBack {
            fun countdownAboutToFinish()
            fun countdownFinished()
        }
    
    
        fun pauseCountDownTimer() {
            countDownTimer?.cancel()
        }
    
        fun resumeCountDownTimer() {
            startCountDown(milliLeft)
        }
    
    
        fun setCustomTypeface(typeface: Typeface) {
            bindingSimpleClock.apply {
                firstDigitDays.setTypeFace(typeface)
                firstDigitDays.setTypeFace(typeface)
                secondDigitDays.setTypeFace(typeface)
                secondDigitDays.setTypeFace(typeface)
                firstDigitHours.setTypeFace(typeface)
                firstDigitHours.setTypeFace(typeface)
                secondDigitHours.setTypeFace(typeface)
                secondDigitHours.setTypeFace(typeface)
                firstDigitMinute.setTypeFace(typeface)
                firstDigitMinute.setTypeFace(typeface)
                secondDigitMinute.setTypeFace(typeface)
                secondDigitMinute.setTypeFace(typeface)
                firstDigitSecond.setTypeFace(typeface)
                firstDigitSecond.setTypeFace(typeface)
                secondDigitSecond.setTypeFace(typeface)
                secondDigitSecond.setTypeFace(typeface)
            }
        }
    
    
    }
    

    This is the layout I m getting Capture Below is the output when application is running. Screenshot_20211108-103725 1

    opened by Syedwaheed 0
  • Doesn't work with AndroidX

    Doesn't work with AndroidX

    I'm on an Android X project and even though it shows the countdown on the preview, when I run it, it doesn't show the widget -- only the Days Hours Mins Secs show up.

    Can we upgrade the libraries to Android X and try to see if it works?

    Best,

    Tom

    opened by tomafc330 2
Releases(v1.5)
Owner
Anu S Pillai
Kotliner | Developer | Blogger
Anu S Pillai
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments

/!\ This Project is no longer maintained /!\ DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numb

Code-Troopers 2.7k Dec 29, 2022
An android library which provides a compact calendar view much like the one used in google calenders.

CompactCalendarView CompactCalendarView is a simple calendar view which provides scrolling between months. It's based on Java's Date and Calendar clas

SundeepK 1.5k Dec 9, 2022
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments

/!\ This Project is no longer maintained /!\ DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numb

Code-Troopers 2.7k Dec 29, 2022
A customizable, easy-to-use, and functional circular time range picker library for Android

A customizable, easy-to-use, and functional circular time range picker library for Android. Use this library to mimic Apple's iOS or Samsung's bedtime picker.

Joery Droppers 251 Dec 30, 2022
Appleader707 1 Aug 9, 2022
Jetlime - A simple library for TimeLine view in Android

JetLime ⏱️ A simple yet highly customizable library for showing a TimeLine view

Pushpal Roy 107 Dec 6, 2022
Android Compose wheel picker library based on LazyColumn in vertical and LazyRow in horizontal.

About Android Compose wheel picker library based on LazyColumn in vertical and LazyRow in horizontal. Gradle Sample Default Item size Unfocused count

null 6 Dec 22, 2022
Nepali Date Picker library in Jetpack compose for android with Date conversion from BS to AD and vice-versa

Nepali Date picker Converter - Re in Compose This is a re-work of Nepali Date Picker Converter in jetpack compose and kotlin. English Locale Nepali Lo

Kiran Gyawali 4 Dec 23, 2022
Alwan 🎨 is an Android Jetpack Compose color picker library.

Alwan Alwan is an Android Jetpack Compose color picker library. Preview Recording.mp4 Download Gradle: dependencies { implementation 'com.raedapps:a

Raed Mughaus 6 Sep 16, 2022
JetCalendarView - A calendar library for Jetpack Compose

JetCalendar WIP 2022 Hit Refresh! Calendar view ❤️ Jetpack Compose License Copyr

Anmol Verma 8 Aug 17, 2022