Skip to content

Commit

Permalink
Merge branch 'release/0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
h6ah4i committed Feb 2, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents b1338d0 + 0b74970 commit cea246e
Showing 81 changed files with 5,250 additions and 272 deletions.
51 changes: 34 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Advanced RecyclerView
===============

This RecyclerView extension library provides Google's Inbox app like swiping and Play Music app like drag and drop sorting features. Works on API level 9 or later.
This RecyclerView extension library provides Google's Inbox app like swiping, Play Music app like drag-andr-drop sorting and expandable item features. Works on API level 9 or later.

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Advanced%20RecyclerView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1432)

@@ -34,7 +34,7 @@ Target platforms
Latest version
---

- Version 0.5.0 (January 25, 2015)
- Version 0.6.0 (February 2, 2015)

Getting started
---
@@ -43,15 +43,18 @@ This library is published on jCenter. Just add these lines to `build.gradle`.

```groovy
dependencies {
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.5.0'
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.6.0'
}
```

Usage
---

Please check the [`RecyclerListViewFragment`](example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo/fragment/RecyclerListViewFragment.java) and the
[`MyItemAdapter`](example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo/MyItemAdapter.java) classes in the example code.
Please check the implementation of the simple examples.

- [Drag & Drop example](example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_d/)
- [Swipe example](example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_s/)
- [Expandable item example](example/src/main/java/com/h6ah4i/android/example/advrecyclerview/demo_e/)


Primary classes/interfaces
@@ -61,36 +64,50 @@ Primary classes/interfaces

| Class/Interface name | Description |
|---------------------------------------|----------------------------------------------------------|
| `RecyclerViewDragDropManager` | Provides Drag & Drop sort operation |
| `DraggableItemAdapter<T>` | Implement this interface on your RecyclerView.Adapter |
| `DraggableItemViewHolder` | Implement this interface on your RecyclerView.ViewHolder |
| [`RecyclerViewDragDropManager`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/RecyclerViewDragDropManager.java) | Provides Drag & Drop sort operation |
| [`DraggableItemAdapter<T>`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemAdapter.java) | Implement this interface on your RecyclerView.Adapter |
| [`DraggableItemViewHolder`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/DraggableItemViewHolder.java) | Implement this interface on your RecyclerView.ViewHolder |


### Swiping related classes/interfaces

| Class/Interface name | Description |
|---------------------------------------|----------------------------------------------------------|
| `RecyclerViewSwipeManager` | Provides Swipe operation   |
| `SwipeableItemAdapter<T>` | Implement this interface on your RecyclerView.Adapter |
| `SwipeableItemViewHolder` | Implement this interface on your RecyclerView.ViewHolder |
| [`RecyclerViewSwipeManager`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/RecyclerViewSwipeManager.java) | Provides Swipe operation   |
| [`SwipeableItemAdapter<T>`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemAdapter.java) | Implement this interface on your RecyclerView.Adapter |
| [`SwipeableItemViewHolder`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/swipeable/SwipeableItemViewHolder.java) | Implement this interface on your RecyclerView.ViewHolder |


### Expandable item related classes/interfaces

| Class/Interface name | Description |
|---------------------------------------|----------------------------------------------------------|
| [`RecyclerViewExpandableItemManager`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/RecyclerViewExpandableItemManager.java) | Provides Expandable item function   |
| [`ExpandableItemViewHolder`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableItemViewHolder.java) | Implement this interface on your RecyclerView.ViewHolder |
| [`ExpandableItemAdapter<GVH, CVH>`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableItemAdapter.java) | Implement this interface on your RecyclerView.Adapter |
| [`ExpandableDraggableItemAdapter<GVH, CVH>`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableDraggableItemAdapter.java) | (optional) Implement this interface on your RecyclerView.Adapter to support Drag & Drop sort operation |
| [`ExpandableSwipeableItemAdapter<GVH, CVH>`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/expandable/ExpandableSwipeableItemAdapter.java) | (optional) Implement this interface on your RecyclerView.Adapter to support Swipe operation |



### RecyclerView decorations

| Class/Interface name | Description |
|---------------------------------------|----------------------------------------------------------|
| `ItemShadowDecorator` | Drop shadow decoration for pre-Lollipop devices |
| `SimpleListDividerDecorator` | Simple list divider decoration |
| [`ItemShadowDecorator`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/ItemShadowDecorator.java) | Drop shadow decoration for pre-Lollipop devices |
| [`SimpleListDividerDecorator`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/decoration/SimpleListDividerDecorator.java) | Simple list divider decoration |


### Misc.

| Class name | Description |
|--------------------------------------------|----------------------------------------------------------|
| `RecyclerViewTouchActionGuardManager` | Suppress scrolling while item animations are running |
| `AbstractDraggableItemViewHolder` | ViewHolder class which implements boilerplate code of `DraggableItemViewHolder` interface |
| `AbstractSwipeableItemViewHolder` | ViewHolder class which implements boilerplate code of `SwipeableItemViewHolder` interface |
| `AbstractDraggableSwipeableItemViewHolder` | ViewHolder class which implements boilerplate code of `DraggableItemViewHolder` and `SwipeableItemViewHolder` interfaces |
| [`RecyclerViewTouchActionGuardManager`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/touchguard/RecyclerViewTouchActionGuardManager.java) | Suppress scrolling while item animations are running |
| [`AbstractDraggableItemViewHolder`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableItemViewHolder.java) | ViewHolder class which implements boilerplate code of the `DraggableItemViewHolder` interface |
| [`AbstractSwipeableItemViewHolder`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractSwipeableItemViewHolder.java) | ViewHolder class which implements boilerplate code of the `SwipeableItemViewHolder` interface |
| [`AbstractExpandableItemViewHolder`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemViewHolder.java) | ViewHolder class which implements boilerplate code of the `ExpandableItemViewHolder` interface |
| [`AbstractDraggableSwipeableItemViewHolder`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractDraggableSwipeableItemViewHolder.java) | ViewHolder class which implements boilerplate code of the `DraggableItemViewHolder` and the `SwipeableItemViewHolder` interfaces |
| [`AbstractExpandableItemAdapter<GVH, CVH>`](library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/utils/AbstractExpandableItemAdapter.java) | Adapter class which implements boilerplate code of the `ExpandableItemAdapter` interface |


License
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -2,3 +2,7 @@

- Initial release

## 0.6.0

- Introduced "Expandable item" feature
- Minor bug fixes
4 changes: 2 additions & 2 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ android {
applicationId "com.h6ah4i.android.example.advrecyclerview"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "0.5"
versionCode 2
versionName "0.6"
}

signingConfigs {
25 changes: 22 additions & 3 deletions example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -25,15 +25,34 @@
android:theme="@style/AppTheme">

<activity
android:name=".demo.MainActivity"
android:label="@string/activity_title_demo">
android:name=".launcher.MainActivity"
android:label="@string/activity_title_launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<activity
android:name=".demo_d.DraggableExampleActivity"
android:label="@string/activity_title_demo_d" />

<activity
android:name=".demo_s.SwipeableExampleActivity"
android:label="@string/activity_title_demo_s" />

<activity
android:name=".demo_e.ExpandableExampleActivity"
android:label="@string/activity_title_demo_e" />

<activity
android:name=".demo_ds.DraggableSwipeableExampleActivity"
android:label="@string/activity_title_demo_ds" />

<activity
android:name=".demo_eds.ExpandableDraggableSwipeableExampleActivity"
android:label="@string/activity_title_demo_eds" />

<activity
android:name=".about.AboutActivity"
android:label="@string/activity_title_about"/>
1 change: 1 addition & 0 deletions example/src/main/assets/oss/0_advanced_recyclerview/LINK
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/h6ah4i/android-advancedrecyclerview
1 change: 1 addition & 0 deletions example/src/main/assets/oss/1_snackbar/LINK
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/nispok/snackbar
1 change: 1 addition & 0 deletions example/src/main/assets/oss/2_android_support_v4/LINK
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://developer.android.com/tools/support-library/features.html#v4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://developer.android.com/tools/support-library/features.html#v7-appcompat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://developer.android.com/tools/support-library/features.html#v7-recyclerview
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -104,7 +106,12 @@ public View getView(int position, View convertView, ViewGroup parent) {
v = convertView;
}

vh.mName.setText(info.mLibraryName);
if (info.mLink == null) {
vh.mName.setText(info.mLibraryName);
} else {
vh.mName.setMovementMethod(LinkMovementMethod.getInstance());
vh.mName.setText(Html.fromHtml("<a href=\"" + info.mLink.toString() + "\">" + info.mLibraryName + "</a>"));
}

if (info.mNoticeText != null) {
vh.mLicenseNotice.setText(info.mNoticeText);
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@

import android.content.Context;
import android.content.res.AssetManager;
import android.net.Uri;
import android.util.Log;

import java.io.IOException;
@@ -39,6 +40,7 @@ public static class LibraryInfo {
public String mLibraryName;
public String mLicenseText;
public String mNoticeText;
public Uri mLink;
}

public AssetFileLibraryLicenseDataCollector(Context context, String baseAssetDir) {
@@ -93,13 +95,15 @@ private LibraryInfo loadLicenseInfo(AssetManager assets, String dirname) {
String name = loadTextFile(assets, dirname + "/NAME");
String license = loadTextFile(assets, dirname + "/LICENSE");
String notice = loadTextFile(assets, dirname + "/NOTICE");
Uri link = safeParseLinkUri(loadTextFile(assets, dirname + "/LINK"));

if (name != null && (license != null || notice != null)) {
LibraryInfo info = new LibraryInfo();

info.mLibraryName = name;
info.mLicenseText = license;
info.mNoticeText = notice;
info.mLink = link;

return info;
} else {
@@ -108,6 +112,21 @@ private LibraryInfo loadLicenseInfo(AssetManager assets, String dirname) {
}
}

private static Uri safeParseLinkUri(String s) {
if (s == null) {
return null;
}

final String[] lines = s.split("\n");

if (lines == null || lines.length == 0) {
return null;
}


return Uri.parse(lines[0]);
}

// http://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string
private static String loadTextFile(AssetManager assets, String path) {
InputStream stream = null;
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.h6ah4i.android.example.advrecyclerview.demo.data;
package com.h6ah4i.android.example.advrecyclerview.common.data;

public abstract class AbstractDataProvider {

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

package com.h6ah4i.android.example.advrecyclerview.common.data;

public abstract class AbstractExpandableDataProvider {
public static abstract class BaseData {

public abstract int getSwipeReactionType();

public abstract String getText();

public abstract void setPinnedToSwipeLeft(boolean pinned);

public abstract boolean isPinnedToSwipeLeft();
}

public static abstract class GroupData extends BaseData {
public abstract long getGroupId();
}

public static abstract class ChildData extends BaseData {
public abstract long getChildId();
}

public abstract int getGroupCount();
public abstract int getChildCount(int groupPosition);

public abstract GroupData getGroupItem(int groupPosition);
public abstract ChildData getChildItem(int groupPosition, int childPosition);

public abstract void moveGroupItem(int fromGroupPosition, int toGroupPosition);
public abstract void moveChildItem(int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition);

public abstract void removeGroupItem(int groupPosition);
public abstract void removeChildItem(int groupPosition, int childPosition);

public abstract long undoLastRemoval();
}
Original file line number Diff line number Diff line change
@@ -14,10 +14,9 @@
* limitations under the License.
*/

package com.h6ah4i.android.example.advrecyclerview.demo.data;
package com.h6ah4i.android.example.advrecyclerview.common.data;

import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager;
import com.h6ah4i.android.widget.advrecyclerview.swipeable.SwipeableItemViewHolder;

import java.util.LinkedList;
import java.util.List;
Loading

0 comments on commit cea246e

Please sign in to comment.