CountDownView


Source link: https://github.com/alexfu/CountDownView

CountDownView

What is it? It's a custom View that displays a simple countdown. It looks like this:

CountDownView is backed by CountDownTimer so that you don't have to worry about lifting any boxes...

It also uses Android-RobotoTextView for API levels below 11 to keep consistency.

Interested? Here's how to use it

First, specify the following in your AndroidManifest.xml. This library uses a Service to handle the CountDownTimer.

<service android:name="com.alexfu.countdownview.core.TimerService"/>

Sample layout...

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:custom="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

<com.alexfu.countdownview.widget.CountDownView

android:id="@+id/countdownview"

android:layout_width="match_parent"

android:layout_height="wrap_content"/>  </FrameLayout>

By default, the above wont show you anything. Choose to display hours or minutes or seconds or milliseconds, or all 4.

Show only hours:

<com.alexfu.countdownview.widget.CountDownView
  android:id="@+id/countdownview"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  custom:showHour="true"/>

Show hours and minutes:

<com.alexfu.countdownview.widget.CountDownView
  android:id="@+id/countdownview"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  custom:showHour="true"
  custom:showMin="true"/>

You can also set text colors for digits and units:

<com.alexfu.countdownview.widget.CountDownView
  android:id="@+id/countdownview"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  custom:showHour="true"
  custom:showMin="true"
  custom:numberColor="@color/black"
  custom:unitColor="@color/grey"/>

In code:

CountDownView cdv = (CountDownView) findViewById(R.id.countdownview);
 cdv.setInitialTime(30000);
 // Initial time of 30 seconds. cdv.start();
 cdv.stop();
 cdv.reset();
 

To get notified when timer reaches zero implement TimerListener in your activity and override timerElapsed

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

......

.....

cdv.setListener(this);

  
}
  @Override
  public void timerElapsed() {

//Do something here
  
}

TODO

  • Implement an event listener when timer is done/reaches zero.
  • Add support for different text sizes.
  • Add more TODO items.

Resources

Bring your apps to life with voice and messaging using the Sinch SDK for iOS, Android and JavaScript. The Sinch SDK takes care of app communications in a cinch.

ButtonMenu is an Android library created to build user interfaces based on buttons. This library has been implemented using Model View ViewModel pattern combined with an Android custom view that extends LinearLayout.

It works on Android 2.X or higher versions.

Effects for android notifications. It is based on Crouton.

custom-typeface is an Android library to apply custom typefaces directly from layouts, styles or themes.

EnhancedEditText allows you to simply add Iconify or text on each end of an EditText. It's awesome to get rid of TextView aligned with the component to say what's the purpose of the field, or to show value unit.

aSmack - build system for Smack on Android.

This repository contains a source fetching, patching and building script. As well as all the minor changes to make an Android version fly.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes