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 12, 2013
2 parents dd31b8f + e8544e3 commit 32e7463
Show file tree
Hide file tree
Showing 33 changed files with 1,107 additions and 297 deletions.
Binary file modified ListViewAnimationsExample.apk
Binary file not shown.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ Known applications using ListViewAnimations
* Running Coach ([Play Store][9])
* Car Hire ([Play Store][10])
* Super BART ([Play Store][11])
* DK FlashCards ([Play Store][15])

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]`.

Features
-----
ListViewAnimations provides the following features:
* Appearance animations for items in ListViews, GridViews, and other AbsListViews;
* Built in animations include Alpha, SwingRightIn, SwingLeftIn, SwingBottomIn, SwingRightIn and ScaleIn.
* Other animations can easily be added
* Swipe-to-Dismiss, Swipe-To-Dismiss with contextual undo (and optionally count down);
* Drag-and-Drop reordering;
* Animate dismissal of items;
* Smoothly expand your items to reveal more content;

Setup
-----
* In Eclipse, just import the library as an Android library project.
Expand All @@ -33,6 +45,7 @@ Please refer to the [Wiki][13] pages to learn more about how to use this library
Contribute
-----
Please do! I'm happy to review and accept pull requests.
Also if you've created an awesome appearance animation that you'd like to share, let 'em come!

Developed By
-----
Expand All @@ -41,6 +54,7 @@ Developed By
Special Thanks
-----
* Roman Nurik - The ListViewAnimations library uses a modified version of his [SwipeDismissListViewTouchListener][5] to support swipe-to-dismiss.
* DevBytes - Drag-and-Drop reordering is done by a modified version of their [DynamicListView][16].
* 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.

Expand All @@ -64,7 +78,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.3.1.jar?raw=true
[4]: https://github.com/nhaarman/ListViewAnimations/blob/master/com.haarman.listviewanimations-2.4.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 @@ -75,3 +89,5 @@ License
[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/
[15]: https://play.google.com/store/apps/details?id=com.ducky.flashcards
[16]: http://youtu.be/_BZIvjMgH-Q
Binary file removed com.haarman.listviewanimations-2.3.1.jar
Binary file not shown.
Binary file added com.haarman.listviewanimations-2.4.0.jar
Binary file not shown.
7 changes: 5 additions & 2 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="22"
android:versionName="2.3.1" >
android:versionCode="201309122"
android:versionName="2.4.0" >

<uses-sdk
android:minSdkVersion="8"
Expand All @@ -28,6 +28,9 @@
<activity
android:name="com.haarman.listviewanimations.itemmanipulationexamples.ItemManipulationsExamplesActivity"
android:label="@string/itemmanipulation" />
<activity
android:name="com.haarman.listviewanimations.itemmanipulationexamples.DragAndDropActivity"
android:label="@string/draganddrop" />
<activity
android:name="com.haarman.listviewanimations.itemmanipulationexamples.SwipeDismissActivity"
android:label="@string/swipedismiss" />
Expand Down
Binary file modified example/res/drawable/img_nature1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/res/drawable/img_nature2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/res/drawable/img_nature3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/res/drawable/img_nature4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/res/drawable/img_nature5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions example/res/layout/activity_examples_itemmanipulations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
android:orientation="vertical"
android:padding="8dp" >

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

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
Expand Down
11 changes: 5 additions & 6 deletions example/res/layout/activity_expandablelistitem_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
android:layout_height="wrap_content"
android:background="@drawable/card_background_white"
android:orientation="vertical"
android:padding="16dp">
android:padding="16dp" >

<FrameLayout
android:id="@+id/activity_expandablelistitem_card_parent"
android:id="@+id/activity_expandablelistitem_card_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


<FrameLayout
android:layout_marginTop="4dp"
android:layout_width="match_parent"
android:id="@+id/activity_expandablelistitem_card_content"
android:layout_height="wrap_content" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" />

</LinearLayout>
7 changes: 3 additions & 4 deletions example/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false" android:gravity="center_horizontal"
android:clipToPadding="false"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="8dp"
android:scrollbarStyle="outsideOverlay" >
Expand All @@ -13,15 +14,13 @@
android:layout_margin="8dp"
android:onClick="onGoogleCardsExampleClicked"
android:text="@string/googlecards" />

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



<Button
android:layout_width="150dp"
Expand Down
1 change: 1 addition & 0 deletions example/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<string name="sticky">Sticky</string>
<string name="itemmanipulation">Item Manipulation</string>
<string name="gridviewexample">GridView example</string>
<string name="draganddrop">Drag and Drop</string>
<string name="swipedismiss">Swipe to dismiss</string>
<string name="animateremoval">Animate dismiss</string>
<string name="removeselected">Remove selected</string>
Expand Down
27 changes: 27 additions & 0 deletions example/src/com/haarman/listviewanimations/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.haarman.listviewanimations;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;

public class BaseActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
33 changes: 16 additions & 17 deletions example/src/com/haarman/listviewanimations/GoogleCardsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
Expand All @@ -31,11 +30,11 @@
import android.widget.ListView;
import android.widget.TextView;

import com.haarman.listviewanimations.itemmanipulation.SwipeDismissAdapter;
import com.haarman.listviewanimations.itemmanipulation.OnDismissCallback;
import com.haarman.listviewanimations.itemmanipulation.SwipeDismissAdapter;
import com.haarman.listviewanimations.swinginadapters.prepared.SwingBottomInAnimationAdapter;

public class GoogleCardsActivity extends Activity implements OnDismissCallback {
public class GoogleCardsActivity extends BaseActivity implements OnDismissCallback {

private GoogleCardsAdapter mGoogleCardsAdapter;

Expand Down Expand Up @@ -117,20 +116,20 @@ public View getView(int position, View convertView, ViewGroup parent) {
private void setImageView(ViewHolder viewHolder, int position) {
int imageResId;
switch (getItem(position) % 5) {
case 0:
imageResId = R.drawable.img_nature1;
break;
case 1:
imageResId = R.drawable.img_nature2;
break;
case 2:
imageResId = R.drawable.img_nature3;
break;
case 3:
imageResId = R.drawable.img_nature4;
break;
default:
imageResId = R.drawable.img_nature5;
case 0:
imageResId = R.drawable.img_nature1;
break;
case 1:
imageResId = R.drawable.img_nature2;
break;
case 2:
imageResId = R.drawable.img_nature3;
break;
case 3:
imageResId = R.drawable.img_nature4;
break;
default:
imageResId = R.drawable.img_nature5;
}

Bitmap bitmap = getBitmapFromMemCache(imageResId);
Expand Down
31 changes: 22 additions & 9 deletions example/src/com/haarman/listviewanimations/MyListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,47 @@

import java.util.ArrayList;

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

public class MyListActivity extends ListActivity {
public class MyListActivity extends BaseActivity {

private ListView mListView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getListView().setDivider(null);
mListView = new ListView(this);
setContentView(mListView);
mListView.setDivider(null);
}

public ListView getListView() {
return mListView;
}

protected ArrayAdapter<String> createListAdapter() {
protected ArrayAdapter<Integer> createListAdapter() {
return new MyListAdapter(this, getItems());
}

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

private static class MyListAdapter extends ArrayAdapter<String> {
private static class MyListAdapter extends ArrayAdapter<Integer> {

private Context mContext;

public MyListAdapter(Context context, ArrayList<String> items) {
public MyListAdapter(Context context, ArrayList<Integer> items) {
super(items);
mContext = context;
}
Expand All @@ -59,6 +67,11 @@ public long getItemId(int position) {
return getItem(position).hashCode();
}

@Override
public boolean hasStableIds() {
return true;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv = (TextView) convertView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBar.OnNavigationListener;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -35,6 +34,7 @@

import com.emilsjolander.components.stickylistheaders.StickyListHeadersAdapter;
import com.haarman.listviewanimations.ArrayAdapter;
import com.haarman.listviewanimations.BaseActivity;
import com.haarman.listviewanimations.R;
import com.haarman.listviewanimations.swinginadapters.AnimationAdapter;
import com.haarman.listviewanimations.swinginadapters.prepared.AlphaInAnimationAdapter;
Expand All @@ -43,7 +43,7 @@
import com.haarman.listviewanimations.swinginadapters.prepared.SwingLeftInAnimationAdapter;
import com.haarman.listviewanimations.swinginadapters.prepared.SwingRightInAnimationAdapter;

public class AppearanceExamplesActivity extends ActionBarActivity implements OnNavigationListener {
public class AppearanceExamplesActivity extends BaseActivity implements OnNavigationListener {

private BaseAdapter mAdapter;

Expand All @@ -70,7 +70,6 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(new AnimSelectionAdapter(), this);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

Toast.makeText(this, "You can turn StickyListHeaders on or off in the menu", Toast.LENGTH_LONG).show();
}
Expand Down Expand Up @@ -175,9 +174,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
switchListViews();
item.setChecked(mCurrentListView == mStickyListView);
return true;
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down
Loading

0 comments on commit 32e7463

Please sign in to comment.