From e2f8f01364f88122d71f9a6c5d5bf0293340ae79 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Mon, 4 Jul 2016 13:06:59 +0800 Subject: [PATCH 01/19] upgrade com.android.tools.build:gradle to 2.1.2 --- UltimateRecyclerView/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltimateRecyclerView/build.gradle b/UltimateRecyclerView/build.gradle index 33e3b3bb..f6d455bc 100644 --- a/UltimateRecyclerView/build.gradle +++ b/UltimateRecyclerView/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { // - @ https://oss.sonatype.org/ - classpath 'com.android.tools.build:gradle:2.1.0' + classpath 'com.android.tools.build:gradle:2.1.2' // - tutorials @https://github.com/novoda/bintray-release classpath 'com.novoda:bintray-release:0.3.4' } From 54b0c2d43a7e555011eb3211ee89e3410a1795bc Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Mon, 4 Jul 2016 13:22:53 +0800 Subject: [PATCH 02/19] upgrade SUPPORT_LIBRARY version --- UltimateRecyclerView/gradle.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UltimateRecyclerView/gradle.properties b/UltimateRecyclerView/gradle.properties index 55e65dd7..d437ea72 100644 --- a/UltimateRecyclerView/gradle.properties +++ b/UltimateRecyclerView/gradle.properties @@ -1,8 +1,8 @@ -SUPPORT_LIBRARY=23.4.0 +SUPPORT_LIBRARY=24.0.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 +ANDROID_BUILD_TARGET_SDK_VERSION=24 +ANDROID_BUILD_SDK_VERSION=24 +ANDROID_BUILD_TOOLS_VERSION=24.0.0 #version check on @link https://github.com/square/leakcanary LEAKCANARY=1.4-beta2 From 21958edfc5a921bc847ee671e9a0489f1a28167a Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Mon, 4 Jul 2016 14:42:22 +0800 Subject: [PATCH 03/19] update travis file --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a480206..01fd8a74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,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 @@ -23,9 +23,9 @@ android: components: # We are using the latest revision of Android SDK Tools - - android-23 + - android-24 # The BuildTools version we are using for our project - - build-tools-23.0.1 + - build-tools-24.0.0 - platform-tools - tools From 794b54d8bd06d796f99727e2019bdd8f31536f26 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Tue, 2 Aug 2016 13:58:17 +0800 Subject: [PATCH 04/19] update support version --- UltimateRecyclerView/build.gradle | 6 ------ UltimateRecyclerView/gradle.properties | 6 +++--- .../gradle/wrapper/gradle-wrapper.properties | 2 +- UltimateRecyclerView/ultimaterecyclerview/build.gradle | 10 +++------- .../ultimaterecyclerview/gradle.properties | 4 ++-- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/UltimateRecyclerView/build.gradle b/UltimateRecyclerView/build.gradle index f6d455bc..f1591129 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.2' - // - tutorials @https://github.com/novoda/bintray-release - classpath 'com.novoda:bintray-release:0.3.4' } } @@ -47,9 +44,6 @@ ext { 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}", diff --git a/UltimateRecyclerView/gradle.properties b/UltimateRecyclerView/gradle.properties index d437ea72..91fc3c40 100644 --- a/UltimateRecyclerView/gradle.properties +++ b/UltimateRecyclerView/gradle.properties @@ -1,8 +1,8 @@ -SUPPORT_LIBRARY=24.0.0 -ANDROID_BUILD_MIN_SDK_VERSION=13 +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.0 +ANDROID_BUILD_TOOLS_VERSION=24.0.1 #version check on @link https://github.com/square/leakcanary LEAKCANARY=1.4-beta2 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..43ad57c8 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/build.gradle +++ b/UltimateRecyclerView/ultimaterecyclerview/build.gradle @@ -24,12 +24,9 @@ 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' @@ -39,4 +36,3 @@ dependencies { //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 From 410ff50803f7e24bdbeb570ac08ec321d74fb711 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Tue, 2 Aug 2016 14:29:35 +0800 Subject: [PATCH 05/19] update travis --- .travis.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 01fd8a74..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 @@ -22,13 +24,12 @@ before_install: android: components: # We are using the latest revision of Android SDK Tools - + - tools + - platform-tools - android-24 # The BuildTools version we are using for our project - - build-tools-24.0.0 - - - platform-tools - - tools + - build-tools-24.0.1 + # Additional components - extra-google-google_play_services - extra-google-m2repository From 3b3b48aec42cc525bebcc78a7faa9829f03191cf Mon Sep 17 00:00:00 2001 From: Rodrigo Bernardi Date: Tue, 2 Aug 2016 10:23:24 -0300 Subject: [PATCH 06/19] Set to run only the first time isFirstLoadingOnlineAdapter was never true --- .../marshalchen/ultimaterecyclerview/UltimateRecyclerView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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..5ab29416 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(); } From b22ae13a63326ab637bab0180198eb699781da12 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Wed, 3 Aug 2016 19:01:42 +0800 Subject: [PATCH 07/19] add launcherActivity --- .../app/src/main/AndroidManifest.xml | 2 +- .../demo/LauncherActivity.java | 374 ++++++++++++++++++ .../demo/SimpleAdapter.java | 221 +++++++++++ .../demo/modules/MainWatcher.java | 1 - .../src/main/res/layout/activity_launcher.xml | 56 +++ .../main/res/layout/recycler_view_adapter.xml | 30 ++ 6 files changed, 682 insertions(+), 2 deletions(-) create mode 100644 UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java create mode 100644 UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java create mode 100644 UltimateRecyclerView/app/src/main/res/layout/activity_launcher.xml create mode 100644 UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml 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..3f3e9b76 --- /dev/null +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java @@ -0,0 +1,374 @@ +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.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); + ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); + + 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.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.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(); +// ultimateRecyclerView.addOnItemTouchListener(new SwipeableRecyclerViewTouchListener(ultimateRecyclerView.mRecyclerView, +// new SwipeableRecyclerViewTouchListener.SwipeListener() { +// @Override +// public boolean canSwipe(int position) { +// +// if (position > 0 && position < stringList.size()) +// return true; +// else return false; +// } +// +// @Override +// public void onDismissedBySwipeLeft(RecyclerView recyclerView, int[] reverseSortedPositions) { +// for (int position : reverseSortedPositions) { +// simpleRecyclerViewAdapter.remove(position); +// } +// simpleRecyclerViewAdapter.notifyDataSetChanged(); +// } +// +// @Override +// public void onDismissedBySwipeRight(RecyclerView recyclerView, int[] reverseSortedPositions) { +// for (int position : reverseSortedPositions) { +// simpleRecyclerViewAdapter.remove(position); +// } +// simpleRecyclerViewAdapter.notifyDataSetChanged(); +// } +// })); + + + 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(300); + ultimateRecyclerView.getItemAnimator().setRemoveDuration(300); + } + + @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); + } + }); + +// ultimateRecyclerView.addItemDecoration( +// new HorizontalDividerItemDecoration.Builder(this).build()); + +// ultimateRecyclerView.setCustomSwipeToRefresh(); +// final StoreHouseHeader header = new StoreHouseHeader(this); +// // header.setPadding(0, 15, 0, 0); +// +// header.initWithString("Marshal Chen"); +// // header.initWithStringArray(R.array.akta); +// ultimateRecyclerView.mPtrFrameLayout.setHeaderView(header); +// ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(header); +// +// ultimateRecyclerView.mPtrFrameLayout.setPtrHandler(new PtrHandler() { +// @Override +// public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view2) { +// boolean canbePullDown = PtrDefaultHandler.checkContentCanBePulledDown(ptrFrameLayout, view, view2); +// return canbePullDown; +// } +// +// @Override +// public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) { +// ptrFrameLayout.postDelayed(new Runnable() { +// @Override +// public void run() { +// simpleRecyclerViewAdapter.insert("Refresh things", 0); +// // ultimateRecyclerView.scrollBy(0, -50); +// linearLayoutManager.scrollToPosition(0); +// ultimateRecyclerView.mPtrFrameLayout.refreshComplete(); +// } +// }, 1800); +// } +// }); + + } + + 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()), + FadeInDown(new FadeInDownAnimator()), + FadeInUp(new FadeInUpAnimator()), + FadeInLeft(new FadeInLeftAnimator()), + FadeInRight(new FadeInRightAnimator()), + Landing(new LandingAnimator()), + ScaleIn(new ScaleInAnimator()), + ScaleInTop(new ScaleInTopAnimator()), + ScaleInBottom(new ScaleInBottomAnimator()), + ScaleInLeft(new ScaleInLeftAnimator()), + ScaleInRight(new ScaleInRightAnimator()), + FlipInTopX(new FlipInTopXAnimator()), + FlipInBottomX(new FlipInBottomXAnimator()), + FlipInLeftY(new FlipInLeftYAnimator()), + FlipInRightY(new FlipInRightYAnimator()), + SlideInLeft(new SlideInLeftAnimator()), + SlideInRight(new SlideInRightAnimator()), + SlideInDown(new SlideInDownAnimator()), + SlideInUp(new SlideInUpAnimator()), + OvershootInRight(new OvershootInRightAnimator()), + OvershootInLeft(new OvershootInLeftAnimator()); + + 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/SimpleAdapter.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java new file mode 100644 index 00000000..9831db7a --- /dev/null +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java @@ -0,0 +1,221 @@ +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.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 null; + } + + @Override + public RecyclerView.ViewHolder newHeaderHolder(View view) { + return null; + } + + @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) { + swapPositions(fromPosition, toPosition); +// notifyItemMoved(fromPosition, toPosition); + super.onItemMove(fromPosition, toPosition); + } + + @Override + public void onItemDismiss(int position) { + 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--; + if (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/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/recycler_view_adapter.xml b/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml new file mode 100644 index 00000000..23b32420 --- /dev/null +++ b/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml @@ -0,0 +1,30 @@ + + + + + + + + + \ No newline at end of file From 0ffbd9374bae7e520a3f04537d56656fd10b407e Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Wed, 3 Aug 2016 19:01:58 +0800 Subject: [PATCH 08/19] remove me.drakeet.library:crashwoodpecker --- UltimateRecyclerView/app/build.gradle | 17 +++++------------ .../ultimaterecyclerview/demo/MainList.java | 2 +- UltimateRecyclerView/build.gradle | 17 ----------------- 3 files changed, 6 insertions(+), 30 deletions(-) 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/java/com/marshalchen/ultimaterecyclerview/demo/MainList.java b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/MainList.java index 1aa62d5a..b742a90a 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); diff --git a/UltimateRecyclerView/build.gradle b/UltimateRecyclerView/build.gradle index f1591129..f005a39b 100644 --- a/UltimateRecyclerView/build.gradle +++ b/UltimateRecyclerView/build.gradle @@ -32,23 +32,6 @@ ext { //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}", - - - ] IS_UPLOADING = project.getGradle().startParameter.taskNames.any { it.contains('bintrayUpload') } } From 19fec71e9591b23c1dbc6b78325672240831e993 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Wed, 3 Aug 2016 19:22:22 +0800 Subject: [PATCH 09/19] fix the height of SimpleAdapter --- .../app/src/main/res/layout/recycler_view_adapter.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml b/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml index 23b32420..04573a09 100644 --- a/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml +++ b/UltimateRecyclerView/app/src/main/res/layout/recycler_view_adapter.xml @@ -1,7 +1,7 @@ + android:layout_height="wrap_content" android:id="@+id/itemview"> Date: Wed, 3 Aug 2016 19:48:58 +0800 Subject: [PATCH 10/19] fix PTR activity --- .../demo/loadmoredemo/PullToRefreshActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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..66289b9a 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; @@ -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(); From b46d6e4ef664ec754cef96bdae4df6d802e46378 Mon Sep 17 00:00:00 2001 From: marshalchen Date: Thu, 4 Aug 2016 23:45:25 +0800 Subject: [PATCH 11/19] upgrade SimpleAdapter --- .../ultimaterecyclerview/demo/SimpleAdapter.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 index 9831db7a..41aef50e 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java @@ -3,6 +3,7 @@ /** * Created by Marshal Chen on 3/8/2016. */ + import android.graphics.Color; import android.support.v4.view.MotionEventCompat; import android.support.v7.widget.RecyclerView; @@ -17,6 +18,7 @@ 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; @@ -66,7 +68,8 @@ public int getAdapterItemCount() { @Override public RecyclerView.ViewHolder newFooterHolder(View view) { - return null; + // return new itemCommonBinder(view, false); + return new UltimateRecyclerviewViewHolder<>(view); } @Override @@ -168,7 +171,7 @@ public void setOnDragStartListener(OnStartDragListener dragStartListener) { } - class ViewHolder extends UltimateRecyclerviewViewHolder { + class ViewHolder extends UltimateRecyclerviewViewHolder { TextView textViewSample; ImageView imageViewSample; From 57610c0b970b8d872448365869a46ccece41eb00 Mon Sep 17 00:00:00 2001 From: marshalchen Date: Thu, 4 Aug 2016 23:50:33 +0800 Subject: [PATCH 12/19] upgrade Recyclerview Animation --- .../demo/LauncherActivity.java | 98 ++++++++++--------- .../ultimaterecyclerview/build.gradle | 2 +- 2 files changed, 52 insertions(+), 48 deletions(-) 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 index 3f3e9b76..aa872ac7 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java @@ -73,26 +73,27 @@ protected void onCreate(Bundle savedInstanceState) { linearLayoutManager = new LinearLayoutManager(this); ultimateRecyclerView.setLayoutManager(linearLayoutManager); - ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); 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.enableLoadmore(); + //simpleRecyclerViewAdapter.setCustomLoadMoreView(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.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 @@ -120,6 +121,8 @@ public void onStartDrag(RecyclerView.ViewHolder viewHolder) { mItemTouchHelper.startDrag(viewHolder); } }); + ultimateRecyclerView.reenableLoadmore(); + ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter); ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() { @Override @@ -143,37 +146,37 @@ public void run() { // 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.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.STOP) { +// } else if (observableScrollState == ObservableScrollState.DOWN) { +// ultimateRecyclerView.showToolbar(toolbar, ultimateRecyclerView, getScreenHeight()); +// ultimateRecyclerView.showFloatingActionMenu(); // } - 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(); // ultimateRecyclerView.addOnItemTouchListener(new SwipeableRecyclerViewTouchListener(ultimateRecyclerView.mRecyclerView, @@ -203,7 +206,6 @@ public void onUpOrCancelMotionEvent(ObservableScrollState observableScrollState) // } // })); - Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); @@ -215,15 +217,17 @@ public void onUpOrCancelMotionEvent(ObservableScrollState observableScrollState) @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { ultimateRecyclerView.setItemAnimator(Type.values()[position].getAnimator()); - ultimateRecyclerView.getItemAnimator().setAddDuration(300); - ultimateRecyclerView.getItemAnimator().setRemoveDuration(300); + ultimateRecyclerView.getItemAnimator().setAddDuration(500); + ultimateRecyclerView.getItemAnimator().setRemoveDuration(500); } - @Override - public void onNothingSelected(AdapterView parent) { + @Override public void onNothingSelected(AdapterView parent) { } }); + + + findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/UltimateRecyclerView/ultimaterecyclerview/build.gradle b/UltimateRecyclerView/ultimaterecyclerview/build.gradle index 43ad57c8..caedfb78 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/build.gradle +++ b/UltimateRecyclerView/ultimaterecyclerview/build.gradle @@ -30,7 +30,7 @@ dependencies { //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' From 7ec0ff2f70a92657d11c200b1dda12a3a386f921 Mon Sep 17 00:00:00 2001 From: marshalchen Date: Fri, 5 Aug 2016 00:25:23 +0800 Subject: [PATCH 13/19] upgrade parallax header --- .../UltimateRecyclerView.java | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) 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 5ab29416..a79cb58a 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateRecyclerView.java +++ b/UltimateRecyclerView/ultimaterecyclerview/src/main/java/com/marshalchen/ultimaterecyclerview/UltimateRecyclerView.java @@ -984,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); @@ -997,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); } From 5fca65408f230aaed775a4463781a5d905dae6fd Mon Sep 17 00:00:00 2001 From: marshalchen Date: Fri, 5 Aug 2016 00:25:42 +0800 Subject: [PATCH 14/19] fix bugs in SImpleAdapter for Parallax Header --- .../demo/LauncherActivity.java | 121 +++++------------- .../demo/SimpleAdapter.java | 5 +- 2 files changed, 35 insertions(+), 91 deletions(-) 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 index aa872ac7..568eb4e8 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/LauncherActivity.java @@ -15,6 +15,7 @@ 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; @@ -76,7 +77,7 @@ protected void onCreate(Bundle savedInstanceState) { StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(simpleRecyclerViewAdapter); ultimateRecyclerView.addItemDecoration(headersDecor); -// ultimateRecyclerView.setEmptyView(getResources().getIdentifier("empty_view","layout",getPackageName())); +//// ultimateRecyclerView.setEmptyView(getResources().getIdentifier("empty_view","layout",getPackageName())); // ultimateRecyclerView.showEmptyView(); // ultimateRecyclerView.enableLoadmore(); //simpleRecyclerViewAdapter.setCustomLoadMoreView(LayoutInflater.from(this) @@ -84,16 +85,16 @@ protected void onCreate(Bundle savedInstanceState) { 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.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.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 @@ -179,33 +180,7 @@ public void run() { // }); ultimateRecyclerView.showFloatingButtonView(); -// ultimateRecyclerView.addOnItemTouchListener(new SwipeableRecyclerViewTouchListener(ultimateRecyclerView.mRecyclerView, -// new SwipeableRecyclerViewTouchListener.SwipeListener() { -// @Override -// public boolean canSwipe(int position) { -// -// if (position > 0 && position < stringList.size()) -// return true; -// else return false; -// } // -// @Override -// public void onDismissedBySwipeLeft(RecyclerView recyclerView, int[] reverseSortedPositions) { -// for (int position : reverseSortedPositions) { -// simpleRecyclerViewAdapter.remove(position); -// } -// simpleRecyclerViewAdapter.notifyDataSetChanged(); -// } -// -// @Override -// public void onDismissedBySwipeRight(RecyclerView recyclerView, int[] reverseSortedPositions) { -// for (int position : reverseSortedPositions) { -// simpleRecyclerViewAdapter.remove(position); -// } -// simpleRecyclerViewAdapter.notifyDataSetChanged(); -// } -// })); - Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); @@ -242,39 +217,7 @@ public void onClick(View v) { } }); -// ultimateRecyclerView.addItemDecoration( -// new HorizontalDividerItemDecoration.Builder(this).build()); - -// ultimateRecyclerView.setCustomSwipeToRefresh(); -// final StoreHouseHeader header = new StoreHouseHeader(this); -// // header.setPadding(0, 15, 0, 0); -// -// header.initWithString("Marshal Chen"); -// // header.initWithStringArray(R.array.akta); -// ultimateRecyclerView.mPtrFrameLayout.setHeaderView(header); -// ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(header); -// -// ultimateRecyclerView.mPtrFrameLayout.setPtrHandler(new PtrHandler() { -// @Override -// public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view2) { -// boolean canbePullDown = PtrDefaultHandler.checkContentCanBePulledDown(ptrFrameLayout, view, view2); -// return canbePullDown; -// } // -// @Override -// public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) { -// ptrFrameLayout.postDelayed(new Runnable() { -// @Override -// public void run() { -// simpleRecyclerViewAdapter.insert("Refresh things", 0); -// // ultimateRecyclerView.scrollBy(0, -50); -// linearLayoutManager.scrollToPosition(0); -// ultimateRecyclerView.mPtrFrameLayout.refreshComplete(); -// } -// }, 1800); -// } -// }); - } private void toggleSelection(int position) { @@ -343,27 +286,27 @@ public boolean onOptionsItemSelected(MenuItem item) { } enum Type { - FadeIn(new FadeInAnimator()), - FadeInDown(new FadeInDownAnimator()), - FadeInUp(new FadeInUpAnimator()), - FadeInLeft(new FadeInLeftAnimator()), - FadeInRight(new FadeInRightAnimator()), - Landing(new LandingAnimator()), - ScaleIn(new ScaleInAnimator()), - ScaleInTop(new ScaleInTopAnimator()), - ScaleInBottom(new ScaleInBottomAnimator()), - ScaleInLeft(new ScaleInLeftAnimator()), - ScaleInRight(new ScaleInRightAnimator()), - FlipInTopX(new FlipInTopXAnimator()), - FlipInBottomX(new FlipInBottomXAnimator()), - FlipInLeftY(new FlipInLeftYAnimator()), - FlipInRightY(new FlipInRightYAnimator()), - SlideInLeft(new SlideInLeftAnimator()), - SlideInRight(new SlideInRightAnimator()), - SlideInDown(new SlideInDownAnimator()), - SlideInUp(new SlideInUpAnimator()), - OvershootInRight(new OvershootInRightAnimator()), - OvershootInLeft(new OvershootInLeftAnimator()); + 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; 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 index 41aef50e..3c4d0d56 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java @@ -74,7 +74,7 @@ public RecyclerView.ViewHolder newFooterHolder(View view) { @Override public RecyclerView.ViewHolder newHeaderHolder(View view) { - return null; + return new UltimateRecyclerviewViewHolder<>(view); } @Override @@ -216,7 +216,8 @@ public void onItemClear() { public String getItem(int position) { if (customHeaderView != null) position--; - if (position < stringList.size()) + URLogs.d("position----"+position); + if (position>=0&& position < stringList.size()) return stringList.get(position); else return ""; } From f09ec8cb57d3536ba81210f820ac92af4fa89906 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Fri, 5 Aug 2016 11:32:31 +0800 Subject: [PATCH 15/19] temp change onItemMove in SimpleAdapter --- .../demo/SimpleAdapter.java | 26 ++++++++++++------- .../UltimateViewAdapter.java | 8 +++--- 2 files changed, 20 insertions(+), 14 deletions(-) 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 index 3c4d0d56..a1f977c9 100644 --- a/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java +++ b/UltimateRecyclerView/app/src/main/java/com/marshalchen/ultimaterecyclerview/demo/SimpleAdapter.java @@ -68,13 +68,13 @@ public int getAdapterItemCount() { @Override public RecyclerView.ViewHolder newFooterHolder(View view) { - // return new itemCommonBinder(view, false); - return new UltimateRecyclerviewViewHolder<>(view); + // return new itemCommonBinder(view, false); + return new UltimateRecyclerviewViewHolder<>(view); } @Override public RecyclerView.ViewHolder newHeaderHolder(View view) { - return new UltimateRecyclerviewViewHolder<>(view); + return new UltimateRecyclerviewViewHolder<>(view); } @Override @@ -146,17 +146,23 @@ public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int posit @Override public void onItemMove(int fromPosition, int toPosition) { - swapPositions(fromPosition, toPosition); + if (fromPosition > 0 && toPosition > 0) { + swapPositions(fromPosition, toPosition); // notifyItemMoved(fromPosition, toPosition); - super.onItemMove(fromPosition, toPosition); + super.onItemMove(fromPosition, toPosition); + } + } @Override public void onItemDismiss(int position) { - remove(position); - // notifyItemRemoved(position); + if (position > 0) { + remove(position); + // notifyItemRemoved(position); // notifyDataSetChanged(); - super.onItemDismiss(position); + super.onItemDismiss(position); + } + } // // private int getRandomColor() { @@ -216,8 +222,8 @@ public void onItemClear() { public String getItem(int position) { if (customHeaderView != null) position--; - URLogs.d("position----"+position); - if (position>=0&& position < stringList.size()) + // URLogs.d("position----"+position); + if (position >= 0 && position < stringList.size()) return stringList.get(position); else return ""; } 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() { From 022048b357abb83c7894f1a927dab1d57138ed15 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Fri, 5 Aug 2016 11:45:27 +0800 Subject: [PATCH 16/19] temp disable some bugs in demo --- .../ultimaterecyclerview/demo/MainList.java | 1 - .../demo/loadmoredemo/BasicFunctions.java | 22 +++++++++---------- .../loadmoredemo/PullToRefreshActivity.java | 10 ++++----- .../app/src/main/res/layout/header_love.xml | 4 ++-- 4 files changed, 18 insertions(+), 19 deletions(-) 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 b742a90a..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 @@ -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/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 66289b9a..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 @@ -40,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); } @@ -156,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); } @@ -257,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/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 From cb2422449b3d4b666f5ecc454de63633c1bfeea7 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Fri, 5 Aug 2016 14:29:00 +0800 Subject: [PATCH 17/19] update jcenter version for release 0.7.0 --- UltimateRecyclerView/build.gradle | 3 +-- UltimateRecyclerView/gradle.properties | 25 +++++++++++++++++++ .../ultimaterecyclerview/build.gradle | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/UltimateRecyclerView/build.gradle b/UltimateRecyclerView/build.gradle index f005a39b..2c8e9753 100644 --- a/UltimateRecyclerView/build.gradle +++ b/UltimateRecyclerView/build.gradle @@ -24,8 +24,7 @@ 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 diff --git a/UltimateRecyclerView/gradle.properties b/UltimateRecyclerView/gradle.properties index 91fc3c40..9921d01d 100644 --- a/UltimateRecyclerView/gradle.properties +++ b/UltimateRecyclerView/gradle.properties @@ -7,3 +7,28 @@ 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/ultimaterecyclerview/build.gradle b/UltimateRecyclerView/ultimaterecyclerview/build.gradle index caedfb78..90517adc 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/build.gradle +++ b/UltimateRecyclerView/ultimaterecyclerview/build.gradle @@ -33,6 +33,6 @@ dependencies { compile 'jp.wasabeef:recyclerview-animators:2.2.3' } -//apply from: 'android-release-aar.gradle' +apply from: 'android-release-aar.gradle' //apply from: 'maven-push.gradle' //apply from: 'bintray-release-aar.gradle' From 06a20778c10144e6af269cfb438b53311b046c30 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Fri, 5 Aug 2016 15:38:06 +0800 Subject: [PATCH 18/19] upgrade version code for demo --- UltimateRecyclerView/build.gradle | 4 ++-- UltimateRecyclerView/ultimaterecyclerview/build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/UltimateRecyclerView/build.gradle b/UltimateRecyclerView/build.gradle index 2c8e9753..783cdbd8 100644 --- a/UltimateRecyclerView/build.gradle +++ b/UltimateRecyclerView/build.gradle @@ -29,8 +29,8 @@ ext { //your version //Application - app_demo_versionCode = 23 - app_demo_versionName = '1.4.0' + app_demo_versionCode = 24 + app_demo_versionName = '1.7.0' IS_UPLOADING = project.getGradle().startParameter.taskNames.any { it.contains('bintrayUpload') } } diff --git a/UltimateRecyclerView/ultimaterecyclerview/build.gradle b/UltimateRecyclerView/ultimaterecyclerview/build.gradle index 90517adc..caedfb78 100644 --- a/UltimateRecyclerView/ultimaterecyclerview/build.gradle +++ b/UltimateRecyclerView/ultimaterecyclerview/build.gradle @@ -33,6 +33,6 @@ dependencies { compile 'jp.wasabeef:recyclerview-animators:2.2.3' } -apply from: 'android-release-aar.gradle' +//apply from: 'android-release-aar.gradle' //apply from: 'maven-push.gradle' //apply from: 'bintray-release-aar.gradle' From 9b5144b6b8836784178a063230aa313969626d74 Mon Sep 17 00:00:00 2001 From: MarshalChen Date: Fri, 5 Aug 2016 15:38:22 +0800 Subject: [PATCH 19/19] update Readme for 0.7.0 --- README.md | 109 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 61 insertions(+), 48 deletions(-) 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.