Skip to content

Commit

Permalink
minSdk 7
Browse files Browse the repository at this point in the history
- Support minSdk 7
- Add used Arrays method to Utils to support 7+
  • Loading branch information
eveliotc committed Dec 30, 2014
1 parent 2d48cf0 commit 18e60d3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Mr. Vector
==========
![Mr. Vector](http://i.imgur.com/ucFr5T7.png)

AKA VectorDrawableCompat: A 14+ backport of [VectorDrawable](https://developer.android.com/reference/android/graphics/drawable/VectorDrawable.html).
AKA VectorDrawableCompat: A 7+ backport of [VectorDrawable](https://developer.android.com/reference/android/graphics/drawable/VectorDrawable.html).

### Demo

Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/res/layout/activity_basic_inflate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="?android:selectableItemBackground"
android:background="?selectableItemBackground"
/>
</FrameLayout>
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POM_NAME=Mr. Vector Library
POM_ARTIFACT_ID=mrvector
POM_PACKAGING=aar

POM_DESCRIPTION=Mr. Vector (VectorDrawableCompat): A 14+ backport of VectorDrawable
POM_DESCRIPTION=Mr. Vector (VectorDrawableCompat): A 7+ backport of VectorDrawable
POM_URL=https://github.com/telly/MrVector
POM_SCM_URL=https://github.com/telly/MrVector
POM_SCM_CONNECTION=scm:git@github.com:telly/MrVector.git
Expand All @@ -17,7 +17,7 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=eveliotc
POM_DEVELOPER_NAME=Evelio Tarazona Caceres

ANDROID_BUILD_MIN_SDK_VERSION=14
ANDROID_BUILD_MIN_SDK_VERSION=7
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.1.2
Expand Down
5 changes: 2 additions & 3 deletions library/src/main/java/com/telly/mrvector/PathParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import android.util.Log;

import java.util.ArrayList;
import java.util.Arrays;

import static android.os.Build.VERSION_CODES.LOLLIPOP;

Expand Down Expand Up @@ -189,7 +188,7 @@ private static float[] getFloats(String s) {
startPosition = endPosition + 1;
}
}
return Arrays.copyOf(results, count);
return Utils.copyOf(results, count);
} catch (NumberFormatException e) {
Log.e(LOGTAG, "error in parsing \"" + s + "\"");
throw e;
Expand Down Expand Up @@ -247,7 +246,7 @@ private PathDataNode(char type, float[] params) {

private PathDataNode(PathDataNode n) {
mType = n.mType;
mParams = Arrays.copyOf(n.mParams, n.mParams.length);
mParams = Utils.copyOf(n.mParams, n.mParams.length);
}

/**
Expand Down
25 changes: 23 additions & 2 deletions library/src/main/java/com/telly/mrvector/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import android.util.Log;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

import static android.graphics.PorterDuff.Mode;
import static android.graphics.PorterDuff.Mode.SRC_IN;
Expand Down Expand Up @@ -87,6 +85,7 @@ static int getLayoutDirection(Drawable drawable) {
*
* @hide
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
static Mode parseTintMode(int value, Mode defaultMode) {
switch (value) {
case 3: return Mode.SRC_OVER;
Expand Down Expand Up @@ -133,4 +132,26 @@ static int getChangingConfigurations(TypedArray a) {
}
return 0;
}

static float[] copyOf(float[] original, int newLength) {
if (newLength < 0) {
throw new NegativeArraySizeException(Integer.toString(newLength));
}
return copyOfRange(original, 0, newLength);
}

static float[] copyOfRange(float[] original, int start, int end) {
if (start > end) {
throw new IllegalArgumentException();
}
int originalLength = original.length;
if (start < 0 || start > originalLength) {
throw new ArrayIndexOutOfBoundsException();
}
int resultLength = end - start;
int copyLength = Math.min(resultLength, originalLength - start);
float[] result = new float[resultLength];
System.arraycopy(original, start, result, 0, copyLength);
return result;
}
}

0 comments on commit 18e60d3

Please sign in to comment.