HoldToLoadLayout


Source link: https://github.com/melihaksoy/HoldToLoadLayout

HoldToLoadLayout

HoldToLoadLayout is a view group that can contain a single child. It draws your child to middle of layout, and performs loading wheel around it with settings you determined.

Sample Gifs

Usage

Simply, add a child to HoldToLoadLayout, than set properties about the animation you'd like.

  <com.melih.holdtoload.HoldToLoadLayout

 android:id="@+id/holdToLoadLayout"

 android:layout_width="match_parent"

 android:layout_height="match_parent">

<ImageView

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:src="@drawable/github"/>

</com.melih.holdtoload.HoldToLoadLayout>

HoldToLoadLayout holdToLoadLayout = (HoldToLoadLayout) findViewById(R.id.holdToLoadLayout);

  holdToLoadLayout.setStrokeWidth(10);
 // Set stroke width in px ( dp in xml )

 holdToLoadLayout.setStrokeAlpha(255);
 // Set alpha value of paint ( 0 - 255 )

 holdToLoadLayout.setPlayReverseAnimation(true);
 // Reverse like it fills, with animation

 holdToLoadLayout.setStopWhenFilled(false);
 // Stop when holded fully

 holdToLoadLayout.setColorAnimator(Color.YELLOW, Color.RED);
 // Animate color while drawing

 holdToLoadLayout.setStartAngle(Angle.TOP);
 // Use any of the pre-defined starting angle

 holdToLoadLayout.setStartAngle(30);
 // Starting angle of loading

Customization

setStrokeWidth(int strokeWidth)
  • Sets stroke width in pixels if strokeWidth is greater than 0.
    You can set dp values from XML. Default is 0.
    Does NOT updates stroke width dynamically.
setPlayReverseAnimation(boolean isReverseAnimationEnabled)
  • If set true, loading will reverse from the point user stopped touching to 0. If set false, loading will disappear instantly.
    Default value is true.
setStopWhenFilled(boolean stopWhenFilled)
  • If set true, loading will stop when it's completed. If set false, loading will be reversed /disappear even if it is filled.
    Default value is true;
setHoldAtLastPosition(boolean isHoldAtLastPosition)
  • If set true, progress will not be reverted or reset when user lifts up his/her finger. This will suppress stopWhenFilled and setPlayReverseAnimation.
    Default value is false.
setColorAnimator(int startingColor, int endingColor)
  • When set, changes color of loading animation up to progress, starting with startingColor and ending with endingColor.
    There is no color animation by default.
setStrokeColor(int color) setStrokeColor(String color)
  • Set loading's color. Default color is Color.GREEN ( HoldToLoadLayout.DEFAULT_COLOR ).
    Does NOT updates color dynamically.
setDuration(int durationInMillis)
  • Set duration of fill time in milliseconds. This will throw IllegalArgumentException if durationInMillis is not greater than 0.
    Default value is 1500 ( HoldToLoadLayout.DEFAULT_DURATION ).
setStrokeAlpha(int alpha)
  • Set paint's alpha value. This will throw IllegalArgumentException if alpha is less than 0 or greater than 255.
    Default value is 255 ( HoldToLoadLayout.DEFAULT_ALPHA ).
setStartAngle(Angle startAngle)
  • Set loading's starting point from pre-defined angles. Default value is Angle.TOP
setStartAngle(float startAngle)
  • Set loading's starting point as angle. Default value is 270 ( top ) ( HoldToLoadLayout.DEFAULT_START_ANGLE ).
setFillListener(FillListener fillListener)
  • Set a fill listener ( HoldToLoadLayout.FillListener() ), which has onFull(), onEmpty(), onAngleChanged(float angle) and onOffsetChanged(float offset)methods.
    Setting null will remove the listener.
setFillListener(FillListener fillListener)
  • Set a fill listener ( HoldToLoadLayout.FillListener() ), which has onFull(), onEmpty() and onAngleChanged(float angle) methods.
removeFillListener()
  • Removes fill listener.

XML Attributes


  <attr name="hold_strokeColor" format="string"/>

  <attr name="hold_strokeWidth" format="dimension"/>

  <attr name="hold_strokeAlpha" format="integer"/>

  <attr name="hold_duration" format="integer"/>

  <attr name="hold_stopWhenFilled" format="boolean"/>

  <attr name="hold_startAngle" format="float"/>

Download

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

allprojects {

repositories {

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

}
  
}

Add library dependency to your build.gradle file:

dependencies {

 compile 'com.github.melihaksoy:HoldToLoadLayout:1.0.7' 
}

License

The MIT License (MIT)  Copyright (c) 2016 Melihcan Aksoy  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. 

Resources

A simple way to bind and exchange messages between activities and services.

Acacia lets you use Android Services as Plain Old Java Objects (POJO's) by defining an interface and its implementing class. All the wiring around bound services, service connection and threading is automatically handled. Also having the service implementation and the actual Android Service instance as separate classes, allows them to be easily tested.

A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.

Android Spinner Widget with multi selectable list.

Library for unique identification of an Android device. Provides also a backup solution

HeaderRecyclerView is an Android library created to be able to use RecyclerView.Adapter with a header in a easy way. To use this library create your RecyclerView.Adapter classes extending from HeaderRecyclerViewAdapter.

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