diff --git a/.travis.yml b/.travis.yml index 6a480206..e2ba17a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: android +jdk: + - oraclejdk8 # Turning off caching to avoid caching Issues # cache: false @@ -12,7 +14,7 @@ env: # Amount of memory granted to Gradle JVM - GRADLE_OPTS="-Xmx512m -XX:MaxPermSize=512m" # General Android settings used in builds - - ANDROID_TARGET=android-23 + - ANDROID_TARGET=android-24 before_install: # Making sure gradlew has executable permissions @@ -22,13 +24,12 @@ before_install: android: components: # We are using the latest revision of Android SDK Tools - - - android-23 - # The BuildTools version we are using for our project - - build-tools-23.0.1 - - - platform-tools - tools + - platform-tools + - android-24 + # The BuildTools version we are using for our project + - build-tools-24.0.1 + # Additional components - extra-google-google_play_services - extra-google-m2repository diff --git a/README.md b/README.md index 93eb1d94..2311f578 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,67 @@ # UltimateRecyclerView -[![Download](https://api.bintray.com/packages/jjhesk/maven/MenuURV/images/download.svg) ](https://bintray.com/jjhesk/maven/MenuURV/_latestVersion)[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)[![Stories in Ready](https://badge.waffle.io/cymcsg/UltimateRecyclerView.svg?label=ready&title=Ready)](http://waffle.io/cymcsg/UltimateRecyclerView) + [ ![Download](https://api.bintray.com/packages/marshalchen/UltimateRecyclerview/UltimateRecyclerview/images/download.svg) ](https://bintray.com/marshalchen/UltimateRecyclerview/UltimateRecyclerview/_latestVersion)[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)[![Stories in Ready](https://badge.waffle.io/cymcsg/UltimateRecyclerView.svg?label=ready&title=Ready)](http://waffle.io/cymcsg/UltimateRecyclerView) + -[![Throughput Graph](https://graphs.waffle.io/cymcsg/UltimateRecyclerView/throughput.svg)](https://waffle.io/cymcsg/UltimateRecyclerView/metrics) #### Master branch:[![Build Status](https://travis-ci.org/cymcsg/UltimateRecyclerView.svg?branch=master)](https://travis-ci.org/cymcsg/UltimateRecyclerView) +#### Dev branch:[![Build Status](https://travis-ci.org/cymcsg/UltimateRecyclerView.svg?branch=dev)](https://travis-ci.org/cymcsg/UltimateRecyclerView) ##### Project website:[https://github.com/cymcsg/UltimateRecyclerView](https://github.com/cymcsg/UltimateRecyclerView) -### Quick Setup(Basic Usage) -###### 1.Integration jcenter +### Description + +UltimateRecyclerView is a RecyclerView(advanced and flexible version of ListView) with pulling to refresh, loading more, swiping to dismiss, draging and drop, animations ,sticky header,show or hide toolbar and FAB when scrolling and many other features.You can use it ```just like RecyclerView```. + +Notice that UltimateRecyclerView is a project under development. + +[Your donations is highly appreciated. Thank you!](#donations) -Please follow the latest publishing aar on jcenter. +### Features: -follow by the gradle code -```gradle -dependencies{ - compile 'com.hkm.ui:ultimaterecyclerview:0.5.8' +* Swipe to refresh(using android.support.v4.widget.SwipeRefreshLayout) +* Many kinds of animations +* Swipe to dismiss +* Parallax or normal head view +* Drag and drop items +* Loading more when reach the last item(infinite scrolling) +* Custom views in loading more +* Showing or hiding toolbar and floating button when scrolling +* Scrollbars +* Colorful styles of ``swipe to refresh`` +* Sticky header like instagram +* Support different layout in adapter +* Loading adapter with animation +* Expandable view in recyclerview + + +#### Quick Setup (Basic Usage) +##### 1.Using Gradle: +```groovy +repositories { + jcenter() + } +dependencies { + ... + compile 'com.marshalchen.ultimaterecyclerview:library:0.7.0' } ``` -###### 2.Usage: +or grab via Maven + +```xml + + com.marshalchen.ultimaterecyclerview + library + 0.7.0 + +``` + +##### 2.Usage: ``` xml ``` +For more details, you can read the Wiki and the demo of the project. + -Remote server: dont forget to declare the repos location -``` -repositories { - jcenter() - maven { url "http://dl.bintray.com/jjhesk/maven" } - } -``` ### Version Log + +* ***v0.7.0*** Support most features in Recyclerview 24.0.0. Improve the UltimateAdapter. Reduce the size of the library. Fix some bugs. + * ***v0.5.8*** In this version we are now based on support library 23.4.0. We have fixed the load more and disable load more function from early triggers. There is no need to change anything from their implementations. Please read up on the example code if you have any questions from the implementations. * ***v0.5.6*** In this version we now have 23.3.0 support library and the min version is supported all the ways to v13. New added feature that allow us to adding have node connector on each item on `linearlayoutmanager`. By extending `TimeLineView` you will now have unlimited builds from the things that connected to each dot. @@ -51,29 +86,7 @@ repositories { * ***v0.4.9*** This is the last version that will be based on V23.1.1. and this library will not be supported on this version. For further supports please refer to the latest release. * ***v0.3.11*** There are still version that is based on 22.+ -### Description - -UltimateRecyclerView is a RecyclerView(advanced and flexible version of ListView) with pulling to refresh, loading more, swiping to dismiss, draging and drop, animations ,sticky header,show or hide toolbar and FAB when scrolling and many other features.You can use it ```just like RecyclerView```. - -Notice that UltimateRecyclerView is a project under development. - -[Your donations is highly appreciated. Thank you!](#donations) - -### Features: -* Swipe to refresh(using android.support.v4.widget.SwipeRefreshLayout) -* Many kinds of animations -* Swipe to dismiss -* Parallax or normal head view -* Drag and drop items -* Loading more when reach the last item(infinite scrolling) -* Custom views in loading more -* Showing or hiding toolbar and floating button when scrolling -* Scrollbars -* Colorful styles of ``swipe to refresh`` -* Sticky header like instagram -* Support different layout in adapter -* Loading adapter with animation ### Upcoming features: * Refer to discussion for headers [#299](https://github.com/cymcsg/UltimateRecyclerView/issues/299) @@ -96,18 +109,18 @@ Notice that UltimateRecyclerView is a project under development. If you have some good ideas, please tell us. My email is cymcsg # gmail.com.And it is a good idea to put your idea on the issue. If you want to use a rapid development framework for developing apps, you can try [UltimateAndroid Framework](https://github.com/cymcsg/UltimateAndroid). ### Screenshot - +![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/44beb162121c719ea4094bd7ea1c9f0cd7de4c04/ultimaterecyclerview/ultimate_recyclerview11.gif) +![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/44beb162121c719ea4094bd7ea1c9f0cd7de4c04/ultimaterecyclerview/ultimate_recyclerview12.gif) +![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/44beb162121c719ea4094bd7ea1c9f0cd7de4c04/ultimaterecyclerview/ultimate_recyclerview7.gif) +![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/f4794974d8de71ab1d0f0efddda556df7e792df2/ultimaterecyclerview/ultimate_recyclerview3.gif) +![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/44beb162121c719ea4094bd7ea1c9f0cd7de4c04/ultimaterecyclerview/ultimate_recyclerview9.gif) ![grid_layout](http://i.giphy.com/UVKEWEGu64z60.gif) ![grid_layout](http://i.giphy.com/UKxCkkUHVH8Fq.gif) ![admob](http://i.giphy.com/bExwitMhjtUqI.gif) ![expandable](http://i.giphy.com/pLWHKsEdVlsKA.gif) ![node](http://i.giphy.com/Xjf7Y8pZ84OxW.gif) ![multitype](http://i.giphy.com/bvU4HcWvMhejm.gif) -![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/44beb162121c719ea4094bd7ea1c9f0cd7de4c04/ultimaterecyclerview/ultimate_recyclerview11.gif) -![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/44beb162121c719ea4094bd7ea1c9f0cd7de4c04/ultimaterecyclerview/ultimate_recyclerview12.gif) -![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/44beb162121c719ea4094bd7ea1c9f0cd7de4c04/ultimaterecyclerview/ultimate_recyclerview7.gif) -![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/f4794974d8de71ab1d0f0efddda556df7e792df2/ultimaterecyclerview/ultimate_recyclerview3.gif) -![ultimate_recyclerview](https://bytebucket.org/marshalchen/images/raw/44beb162121c719ea4094bd7ea1c9f0cd7de4c04/ultimaterecyclerview/ultimate_recyclerview9.gif) + ### Thanks @@ -128,13 +141,13 @@ Donate $9.99: [![$9.99](https://bytebucket.org/marshalchen/images/raw/9c44264549 Alipay:![donate](https://bytebucket.org/marshalchen/images/raw/9c442645492ddc10474416debf511a57a0367397/others/alipay.png) -###Bitcoin Donation Accepted +Bitcoin Donation Accepted ![wallet](http://s32.postimg.org/sdd1oio1t/qrwallet.jpg) ## License -``` -Copyright 2015 MarsellChan +``` +Copyright 2014-present Marshal Chen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/UltimateRecyclerView/app/build.gradle b/UltimateRecyclerView/app/build.gradle index aaa8fd37..98564e69 100644 --- a/UltimateRecyclerView/app/build.gradle +++ b/UltimateRecyclerView/app/build.gradle @@ -30,19 +30,12 @@ repositories { } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile supportDependencies.appCompat - compile supportDependencies.annotation - compile supportDependencies.cv - - debugCompile supportDependencies.leakcanary - releaseCompile supportDependencies.leakcanarynoop - testCompile supportDependencies.leakcanarynoop - - // compile 'com.marshalchen.ultimaterecyclerview:library:0.4.0' + compile "com.android.support:appcompat-v7:${SUPPORT_LIBRARY}" + compile "com.android.support:cardview-v7:${SUPPORT_LIBRARY}" + debugCompile "com.squareup.leakcanary:leakcanary-android:${LEAKCANARY}" + releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${LEAKCANARY}" + testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${LEAKCANARY}" compile 'com.google.android.gms:play-services:7.3.0' - debugCompile 'me.drakeet.library:crashwoodpecker:0.9.7' - releaseCompile 'me.drakeet.library:crashwoodpecker-do-nothing:0.9.7' - compile 'com.hkm.loyalslider:library:1.6.2' compile project(':ultimaterecyclerview') //used in the gridlayout diff --git a/UltimateRecyclerView/app/src/main/AndroidManifest.xml b/UltimateRecyclerView/app/src/main/AndroidManifest.xml index 55e9216f..592e649b 100644 --- a/UltimateRecyclerView/app/src/main/AndroidManifest.xml +++ b/UltimateRecyclerView/app/src/main/AndroidManifest.xml @@ -26,7 +26,7 @@ - + diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java new file mode 100644 index 00000000..568eb4e8 --- /dev/null +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java @@ -0,0 +1,321 @@ +package com.marshalchen.ultimaterecyclerview.demo; + +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.os.Handler; +import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.view.ActionMode; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.support.v7.widget.helper.ItemTouchHelper; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.animation.OvershootInterpolator; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Spinner; + +import com.marshalchen.ultimaterecyclerview.ObservableScrollState; +import com.marshalchen.ultimaterecyclerview.ObservableScrollViewCallbacks; +import com.marshalchen.ultimaterecyclerview.URLogs; +import com.marshalchen.ultimaterecyclerview.UltimateRecyclerView; +import com.marshalchen.ultimaterecyclerview.demo.modules.FastBinding; +import com.marshalchen.ultimaterecyclerview.itemTouchHelper.SimpleItemTouchHelperCallback; +import com.marshalchen.ultimaterecyclerview.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration; + +import java.util.ArrayList; +import java.util.List; + +import jp.wasabeef.recyclerview.animators.*; + +/** + * Created by Marshal Chen on 3/8/2016. + */ +public class LauncherActivity extends AppCompatActivity implements ActionMode.Callback { + UltimateRecyclerView ultimateRecyclerView; + SimpleAdapter simpleRecyclerViewAdapter = null; + LinearLayoutManager linearLayoutManager; + int moreNum = 2; + private ActionMode actionMode; + + Toolbar toolbar; + boolean isDrag = true; + + private ItemTouchHelper mItemTouchHelper; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_launcher); + + toolbar = (Toolbar) findViewById(R.id.tool_bar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayShowTitleEnabled(false); + + + ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view); + ultimateRecyclerView.setHasFixedSize(false); + final List stringList = new ArrayList<>(); + + stringList.add("111"); + stringList.add("aaa"); + stringList.add("222"); + stringList.add("33"); + stringList.add("44"); + stringList.add("55"); + stringList.add("66"); + stringList.add("11771"); + simpleRecyclerViewAdapter = new SimpleAdapter(stringList); + + linearLayoutManager = new LinearLayoutManager(this); + ultimateRecyclerView.setLayoutManager(linearLayoutManager); + + StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(simpleRecyclerViewAdapter); + ultimateRecyclerView.addItemDecoration(headersDecor); +//// ultimateRecyclerView.setEmptyView(getResources().getIdentifier("empty_view","layout",getPackageName())); +// ultimateRecyclerView.showEmptyView(); + // ultimateRecyclerView.enableLoadmore(); + //simpleRecyclerViewAdapter.setCustomLoadMoreView(LayoutInflater.from(this) + // .inflate(R.layout.custom_bottom_progressbar, null)); + + ultimateRecyclerView.setLoadMoreView(LayoutInflater.from(this) + .inflate(R.layout.custom_bottom_progressbar, null)); + ultimateRecyclerView.setParallaxHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false)); +// // ultimateRecyclerView.setNormalHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false)); + ultimateRecyclerView.setOnParallaxScroll(new UltimateRecyclerView.OnParallaxScroll() { + @Override + public void onParallaxScroll(float percentage, float offset, View parallax) { + Drawable c = toolbar.getBackground(); + c.setAlpha(Math.round(127 + percentage * 128)); + toolbar.setBackgroundDrawable(c); + } + }); + ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff")); + ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + simpleRecyclerViewAdapter.insert(moreNum++ + " Refresh things", 0); + ultimateRecyclerView.setRefreshing(false); + // ultimateRecyclerView.scrollBy(0, -50); + linearLayoutManager.scrollToPosition(0); +// ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); +// simpleRecyclerViewAdapter.notifyDataSetChanged(); + } + }, 1000); + } + }); + + ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(simpleRecyclerViewAdapter); + mItemTouchHelper = new ItemTouchHelper(callback); + mItemTouchHelper.attachToRecyclerView(ultimateRecyclerView.mRecyclerView); + simpleRecyclerViewAdapter.setOnDragStartListener(new SimpleAdapter.OnStartDragListener() { + @Override + public void onStartDrag(RecyclerView.ViewHolder viewHolder) { + mItemTouchHelper.startDrag(viewHolder); + } + }); + ultimateRecyclerView.reenableLoadmore(); + ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); + + ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() { + @Override + public void loadMore(int itemsCount, final int maxLastVisiblePosition) { + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + public void run() { + simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount()); + simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount()); + simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount()); + // linearLayoutManager.scrollToPositionWithOffset(maxLastVisiblePosition,-1); + // linearLayoutManager.scrollToPosition(maxLastVisiblePosition); + + } + }, 1000); + } + }); + +// ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(getResources().getColor(android.R.color.holo_blue_bright), +// getResources().getColor(android.R.color.holo_green_light), +// getResources().getColor(android.R.color.holo_orange_light), +// getResources().getColor(android.R.color.holo_red_light)); + +// ultimateRecyclerView.setScrollViewCallbacks(new ObservableScrollViewCallbacks() { +// @Override +// public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { +// +// } +// +// @Override +// public void onDownMotionEvent() { +// +// } +// +// @Override +// public void onUpOrCancelMotionEvent(ObservableScrollState observableScrollState) { +//// if (observableScrollState == ObservableScrollState.DOWN) { +//// ultimateRecyclerView.showToolbar(toolbar, ultimateRecyclerView, getScreenHeight()); +//// ultimateRecyclerView.showFloatingActionMenu(); +//// } else if (observableScrollState == ObservableScrollState.UP) { +//// ultimateRecyclerView.hideToolbar(toolbar, ultimateRecyclerView, getScreenHeight()); +//// ultimateRecyclerView.hideFloatingActionMenu(); +//// } else if (observableScrollState == ObservableScrollState.STOP) { +//// } +// URLogs.d("onUpOrCancelMotionEvent"); +// if (observableScrollState == ObservableScrollState.UP) { +// ultimateRecyclerView.hideToolbar(toolbar, ultimateRecyclerView, getScreenHeight()); +// ultimateRecyclerView.hideFloatingActionMenu(); +// } else if (observableScrollState == ObservableScrollState.DOWN) { +// ultimateRecyclerView.showToolbar(toolbar, ultimateRecyclerView, getScreenHeight()); +// ultimateRecyclerView.showFloatingActionMenu(); +// } +// } +// }); + + ultimateRecyclerView.showFloatingButtonView(); +// + Spinner spinner = (Spinner) findViewById(R.id.spinner); + ArrayAdapter spinnerAdapter = + new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); + for (Type type : Type.values()) { + spinnerAdapter.add(type.name()); + } + spinner.setAdapter(spinnerAdapter); + spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + ultimateRecyclerView.setItemAnimator(Type.values()[position].getAnimator()); + ultimateRecyclerView.getItemAnimator().setAddDuration(500); + ultimateRecyclerView.getItemAnimator().setRemoveDuration(500); + } + + @Override public void onNothingSelected(AdapterView parent) { + + } + }); + + + + findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + simpleRecyclerViewAdapter.insert("newly added item", 1); + } + }); + + findViewById(R.id.del).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + simpleRecyclerViewAdapter.remove(1); + } + }); + +// + } + + private void toggleSelection(int position) { + simpleRecyclerViewAdapter.toggleSelection(position); + actionMode.setTitle("Selected " + "1"); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + + + } + + public int getScreenHeight() { + return findViewById(android.R.id.content).getHeight(); + } + + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + URLogs.d("actionmode---" + (mode == null)); + mode.getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + // return false; + } + + /** + * Called to refresh an action mode's action menu whenever it is invalidated. + * + * @param mode ActionMode being prepared + * @param menu Menu used to populate action buttons + * @return true if the menu or action mode was updated, false otherwise. + */ + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + // swipeToDismissTouchListener.setEnabled(false); + this.actionMode = mode; + return false; + } + + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + return false; + } + + + @Override + public void onDestroyActionMode(ActionMode mode) { + this.actionMode = null; + } + + + // + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + FastBinding.startactivity(this, item.getItemId()); + return super.onOptionsItemSelected(item); + } + + enum Type { + FadeIn(new FadeInAnimator(new OvershootInterpolator(1f))), + FadeInDown(new FadeInDownAnimator(new OvershootInterpolator(1f))), + FadeInUp(new FadeInUpAnimator(new OvershootInterpolator(1f))), + FadeInLeft(new FadeInLeftAnimator(new OvershootInterpolator(1f))), + FadeInRight(new FadeInRightAnimator(new OvershootInterpolator(1f))), + Landing(new LandingAnimator(new OvershootInterpolator(1f))), + ScaleIn(new ScaleInAnimator(new OvershootInterpolator(1f))), + ScaleInTop(new ScaleInTopAnimator(new OvershootInterpolator(1f))), + ScaleInBottom(new ScaleInBottomAnimator(new OvershootInterpolator(1f))), + ScaleInLeft(new ScaleInLeftAnimator(new OvershootInterpolator(1f))), + ScaleInRight(new ScaleInRightAnimator(new OvershootInterpolator(1f))), + FlipInTopX(new FlipInTopXAnimator(new OvershootInterpolator(1f))), + FlipInBottomX(new FlipInBottomXAnimator(new OvershootInterpolator(1f))), + FlipInLeftY(new FlipInLeftYAnimator(new OvershootInterpolator(1f))), + FlipInRightY(new FlipInRightYAnimator(new OvershootInterpolator(1f))), + SlideInLeft(new SlideInLeftAnimator(new OvershootInterpolator(1f))), + SlideInRight(new SlideInRightAnimator(new OvershootInterpolator(1f))), + SlideInDown(new SlideInDownAnimator(new OvershootInterpolator(1f))), + SlideInUp(new SlideInUpAnimator(new OvershootInterpolator(1f))), + OvershootInRight(new OvershootInRightAnimator(1.0f)), + OvershootInLeft(new OvershootInLeftAnimator(1.0f)); + + private BaseItemAnimator mAnimator; + + Type(BaseItemAnimator animator) { + mAnimator = animator; + } + + public BaseItemAnimator getAnimator() { + return mAnimator; + } + } +} diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/MainList.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/MainList.java index 1aa62d5a..c0614925 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/MainList.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/MainList.java @@ -55,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) { } public void initList() { - + data.put("LauncherActivity", LauncherActivity.class); data.put("Debug Grid Test", GridLayoutRVTest.class); data.put("Issue #374, #363 enabled and disable load more off screen", GridTestOnlyOnePage.class); data.put("Debug load more", DebugLoadMoreActivity.class); @@ -70,7 +70,6 @@ public void initList() { data.put("Debug Stagger Load More", StaggerLoadMoreActivity.class); data.put("Debug Swipe List", SwipeListViewExampleActivity.class); data.put("Debug expandable", TestExpandableRV.class); - data.put("Debug dragging", DragActivity.class); data.put("Debug multi view types", MultiViewTypesActivity.class); } diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java new file mode 100644 index 00000000..a1f977c9 --- /dev/null +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java @@ -0,0 +1,231 @@ +package com.marshalchen.ultimaterecyclerview.demo; + +/** + * Created by Marshal Chen on 3/8/2016. + */ + +import android.graphics.Color; +import android.support.v4.view.MotionEventCompat; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.marshalchen.ultimaterecyclerview.URLogs; +import com.marshalchen.ultimaterecyclerview.UltimateRecyclerviewViewHolder; +import com.marshalchen.ultimaterecyclerview.UltimateViewAdapter; +import com.marshalchen.ultimaterecyclerview.demo.rvComponents.itemCommonBinder; +import com.marshalchen.ultimaterecyclerview.itemTouchHelper.ItemTouchHelperViewHolder; + +import java.security.SecureRandom; +import java.util.List; + + +public class SimpleAdapter extends UltimateViewAdapter { + private List stringList; + + public SimpleAdapter(List stringList) { + this.stringList = stringList; + } + + + @Override + public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { + if (position < getItemCount() && (customHeaderView != null ? position <= stringList.size() : position < stringList.size()) && (customHeaderView != null ? position > 0 : true)) { + + ((ViewHolder) holder).textViewSample.setText(stringList.get(customHeaderView != null ? position - 1 : position)); + // ((ViewHolder) holder).itemView.setActivated(selectedItems.get(position, false)); + if (mDragStartListener != null) { +// ((ViewHolder) holder).imageViewSample.setOnTouchListener(new View.OnTouchListener() { +// @Override +// public boolean onTouch(View v, MotionEvent event) { +// if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { +// mDragStartListener.onStartDrag(holder); +// } +// return false; +// } +// }); + + ((ViewHolder) holder).item_view.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + return false; + } + }); + } + } + + } + + @Override + public int getAdapterItemCount() { + return stringList.size(); + } + + @Override + public RecyclerView.ViewHolder newFooterHolder(View view) { + // return new itemCommonBinder(view, false); + return new UltimateRecyclerviewViewHolder<>(view); + } + + @Override + public RecyclerView.ViewHolder newHeaderHolder(View view) { + return new UltimateRecyclerviewViewHolder<>(view); + } + + @Override + public UltimateRecyclerviewViewHolder onCreateViewHolder(ViewGroup parent) { + View v = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.recycler_view_adapter, parent, false); + ViewHolder vh = new ViewHolder(v); + return vh; + } + + + public void insert(String string, int position) { + insertInternal(stringList, string, position); + } + + public void remove(int position) { + removeInternal(stringList, position); + } + + public void clear() { + clearInternal(stringList); + } + + + public void swapPositions(int from, int to) { + swapPositions(stringList, from, to); + } + + + @Override + public long generateHeaderId(int position) { + // URLogs.d("position--" + position + " " + getItem(position)); + if (getItem(position).length() > 0) + return getItem(position).charAt(0); + else return -1; + } + + @Override + public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup viewGroup) { + View view = LayoutInflater.from(viewGroup.getContext()) + .inflate(R.layout.stick_header_item, viewGroup, false); + return new RecyclerView.ViewHolder(view) { + }; + } + + @Override + public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int position) { + + TextView textView = (TextView) viewHolder.itemView.findViewById(R.id.stick_text); + textView.setText(String.valueOf(getItem(position).charAt(0))); +// viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93")); + viewHolder.itemView.setBackgroundColor(Color.parseColor("#AAffffff")); + ImageView imageView = (ImageView) viewHolder.itemView.findViewById(R.id.stick_img); + + SecureRandom imgGen = new SecureRandom(); + switch (imgGen.nextInt(3)) { + case 0: + imageView.setImageResource(R.drawable.jr1); + break; + case 1: + imageView.setImageResource(R.drawable.jr2); + break; + case 2: + imageView.setImageResource(R.drawable.jr3); + break; + } + + } + + @Override + public void onItemMove(int fromPosition, int toPosition) { + if (fromPosition > 0 && toPosition > 0) { + swapPositions(fromPosition, toPosition); +// notifyItemMoved(fromPosition, toPosition); + super.onItemMove(fromPosition, toPosition); + } + + } + + @Override + public void onItemDismiss(int position) { + if (position > 0) { + remove(position); + // notifyItemRemoved(position); +// notifyDataSetChanged(); + super.onItemDismiss(position); + } + + } +// +// private int getRandomColor() { +// SecureRandom rgen = new SecureRandom(); +// return Color.HSVToColor(150, new float[]{ +// rgen.nextInt(359), 1, 1 +// }); +// } + + public void setOnDragStartListener(OnStartDragListener dragStartListener) { + mDragStartListener = dragStartListener; + + } + + class ViewHolder extends UltimateRecyclerviewViewHolder { + + TextView textViewSample; + ImageView imageViewSample; + ProgressBar progressBarSample; + View item_view; + + public ViewHolder(View itemView) { + super(itemView); +// itemView.setOnTouchListener(new SwipeDismissTouchListener(itemView, null, new SwipeDismissTouchListener.DismissCallbacks() { +// @Override +// public boolean canDismiss(Object token) { +// Logs.d("can dismiss"); +// return true; +// } +// +// @Override +// public void onDismiss(View view, Object token) { +// // Logs.d("dismiss"); +// remove(getPosition()); +// +// } +// })); + textViewSample = (TextView) itemView.findViewById( + R.id.textview); + imageViewSample = (ImageView) itemView.findViewById(R.id.imageview); + progressBarSample = (ProgressBar) itemView.findViewById(R.id.progressbar); + progressBarSample.setVisibility(View.GONE); + item_view = itemView.findViewById(R.id.itemview); + } + + @Override + public void onItemSelected() { + itemView.setBackgroundColor(Color.LTGRAY); + } + + @Override + public void onItemClear() { + itemView.setBackgroundColor(0); + } + } + + public String getItem(int position) { + if (customHeaderView != null) + position--; + // URLogs.d("position----"+position); + if (position >= 0 && position < stringList.size()) + return stringList.get(position); + else return ""; + } + +} \ No newline at end of file diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/BasicFunctions.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/BasicFunctions.java index 68d3158d..a389a25e 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/BasicFunctions.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/BasicFunctions.java @@ -73,17 +73,17 @@ public void run() { protected abstract void onFireRefresh(); protected void enableRefresh() { - ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - onFireRefresh(); - } - }, 1000); - } - }); +// ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { +// @Override +// public void onRefresh() { +// new Handler().postDelayed(new Runnable() { +// @Override +// public void run() { +// onFireRefresh(); +// } +// }, 1000); +// } +// }); // ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(getResources().getColor(android.R.color.holo_blue_bright), // getResources().getColor(android.R.color.holo_green_light), // getResources().getColor(android.R.color.holo_orange_light), diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/PullToRefreshActivity.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/PullToRefreshActivity.java index 61a4e806..3f6fb997 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/PullToRefreshActivity.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/loadmoredemo/PullToRefreshActivity.java @@ -3,10 +3,13 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.support.v7.widget.Toolbar; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Spinner; import com.marshalchen.ultimaterecyclerview.CustomUltimateRecyclerview; import com.marshalchen.ultimaterecyclerview.URLogs; @@ -37,9 +40,9 @@ protected void onLoadmore() { @Override protected void onFireRefresh() { - simpleRecyclerViewAdapter.insertLast("Refresh things"); +// simpleRecyclerViewAdapter.insertLast("Refresh things"); // ultimateRecyclerView.scrollBy(0, -50); - linearLayoutManager.scrollToPosition(0); +// linearLayoutManager.scrollToPosition(0); ultimateRecyclerView.mPtrFrameLayout.refreshComplete(); changeHeaderHandler.sendEmptyMessageDelayed(0, 500); } @@ -54,10 +57,12 @@ protected void removeButtonTrigger() { } + @Override protected void onCreate(Bundle savedInstanceState) { - ultimateRecyclerView = (CustomUltimateRecyclerview) findViewById(R.id.custom_ultimate_recycler_view); super.onCreate(savedInstanceState); + setContentView(R.layout.custom_refresh_activity); + ultimateRecyclerView = (CustomUltimateRecyclerview) findViewById(R.id.custom_ultimate_recycler_view); ultimateRecyclerView.setCustomSwipeToRefresh(); // refreshingMaterial(); refreshingString(); @@ -151,9 +156,9 @@ public void onRefreshBegin(final PtrFrameLayout frame) { frame.postDelayed(new Runnable() { @Override public void run() { - simpleRecyclerViewAdapter.insertLast("Refresh things"); + // simpleRecyclerViewAdapter.insertLast("Refresh things"); // ultimateRecyclerView.scrollBy(0, -50); - linearLayoutManager.scrollToPosition(0); + // linearLayoutManager.scrollToPosition(0); ultimateRecyclerView.mPtrFrameLayout.refreshComplete(); // changeHeaderHandler.sendEmptyMessageDelayed(2, 500); } @@ -252,7 +257,7 @@ public void onRefreshBegin(final PtrFrameLayout frame) { @Override public void run() { // frame.refreshComplete(); - simpleRecyclerViewAdapter.insertLast("Refresh things"); +// simpleRecyclerViewAdapter.insertLast("Refresh things"); // ultimateRecyclerView.scrollBy(0, -50); linearLayoutManager.scrollToPosition(0); ultimateRecyclerView.mPtrFrameLayout.refreshComplete(); diff --git a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/MainWatcher.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/MainWatcher.java index 94602ccb..b36b2338 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/MainWatcher.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/modules/MainWatcher.java @@ -3,7 +3,6 @@ import android.app.Application; import android.content.pm.ApplicationInfo; -import me.drakeet.library.CrashWoodpecker; /** * Created by hesk on 2/10/15. diff --git a/UltimateRecyclerView/app/src/main/res/layout/activity_launcher.xml b/UltimateRecyclerView/app/src/main/res/layout/activity_launcher.xml new file mode 100644 index 00000000..abf73eff --- /dev/null +++ b/UltimateRecyclerView/app/src/main/res/layout/activity_launcher.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UltimateRecyclerView/app/src/main/res/layout/header_love.xml b/UltimateRecyclerView/app/src/main/res/layout/header_love.xml index f12ba47a..363ee897 100644 --- a/UltimateRecyclerView/app/src/main/res/layout/header_love.xml +++ b/UltimateRecyclerView/app/src/main/res/layout/header_love.xml @@ -7,6 +7,6 @@ + android:src="@drawable/jr1" + /> \ No newline at end of file diff --git a/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml b/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml new file mode 100644 index 00000000..04573a09 --- /dev/null +++ b/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml @@ -0,0 +1,30 @@ + + + + + + + + + \ No newline at end of file diff --git a/UltimateRecyclerView/build.gradle b/UltimateRecyclerView/build.gradle index 33e3b3bb..783cdbd8 100644 --- a/UltimateRecyclerView/build.gradle +++ b/UltimateRecyclerView/build.gradle @@ -5,10 +5,7 @@ buildscript { jcenter() } dependencies { - // - @ https://oss.sonatype.org/ - classpath 'com.android.tools.build:gradle:2.1.0' - // - tutorials @https://github.com/novoda/bintray-release - classpath 'com.novoda:bintray-release:0.3.4' + classpath 'com.android.tools.build:gradle:2.1.2' } } @@ -27,34 +24,13 @@ ext { //Library configurations PUBLISH_GROUP_ID = 'com.marshalchen.ultimaterecyclerview' PUBLISH_ARTIFACT_ID = 'library' - - ARTIFACT_ID = 'urvlib' + PUBLISH_VERSION = '0.7.0' VERSION_CODE = 23 //your version //Application - app_demo_versionCode = 23 - app_demo_versionName = '1.4.0' - //Support and Build tools version - ftKit = '0.4.1' - - //Support Libraries dependencies - supportDependencies = [ - percent : "com.android.support:percent:${SUPPORT_LIBRARY}", - annotation : "com.android.support:support-annotations:${SUPPORT_LIBRARY}", - support : "com.android.support:support-v13:${SUPPORT_LIBRARY}", - appCompat : "com.android.support:appcompat-v7:${SUPPORT_LIBRARY}", - rv : "com.android.support:recyclerview-v7:${SUPPORT_LIBRARY}", - cv : "com.android.support:cardview-v7:${SUPPORT_LIBRARY}", - kitCore : "com.52inc:52Kit-core:${ftKit}", - - - - leakcanary : "com.squareup.leakcanary:leakcanary-android:${LEAKCANARY}", - leakcanarynoop: "com.squareup.leakcanary:leakcanary-android-no-op:${LEAKCANARY}", - - - ] + app_demo_versionCode = 24 + app_demo_versionName = '1.7.0' IS_UPLOADING = project.getGradle().startParameter.taskNames.any { it.contains('bintrayUpload') } } diff --git a/UltimateRecyclerView/gradle.properties b/UltimateRecyclerView/gradle.properties index 55e65dd7..9921d01d 100644 --- a/UltimateRecyclerView/gradle.properties +++ b/UltimateRecyclerView/gradle.properties @@ -1,9 +1,34 @@ -SUPPORT_LIBRARY=23.4.0 -ANDROID_BUILD_MIN_SDK_VERSION=13 -ANDROID_BUILD_TARGET_SDK_VERSION=23 -ANDROID_BUILD_SDK_VERSION=23 -ANDROID_BUILD_TOOLS_VERSION=23.0.3 +SUPPORT_LIBRARY=24.1.1 +ANDROID_BUILD_MIN_SDK_VERSION=14 +ANDROID_BUILD_TARGET_SDK_VERSION=24 +ANDROID_BUILD_SDK_VERSION=24 +ANDROID_BUILD_TOOLS_VERSION=24.0.1 #version check on @link https://github.com/square/leakcanary LEAKCANARY=1.4-beta2 + + + +POM_NAME=ultimaterecyclerview +POM_ARTIFACT_ID=library +POM_PACKAGING=aar +VERSION_NAME=0.7.0 +VERSION_CODE=30 +GROUP=com.marshalchen.ultimaterecyclerview + +POM_DESCRIPTION=A RecyclerView(advanced and flexible version of ListView) with refreshing,loading more,animation and many other features. +POM_URL=https://github.com/cymcsg/UltimateRecyclerView +POM_SCM_URL=https://github.com/cymcsg/UltimateRecyclerView +POM_SCM_CONNECTION=https://github.com/cymcsg/UltimateRecyclerView.git +POM_SCM_DEV_CONNECTION=https://github.com/cymcsg/UltimateRecyclerView.git +POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo +POM_DEVELOPER_ID=cymcsg +POM_DEVELOPER_NAME=marshalchen + + + +SNAPSHOT_REPOSITORY_URL=https://oss.sonatype.org/content/repositories/snapshots +RELEASE_REPOSITORY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2 diff --git a/UltimateRecyclerView/gradle/wrapper/gradle-wrapper.properties b/UltimateRecyclerView/gradle/wrapper/gradle-wrapper.properties index 5ede2e19..c12bdcea 100644 --- a/UltimateRecyclerView/gradle/wrapper/gradle-wrapper.properties +++ b/UltimateRecyclerView/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip diff --git a/UltimateRecyclerView/ultimaterecyclerview/build.gradle b/UltimateRecyclerView/ultimaterecyclerview/build.gradle index a822aaae..caedfb78 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/build.gradle +++ b/UltimateRecyclerView/ultimaterecyclerview/build.gradle @@ -24,19 +24,15 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile supportDependencies.appCompat - compile supportDependencies.annotation - compile supportDependencies.support - compile supportDependencies.rv - compile supportDependencies.cv - + compile "com.android.support:appcompat-v7:${SUPPORT_LIBRARY}" + compile "com.android.support:support-v13:${SUPPORT_LIBRARY}" + compile "com.android.support:recyclerview-v7:${SUPPORT_LIBRARY}" //compile 'com.nineoldandroids:library:2.4.0' compile 'in.srain.cube:ultra-ptr:1.0.11' compile 'com.github.bumptech.glide:glide:3.7.0' - compile 'jp.wasabeef:recyclerview-animators:2.2.1' + compile 'jp.wasabeef:recyclerview-animators:2.2.3' } //apply from: 'android-release-aar.gradle' //apply from: 'maven-push.gradle' //apply from: 'bintray-release-aar.gradle' -apply from: 'bintray_3_4.gradle' \ No newline at end of file diff --git a/UltimateRecyclerView/ultimaterecyclerview/gradle.properties b/UltimateRecyclerView/ultimaterecyclerview/gradle.properties index b84e8fff..a0d8f845 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/gradle.properties +++ b/UltimateRecyclerView/ultimaterecyclerview/gradle.properties @@ -1,7 +1,7 @@ POM_NAME=ultimaterecyclerview POM_ARTIFACT_ID=library POM_PACKAGING=aar -VERSION_NAME=0.5.8 +VERSION_NAME=0.7.0 VERSION_CODE=70 GROUP=com.marshalchen.ultimaterecyclerview POM_DESCRIPTION=A RecyclerView(advanced and flexible version of ListView) with refreshing,loading more,animation and many other features. @@ -12,7 +12,7 @@ POM_SCM_DEV_CONNECTION=https://github.com/cymcsg/UltimateRecyclerView.git POM_LICENCE_NAME=The Apache Software License, Version 2.0 POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo -POM_DEVELOPER_ID=cymcsg ; +POM_DEVELOPER_ID=cymcsg POM_DEVELOPER_NAME=marshalchen SNAPSHOT_REPOSITORY_URL=https://oss.sonatype.org/content/repositories/snapshots diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateRecyclerView.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateRecyclerView.java index 5307c822..a79cb58a 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateRecyclerView.java +++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateRecyclerView.java @@ -856,6 +856,7 @@ private void updateHelperDisplays() { * + getItemCount is zero */ if (!isFirstLoadingOnlineAdapter) { + isFirstLoadingOnlineAdapter = true; if (mAdapter.getAdapterItemCount() == 0) { mEmpty.setVisibility(mEmptyView == null ? View.VISIBLE : View.GONE); @@ -866,7 +867,7 @@ private void updateHelperDisplays() { mEmpty.setVisibility(View.GONE); } } else { - isFirstLoadingOnlineAdapter = false; + //isFirstLoadingOnlineAdapter = false; setRefreshing(false); implementLoadMorebehavior(); } @@ -983,12 +984,19 @@ public void setOnParallaxScroll(OnParallaxScroll parallaxScroll) { mParallaxScroll.onParallaxScroll(0, 0, mHeader); } - private void translateHeader(float of) { - float ofCalculated = of * SCROLL_MULTIPLIER; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - //Logs.d("ofCalculated " + ofCalculated+" "+mHeader.getHeight()); + + private float mScrollMultiplier = 0.5f; + + /** + * Translates the adapter in Y + * + * @param of offset in px + */ + public void translateHeader(float of) { + float ofCalculated = of * mScrollMultiplier; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && of < mHeader.getHeight()) { mHeader.setTranslationY(ofCalculated); - } else { + } else if (of < mHeader.getHeight()) { TranslateAnimation anim = new TranslateAnimation(0, 0, ofCalculated, ofCalculated); anim.setFillAfter(true); anim.setDuration(0); @@ -996,11 +1004,35 @@ private void translateHeader(float of) { } mHeader.setClipY(Math.round(ofCalculated)); if (mParallaxScroll != null) { - float left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * SCROLL_MULTIPLIER))); + final RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(0); + float left; + if (holder != null) { + left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * mScrollMultiplier))); + }else { + left = 1; + } mParallaxScroll.onParallaxScroll(left, of, mHeader); } } + /** + * Set parallax scroll multiplier. + * + * @param mul The multiplier + */ + public void setScrollMultiplier(float mul) { + this.mScrollMultiplier = mul; + } + + /** + * Get the current parallax scroll multiplier. + * + */ + public float getScrollMultiplier() { + return this.mScrollMultiplier; + } + + public interface OnParallaxScroll { void onParallaxScroll(float percentage, float offset, View parallax); } diff --git a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateViewAdapter.java b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateViewAdapter.java index a249256a..12e945fa 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateViewAdapter.java +++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateViewAdapter.java @@ -84,10 +84,10 @@ public final boolean enableLoadMore() { } - private class delayenableloadmore implements Runnable { + private class delayEnableLoadmore implements Runnable { private boolean enabled; - public delayenableloadmore(final boolean b) { + public delayEnableLoadmore(final boolean b) { enabled = b; } @@ -111,7 +111,7 @@ public void run() { } } - public delayenableloadmore cbloadmore; + public delayEnableLoadmore cbloadmore; /** * as the set function to switching load more feature @@ -119,7 +119,7 @@ public void run() { * @param b bool */ public final void enableLoadMore(final boolean b) { - cbloadmore = new delayenableloadmore(b); + cbloadmore = new delayEnableLoadmore(b); } public final void internalExecuteLoadingView() {