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 Feb 22, 2014
2 parents 97aba62 + 521159a commit a769467
Show file tree
Hide file tree
Showing 75 changed files with 5,717 additions and 4,064 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ example/proguard-project.txt
*proguard-project.txt

.gradle/
gradle/*
gradlew*
Binary file modified ListViewAnimationsExample.apk
Binary file not shown.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ Setup
Add the following to your `build.gradle`:

repositories {
<!-- repostart -->
<!-- repoend -->
mavenCentral()
}

dependencies{
compile 'com.nhaarman.listviewanimations:library:2.5.2'
compile 'com.nhaarman.listviewanimations:library:2.6.0'
}

**Or**:
Expand All @@ -63,7 +65,7 @@ Add the following to your `pom.xml`:
<dependency>
<groupId>com.nhaarman.listviewanimations</groupId>
<artifactId>library</artifactId>
<version>2.5.2</version>
<version>2.6.0</version>
</dependency>

Usage
Expand Down Expand Up @@ -105,7 +107,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.5.2.jar?raw=true
[4]: https://github.com/nhaarman/ListViewAnimations/blob/master/com.haarman.listviewanimations-2.6.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 @@ -123,3 +125,5 @@ License
[20]: https://play.google.com/store/apps/details?id=com.cafetaso.foodinfo
[21]: https://play.google.com/store/apps/details?id=sa.voorleesVerhaaltjes
[22]: https://play.google.com/store/apps/details?id=com.seedform.counter

<!-- versionName="2.6.0" -->
70 changes: 68 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import java.util.regex.Pattern

buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:0.6.1+'
classpath 'com.android.tools.build:gradle:0.8.+'
}
}

def isReleaseBuild() {
println version
return version.contains("SNAPSHOT") == false
}

allprojects {
group = 'com.haarman.listviewanimations'
group = 'com.nhaarman.listviewanimations'
version = VERSION_NAME

repositories {
mavenCentral()
Expand All @@ -19,3 +27,61 @@ allprojects {
options.encoding = 'UTF-8'
}
}


task('increaseVersionCode') << {
def files = new File[2];
files[0] = file("library/AndroidManifest.xml")
files[1] = file("example/AndroidManifest.xml")
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
for (int i = 0; i < files.length; ++i) {
def manifestText = files[i].getText()
def matcher = pattern.matcher(manifestText)
matcher.find()
def currentVersionCode = Long.parseLong(matcher.group(1));
def versionCode = Long.parseLong(new Date().format('yyyyMMdd') + "1")
while (versionCode <= currentVersionCode) {
++versionCode
}
println(versionCode)
def manifestContent = matcher.replaceAll("versionCode=\"" + versionCode + "\"")
files[i].write(manifestContent)
}
}

task('syncVersionName') << {
def manifestFiles = new File[2];
manifestFiles[0] = file("library/AndroidManifest.xml")
manifestFiles[1] = file("example/AndroidManifest.xml")
def pattern = Pattern.compile("versionName=\"(.+)\"")
for (int i = 0; i < manifestFiles.length; ++i) {
def manifestText = manifestFiles[i].getText()
def matcher = pattern.matcher(manifestText)
matcher.find()
def manifestContent = matcher.replaceAll("versionName=\"" + version + "\"")
manifestFiles[i].write(manifestContent)
}

def readmeFile = file("README.md")
def readmeText = readmeFile.getText()
def matcher = pattern.matcher(readmeText)
matcher.find()
def previousVersion = matcher.group(1)
def readmeContent = readmeText.replaceAll(previousVersion, version)

pattern = Pattern.compile("repostart -->(.+)<!-- repoend", Pattern.DOTALL)
matcher = pattern.matcher(readmeContent)
matcher.find()
def repo = isReleaseBuild() ? "\n\t\t" : "\n\t\tmaven {\n\t\t\turl \"https://oss.sonatype.org/content/repositories/snapshots\"\n\t\t}\n\t\t";
readmeContent = matcher.replaceAll("repostart -->" + repo + "<!-- repoend")

readmeFile.write(readmeContent)
}

tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig') {
task.dependsOn 'increaseVersionCode'
}
}

apply plugin: 'android-reporting'
Binary file removed com.haarman.listviewanimations-2.5.2.jar
Binary file not shown.
Binary file added com.haarman.listviewanimations-2.6.0.jar
Binary file not shown.
14 changes: 6 additions & 8 deletions example/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.haarman.listviewanimations"
android:versionCode="201311071"
android:versionName="2.5.2" >
package="com.haarman.listviewanimations">

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />

<uses-permission android:name="com.android.vending.BILLING" />

<application
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 @@ -39,6 +34,9 @@
<activity
android:name="com.haarman.listviewanimations.itemmanipulationexamples.AnimateDismissActivity"
android:label="@string/animateremoval" />
<activity
android:name="com.haarman.listviewanimations.itemmanipulationexamples.AnimateAdditionActivity"
android:label="@string/animateaddition" />
<activity
android:name="com.haarman.listviewanimations.GridViewActivity"
android:label="@string/gridviewexample" />
Expand Down
41 changes: 37 additions & 4 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
apply plugin: 'android'

dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.android.support:appcompat-v7:19.0.+'
compile project(":library")
}

android {
compileSdkVersion 18
buildToolsVersion '18.0.1'
compileSdkVersion 19
buildToolsVersion '19.0.1'

sourceSets {
main {
Expand All @@ -19,4 +18,38 @@ android {
assets.srcDirs = ['assets']
}
}

defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionName project.VERSION_NAME
versionCode Integer.parseInt(new Date().format('yyyyMMddHH'))
}

signingConfigs {
debug {
storeFile file(System.getProperty("user.home") + "/.android/debug.keystore")
}

release {
storeFile file(System.getProperty("user.home") + "/.android/nhaarman.keystore")
storePassword nhaarman_lva_storePassword
keyAlias nhaarman_lva_keyAlias
keyPassword nhaarman_lva_keyPassword
}
}

buildTypes {

debug {
debuggable true
signingConfig signingConfigs.debug
}

release {
debuggable false
signingConfig signingConfigs.release
}

}
}
Binary file modified example/libs/android-support-v4.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion example/res/layout/activity_draganddrop.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >

<com.haarman.listviewanimations.view.DynamicListView
<com.nhaarman.listviewanimations.widget.DynamicListView
android:id="@+id/activity_draganddrop_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
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 @@ -37,6 +37,13 @@
android:onClick="onAnimateRemovalClicked"
android:text="@string/animateremoval" />

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

<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion example/res/layout/activity_expandablelistitem_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
android:id="@+id/activity_expandablelistitem_card_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" />
android:paddingTop="4dp" />

</LinearLayout>
1 change: 1 addition & 0 deletions example/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<string name="draganddrop">Drag and Drop</string>
<string name="swipedismiss">Swipe to dismiss</string>
<string name="animateremoval">Animate dismiss</string>
<string name="animateaddition">Animate addition</string>
<string name="removeselected">Remove selected</string>
<string name="expandablelistitemadapter">Expand list items</string>
<string name="itemdeleted">Item deleted</string>
Expand Down
6 changes: 3 additions & 3 deletions example/src/com/haarman/listviewanimations/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ public class BaseActivity extends ActionBarActivity {

@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= 19) {
protected void onCreate(final Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
Expand Down
32 changes: 15 additions & 17 deletions example/src/com/haarman/listviewanimations/GoogleCardsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@
import android.widget.ListView;
import android.widget.TextView;

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

public class GoogleCardsActivity extends BaseActivity implements OnDismissCallback {

private GoogleCardsAdapter mGoogleCardsAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_googlecards);

Expand All @@ -64,27 +65,24 @@ private ArrayList<Integer> getItems() {
}

@Override
public void onDismiss(AbsListView listView, int[] reverseSortedPositions) {
public void onDismiss(final AbsListView listView, final int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
mGoogleCardsAdapter.remove(position);
}
}

private static class GoogleCardsAdapter extends ArrayAdapter<Integer> {

private Context mContext;
private LruCache<Integer, Bitmap> mMemoryCache;
private final Context mContext;
private final LruCache<Integer, Bitmap> mMemoryCache;

public GoogleCardsAdapter(Context context) {
public GoogleCardsAdapter(final Context context) {
mContext = context;

final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);

// Use 1/8th of the available memory for this memory cache.
final int cacheSize = maxMemory;
final int cacheSize = (int) (Runtime.getRuntime().maxMemory() / 1024);
mMemoryCache = new LruCache<Integer, Bitmap>(cacheSize) {
@Override
protected int sizeOf(Integer key, Bitmap bitmap) {
protected int sizeOf(final Integer key, final Bitmap bitmap) {
// The cache size will be measured in kilobytes rather than
// number of items.
return bitmap.getRowBytes() * bitmap.getHeight() / 1024;
Expand All @@ -93,7 +91,7 @@ protected int sizeOf(Integer key, Bitmap bitmap) {
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
public View getView(final int position, final View convertView, final ViewGroup parent) {
ViewHolder viewHolder;
View view = convertView;
if (view == null) {
Expand All @@ -114,7 +112,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
return view;
}

private void setImageView(ViewHolder viewHolder, int position) {
private void setImageView(final ViewHolder viewHolder, final int position) {
int imageResId;
switch (getItem(position) % 5) {
case 0:
Expand All @@ -141,13 +139,13 @@ private void setImageView(ViewHolder viewHolder, int position) {
viewHolder.imageView.setImageBitmap(bitmap);
}

private void addBitmapToMemoryCache(int key, Bitmap bitmap) {
private void addBitmapToMemoryCache(final int key, final Bitmap bitmap) {
if (getBitmapFromMemCache(key) == null) {
mMemoryCache.put(key, bitmap);
}
}

private Bitmap getBitmapFromMemCache(int key) {
private Bitmap getBitmapFromMemCache(final int key) {
return mMemoryCache.get(key);
}

Expand Down
Loading

0 comments on commit a769467

Please sign in to comment.