Dragger


Source link: https://github.com/ppamorim/Dragger

If you want to use these transitions with fragments, take a look at PrismView library!

The library was created in order to provide new animations for activities on Android. Using the ViewDragHelper class, it is possible to create smooth animations that allow full control of the view by the user.

This new component has been created using some concepts described on Flavien Laurent Blog and Denevell Blog.

Dragger now uses Rebound(tiny, 41.7kb) from Facebook to provide more realistic animations and improve performance for old devices.

This library should work on API 10 (but not tested yet).

Usage

You can use this library like a view, you just need to do the following:

    1. Add ''DraggerView'' view to your root layout and add two layouts inside it. You can add a shadow view if you want (the first one) and it needs to be invisible.
<com.github.ppamorim.library.DraggerView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  dragger_layout:drag_view_id="@+id/drag_view"
  dragger_layout:shadow_view_id="@+id/shadow_view"
  dragger_layout:drag_position="top">

<FrameLayout

  android:id="@+id/shadow_view"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:background="@color/transparent"

  android:visibility="invisible"/>

<LinearLayout

  android:id="@+id/drag_view"

  android:layout_width="match_parent"

  android:layout_height="match_parent"/>  </com.github.ppamorim.library.DraggerView>

In your ''styles'' file, you need a config like this:

<style name="YourTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowNoTitle">true</item>
  <item name="windowActionBar">false</item>
  <item name="android:windowAnimationStyle">@null</item> </style>

And your ''manifest'':

<activity
  android:name="com.github.dragger.BaseActivity"
  android:theme="@style/YourTheme"/>

Or, if you need it to be fast:

public class YourActivity extends DraggerActivity {

@Override public void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setShadowView(R.layout.custom_shadow);
 // It is not necessary, use if you want.
  setContentView(R.layout.layout_content);

}
 
}

Now you can control the slide of the view, just use the method expand() when you want.

Some methods that you can use:

setDraggerCallback(DraggerCallback) //Interface that's provides some infos of the animation. setSlideEnabled(boolean) //Enable or disable the drag, useful to use with ScrollViews. setHorizontalDragRange(float) //Draggable distance that the draggableView can use, horizontally. setVerticalDragRange(float) //Draggable distance that the draggableView can use, vertically. setRunAnimationOnFinishInflate(boolean) //Run the initial animation, useful if you only want the drag function. setDraggerLimit(float) //Set the max limit drag, default is 0.5 (center of the screen). setDraggerPosition(DraggerPosition) //Set the position of archor. setTension(float) //Tension of the animation. This represent with the friction, how much time the animation will be executed. setFriction(float) //Friction of the animation. This represent with the tension, how much friction is applied at the tension animation. show() //Show the drag view with Rebound animation. closeActivity() //Simply close the activity with Rebound animation, based of the DraggerPosition choosen. 

Sample

Import dependency

This library use appcompat-v7:23.1.0.

But why not to add in MavenCentral? Because it is so much bureaucratic.

JitPack is there and is the future!

Into your build.gradle:

repositories {

maven {

  url "https://jitpack.io"

}
 
}
  dependencies {

compile 'com.github.ppamorim:dragger:1.2' 
}

Will you use with lists(RecyclerView, List/GridView, ScrollView)?

I decided that need to be Out-Of-Box, then... You must use the Android-ObservableScrollView, like this:

dependencies {

compile 'com.github.ksoichiro:android-observablescrollview:VERSION' 
}
public void configRecyclerView() {

...
recyclerView.setScrollViewCallbacks(onObservableScrollViewCallbacks);
 
}
  private ObservableScrollViewCallbacks onObservableScrollViewCallbacks =
  new ObservableScrollViewCallbacks() {

@Override public void onScrollChanged(int scrollY, boolean firstScroll,

 boolean dragging) {

  draggerView.setSlideEnabled(scrollY != 0);

}

@Override public void onDownMotionEvent() {
 
}

@Override public void onUpOrCancelMotionEvent(ScrollState scrollState) {
 
}
 
}
;

Contributors

This was only possible because Pedro Vicente Gómez Sánchez helped me and I am very grateful for that! Thank you. :) And thank you Facebook for provide Rebound library!

Developed By

Libraries used on the sample project

License

Copyright 2015 Pedro Paulo de Amorim  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Handles the drawable binding and position on View, EditText, ImageView or TextView. Also can change the icon color, alpha and size using a SelectorDrawable.

This is mainly core java project. It solves the problem of valid and meaningful random data generation in code flow itself (rather than parsing some random data file and loading data into some list).

It can use existing class models and generate wide range of preexisting random data to test data intensive application in absence of APIs.

Flare provide the easy implementation of circular indicator with ViewPager. (viewpager indicator)

A custom view that display multiple attributes by a polygon shape.

A small library that allows You to easily manage fingererprint authentication inside your Activity or Fragment on devices with fingerprint scanner and Android M and higher. Min sdk 14

A tiny library for handling hardware back button click in fragments.

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