CircularView


Source link: https://github.com/rjsvieira/circularView

CircularView

A special shoutout to @carlossotelo for his suggestions on anti-aliasing solutions

Include in your project

In your root/build.gradle

allprojects {

repositories {

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

}
 
}
  

In your app/build.gradle

dependencies {

compile 'com.github.rjsvieira:circularView:1.3.0' 
}

Customization

CircleView allows you to customize its default fields for your personal use. The attribute list can be found within the attrs.xml file.

Below is the configuration for the circleView presented on the first gif

<rjsv.circularview.CircleView
android:id="@+id/circle_view"
circleview:layout_constraintTop_toTopOf="parent"
circleview:layout_constraintBottom_toBottomOf="parent"
circleview:layout_constraintStart_toStartOf="parent"
circleview:layout_constraintEnd_toEndOf="parent"
android:layout_width="500dp"
android:layout_height="500dp"
circleview:suffixEnabled="true"
circleview:suffixValue="EUR"
circleview:arcBorderColor="@color/color_arc"
circleview:arcColor="@color/color_arc"
circleview:arcHasBorder="false"
circleview:arcWidth="15dp"
circleview:hasIndicator="false"
circleview:indicatorColor="@color/theme_red_primary"
circleview:indicatorRadius="6"
circleview:progressColor="@color/color_progress"
circleview:progressMaximumValue="10"
circleview:progressMinimumValue="0"
circleview:progressStepValue="1"
circleview:progressStepAsInteger="false"
circleview:progressWidth="15dp"
circleview:textColor="@color/sample_green"
circleview:textEnabled="true"
circleview:textFont="fonts/Roboto-Bold.ttf"
circleview:textSize="36sp"/>

Attribute configuration list

Attribute Type Default Default
progressCurrentValue float The starting value 0
progressMaximumValue float The maximum allowed value of the circle view 100
progressMinimumValue float The minimum allowed value of the circle view 0
progressStepValue float The step allows the developer to set a constraint for the values the user can choose. If different from 0, the step will be considered and whenever the user moves the progress to a non-integer value, it will round it to its Ceiling or Floor (whichever is closer) 0
progressStepAsInteger boolean The step allows the developer to constraint the value to an integer rather than a float false
progressBarSquared boolean If there is no indicator overlapping it, the progress bar can be set as squared or rounded false
progressWidth dimension The width of the progress bar
progressColor color The color of the progress bar
suffixEnabled boolean Specifies whether a suffix can be added after the progress value. Used to indicate time or currencies, etc false
suffixValue string The string value for the suffix. E.g. "EUR" false
hasIndicator boolean The indicator is a simple small circle that leads the progress bar false
indicatorColor color The indicator's color
indicatorRadius integer Specifies the radius, if it exists, of the indicator
arcWidth dimension The width of the circle's arc 20
arcColor color The color of the circle's arc.
arcHasBorder boolean Defines whether the circle's arc has a border. By default, if has exists, has 1.2x the width of the circle's arc
arcBorderColor color Specifies the arc's border color if the arc's border exists false
hasText boolean Specifies whether the arc's current progress will be displayed in the center of the circle true
textSize dimension Specifies the text size 72
textColor color Specifies the text color
textFont string Specifies the custom font attribute Typeface.DEFAULT
clockwise boolean Specifies whether the CircleView takes a clockwise or a counter-clockwise orientation true
enabled boolean Specifies whether the user can interact (changing the progress) with the CircleView or not. Made with the intent of allowing the developer to lock the value and operate it without user interaction true

CircleView Change Listener

You can keep track of the values when they change as well as the moment when the point tracking starts or stops.

public interface CircleViewChangeListener {

void onPointsChanged(CircleView circleView, float points);

void onStartTracking(CircleView circleView);

void onStopTracking(CircleView circleView);
  
}

CircleView Animation (Wrapper)

In order to facilitate animations (because yeah, animations are the coolest part of views), the custom CircleViewAnimation wrapper has been added. Configurations are few and easy to implement. Notes :

  1. The AnimationListener is bound to the View. Thus said, if the Activity goes to the background, the animation will be briefly paused until it comes back to the foreground.
  2. To complement the previous point, the method setTimerOperationOnFinish allows you to specify a Runnable that will run at the end of the duration regardless of the Activity's state

Consider the following example :

CircleView circleView = (CircleView) findViewById(R.id.circle_view);
 CircleViewAnimation circleViewAnimation = new CircleViewAnimation(circleView)
.setAnimationStyle(AnimationStyle.CONTINUOUS)

.setDuration(circleView.getProgressValue())

.setCustomAnimationListener(new Animation.AnimationListener() {

 @Override
 public void onAnimationStart(Animation animation) {

  // Animation Starts
 
}

  @Override
 public void onAnimationEnd(Animation animation) {

  // Animation Ends
 
}

  @Override
 public void onAnimationRepeat(Animation animation) {

  
}

}
).setTimerOperationOnFinish(new Runnable() {

 @Override

 public void run() {

  // Run when the duration reaches 0. Regardless of the AnimationLifecycle or main thread.

  // Runs and triggers on background.

 
}

}
)

.setCustomInterpolator(new LinearInterpolator());

Resources

Lib overrides android.support.v4.util.LruCache and uses code from article to measure size of objects in heap.

  • It is the superfast view to display contacts in RecyclerView with rich material design UI.
  • This view can be used as a contact picker using bottom sheet dialog and activity.

Bugsee is a bug and crash reporting tool for iOS and Android apps. Like a black box on an airplane, Bugsee locally records everything that the app is doing. Whenever a bug occurs, everything that led to it has already been recorded:

  • Video of user’s actions + touches (including in live apps)
  • All Network traffic
  • Console logs and more

This public toolbox allows you to easily test and debug the Firebase Cloud Messaging service.

  • Send and receive FCM payloads
  • Manage registered devices
  • Self-hosting capabilities

This demo emulates the animation of the circles which are present in Apple Music iOS app. Unfortunately, Apple Music Android app doesn't come with such animations. So i tried my hands and made it for Android. The initial version of the animation covers the most important functionalities of that.

FeedFire is a project to help developers integrate with Google Firebase.

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