Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaarman committed Sep 5, 2013
2 parents 8b3b33f + 79b838f commit ad74151
Show file tree
Hide file tree
Showing 14 changed files with 219 additions and 358 deletions.
Binary file modified ListViewAnimationsExample.apk
Binary file not shown.
82 changes: 13 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ ListViewAnimations ([Play Store Demo][1])

ListViewAnimations is an Open Source Android library that allows developers to easily create ListViews with animations.
Feel free to use it all you want in your Android apps provided that you cite this project and include the license in your app.

ListViewAnimations uses the [NineOldAndroids][2] library to support devices <3.0.
It also uses Roman Nurik's BETA [SwipeDismissListViewTouchListener][5] to support swipe to dismiss.

Version 2.0 now supports GridViews! (And other implementations of AbsListView)
It also contains an ExpandableListItemAdapter for smoothly expanding your Views!
A mention to haarman.niek [at] gmail.com about your app using this library is very welcome! Start your message's title with `[LVA]`.

Known applications using ListViewAnimations
-----
Expand All @@ -18,7 +13,7 @@ Known applications using ListViewAnimations
* Car Hire ([Play Store][10])
* Super BART ([Play Store][11])

If you want your app to be listed as well please contact me via [Google Plus][8]!
If you want your app to be listed as well please contact me via [Google Plus][8], or send me an email at haarman.niek [at] gmail.com, starting the title with `[LVA]`.

Setup
-----
Expand All @@ -29,70 +24,11 @@ Setup
Or:

* [Download the .jar file][4]
* Add the .jar to your project's `libs` folder.
* Add the .jar to your project's `libs` folder, or add it as an external jar to your project's build path.

Usage
-----
This library uses the [Decorator Pattern][3] to stack multiple `BaseAdapterDecorator`s on each other:

* Implement your own `BaseAdapter`, or reuse an existing one.
* Stack multiple `BaseAdapterDecorator`s on each other, with your `BaseAdapter` as a base.
* Set the `ListView` to your last `BaseAdapterDecorator`.
* Set your last `BaseAdapterDecorator` to the `ListView`.

Example:
-----

/* This example will stack two animations on top of eachother */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

MyListAdapter mAdapter = new MyListAdapter(this, getItems());
SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(mAdapter);
SwingRightInAnimationAdapter swingRightInAnimationAdapter = new SwingRightInAnimationAdapter(swingBottomInAnimationAdapter);
// Or in short notation:
swingRightInAnimationAdapter =
new SwingRightInAnimationAdapter(
new SwingBottomInAnimationAdapter(
new MyListAdapter(this, getItems())));
// Assign the ListView to the AnimationAdapter and vice versa
swingRightInAnimationAdapter.setAbsListView(getListView());
getListView().setAdapter(swingRightInAnimationAdapter);
}

private class MyListAdapter extends com.haarman.listviewanimations.ArrayAdapter<String> {

private Context mContext;

public MyListAdapter(Context context, ArrayList<String> items) {
super(items);
mContext = context;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv = (TextView) convertView;
if (tv == null) {
tv = (TextView) LayoutInflater.from(mContext).inflate(R.layout.list_row, parent, false);
}
tv.setText(getItem(position));
return tv;
}
}

Custom AnimationAdapters
-----
Instead of using the ready-made adapters in the `.swinginadapters.prepared` package, you can also implement your own `AnimationAdapter`.
Implement one of the following classes:

* `ResourceAnimationAdapter`
* `SingleAnimationAdapter`
* `AnimationAdapter`

See the examples.
Please refer to the [Wiki][13] pages to learn more about how to use this library.

Contribute
-----
Expand All @@ -102,6 +38,12 @@ Developed By
-----
* Niek Haarman

Special thanks
-----
* Roman Nurik - The ListViewAnimations library uses a modified version of his [SwipeDismissListViewTouchListener][5] to support swipe-to-dismiss.
* Jake Warthon - To support devices pre-HC (<3.0), a jar file of [NineOldAndroids][2] is included.
* Emil Sjölander - If you're already using the [StickyListHeaders][14] library, the ListViewAnimations library makes sure your header views are animated as well. Therefore, a copy of the StickyListHeaders jar file is included.

License
-----

Expand All @@ -122,7 +64,7 @@ License
[1]: https://play.google.com/store/apps/details?id=com.haarman.listviewanimations
[2]: http://nineoldandroids.com/
[3]: http://en.wikipedia.org/wiki/Decorator_pattern
[4]: https://github.com/nhaarman/ListViewAnimations/blob/master/com.haarman.listviewanimations-2.2.3.jar?raw=true
[4]: https://github.com/nhaarman/ListViewAnimations/blob/master/com.haarman.listviewanimations-2.3.0.jar?raw=true
[5]: https://gist.github.com/romannurik/2980593
[6]: https://play.google.com/store/apps/details?id=com.haarman.treinverkeer
[7]: https://www.twitter.com/niekfct
Expand All @@ -131,3 +73,5 @@ License
[10]: https://play.google.com/store/apps/details?id=com.rentalcars.handset
[11]: https://play.google.com/store/apps/details?id=com.getgoodcode.bart
[12]: https://play.google.com/store/apps/details?id=com.haarman.ultimatettt
[13]: https://github.com/nhaarman/ListViewAnimations/wiki
[14]: http://emilsjolander.github.io/StickyListHeaders/
Binary file not shown.
11 changes: 7 additions & 4 deletions example/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.haarman.listviewanimations"
android:versionCode="20"
android:versionName="2.2.3">
android:versionCode="21"
android:versionName="2.3.0" >

<uses-sdk
android:minSdkVersion="8"
Expand All @@ -11,8 +11,8 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name="com.haarman.listviewanimations.MainActivity">
android:theme="@style/AppTheme" >
<activity android:name="com.haarman.listviewanimations.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -22,6 +22,9 @@
<activity
android:name="com.haarman.listviewanimations.animationinexamples.AnimationInExamplesActivity"
android:label="@string/swingin" />
<activity
android:name="com.haarman.listviewanimations.animationinexamples.StickyListHeadersExample"
android:label="@string/stickylistheaders" />
<activity
android:name="com.haarman.listviewanimations.animationinexamples.SwingBottomInActivity"
android:label="@string/bottomin" />
Expand Down
27 changes: 17 additions & 10 deletions example/res/layout/activity_examples_animationin.xml
Original file line number Diff line number Diff line change
@@ -1,56 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="8dp">
android:padding="8dp" >

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="onStickyListHeadersClicked"
android:text="@string/stickylistheaders" />

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="onBottomInClicked"
android:text="@string/bottomin"/>
android:text="@string/bottomin" />

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="onRightInClicked"
android:text="@string/rightin"/>
android:text="@string/rightin" />

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="onLeftInClicked"
android:text="@string/leftin"/>
android:text="@string/leftin" />

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="onBottomRightInClicked"
android:text="@string/bottomrightin"/>
android:text="@string/bottomrightin" />

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="onScaleInClicked"
android:text="@string/scalein"/>
android:text="@string/scalein" />

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:onClick="onAlphaInClicked"
android:text="@string/alphain"/>

android:text="@string/alphain" />
</LinearLayout>

</ScrollView>
12 changes: 12 additions & 0 deletions example/res/layout/activity_stickylistheaders.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<com.emilsjolander.components.stickylistheaders.StickyListHeadersListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>
1 change: 1 addition & 0 deletions example/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<string name="menu_github">Github</string>
<string name="swingin">Animation in adapters</string>
<string name="itemmanipulation">Item manipulation</string>
<string name="stickylistheaders">Sticky List Headers</string>
<string name="bottomin">Bottom in</string>
<string name="rightin">Right in</string>
<string name="leftin">Left in</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_examples_animationin);
}

public void onStickyListHeadersClicked(View view) {
Intent intent = new Intent(this, StickyListHeadersExample.class);
startActivity(intent);
}

public void onBottomInClicked(View view) {
Intent intent = new Intent(this, SwingBottomInActivity.class);
startActivity(intent);
Expand All @@ -55,8 +60,8 @@ public void onScaleInClicked(View view) {
startActivity(intent);
}

public void onAlphaInClicked(View view){
Intent intent = new Intent(this, AlphaInActivity.class);
startActivity(intent);
}
public void onAlphaInClicked(View view) {
Intent intent = new Intent(this, AlphaInActivity.class);
startActivity(intent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.haarman.listviewanimations.animationinexamples;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.emilsjolander.components.stickylistheaders.StickyListHeadersAdapter;
import com.haarman.listviewanimations.ArrayAdapter;
import com.haarman.listviewanimations.R;
import com.haarman.listviewanimations.swinginadapters.prepared.AlphaInAnimationAdapter;

public class StickyListHeadersExample extends ListActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stickylistheaders);
getListView().setDivider(null);

MyStickyListAdapter myStickyListAdapter = new MyStickyListAdapter(this, getItems());
AlphaInAnimationAdapter animAdapter = new AlphaInAnimationAdapter(myStickyListAdapter);
animAdapter.setAbsListView(getListView());
getListView().setAdapter(animAdapter);
}

public static ArrayList<Integer> getItems() {
ArrayList<Integer> items = new ArrayList<Integer>();
for (int i = 0; i < 1000; i++) {
items.add(i);
}
return items;
}

private static class MyStickyListAdapter extends ArrayAdapter<Integer> implements StickyListHeadersAdapter {

private Context mContext;

public MyStickyListAdapter(Context context, ArrayList<Integer> items) {
super(items);
mContext = context;
}

@Override
public long getItemId(int position) {
return getItem(position).hashCode();
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv = (TextView) convertView;
if (tv == null) {
tv = (TextView) LayoutInflater.from(mContext).inflate(R.layout.list_row, parent, false);
}
tv.setText("This is row number " + getItem(position));
return tv;
}

@Override
public long getHeaderId(int position) {
return getItem(position) / 10;
}

@Override
public View getHeaderView(int position, View convertView, ViewGroup parent) {
TextView tv = (TextView) convertView;
if (tv == null) {
tv = (TextView) LayoutInflater.from(mContext).inflate(R.layout.list_row, parent, false);
tv.setBackgroundColor(Color.CYAN);
}
tv.setText(String.valueOf(getItem(position) / 10));
return tv;
}
}

}
4 changes: 2 additions & 2 deletions library/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.haarman.listviewanimations"
android:versionCode="20"
android:versionName="2.2.3" >
android:versionCode="21"
android:versionName="2.3.0" >

<uses-sdk
android:minSdkVersion="8"
Expand Down
Binary file added library/libs/stickylistheaders_lib.jar
Binary file not shown.
Loading

0 comments on commit ad74151

Please sign in to comment.