PullSwitcher


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

PullSwitcher

This library is learn from liaohuqiu/android-Ultra-Pull-To-Refresh and learn the pull to next layout effect from zzz40500/Android-PullToNextLayout, this fragments adapter make the fragment hide or show in the activity. So, you can keep data in those.

The child of the pushswitcherview in the fragment must be NestedScrollingChild, such as a RecyclerView, NestedScrollView and viewpager wrap pre-view

Screeshot

Installation

dependencies {

  compile 'com.loopeer.library:pullswitcherview:1.0.6' 
}

Usage

###1. Add adapter and holder in activity

 private SwitcherAdapter adapter;
  private SwitcherHolder mSwitchHolder;

 ...{

mSwitchHolder = new SwitcherHolder(containerLayout);

adapter = new TestSwitcherAdapter(getSupportFragmentManager());

mSwitchHolder.setAdapter(adapter);

}
 

Then, create your custom switcher adapter.

public class TestSwitcherAdapter extends SwitchFragmentAdapter {

public TestSwitcherAdapter(FragmentManager fm) {

super(fm);

  
}

@Override
  public Fragment getItem(int position) {

Fragment fragment;

switch (position) {

 case 0:

  fragment = TestFragment1Recycler.newInstance(getSwitcherHolder());

  break;

 case 1:

  fragment = TestFragment2Scroll.newInstance(getSwitcherHolder());

  break;

 case 2:

  fragment = TestFragment3ViewPager.newInstance(getSwitcherHolder());

  break;

 default:

  fragment = null;

}

return fragment;
  
}

@Override
  public int getCount() {

return 3;
  
}
 
}

###2. Create cutom fragment

You can create the single fragment or view by the PullSwitchView, add the layout. set the PullSwitchView as your layou which layout you want to move. PullSwitchView can host only one direct child. And the footer and header must implements FooterImpl or HeaderImpl. The pullSwitchView will add header and footer for you by default. But you can set your custom view which must implements the Impl.

<?xml version="1.0" encoding="utf-8"?> <com.loopeer.android.librarys.PullSwitchView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/switcher"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#dddddd">

<LinearLayout

android:id="@+id/text_wrapper"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="vertical">

 <android.support.v7.widget.RecyclerView

 android:id="@+id/my_recycler_view"

 android:scrollbars="vertical"

 android:layout_width="match_parent"

 android:layout_height="match_parent"/>

</LinearLayout>  </com.loopeer.android.librarys.PullSwitchView>

init your pullswitchview

 private void initSwitchView(View view) {

pullSwitchView = (PullSwitchView) view.findViewById(R.id.switcher);

pullSwitchView.setSwitcherHolder(switcherHolder);

  
}

If you want go back by press the back key, you should add this in activity:

 @Override
  public void onBackPressed() {

mSwitchHolder.doBack();

  
}

####You can add switcher listener

public class TestFragment1Recycler extends Fragment implements PullHandler, SwitchListener {

  ...

@Override
  public void onPagePause() {

Toast.makeText(getActivity(), "test recycler pause", Toast.LENGTH_SHORT).show();

  
}

@Override
  public void onPageResume() {

Toast.makeText(getActivity(), "test recycler resume", Toast.LENGTH_SHORT).show();

  
}
 
}

####You can add your custom footer and header view
create your custom view and implements the footer


  pullSwitchView.setFooterView(new TestCustomFooterView(getActivity()));
 

and the custom footer can set your pull tips

public class TestCustomFooterView extends TextView implements Footer{

public TestCustomFooterView(Context context) {

this(context, null);

  
}

public TestCustomFooterView(Context context, AttributeSet attrs) {

this(context, attrs, 0);

  
}

public TestCustomFooterView(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

setPadding(20, 20, 20, 20);

setGravity(Gravity.CENTER);

  
}

@Override
  public void onMoveStart(int currentPosY, int startSwitchOffset, CharSequence string) {

setText("Test custom footer text onMoveStart");

  
}

@Override
  public void onCanStartSwitch(int currentPosY, int startSwitchOffset, CharSequence string) {

setText("Test custom footer text onCanStartSwitch");

}
 
}

License

Copyright 2015 Loopeer  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

An Implementation of WebView with Ad-blocked Interface. Blocks Banner And Video Apps From Web Page

Eleven music player (CyanogenMod) - compatible with Android version > 14.

SQLite Connection for Android. ORM tool for Android devices. First ORM with Geometric-Spatial data support for Android operating systems.

UPDATE 1.0.3 -> There is relational table support. OneToOne and OneToMany are fully supported.

Signin and Signup in single Screen using PercentRelativeLayout. A new way to onboard users using interactive signin and signup screen.

Simple Meter for Android.

An easy way to let your titlebar or bottom navigation hiding on scroll for Android.

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