Coder Social home page Coder Social logo

tarek360 / richpath Goto Github PK

View Code? Open in Web Editor NEW
2.3K 58.0 251.0 2.9 MB

💪 Rich Android Path. 🤡 Draw as you want. 🎉 Animate much as you can.

Home Page: https://twitter.com/a_tarek360

Java 12.59% Kotlin 87.41%
android vector-drawable animation path vector svg icons path-animation

richpath's Introduction

*** Library maintenance is paused until further notice! ***

CircleCI Release API Twitter URL

💪 Rich Android Path. 🤡 Draw as you want. 🎉 Animate much as you can.

Download sample app:

Features

  • Full Animation Control on Paths and VectorDrawables: Animate any attribute in a specific path in the VectorDrawable

fillColor, strokeColor, strokeAlpha, fillAlpha, size, width, height, scale, scaleX, scaleY, rotation, translationX, translationY, trimPathStart, trimPathEnd, trimPathOffset.

  • Path morphing:

RichPathAnimator.animate(richPath)
       .pathData(pathData1, pathData2, ...)
       .start();

Just 3 Steps to Animate any path.

1. In your layout.

    <com.richpath.RichPathView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:vector="@drawable/vector_drawable" />

2. Find your richPath.

// by path name
RichPath richPath = richPathView.findRichPathByName("path_name");
// or if it contains one path
RichPath richPath = richPathView.findFirstRichPath();
// or by index
RichPath richPath = richPathView.findRichPathByIndex(0);

3. Use the RichPathAnimator to animate your richPath.

RichPathAnimator.animate(richPath)
       .trimPathEnd(value1, value2, ...)
       .fillColor(value1, value2, ...)
       .start();

Example

notification icon vector drawable

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="32dp"
    android:height="32dp"
    android:viewportHeight="32.0"
    android:viewportWidth="32.0">

    <group
        android:pivotX="16"
        android:pivotY="6.25">
        <path
            android:name="top"
            android:fillColor="#FFF7F7F7"
            android:pathData="M22,19.8v-5c0-3.1-1.6-5.6-4.5-6.3V7.8c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5v0.7c-2.9,0.7-4.5,3.2-4.5,6.3v5l-2,2v1h16v-1L22,19.8z" />

        <path
            android:name="bottom"
            android:fillColor="#FFF7F7F7"
            android:pathData="M16,25.8c1.1,0,2-0.9,2-2h-4C14,24.9,14.9,25.8,16,25.8z" />
    </group>
</vector>

XML

    <com.richpath.RichPathView
        android:id="@+id/ic_notifications"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:vector="@drawable/ic_notifications" />

Java

RichPath top = notificationsRichPathView.findRichPathByName("top");
RichPath bottom = notificationsRichPathView.findRichPathByName("bottom");

RichPathAnimator.animate(top)
        .interpolator(new DecelerateInterpolator())
        .rotation(0, 20, -20, 10, -10, 5, -5, 2, -2, 0)
        .duration(4000)
        .andAnimate(bottom)
        .interpolator(new DecelerateInterpolator())
        .rotation(0, 10, -10, 5, -5, 2, -2, 0)
        .startDelay(50)
        .duration(4000)
        .start();

Installation

Add the following dependency to your module build.gradle file:

dependencies {
	...
	implementation 'com.github.tarek360.RichPath:animator:0.1.1'
}

Add this to your root build.gradle file (not your module build.gradle file) :

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

More Control by the RichPathAnimator

  • Animate multiple paths sequentially or at the same time
RichPathAnimator
       .animate(richPath1, richPath2)
       .rotation(value1, value2, ...)

       //Animate the same path or another with different animated attributes.
       .andAnimate(richPath3)
       .scale(value1, value2, ...)

       //Animate after the end of the last animation.
       .thenAnimate(richPath4)
       .strokeColor(value1, value2, ...)

       // start your animation 🎉
       .start();
  • Which one of the paths is clicked?
richPathView.setOnPathClickListener(new RichPath.OnPathClickListener() {
    @Override
    public void onClick(RichPath richPath) {
       if (richPath.getName().equals("path_name")) {
           //TODO do an action when a specific path is clicked.
       }
    }
});

TODO

  • Clickable path (Done)
  • Support clip-path
  • Path animation (animate a RichPath on a path)
  • Reverse animation
  • ...

If you have any suggestion please open an issue for it.

Credits

  • florent37 He is the creator of ViewAnimator which gave me the idea of this project. Some core concepts and ideas were reused, but everything is written from scratch.
  • Android Some code is reused form the android source code and the VectorDrawableCompat support library.
  • Alex Lockwood The paths of the morphing sample is extracted from the Shape Shifter demo.

Developed By

License

Copyright 2017 Tarek360

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

richpath's People

Contributors

amrelmasry avatar jonathan-caryl avatar tarek360 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

richpath's Issues

Animation does not work, after the change Drawable.

Hello Ahmed! Thank You for library! Good work!!!
I have a small problem. I need to programmatically replace drawable.
Drawable1 and Drawable2 different only in the attribute "android: fillColor".
For example
Drawable1:
<path android:name="name" android:fillColor="#ffffff" android:pathData="M----z" />
Drawable2:
<path android:name="name" android:fillColor="#000000" android:pathData="M----z" />

Drawable successfully replaced, but RichPathAnimator stops working.

SVG Remove White space

How to remove white space around svg file? "adjustviewbound:" or "scaletype:" property not working as like normal imageview. i want to display svg image with my custom size, is it possible then please let me know.

"RichPathView" is taking whole screen even after i set it to "wrap_content" for custom width and height.

Thank you.

RichPath for iOS

Hello Team ,

I found this is very productive library .
Is there any equivalent library is available for iOS(Objective-c / Swift 4) ?

Path is not rendered as seen in vector preview (drawable-xml) in Android Studio.

The path is not rendered at right location when wrapped within a group tag with multiple attributes like:

<group
    android:width="240dp"
    android:height="280dp"
    android:pivotX="120"
    android:pivotY="140"
    android:rotation="-60"
    android:translateX="95"
    android:translateY="33">
    <path
            android:fillColor="#ffaa00"
            android:pathData=" _some-path-data_ "/>
</group>

The resultant path on device is at different screen-location than the preview shows for drawable.xml

Some device report (crashlytics) crash Caused by java.lang.NumberFormatException

Hi,
Great library, We used in our production app and we love it, keep up the good work.

But we some devices are reporting a crash with this stack trace:
"Caused by java.lang.NumberFormatException
For input string: "round""

java.lang.Integer.parseInt (Integer.java:615)
java.lang.Integer.parseInt (Integer.java:650)
com.richpath.c.c.a (XmlParser.java:139)
com.richpath.RichPath.inflate (RichPath.java:419)
com.richpath.c.c.b (XmlParser.java:88)
com.richpath.c.c.a (XmlParser.java:55)
com.richpath.RichPathView.setVectorDrawable (RichPathView.java:84)
com.richpath.RichPathView.setupAttributes (RichPathView.java:67)
com.richpath.RichPathView. (RichPathView.java:45)
com.richpath.RichPathView. (RichPathView.java:39)

According to the "round" string I see, I'm guessing it might have something to do with our vector , our path's have
android:strokeLineCap="round"
android:strokeLineJoin="round"

In them.. is that a problem ?

(we use com.github.tarek360.RichPath:animator:0.1.1 )

Release apk - Proguard - No animations?

Hi!
First of all, thank you for your work. Excellent library.
I have one little problem when exporting a signed apk with proguard. When starting face love, animations are not happening.
If turn off the animation, the animations start to work again.
Any idea?
Thanks in advance

[FIXED] the click listener on RichPath would be specific if the offset=0 in PathUtils.class because if you zoom * 14 and click in path it will handle the click of next path.

public static boolean isTouched(Path path, float x, float y) {
Region region = new Region();
RectF rectF = new RectF();
path.computeBounds(rectF, true);
region.setPath(path,
new Region((int) rectF.left, (int) rectF.top, (int) rectF.right, (int) rectF.bottom));
int offset = 0;
return region.contains((int) x, (int) y)
|| region.contains((int) x + offset, (int) y + offset)
|| region.contains((int) x + offset, (int) y - offset)
|| region.contains((int) x - offset, (int) y - offset)
|| region.contains((int) x - offset, (int) y + offset);
}

java.lang.IllegalArgumentException com.richpathanimator.RichPathAnimator$1.onAnimationEnd

some device error with
image
when i `call:

`
final RichPath[] allPaths = notificationsRichPathView.findAllRichPaths();
RichPathAnimator.animate(allPaths)
.trimPathEnd(0, 1)
.duration(1000)
.thenAnimate(allPaths)
.interpolator(new AccelerateInterpolator())
.animationListener(new AnimationListener() {
@OverRide
public void onStart() {

                }

                @Override
                public void onStop() {
                    if (getView() != null) {
                        Navigation.findNavController(getView()).navigate(R.id.action_splashFragment_to_homeFragment2);
                    }
                }
            })
            .start();``

Thank you.

Load Svg from String

Ex:

<svg width="285" height="350" viewBox="0 0 285 350" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.725098 20.775C0.725098 9.78453 9.63483 0.875 20.6251 0.875H194.75L284.3 90.425V329.225C284.3 340.215 275.39 349.125 264.4 349.125H20.6251C9.63483 349.125 0.725098 340.215 0.725098 329.225V20.775Z" fill="url(#paint0_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M194.75 0.875V70.525C194.75 81.5153 203.66 90.425 214.65 90.425H284.3L194.75 0.875Z" fill="url(#paint1_linear)"/>
<defs>
<linearGradient id="paint0_linear" x1="0.725098" y1="0.875" x2="0.725098" y2="349.125" gradientUnits="userSpaceOnUse">
<stop offset="1" stop-color="#FFCA8A"/>
</linearGradient>
</defs>
</svg>

I have a kind of SVG content string. Is there any way to load from string to RichPathView?

RichPath for Kotlin

Hi, @tarek360 :)
I'm very impressed your work.
I think RichPath is the best sample for learning VectorDrawable animation.
I really appreciate it.
Do you by any chance make kotlin version?

want to get particular path in center

Hello,
I want to get particular path segment in center with whole image.
when user click on any path of svg then it will come in center.
Looking forward to hearing from you.
Thanks

crash on load :did not set the measured dimension by calling setMeasuredDimension()

Hello how do i fix the error:

4: com.richpath.RichPathView#onMeasure() did not set the measured dimension by calling setMeasuredDimension()

val richPath: RichPath? = imageViewCalibrate.findRichPathByName("1")
RichPathAnimator.animate(richPath)
.fillColor(Color.WHITE)
.start()

java.lang.IllegalStateException: View with id 2131231004: com.richpath.RichPathView#onMeasure() did not set the measured dimension by calling setMeasuredDimension()
at android.view.View.measure(View.java:25461)
at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
at android.view.View.measure(View.java:25448)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6884)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:25448)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6884)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:25448)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6884)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:25448)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6884)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:25448)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6884)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:739)
at android.view.View.measure(View.java:25448)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3361)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2203)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2460)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1934)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8127)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:731)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)

Unresolved reference: richPathView Kotlin

Hello, I have a very simple and crucial problem with the package in kotlin:

In the line below:
val richPath: RichPath = richPathView.findRichPathByName("name")

I get this error:
Unresolved reference: richPathView

Is there any solution please?

java.lang.IllegalArgumentException: Unknown color

Hi when i used this in vector

problem is in fillColor value. I have error

Caused by: java.lang.IllegalArgumentException: Unknown color
at android.graphics.Color.parseColor(Color.java:154)
at com.richpath.util.XmlParser.getAttributeColor(XmlParser.java:134)
at com.richpath.RichPath.inflate(RichPath.java:413)
at com.richpath.util.XmlParser.parsePathElement(XmlParser.java:89)
at com.richpath.util.XmlParser.parseVector(XmlParser.java:56)
at com.richpath.RichPathView.setVectorDrawable(RichPathView.java:83)
at com.richpath.RichPathView.setupAttributes(RichPathView.java:66)
at com.richpath.RichPathView.(RichPathView.java:44)
E/AndroidRuntime: at com.richpath.RichPathView.(RichPathView.java:38)

PathEffect

Hi,

First of all thanks a lot for all this work, I've been porting an iOS app that uses SVGKit extensively and RichPath has helped me a lot in this endeavour.

I have yet to find a replacement for dash pattern effects I could create easily on iOS using native CAShapeLayer properties like lineDashPattern. Android seems to create the same effect using pathEffects property on Paint, but those are not accessible using on a rich RichPath.

If I'm not mistaken other properties on RichPath like strokeLineJoin are copied to an underlying private Paint property. Would it be possible to add a way to set a strokePathEffect too ?

Thanks a lot for considering

some path do not show sometime?

<path android:pathData="m81 508 910 -24 6 254 -914 28 -2 -258z" android:strokeColor="#000" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="6" />

Path is not properly centered aligned inside RichPathView.

sc
For different width of RichPathView RichPath has different position some are slightly top some centered Vertically but as of requirement they have to be properly center vertical aligned so that they look like in single line. Hope you understand what i am trying to say.

Path Morphing - ArrayIndexOutOfBoundsException

I am trying to accomplish a path morphing animation. My code is below (written in Kotlin).

Animation call:

val waves = holder.settingVibrationOptionRichPath!!.findFirstRichPath()
val up = context.getString(R.string.icon_vibration_up)
val down = context.getString(R.string.icon_vibration_down)

 RichPathAnimator
     .animate(waves)
     .pathData(down)
     .duration(600)
     .thenAnimate(waves)
     .pathData(up)
     .duration(600)
     .start()

RichPathView assigned vector:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="40dp"
    android:height="40dp"
    android:viewportWidth="40"
    android:viewportHeight="40">
       <path
             android:pathData="@string/icon_vibration_up"
             android:fillColor="#ffffff"/>
</vector>

String resources:

<string name="icon_vibration_up">M28.3333,28.3167C26.0833,28.3167 24.6667,29.0167 23.4167,29.65C22.3333,30.2 21.45,30.65 20,30.65C18.5,30.65 17.6667,30.2333 16.5833,29.65C15.3333,29.0167 13.9667,28.3167 11.6667,28.3167C9.3667,28.3167 8,29.0167 6.75,29.65C5.6667,30.2 4.8,30.65 3.3333,30.65L3.3333,33.9C5.5833,33.9 7,33.2 8.25,32.5667C9.3333,32.0167 10.2,31.5667 11.6667,31.5667C13.1333,31.5667 14,31.9833 15.0833,32.5667C16.3333,33.2 17.7,33.9 20,33.9C22.3,33.9 23.6667,33.2 24.9167,32.5667C26,32.0167 26.8833,31.5667 28.3333,31.5667C29.8333,31.5667 30.6667,31.9833 31.75,32.5667C33,33.2 34.3833,33.9 36.6667,33.9V30.65C35.1667,30.65 34.3333,30.2333 33.25,29.65C32,29.0167 30.5833,28.3167 28.3333,28.3167ZM28.3333,20.9C26.0833,20.9 24.6667,21.6167 23.4167,22.2333C22.3333,22.7667 21.45,23.2333 20,23.2333C18.5,23.2333 17.6667,22.8167 16.5833,22.2333C15.3333,21.6 13.9667,20.9 11.6667,20.9C9.3667,20.9 8,21.6167 6.75,22.2333C5.6667,22.7667 4.8,23.2333 3.3333,23.2333L3.3333,26.4833C5.5833,26.4833 7,25.7667 8.25,25.15C9.3333,24.5667 10.1667,24.15 11.6667,24.15C13.1667,24.15 14,24.5667 15.0833,25.15C16.3333,25.7833 17.7,26.4833 20,26.4833C22.3,26.4833 23.6667,25.7667 24.9167,25.15C26,24.5667 26.8333,24.15 28.3333,24.15C29.8333,24.15 30.6667,24.5667 31.75,25.15C33,25.7833 34.3833,26.4833 36.6667,26.4833V23.2333C35.1667,23.2333 34.3333,22.8167 33.25,22.2333C32,21.6 30.5833,20.9 28.3333,20.9ZM33.25,7.4333C32,6.8 30.6167,6.1 28.3333,6.1C26.05,6.1 24.6667,6.8 23.4167,7.4333C22.3333,7.9667 21.45,8.4333 20,8.4333C18.5,8.4333 17.6667,8.0167 16.5833,7.4333C15.3333,6.8167 13.9667,6.1 11.6667,6.1C9.3667,6.1 8,6.8 6.75,7.4333C5.6667,7.9833 4.8,8.4333 3.3333,8.4333L3.3333,11.65C5.5833,11.65 7,10.9333 8.25,10.3167C9.3333,9.7667 10.2,9.3167 11.6667,9.3167C13.1333,9.3167 14,9.7333 15.0833,10.3167C16.3333,10.95 17.7,11.65 20,11.65C22.3,11.65 23.6667,10.9333 24.9167,10.3167C26,9.7833 26.8833,9.3167 28.3333,9.3167C29.8333,9.3167 30.6667,9.7333 31.75,10.3167C33,10.95 34.3833,11.65 36.6667,11.65V8.4C35.1667,8.4 34.3333,7.9833 33.25,7.4333V7.4333ZM28.3333,13.4833C26.0833,13.4833 24.6667,14.2 23.4167,14.8167C22.3333,15.4 21.5,15.8167 20,15.8167C18.5,15.8167 17.6667,15.4 16.5833,14.8167C15.3333,14.1833 13.9667,13.4833 11.6667,13.4833C9.3667,13.4833 8,14.2 6.75,14.8167C5.6667,15.4 4.8333,15.8167 3.3333,15.8167L3.3333,19.0667C5.5833,19.0667 7,18.35 8.25,17.7333C9.3333,17.2 10.2167,16.7333 11.6667,16.7333C13.1167,16.7333 14,17.15 15.0833,17.7333C16.3333,18.3667 17.7,19.0667 20,19.0667C22.3,19.0667 23.6667,18.35 24.9167,17.7333C26,17.2 26.8833,16.7333 28.3333,16.7333C29.8333,16.7333 30.6667,17.15 31.75,17.7333C33,18.3667 34.3833,19.0667 36.6667,19.0667V15.8167C35.1667,15.8167 34.3333,15.4 33.25,14.8167C32,14.1833 30.5833,13.4833 28.3333,13.4833Z</string>

<string name="icon_vibration_down">M11.6667,11.6833C13.9167,11.6833 15.3333,10.9833 16.5833,10.35C17.6667,9.8 18.55,9.35 20,9.35C21.5,9.35 22.3333,9.7667 23.4167,10.35C24.6667,10.9833 26.0333,11.6833 28.3333,11.6833C30.6333,11.6833 32,10.9833 33.25,10.35C34.3333,9.8 35.2,9.35 36.6667,9.35V6.1C34.4167,6.1 33,6.8 31.75,7.4333C30.6667,7.9833 29.8,8.4333 28.3333,8.4333C26.8667,8.4333 26,8.0167 24.9167,7.4333C23.6667,6.8 22.3,6.1 20,6.1C17.7,6.1 16.3333,6.8 15.0833,7.4333C14,7.9833 13.1167,8.4333 11.6667,8.4333C10.1667,8.4333 9.3333,8.0167 8.25,7.4333C7,6.8 5.6167,6.1 3.3333,6.1V9.35C4.8333,9.35 5.6667,9.7667 6.75,10.35C8,10.9833 9.4167,11.6833 11.6667,11.6833ZM11.6667,19.1C13.9167,19.1 15.3333,18.3833 16.5833,17.7667C17.6667,17.2333 18.55,16.7667 20,16.7667C21.5,16.7667 22.3333,17.1833 23.4167,17.7667C24.6667,18.4 26.0333,19.1 28.3333,19.1C30.6333,19.1 32,18.3833 33.25,17.7667C34.3333,17.2333 35.2,16.7667 36.6667,16.7667V13.5167C34.4167,13.5167 33,14.2333 31.75,14.85C30.6667,15.4333 29.8333,15.85 28.3333,15.85C26.8333,15.85 26,15.4333 24.9167,14.85C23.6667,14.2167 22.3,13.5167 20,13.5167C17.7,13.5167 16.3333,14.2333 15.0833,14.85C14,15.4333 13.1667,15.85 11.6667,15.85C10.1667,15.85 9.3333,15.4333 8.25,14.85C7,14.2167 5.6167,13.5167 3.3333,13.5167V16.7667C4.8333,16.7667 5.6667,17.1833 6.75,17.7667C8,18.4 9.4167,19.1 11.6667,19.1ZM6.75,32.5667C8,33.2 9.3833,33.9 11.6667,33.9C13.95,33.9 15.3333,33.2 16.5833,32.5667C17.6667,32.0333 18.55,31.5667 20,31.5667C21.5,31.5667 22.3333,31.9833 23.4167,32.5667C24.6667,33.1833 26.0333,33.9 28.3333,33.9C30.6333,33.9 32,33.2 33.25,32.5667C34.3333,32.0167 35.2,31.5667 36.6667,31.5667V28.35C34.4167,28.35 33,29.0667 31.75,29.6833C30.6667,30.2333 29.8,30.6833 28.3333,30.6833C26.8667,30.6833 26,30.2667 24.9167,29.6833C23.6667,29.05 22.3,28.35 20,28.35C17.7,28.35 16.3333,29.0667 15.0833,29.6833C14,30.2167 13.1167,30.6833 11.6667,30.6833C10.1667,30.6833 9.3333,30.2667 8.25,29.6833C7,29.05 5.6167,28.35 3.3333,28.35V31.6C4.8333,31.6 5.6667,32.0167 6.75,32.5667V32.5667ZM11.6667,26.5167C13.9167,26.5167 15.3333,25.8 16.5833,25.1833C17.6667,24.6 18.5,24.1833 20,24.1833C21.5,24.1833 22.3333,24.6 23.4167,25.1833C24.6667,25.8167 26.0333,26.5167 28.3333,26.5167C30.6333,26.5167 32,25.8 33.25,25.1833C34.3333,24.6 35.1667,24.1833 36.6667,24.1833V20.9333C34.4167,20.9333 33,21.65 31.75,22.2667C30.6667,22.8 29.7833,23.2667 28.3333,23.2667C26.8833,23.2667 26,22.85 24.9167,22.2667C23.6667,21.6333 22.3,20.9333 20,20.9333C17.7,20.9333 16.3333,21.65 15.0833,22.2667C14,22.8 13.1167,23.2667 11.6667,23.2667C10.1667,23.2667 9.3333,22.85 8.25,22.2667C7,21.6333 5.6167,20.9333 3.3333,20.9333V24.1833C4.8333,24.1833 5.6667,24.6 6.75,25.1833C8,25.8167 9.4167,26.5167 11.6667,26.5167Z</string>

Resulting exception:

java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
        at com.richpathanimator.PathEvaluator.evaluate(PathEvaluator.java:26)
        at com.richpathanimator.PathEvaluator.evaluate(PathEvaluator.java:12)
        at android.animation.KeyframeSet.getValue(KeyframeSet.java:202)
        at android.animation.PropertyValuesHolder.calculateValue(PropertyValuesHolder.java:1017)
        at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1542)
        at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:987)
        at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)
        at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)
        at android.animation.ValueAnimator.start(ValueAnimator.java:1069)
        at android.animation.ValueAnimator.start(ValueAnimator.java:1088)
        at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
        at android.animation.ValueAnimator.startWithoutPulsing(ValueAnimator.java:1081)
        at android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1142)
        at android.animation.AnimatorSet.startAnimation(AnimatorSet.java:1227)
        at android.animation.AnimatorSet.start(AnimatorSet.java:729)
        at android.animation.AnimatorSet.start(AnimatorSet.java:684)
        at com.richpathanimator.RichPathAnimator.start(RichPathAnimator.java:142)
        at com.richpathanimator.RichPathAnimator.start(RichPathAnimator.java:138)
        at com.richpathanimator.AnimationBuilder.start(AnimationBuilder.java:88)

I would greatly appreciate it if someone could help me. I have tried using the code in the vector paths in the animals example in the sample application, but I can't figure out the difference that is causing this exception.

One difference I have noticed is the size of the vector paths are different sizes. The vector paths in the animals example are ~9000 character whereas the paths I am using are ~4000 characters.

Thank you,
-Seth

Need zoom feature and Download vector graphics from server feature

Hi Tarek,

I like your library. I have very useful and powerful. But two features are missing in your library.

  1. Zoom feature. It will help to fill the path tiny places.
  2. If we have put graphic xml file on the server or in the sdcard. then it should be load by your library.

repeatCount does not work

RichPathAnimator.animate(top)
                .interpolator(new DecelerateInterpolator())
                .rotation(0, 20, -20, 10, -10, 5, -5, 2, -2, 0)
                .duration(4000)
                .repeatCount(Integer.MAX_VALUE)
                .andAnimate(bottom)
                .interpolator(new DecelerateInterpolator())
                .rotation(0, 10, -10, 5, -5, 2, -2, 0)
                .startDelay(50)
                .duration(4000)
                .repeatCount(Integer.MAX_VALUE)
                .start();

when i use ".repeatCount(Integer.MAX_VALUE)" , the image is quiet

Editor. Render error

Upgrade to Android Studio 2.3 and then the editor displays this error:
The following classes could not be instantiated:
- com.richpath.RichPathView (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.

api <21 issue

hi
everything is ok on api >20 , but when run app on android 4.4.4 or 4.1.1 (Genymotion) my app FC!

here is log :

08-30 07:36:03.414 2632-2632/ir.romroid.illustrativebattery E/AndroidRuntime: FATAL EXCEPTION: main
Process: ir.romroid.illustrativebattery, PID: 2632
java.lang.RuntimeException: Unable to start activity ComponentInfo{ir.romroid.illustrativebattery/ir.romroid.illustrativebattery.activities.MainActivity_v3}: android.view.InflateException: Binary XML file line #78: Error inflating class com.richpath.RichPathView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #78: Error inflating class com.richpath.RichPathView
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at ir.romroid.illustrativebattery.activities.MainActivity_v3.onCreate(MainActivity_v3.java:90)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5001) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at ir.romroid.illustrativebattery.activities.MainActivity_v3.onCreate(MainActivity_v3.java:90) 
at android.app.Activity.performCreate(Activity.java:5231) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5001) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/__ic_launcher_vector.png from xml type xml resource ID #0x7f080006
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2356)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2311)
at android.content.res.Resources.getXml(Resources.java:988)
at com.richpath.RichPathView.setVectorDrawable(RichPathView.java:80)
at com.richpath.RichPathView.setupAttributes(RichPathView.java:67)
at com.richpath.RichPathView.(RichPathView.java:45)
at com.richpath.RichPathView.(RichPathView.java:39)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at ir.romroid.illustrativebattery.activities.MainActivity_v3.onCreate(MainActivity_v3.java:90) 
at android.app.Activity.performCreate(Activity.java:5231) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5001) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.io.FileNotFoundException: Corrupt XML binary file
at android.content.res.AssetManager.openXmlAssetNative(Native Method)
at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:488)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2338)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2311) 
at android.content.res.Resources.getXml(Resources.java:988) 
at com.richpath.RichPathView.setVectorDrawable(RichPathView.java:80) 
at com.richpath.RichPathView.setupAttributes(RichPathView.java:67) 
at com.richpath.RichPathView.(RichPathView.java:45) 
at com.richpath.RichPathView.(RichPathView.java:39) 
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at ir.romroid.illustrativebattery.activities.MainActivity_v3.onCreate(MainActivity_v3.java:90) 
at android.app.Activity.performCreate(Activity.java:5231) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5001) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
at dalvik.system.NativeStart.main(Native Method)

### please help me to fix this problem!

Vector size

The vectors in some devices with higher density the size difference is very large.
device-2017-07-18-174629
device-2017-07-18-175339

It does not support the following properties: layout_height, layout_weight

It does not support the following properties:
layout_height="0dp"
layout_weight="1"

Example code:

<LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:orientation="vertical"
                    android:paddingTop="15dp"
                    android:paddingLeft="10dp"
                    android:paddingRight="10dp"
                    android:paddingBottom="15dp">

                <android.support.v7.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="-3dp"
                        android:text="tarek360/RichPath"
                        android:gravity="center"
                        android:textColor="@android:color/white"
                        android:layout_gravity="center"
                        android:textSize="36sp"/>

                <android.support.v7.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="RichPath"
                        android:textAllCaps="true"
                        android:gravity="center"
                        android:textColor="@android:color/white"
                        android:layout_gravity="center"
                        android:textSize="12sp"/>

                <com.richpath.RichPathView
                        android:id="@+id/logo"
                        android:layout_width="match_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        app:vector="drawable/vector_ag"
                        android:layout_margin="10dp"/>

                <android.support.v7.widget.AppCompatTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="TEST RichPath"
                        android:gravity="center"
                        android:layout_marginTop="4dp"
                        android:textColor="@android:color/white"
                        android:layout_gravity="center"
                        android:textSize="24sp"/>

</LinearLayout>

ezgif com-video-to-gif

Path added using addPath not visible

The following code doesn't add anything visible to the nodeView RichPathView:

for (i in 1..4) {
  val name = "n_$i"
  val nodePath: RichPath = RichPath("M1,3 A2,2 0 1,1 5,3 A2,2 0 1,1 1,3 Z")
  nodePath.fillColor = 0xff00ff
  nodePath.fillAlpha = 1.0f
  nodePath.strokeColor = 0x00ffff
  nodePath.strokeWidth = 0.5f
  nodePath.strokeAlpha = 1.0f
  nodePath.strokeLineCap = Paint.Cap.BUTT
  nodePath.strokeLineJoin = Paint.Join.MITER
  nodePath.name = name
  nodeView.addPath(nodePath)
}

nodeView.findRichPathByName will return the added paths but they are not drawn.

Whereas by using adding paths created in a different RichPathView draws them as expected.

val nodeFactory = RichPathView(this)
for (i in 1..5) {
  val name = "n_$i"
  nodeFactory?.setVectorDrawable(R.drawable.node)
  val nodePath = nodeFactory?.findRichPathByName("node")!!
  nodePath.name = name
  nodeView.addPath(nodePath)
}

ArrayIndexOutOfBoundsException

When try to animate below code

String scanPath = getString(R.string.scan_path1);
        String qrPath = getString(R.string.qr_path1);
        final RichPath richPath = qrAnim.findFirstRichPath();
        RichPathAnimator
                .animate(richPath)
                .pathData(scanPath)
                .duration(600)
                .thenAnimate(richPath)
                .pathData(qrPath)
                .duration(600)
                .start();

and two concerned strings

 <string name="qr_path1">M 0 224 L 192 224 L 192 32 L 0 32 L 0 224 Z M 64 96 L 128 96 L 128 160 L 64 160 L 64 96 Z M 256 32 L 256 224 L 448 224 L 448 32 L 256 32 Z M 384 160 L 320 160 L 320 96 L 384 96 L 384 160 Z M 0 480 L 192 480 L 192 288 L 0 288 L 0 480 Z M 64 352 L 128 352 L 128 416 L 64 416 L 64 352 Z M 416 288 L 448 288 L 448 416 L 352 416 L 352 384 L 320 384 L 320 480 L 256 480 L 256 288 L 352 288 L 352 320 L 416 320 L 416 288 Z M 416 448 L 448 448 L 448 480 L 416 480 L 416 448 Z M 352 448 L 384 448 L 384 480 L 352 480 L 352 448 Z</string>
    <string name="scan_path1">M 3 5 L 3 9 L 5 9 L 5 5 L 9 5 L 9 3 L 5 3 C 3.9 3 3 3.9 3 5 Z M 5 15 L 3 15 L 3 19 C 3 20.1 3.9 21 5 21 L 9 21 L 9 19 L 5 19 L 5 15 Z M 19 19 L 15 19 L 15 21 L 19 21 C 20.1 21 21 20.1 21 19 L 21 15 L 19 15 L 19 19 Z M 19 3 L 15 3 L 15 5 L 19 5 L 19 9 L 21 9 L 21 5 C 21 3.9 20.1 3 19 3 Z</string>

Got below error

java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
        at com.richpathanimator.PathEvaluator.evaluate(PathEvaluator.java:26)
        at com.richpathanimator.PathEvaluator.evaluate(PathEvaluator.java:12)
        at android.animation.KeyframeSet.getValue(KeyframeSet.java:202)
        at android.animation.PropertyValuesHolder.calculateValue(PropertyValuesHolder.java:1017)
        at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1531)
        at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:987)
        at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:668)
        at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:631)
        at android.animation.ValueAnimator.start(ValueAnimator.java:1060)
        at android.animation.ValueAnimator.start(ValueAnimator.java:1079)
        at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
        at android.animation.ValueAnimator.startWithoutPulsing(ValueAnimator.java:1072)
        at android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1142)
        at android.animation.AnimatorSet.startAnimation(AnimatorSet.java:1227)

Off topic: Is there a collection of pre made animated vector drawables somewhere?

Take the following example included in the Readme itself.

image

There's something about the motion, the way the bell moves and the clapper thingy follows. It looks natural, real. I as a developer could not have made this. This is the realm of designers.

And so for the most part, I am at the mercy of what I can Google up and I wonder how others make use of animated vector drawables in general. So I ask, does anyone know of a collection of animated vector drawable files? Something like lottie files perhaps. I reckon this would be immensely helpful to a lot of developers

Scale with action

Hi, I try make scale animation in onClickListener with your library but this dont work.
scale to zero work but when click again scale to 1 dont work.
if (!notif) {
RichPathAnimator rigRichPathAnimator = RichPathAnimator.animate(line5)
.scaleX(0)
.scaleY(0)
.duration(700)
.start();
} else {
RichPathAnimator rigRichPathAnimator = RichPathAnimator.animate(line5)
.scaleX(1)
.scaleY(1)
.duration(700)
.start();
}
notif = !notif;

AnimationBuilder custom how use?

I am sorry.
I don't know how to use AnimationBuilder.java custom method.
And I want control the progress of the animation, pause the animation.
Can you help me ? Thank you.
My English is poor,I'm sorry for that.

Does not support Clip-Path?

I have clipped my Vector in a circle clip-path and when I am using ImageView the vector is clipped and shown the way I want, but when using RichPathVew the clipping is gone.
Any idea why?

Off path click detected

Hi, you have created great library.

I have found one issue like when i click slightly out of path then it still detect nearby path rather then click path.
How this can be possible?
Please assist me on this for how can i overcome from this.

Thank you.

find all paths in a pathView - findAllRichPaths()

There is a use case where we want to get all of the paths in the vector drawable to animate simultaneously or sequentially.

so instead of doing something like this

RichPath[] paths = new RichPath[20];

for (int i = 0; i < paths.length; i++) {
  paths[i] = pathView.findRichPathByIndex(i);
}

RichPathAnimator
  .animate(paths)
  .trimPathEnd(0, 1)
  .duration(1600)
  .start();

if we have this API findAllRichPaths() we can do this:

RichPathAnimator
  .animate(pathView.findAllRichPaths())
  .trimPathEnd(0, 1)
  .duration(1600)
  .start();

also check this usecase on stackoverflow.

Load Original SVG

Hello,
Can we load original svg in richpath view?
I have put svg in Raw folder and without convert it into vector drawable file want to load in richpath.
is this possible?
Looking forward to hearing from you.
Thanks

View not showing on samsung phones

Hello, I am trying to use your library to draw a simple path. Here is my vector:

<path
    android:name="path_outer"
    android:fillAlpha="0"
    android:fillColor="#00000000"
    android:fillType="evenOdd"
    android:pathData="M 6.025 16.311 C 6.748 16.988 7.511 17.713 8.281 18.496 L 8.281 18.5 C 8.282 18.499 8.282 18.499 8.283 18.498 C 8.283 18.499 8.284 18.499 8.285 18.5 L 8.285 18.496 C 11.138 15.598 13.869 13.494 14.957 11.702 C 18.104 6.511 14.144 0.503 8.285 0.5 L 8.285 0.5 C 8.284 0.5 8.283 0.5 8.283 0.5 C 8.282 0.5 8.282 0.5 8.281 0.5 L 8.281 0.5 C 2.423 0.503 -1.537 6.511 1.61 11.701 C 2.144 12.581 3.075 13.537 4.222 14.625"
    android:strokeWidth="1"
    android:strokeAlpha="0.2"
    android:strokeColor="#ffffff"
    android:strokeLineCap="round"
    android:strokeLineJoin="round" />
<path
    android:name="path_middle"
    android:fillColor="#00000000"
    android:pathData="M 12.301 6.847 C 12.433 7.256 12.503 7.69 12.503 8.143 C 12.503 10.472 10.615 12.363 8.285 12.363 C 5.955 12.363 4.066 10.472 4.066 8.143 C 4.066 5.813 5.955 3.923 8.285 3.923 C 9.568 3.923 10.718 4.497 11.492 5.401"
    android:strokeWidth="1"
    android:strokeAlpha="0.2"
    android:strokeColor="#f0f0f0"
    android:strokeLineCap="round"
    android:strokeLineJoin="round" />
<path
    android:name="path_inner"
    android:fillColor="#00000000"
    android:pathData="M 9.833 8.143 C 9.833 8.415 9.761 8.682 9.625 8.917 C 9.49 9.153 9.294 9.349 9.059 9.484 C 8.823 9.62 8.556 9.692 8.284 9.692 C 8.012 9.692 7.745 9.62 7.51 9.484 C 7.274 9.349 7.078 9.153 6.943 8.917 C 6.807 8.682 6.735 8.415 6.735 8.143 C 6.735 7.732 6.898 7.338 7.189 7.048 C 7.479 6.757 7.873 6.594 8.284 6.594 C 8.695 6.594 9.089 6.757 9.379 7.048 C 9.67 7.338 9.833 7.732 9.833 8.143 Z"
    android:strokeWidth="1"
    android:strokeAlpha="0.2"
    android:strokeColor="#f0f0f0"
    android:strokeLineCap="round"
    android:strokeLineJoin="round" />

<path
    android:name="path_outer"
    android:fillAlpha="0"
    android:fillColor="#00000000"
    android:fillType="evenOdd"
    android:pathData="M 6.025 16.311 C 6.748 16.988 7.511 17.713 8.281 18.496 L 8.281 18.5 C 8.282 18.499 8.282 18.499 8.283 18.498 C 8.283 18.499 8.284 18.499 8.285 18.5 L 8.285 18.496 C 11.138 15.598 13.869 13.494 14.957 11.702 C 18.104 6.511 14.144 0.503 8.285 0.5 L 8.285 0.5 C 8.284 0.5 8.283 0.5 8.283 0.5 C 8.282 0.5 8.282 0.5 8.281 0.5 L 8.281 0.5 C 2.423 0.503 -1.537 6.511 1.61 11.701 C 2.144 12.581 3.075 13.537 4.222 14.625"
    android:strokeWidth="1"
    android:strokeAlpha="0"
    android:strokeColor="#ffffff"
    android:strokeLineCap="round"
    android:strokeLineJoin="round"
    android:trimPathEnd="1" />
<path
    android:name="path_middle"
    android:fillColor="#00000000"
    android:pathData="M 12.301 6.847 C 12.433 7.256 12.503 7.69 12.503 8.143 C 12.503 10.472 10.615 12.363 8.285 12.363 C 5.955 12.363 4.066 10.472 4.066 8.143 C 4.066 5.813 5.955 3.923 8.285 3.923 C 9.568 3.923 10.718 4.497 11.492 5.401"
    android:strokeWidth="1"
    android:strokeAlpha="0"
    android:strokeColor="#f0f0f0"
    android:strokeLineCap="round"
    android:strokeLineJoin="round"
    android:trimPathEnd="1" />
<path
    android:name="path_inner"
    android:fillColor="#00000000"
    android:pathData="M 9.833 8.143 C 9.833 8.415 9.761 8.682 9.625 8.917 C 9.49 9.153 9.294 9.349 9.059 9.484 C 8.823 9.62 8.556 9.692 8.284 9.692 C 8.012 9.692 7.745 9.62 7.51 9.484 C 7.274 9.349 7.078 9.153 6.943 8.917 C 6.807 8.682 6.735 8.415 6.735 8.143 C 6.735 7.732 6.898 7.338 7.189 7.048 C 7.479 6.757 7.873 6.594 8.284 6.594 C 8.695 6.594 9.089 6.757 9.379 7.048 C 9.67 7.338 9.833 7.732 9.833 8.143 Z"
    android:strokeWidth="1"
    android:strokeAlpha="0"
    android:strokeColor="#f0f0f0"
    android:strokeLineCap="round"
    android:strokeLineJoin="round"
    android:trimPathEnd="1" />

everything works fine, except when using on samsung phones. I've tried Samsung Galaxy A5 2016 and Samsung Galaxy Note 9, no image

app crash when load map svg

@tarek360
getting this error on load of svg
getting null pointer error some times on click of path

richPathView.setOnPathClickListener { richPath ->
   MyLog.e(TAG,richPath.name)   // error line
}

some times not getting path name i have to click multiple times why it is taking time

this is my code in xml


 <com.richpath.RichPathView
        android:id="@+id/richPathView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:vector="@drawable/ic_map" />
  • it's also not allow me to change android:layout_width or height i'll set particular width and height but it's not changing
  • if i increase size from drawable then it's doesn't show image in all device ex.(if i increase size
android:width="530dp"
   android:height="411dp"

in drawable then it's doesn't show image)

this is my svg file which i am trying to show
https://a.uguu.se/jT23gktObtVY_ic_map.xml

notificationsRichPathView.findRichPathByName not recognize

hey guys this is not recognizing this line:
notificationsRichPathView
from
RichPath top = notificationsRichPathView.findRichPathByName("top");
RichPath bottom = notificationsRichPathView.findRichPathByName("bottom");

i have tries usingRichpathView and i dont find class with the method "findRichPathByName"

i get error program type already present

Program type already present: android.support.design.widget.CoordinatorLayout$BehaviorMessage{kind=ERROR, text=Program type already present: android.support.design.widget.CoordinatorLayout$Behavior, sources=[Unknown source file], tool name=Optional.of(D8)}

Binary XML file line #0: Error inflating class com.richpath.RichPathView

Hello,
I have already use the library at other sample projects and works perfect.

i created a new project:
minSdkVersion 21
targetSdkVersion 26

  <com.richpath.RichPathView
        android:id="@+id/rpv_loader"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="170dp"
        app:vector="@drawable/ic_accept_48" />

xml preview works fine but when i run the app it crashes with:

**FATAL EXCEPTION:  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myalgosapp.www.myalgos/com.myalgosapp.www.myalgos.activities.dashboard.ActivityConnect}: android.view.InflateException: Binary XML file line #0: Error inflating class com.richpath.RichPathView
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:135)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:372)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                                           Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.richpath.RichPathView
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:633)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                                                                              at com.myalgosapp.www.myalgos.activities.dashboard.ActivityConnect.onCreate(ActivityConnect.java:17)
                                                                              at android.app.Activity.performCreate(Activity.java:5990)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
                                                                           Caused by: java.lang.reflect.InvocationTargetException
                                                                              at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:607)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                                                                              at com.myalgosapp.www.myalgos.activities.dashboard.ActivityConnect.onCreate(ActivityConnect.java:17) 
                                                                              at android.app.Activity.performCreate(Activity.java:5990) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
                                                                           Caused by: java.lang.IllegalArgumentException: Unknown color
                                                                              at android.graphics.Color.parseColor(Color.java:216)
                                                                              at com.richpath.util.XmlParser.getAttributeColor(XmlParser.java:134)
                                                                              at com.richpath.RichPath.inflate(RichPath.java:413)
                                                                              at com.richpath.util.XmlParser.parsePathElement(XmlParser.java:89)
                                                                              at com.richpath.util.XmlParser.parseVector(XmlParser.java:56)
                                                                              at com.richpath.RichPathView.setVectorDrawable(RichPathView.java:83)
                                                                              at com.richpath.RichPathView.setupAttributes(RichPathView.java:66)
                                                                              at com.richpath.RichPathView.<init>(RichPathView.java:44)
                                                                              at com.richpath.RichPathView.<init>(RichPathView.java:38)
                                                                              at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                                                                              at com.myalgosapp.www.myalgos.activities.dashboard.ActivityConnect.onCreate(ActivityConnect.java:17) 
                                                                              at android.app.Activity.performCreate(Activity.java:5990) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)** 

Thank you for your time!

Double animation on one path not working

Hi,
I'm currently trying to path.setScale(0) on a click button and on another click button make path.setScale(1). The first animation working perfectly, the path is disappearing as wanted, but the second is not working. Here is the code :

                    RichPath pathb = view.findRichPathByName("test3");
                    if (!menuItem.isSelected()) {
                        RichPathAnimator.animate(pathb).scale(0,0).start();
                    } else {
                        RichPathAnimator.animate(pathb).scale(1,1).start();
                    }

`

Does someone as an idea why the second animation is not working?
Thanks!

draw glitch on specific phone type

Hi i make trimPathEnd animation and try on 5 type phone. But only on HTC one a9 with android 7 have ugly glitch when trimPathEnd = 0.
When i hide all icons. When animation end i have on screen have two little white point and this make only in this htc phone. Workerround is something like that.

add to animation .animationListener(new AnimationListener() {
@OverRide
public void onStart() {

                    }

                    @Override
                    public void onStop() {
                        line1.setFillColor(Color.TRANSPARENT);
                        line1.setStrokeColor(Color.TRANSPARENT);
                    }
                })

i attach screen
screenshot_20171109-154344
screenshot_20171109-153927

It is in the project https://github.com/rmasarovic/RichPathAnimationTest.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.