SpringHeader


Source link: https://github.com/loopeer/SpringHeader

SpringHeader

An implementation of spring-like header (known as pull-to-refresh) that using CoordinatorLayout.

Usage

Simple Way

Just put a com.loopeer.springheader.SimpleRefreshHeader in your CoordinatorLayout, and add the attribute app:layout_behavior="@string/dependent_view_behavior" in the scroll view to let it scroll along header.

<android.support.design.widget.CoordinatorLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".SpringHeaderActivity">

<com.loopeer.springheader.SimpleRefreshHeader

android:id="@+id/header"

android:layout_width="match_parent"

android:layout_height="48dp"

android:background="#cccccc"/>

<include

layout="@layout/scroll_view"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_behavior="@string/dependent_view_behavior"/>  </android.support.design.widget.CoordinatorLayout>

Note:

You can use DependentViewBehavior on other views as well, and you can use it multiple times or not use it at all.

The reason why we don't use CoordinatorLayout.Behavior's layout dependency function is that it won't meet all our needs.

Simple Customization

SimpleRefreshHeader has three attributes textBelowThreshold, textAboveThreshold and textRefreshing. You can also set color scheme via java code.

SimpleRefreshHeader has a DefaultBehavior, the SpringHeaderBehavior. And SpringHeaderBehavior has three params behavior_originalOffset, behavior_hoveringRange and behavior_maxRange:

  • behavior_originalOffset is the original offset of header;
  • behavior_hoveringRange is the range from original offset to hovering offset;
  • behavior_maxRange is the range from original offset to max offset. SimpleRefreshHeader has a default behavior set, but if you set any of above attributes, you may also add attribute app:layout_behavior="@string/spring_header_behavior" to make it work.

Extended Way

com.loopeer.springheader.RefreshHeader is the base class for implementing your own style of refresh header.

Also you can make use of any Views to make it work, just hook it up through the SpringHeaderCallback sets on SpringHeaderBehavior:

public interface SpringHeaderCallback {

  void onScroll(int offset, float fraction);

void onStateChanged(int newState);
 
}

onScroll() method is called whenever the header offset changed.

  • fraction = (currentOffset - originalOffset) / hoveringRange. fraction starts from 0, and when currentOffset equals hoveringOffset, fraction equals 1.

onStateChanged() method is called whenever the header state changed. There are four states STATE_COLLAPSED, STATE_HOVERING, STATE_DRAGGING and STATE_SETTLING.

RefreshHeader implements SpringHeaderCallback.

References

This project is mainly referencing Android Support Library, including Design Support Library and v4 Support Library. There are three class ViewOffsetBehavior, ViewOffsetHelper and MaterialProgressDrawable copied from the Android Support Library.

License

Apache License Version 2.0

Resources

Takt is Android library for measuring the FPS using Choreographer.

Material bootstrap for Android development like Bootstrap or Foundation for web.

Quick Android Review Kit - This tool is designed to look for several security related Android application vulnerabilities, either in source code or packaged APKs. The tool is also capable of creating "Proof-of-Concept" deployable APKs and/or ADB commands, capable of exploiting many of the vulnerabilities it finds. There is no need to root the test device, as this tool focuses on vulnerabilities that can be exploited under otherwise secure conditions.

An interactive view with water waves flowing like in a washing machine.

A Pin view widget for Android.

PinView has a feature that allows you to find out when they have completed all parameters. Support for Android 3.0 and up. It supports portrait and landscape mode, saving the state.

A ToggleLayout that can be used in setting interface.

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