Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Toast;

import com.wnafee.vector.MorphButton;
import com.wnafee.vector.MorphButton.MorphState;
import com.wnafee.vector.MorphButton.OnStateChangedListener;
import com.wnafee.vector.compat.ResourcesCompat;

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class MainActivity extends ActionBarActivity {
Expand Down Expand Up @@ -56,6 +58,10 @@ public void onStateChanged(MorphState changedTo, boolean isAnimating) {

LinearLayout ll = (LinearLayout) findViewById(R.id.base_view);
ll.addView(mb);

ImageView bezierImageView = new ImageView(this);
bezierImageView.setImageDrawable(ResourcesCompat.getDrawable(this, R.drawable.basic_bezier));
ll.addView(bezierImageView);
}


Expand Down
13 changes: 13 additions & 0 deletions library/src/main/java/com/wnafee/vector/compat/PathParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ private static float[] getFloats(String s) {
private static void extract(String s, int start, ExtractFloatResult result) {
// Now looking for ' ', ',' or '-' from the start.
int currentIndex = start;
boolean foundDot = false;
boolean foundSeparator = false;
result.mEndWithNegSign = false;
for (; currentIndex < s.length(); currentIndex++) {
Expand All @@ -212,6 +213,18 @@ private static void extract(String s, int start, ExtractFloatResult result) {
case ',':
foundSeparator = true;
break;
case '.':
if (foundDot) {
// Some SVG compressors will try to be clever and include strings like
// "1.5.5", which really means "1.5 0.5".
// So we need to count the number of dots and consider it a separator
// if we've already seen one.
foundSeparator = true;
currentIndex--; // because the next float needs to include the "."
} else {
foundDot = true;
}
break;
case '-':
if (currentIndex != start) {
foundSeparator = true;
Expand Down
18 changes: 18 additions & 0 deletions library/src/main/res/drawable/basic_bezier.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:width="100dp"
android:height="100dp"
android:viewportWidth="100"
android:viewportHeight="100"
app:vc_viewportWidth="100"
app:vc_viewportHeight="100"
>
<path
android:fillColor="#000000"
android:pathData="s 25.0.50 0 25"
app:vc_fillColor="#000000"
app:vc_pathData="s 25.0.25 0 25"
/>
</vector>