Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
ead600b
Modify link
Trinea Feb 5, 2015
9afa24a
Update README.md
Trinea Feb 5, 2015
6d262da
add side-menu folder
cpacm Feb 6, 2015
a2e5e0d
add .gitignore
cpacm Feb 6, 2015
5dc2084
add nineoldanimations-demo by mr.simple
Feb 7, 2015
5d7c5a1
Merge branch 'master' of github.com:aosp-exchange-group/android-open-…
Feb 7, 2015
0746d52
Update README.md
hehonghui Feb 7, 2015
478cae4
rogary
Rogary Feb 10, 2015
3b47d56
READEME.md
Rogary Feb 11, 2015
a50477f
fix README.md
Rogary Feb 11, 2015
6986bcc
delete error README.md
Rogary Feb 11, 2015
3d1a04b
Merge pull request #1 from Rogary/master
Trinea Feb 11, 2015
26eca9f
add QuickAdapterDemo
Feb 12, 2015
ea29714
androidactive-demo
ouyangxiangshao Feb 13, 2015
f32412a
add apk file
Feb 13, 2015
c6a18c4
Merge branch 'master' of https://github.com/aosp-exchange-group/andro…
Feb 13, 2015
9e0cde9
dl-apk-load complete
FFish Feb 14, 2015
be5db32
add .gitignore
FFish Feb 14, 2015
3cf8c7f
pullToZoomInListviewDemo
Yom9c Feb 16, 2015
d15d17a
Create discrete-seek-bar-demo
wangeason Feb 27, 2015
b580e72
Delete discrete-seek-bar-demo
wangeason Feb 27, 2015
536005f
Create README.md
wangeason Feb 27, 2015
111b5bd
Update README.md
wangeason Feb 27, 2015
362dc0e
Demo
Mar 6, 2015
1cda786
pager-sliding-tab-strip-demo-ayyb1988
Mar 8, 2015
b32fb16
apk
Mar 8, 2015
23a9a4b
.gitignore
Mar 9, 2015
bdac540
pager-sliding-tab-strip-demo-ayyb1988
Mar 9, 2015
dce3c33
Create README.md
ayyb1988 Mar 9, 2015
0291b30
Update README.md
ayyb1988 Mar 9, 2015
836683d
Update README.md
ayyb1988 Mar 9, 2015
0f94032
Update README.md
ayyb1988 Mar 9, 2015
4ef0ca2
Merge pull request #2 from ayyb1988/master
ayyb1988 Mar 9, 2015
37aa832
update
cpacm Mar 9, 2015
1864a5b
add readme
cpacm Mar 9, 2015
c851af0
update readme
cpacm Mar 9, 2015
8a33825
update readme
cpacm Mar 9, 2015
0e272d1
submit sliding-menu-demo
huxian99 Mar 12, 2015
b52e9eb
upload demo gif
huxian99 Mar 23, 2015
3e012fc
complete demo
huxian99 Mar 23, 2015
fa0047a
Demo upload
wangeason Mar 26, 2015
245b2d0
update fresco demo
blackiedm Apr 1, 2015
171d21e
modify comments
wangeason Apr 10, 2015
30c2d7e
Initialize CircularReveal Sample commit!
Apr 15, 2015
e1bf917
Add source commit!
Apr 15, 2015
fe7b7c7
Update README.md commit!
Apr 15, 2015
caad22f
Update README.md commit!
Apr 15, 2015
d3ecfd9
update base-adapter-helper-demo
Apr 17, 2015
d13c786
add retrofit demo
guoGavin Jul 16, 2015
b6e9cd4
change retrofit source
guoGavin Jul 16, 2015
7d73690
add flyrefresh demo
AdrianLCA Jul 24, 2015
de4c942
Merge pull request #4 from skyacer/master
AdrianLCA Jul 24, 2015
e92d7c4
add flyrefresh apk
AdrianLCA Jul 31, 2015
9d5de02
change flyrefresh demo
AdrianLCA Aug 1, 2015
311b417
update fly-refresh demo
AdrianLCA Aug 1, 2015
ac3bb20
update flyrefresh
AdrianLCA Aug 1, 2015
9a6c265
Create volley-demo-Kevin1466
Kevin1466 Aug 27, 2015
f5d8784
能否提交
Aug 27, 2015
2e7a1a5
合肥市的
Aug 27, 2015
c304a3d
改变
Aug 27, 2015
9004e51
file
Aug 27, 2015
6c5fa2e
demo ok
Aug 27, 2015
af8083f
cleaned
Aug 27, 2015
cb0bed2
add folder for android-async-http-demo
yuanhuihui Aug 29, 2015
a2052eb
Merge pull request #5 from yuanhuihui/master
yuanhuihui Aug 29, 2015
219e90f
swipebacklayout demo
Neocomb Oct 1, 2015
f67a589
Create rxjava-demo project; Add create observable demo and unsubscrib…
Oct 10, 2015
d90e68d
add retrofit-demo-xxxzhi
jjjtui Oct 25, 2015
bde16c5
Update README.md
Trinea Oct 27, 2015
84d8de6
Create touchimageview-demo
truistic Oct 27, 2015
329d3f5
Create README.md
truistic Oct 27, 2015
d21400a
Update README.md
truistic Oct 27, 2015
ba22102
update listviewanimations lib
Nov 5, 2015
ba246b8
Update:
Nov 5, 2015
8764a8e
Update README.md
yansha87 Nov 5, 2015
f57ac47
add drag-and-drop feature
Nov 5, 2015
99e1a39
Merge branch 'master' of https://github.com/aosp-exchange-group/andro…
Nov 5, 2015
0d02bc9
Fix some crash bugs
Nov 6, 2015
afecb5e
remove unused file
Nov 11, 2015
911eb73
add android-open-project-demo
Labmem003 Jun 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update listviewanimations lib
  • Loading branch information
demon committed Nov 5, 2015
commit ba221028cf5840f88a55787516067c4b104cd278
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013 Niek Haarman
* Copyright 2014 Niek Haarman
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,264 +15,135 @@
*/
package com.nhaarman.listviewanimations;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.BaseAdapter;

import com.nhaarman.listviewanimations.itemmanipulation.AnimateAdditionAdapter;
import com.nhaarman.listviewanimations.widget.DynamicListView;
import com.nhaarman.listviewanimations.util.Insertable;
import com.nhaarman.listviewanimations.util.Swappable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
* A {@code true} {@link ArrayList} adapter providing access to all ArrayList methods.
* Also implements {@link DynamicListView.Swappable} for easy object swapping, and {@link AnimateAdditionAdapter.Insertable} for inserting objects.
* A true {@link ArrayList} adapter providing access to some of the {@code ArrayList} methods.
* <p/>
* Also implements {@link Swappable} for easy object swapping,
* and {@link Insertable} for inserting objects.
*/
@SuppressWarnings("UnusedDeclaration")
public abstract class ArrayAdapter<T> extends BaseAdapter implements List<T>, DynamicListView.Swappable, AnimateAdditionAdapter.Insertable<T> {
public abstract class ArrayAdapter<T> extends BaseAdapter implements Swappable, Insertable<T> {

protected List<T> mItems;
@NonNull
private final List<T> mItems;

/**
* Creates a new ArrayAdapter with an empty {@code List} .
*/
public ArrayAdapter() {
this(null);
}
private BaseAdapter mDataSetChangedSlavedAdapter;

/**
* Creates a new {@link ArrayAdapter} using given {@code List} , or an empty {@code List} if objects == null.
* Creates a new ArrayAdapter with an empty {@code List}.
*/
public ArrayAdapter(final List<T> objects) {
this(objects, false);
protected ArrayAdapter() {
this(null);
}

/**
* Creates a new {@link ArrayAdapter}, using (a copy of) given {@code List} , or an empty {@code List} if objects = null.
* @param copyList {@code true} to create a copy of the {@code List} , {@code false} to reuse the reference.
* Creates a new ArrayAdapter, using (a copy of) given {@code List}, or an empty {@code List} if objects = null.
*/
public ArrayAdapter(final List<T> objects, final boolean copyList) {
protected ArrayAdapter(@Nullable final List<T> objects) {
if (objects != null) {
if (copyList) {
mItems = new ArrayList<T>(objects);
} else {
mItems = objects;
}
mItems = objects;
} else {
mItems = new ArrayList<T>();
mItems = new ArrayList<>();
}
}


@Override
public int getCount() {
return mItems.size();
}

@Override
public T getItem(final int location) {
return mItems.get(location);
public long getItemId(final int position) {
return position;
}

@Override
public long getItemId(final int location) {
return location;
@NonNull
public T getItem(final int position) {
return mItems.get(position);
}

/**
* Returns the items.
*/
@NonNull
public List<T> getItems() {
return mItems;
}

/**
* Appends the specified element to the end of the {@code List} .
* Appends the specified element to the end of the {@code List}.
*
* @param object the object to add.
*
* @return always true.
*/
@Override
public boolean add(final T object) {
public boolean add(@NonNull final T object) {
boolean result = mItems.add(object);
notifyDataSetChanged();
return result;
}

@Override
public void add(final int location, final T object) {
mItems.add(location, object);
public void add(final int index, @NonNull final T item) {
mItems.add(index, item);
notifyDataSetChanged();
}

/**
* Adds the objects in the specified collection to the end of this List. The objects are added in the order in which they are returned from the collection's iterator.
*
* @param collection the collection of objects.
*
* @return {@code true} if this {@code List} is modified, {@code false} otherwise.
*/
@Override
public boolean addAll(final Collection<? extends T> collection) {
public boolean addAll(@NonNull final Collection<? extends T> collection) {
boolean result = mItems.addAll(collection);
notifyDataSetChanged();
return result;
}

/**
* Appends all of the elements in the specified collection to the end of the
* {@code List} , in the order that they are specified.
* @param objects the array of objects.
* @return {@code true} if the collection changed during insertion.
*/
public boolean addAll(final T... objects) {
boolean result = Collections.addAll(mItems, objects);
notifyDataSetChanged();
return result;
}

@Override
public boolean addAll(final int location, final Collection<? extends T> objects) {
boolean result = mItems.addAll(location, objects);
notifyDataSetChanged();
return result;
}

/**
* Inserts the objects in the specified collection at the specified location in this List. The objects are added in the order that they specified.
* @param location the index at which to insert.
* @param objects the array of objects.
*/
public void addAll(final int location, final T... objects) {
for (int i = location; i < objects.length + location; i++) {
mItems.add(i, objects[i]);
}
notifyDataSetChanged();
public boolean contains(final T object) {
return mItems.contains(object);
}

@Override
public void clear() {
mItems.clear();
notifyDataSetChanged();
}

@Override
public boolean contains(final Object object) {
return mItems.contains(object);
}

@Override
public boolean containsAll(final Collection<?> collection) {
return mItems.containsAll(collection);
}

@Override
public T get(final int location) {
return mItems.get(location);
}

@Override
public T set(final int location, final T object) {
T result = mItems.set(location, object);
notifyDataSetChanged();
return result;
}

@Override
public int size() {
return mItems.size();
}

@Override
public List<T> subList(final int start, final int end) {
return mItems.subList(start, end);
}

@Override
public Object[] toArray() {
return mItems.toArray();
}

@Override
public <T1> T1[] toArray(final T1[] array) {
//noinspection SuspiciousToArrayCall
return mItems.toArray(array);
}

@Override
public boolean remove(final Object object) {
public boolean remove(@NonNull final Object object) {
boolean result = mItems.remove(object);
notifyDataSetChanged();
return result;
}

@Override
@NonNull
public T remove(final int location) {
T result = mItems.remove(location);
notifyDataSetChanged();
return result;
}

/**
* Removes all elements at the specified locations in the {@code List} .
* @param locations the collection of indexes to remove.
* @return a collection containing the removed objects.
*/
public Collection<T> removePositions(final Collection<Integer> locations) {
ArrayList<T> removedItems = new ArrayList<T>();

ArrayList<Integer> locationsList = new ArrayList<Integer>(locations);
Collections.sort(locationsList);
Collections.reverse(locationsList);
for (int location : locationsList) {
removedItems.add(mItems.remove(location));
}
notifyDataSetChanged();
return removedItems;
}

@Override
public boolean removeAll(final Collection<?> objects) {
boolean result = mItems.removeAll(objects);
notifyDataSetChanged();
return result;
}

@Override
public boolean retainAll(final Collection<?> objects) {
boolean result = mItems.retainAll(objects);
public void swapItems(final int positionOne, final int positionTwo) {
T firstItem = mItems.set(positionOne, getItem(positionTwo));
notifyDataSetChanged();
return result;
}

@Override
public int indexOf(final Object object) {
return mItems.indexOf(object);
}

@Override
public Iterator<T> iterator() {
return mItems.iterator();
}

@Override
public int lastIndexOf(final Object object) {
return mItems.lastIndexOf(object);
mItems.set(positionTwo, firstItem);
}

@Override
public ListIterator<T> listIterator() {
return mItems.listIterator();
}

@Override
public ListIterator<T> listIterator(final int location) {
return mItems.listIterator(location);
}

@Override
public void swapItems(final int locationOne, final int locationTwo) {
T temp = getItem(locationOne);
set(locationOne, getItem(locationTwo));
set(locationTwo, temp);
}

private BaseAdapter mDataSetChangedSlavedAdapter;

public void propagateNotifyDataSetChanged(final BaseAdapter slavedAdapter) {
public void propagateNotifyDataSetChanged(@NonNull final BaseAdapter slavedAdapter) {
mDataSetChangedSlavedAdapter = slavedAdapter;
}

Expand Down
Loading