Giter Site home page Giter Site logo

cortinico / slidetoact Goto Github PK

View Code? Open in Web Editor NEW
1.2K 24.0 159.0 7.18 MB

A simple 'Slide to Unlock' Material widget for Android, written in Kotlin 📱🎨🦄

License: MIT License

Java 35.56% Kotlin 64.44%
kotlin kotlin-android kotlin-library android-library android-ui android-development material-design material-ui material material-components

slidetoact's Introduction

Slide To Act

CircleCI Maven Central Android Weekly License Twitter Awesome Kotlin Badge

A simple Slide to Unlock Material widget for Android, written in Kotlin 🇰.

sample-slidetoact gif

Getting Started 👣

Slide To Act is distributed through Maven Central. To use it you need to add the following Gradle dependency to your android app gradle file (NOT the root file):

dependencies {
   implementation "com.ncorti:slidetoact:0.11.0"
}

Or you can download the .AAR artifact directly from Maven Central.

Example 🚸

After setting up the Gradle dependency, you can use SlideToActView widgets inside your XML Layout files

<com.ncorti.slidetoact.SlideToActView
    android:id="@+id/example"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:text="Example" />

And bind them inside your Java/Kotlin code:

SlideToActView sta = (SlideToActView) findViewById(R.id.example);

Features 🎨

  • 100% Vectorial, no .png or other assets provided.
  • Fancy animations! 🦄
  • API >= 14 compatible (since v0.2.0)
  • Easy to integrate (just a gradle compile line).
  • Integrated with your app theme 🖼.
  • Works out of the box, no customization needed.
  • Written in Kotlin (but you don't need Kotlin to use it)!
  • UX Friendly 🐣, button will bump to complete if it's over the 80% of the slider (see the following gif).

ux_friendly gif

Attributes

By the default, every SlideToActView widget fits to your app using the colorAccent and the colorBackground parameters from your theme. You can customize your SlideToActView using the following custom attributes.

<com.ncorti.slidetoact.SlideToActView
    android:id="@+id/example_gray_on_green"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="6dp"
    app:area_margin="4dp"
    app:animation_duration="250"
    app:outer_color="@color/green"
    app:inner_color="@color/grey"
    app:border_radius="2dp"
    app:text="Testing all the custom attributes"
    app:text_size="12sp"
    app:slider_height="80dp"
    app:slider_locked="false"
    app:bounce_on_start="true" />

area_margin

Use the area_marging attribute to control the margin of the inner circular button from the outside area. If not set, this attribute defaults to 8dp.

area_margin_1 area_margin_2

You can also use a negative value to have the inner circular button bigger than the slider. To achieve this effect you also need to set android:clipChildren="false" on the parent layout, like:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clipChildren="false">

    <com.ncorti.slidetoact.SlideToActView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:area_margin="-8dp"/>

to obtain this behavior:

area_margin_3

icon_margin

The attribute icon_margin let you control the margin of the icon inside the circular button. This makes the icon bigger because can take up more space in the button.

This is especially useful when you want to make the height of the slider smaller (see slider_height). In this case, if you don't adjust the icon_margin the image can be too much tiny. By default, the icon_margin is set to 16dp.

In next image you can see how it looks like:

icon_margin icon_margin

inner_color & outer_color

Use the outer_color attribute to control the color of the external area and the color of the arrow icon. If not set, this attribute defaults to colorAccent from your theme.

Use the inner_color attribute to control the color of the inner circular button, the color of the tick icon and the color of the text. If not set, this attribute defaults to colorBackground from your theme.

color_1 color_2

border_radius

Use the border_radius attribute to control the radius of the inner circular button and of the external area. A border_radius set to 0dp will result in a square slider. If not set, this attribute will render your slider as a circle (default behavior).

border_radius_1 border_radius_2

text, text_size, text_style, text_appearance

Use the text attribute to control the text of your slider. If not set, this attribute defaults to SlideToActView.

Use the text_size attribute to control the size of the text of your slider. A text_size set to 0sp will result in hiding the text. If not set, this attribute defaults to 16sp.

Use the text_style attribute to control the style of your text. Accepted values are normal, bold and italic.

Use the text_appearance attribute to provide an Android TextAppearance style to fully customize your Text. Please use this attribute if you want to use a custom font or set the text to be all caps.

slider_text slider_text_appearance

slider_height

Use the slider_height attribute to control the desired height of the widget. If not set, the widget will try to render with 72dp of height.

slider_height_1 slider_height_2

slider_locked

Use the slider_locked attribute to lock the slider (this is a boolean attribute). When a slider is locked, will always bump the button to the beginning (default is false).

locked_slider gif

You can also toggle this attribute programmatically with the provided setter.

SlideToActView sta = (SlideToActView) findViewById(R.id.slider);
sta.setLocked(true);

animation_duration

Use the animation_duration attribute to set the duration of the complete and reset animation (in milliseconds).

You can also set animation duration programmatically with the provided setter.

val sta = (SlideToActView) findViewById(R.id.slider);
sta.animDuration = 600

slider_reversed

Use the slider_reversed attribute to reverse the slider (this is a boolean attribute). When a slider is reversed, the cursor will appear on the right and will progress to the left. (default is false).

reversed_slider gif

You can also toggle this attribute programmatically with the provided setter.

SlideToActView sta = (SlideToActView) findViewById(R.id.slider);
sta.setReversed(true);

slider_icon

You can set a custom icon by setting the slider_iconattribute to a drawable resource.

custom_icon

app:slider_icon="@drawable/custom_icon"

You can also set a custom icon programmatically with the provided setter.

SlideToActView sta = findViewById(R.id.slider);
sta.setSliderIcon(R.drawable.custom_icon);

You can also disable the rotation by setting the rotate_icon attribute to false.

complete_icon

You can set a custom complete icon by setting the complete_iconattribute to a drawable resource.

custom_complete_iconcon

app:complete_icon="@drawable/slidetoact_ic_check"

You can also set a custom complete icon programmatically with the provided setter.

SlideToActView sta = findViewById(R.id.slider);
sta.setCompleteIcon(R.drawable.custom_complete_animated);

slider_icon_color

You can set a custom color for the icon by setting the slider_icon_color attribute.

custom_icon

This attribute defaults to the outer_color if set. If outer_color is not set, this attribute defaults to colorAccent from your theme.

bump_vibration

You can make the device vibrate when the cursor "bumps" to the end of the sliding path by setting the period of vibration through bump_vibration attribute in your layout XML (default is 0)

app:bump_vibration="50"

Note that the period of vibration is in milliseconds

You can achieve the same programmatically using the setter:

SlideToActView sta = (SlideToActView) findViewById(R.id.slider);
sta.setBumpVibration(50);

In order for this feature to work, you need have the permission android.permission.VIBRATE in your AndroidManifest.xml

<uses-permission android:name="android.permission.VIBRATE"/>

android:elevation

Use the android:elevation attribute to set the elevation of the widget. The widgets will take care of providing the proper ViewOutlineProvider during the whole animation (a.k.a. The shadow will be drawn properly).

elevation_1 elevation_2

state_complete

Use state_complete attribute to create SlideToActView in complete state.

app:state_complete="true"

Can be also set programmatically.

With full slide animation:

SlideToActView sta = (SlideToActView) findViewById(R.id.slider);
sta.setCompleted(completed: true, withAnimation: true);

Without slide animation:

SlideToActView sta = (SlideToActView) findViewById(R.id.slider);
sta.setCompleted(completed: true, withAnimation: false);

complete

bounce_on_start

You can enable a bounce animation for the slider when the view is first rendered by setting the bounce_on_start attribute to true (default is false) Also you can set the duration of the bounce animation by setting the bounce_duration attribute (default is 2000) and repeat count by setting the bounce_repeat attribute (default is INFINITE)

bounce on start gif

Event callbacks

You can use the OnSlideCompleteListener and the OnSlideResetListener to simply interact with the widget. If you need to perform operations during animations, you can provide an OnSlideToActAnimationEventListener. With the latter, you will be notified of every animation start/stop.

You can try the Event Callbacks in the Demo app to better understand where every callback is called.

event_log

Demo 📲

Wonna see the widget in action? Just give a try to the Example App, it's inside the example folder.

Otherwise, you can just download the APK from a CircleCI build, and try it on a real device/emulator.

example_app gif

Building/Testing ⚙️

CircleCI CircleCI

This projects is built with Circle CI. The CI environment takes care of building the library .AAR, the example app and to run the Espresso tests. Artifacts are exposed at the end of every build (both the .AAR and the .APK of the example app).

TravisCI Build Status

TravisCI builds are also running but they are considered Legacy. I'm probably going to dismiss it soon or later.

Building locally

Before building, make sure you have the following updated components from the Android SDK:

  • tools
  • platform-tools
  • build-tools-25.0.3
  • android-25
  • extra-android-support
  • extra-android-m2repository
  • extra-google-m2repository

Then just clone the repo locally and build the .AAR with the following command:

git clone [email protected]:cortinico/slidetoact.git
cd slidetoact/
./gradlew slidetoact:assemble

The assembled .AAR will be inside the slidetoact/build/outputs/aar folder.

Testing

Once you're able to build successfully, you can run Espresso tests locally with the following command.

./gradlew clean build connectedCheck 

Make sure your tests are all green ✅ locally before submitting PRs.

Contributing 🤝

Looking for contributors! Don't be shy. 😁 Feel free to open issues/pull requests to help me improve this project.

  • When reporting a new Issue, make sure to attach Screenshots, Videos or GIFs of the problem you are reporting.
  • When submitting a new PR, make sure tests are all green. Write new tests if necessary.

Honorable mentions 🎖

License 📄

This project is licensed under the MIT License - see the License file for details

slidetoact's People

Contributors

adnanhabibmirza avatar andrblum avatar artemcarabash avatar asterixorobelix avatar cortinico avatar etman55 avatar felixonmars avatar jensschadron avatar jershell avatar joshhughes-dev avatar langsmith avatar maruiz81 avatar nataliialapshyna-dna avatar nkizz avatar quanta-kt avatar redwarp avatar renovate[bot] avatar rumitpatel avatar sg-codigo avatar supasintatiyanupanwong avatar teramike avatar tgo1014 avatar tinolaomahei 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

slidetoact's Issues

ic_check not showing on Samsung 7.1.1 (API 25)

What kind of issue is this?

UI bug on Android 7.1.1 Samsung Tablet (of course it's a Samsung)

ezgif com-optimize

Details

I cannot replicate this issue on emulators or actual devices. It seems to be an issue with trimPathStart/trimPathEnd. Notice how the check mark appears briefly after resetting the view.

Migrate to androidx

Shouldn't it be migrated to androidx ?
I wanted to use this in my project, but noticed that the library isn't migrated to androidx (but my project is). This make it unusable in my project

app:icon_margin does not work

Setting icon_margin for my slider gives the following error and does not build project:

AAPT: error: attribute icon_margin (aka packageName:icon_margin) not found.

setOnClickListener not working

final SlideToActView confirm_order = findViewById(R.id.confirm_order);

confirm_order.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) { 
                 Log.d(TAG, "onClick: v " + v);
                 Toast.makeText(mContext, "Please Swipe", Toast.LENGTH_LONG).show();
             }
         });

How to make it vertical?

First of all: amazing job right here!

I was wondering if there is a way to make the slider vertical (from down to up for example?)

Thanks for the information! :D

How to implement onSlideCompleteListener event callback ?

I wasn't able to capture on slide events of the plugin. I am using the latest version 'com.ncorti:slidetoact:0.7.0'

val slideToConfirm = rootView.findViewById<SlideToActView>(R.id.frag_payment_slide_to_confirm)

slideToConfirm.onSlideCompleteListener

I am using the above interface but I can't seem to capture the events. I wasn't able to implement .setOnSlideCompleteListener. I am implementing the slider inside a Fragment.

compileSdkVersion 29
buildToolsVersion "29.0.2"
kotlin_version = '1.3.50'
gradleVersion = '3.4.2'

Set text dynamically

What kind of issue is this?

  • Feature Request. Start by telling what's problem you’re trying to solve. A Pull request is welcome as well.

Details

Have the possibility to change the text dynamically.

attribute 'app:slider_icon' not found.

Hi Nicola Corti,

Thank you for this library.

  • Functional Bug. - while adding attribute app:slider_icon gradle build failed with Error:error: attribute 'app:slider_icon' not found.

Details

  • Library Version- 0.2.0
  • Gradle Version -3.0.1
  • Android Studio Version -3.0.1

Thanks

Error Inflating class com.ncorti.slidetoact.SlideToActView

What kind of issue is this?

  • UI Bug. Please provide a Screenshot/Video/GIF of what's the problem. If you need help to record a video you can follow this guide

  • Functional Bug. Please describe the scenario of the bug. Furthermore, please spend the time to write a failing test.

  • Feature Request. Start by telling what's problem you’re trying to solve. A Pull request is welcome as well.

Details

In case of bug report, please don't forget to include also:

  • Library Version.
  • Android Version.
  • Emulator/Device specs.
  • Logs/Crash reports/Stacktraces.
  • Example Code/Link to repositories.

SlideToActView class should open

Just think this class should open so that people can easily custom it on their end. :)

Anyway, this is a great component, thank you!

please support android minSdkVersion 14 or less.

please support android minSdkVersion 14 or less.Beacuse still have lots of user use phone follow in Android 5.0,if minSdkVersion is higher,that mean lots of people can not use this library.
I suggest auther provide two version for this library(slidetoact),one is use in minSdkVersion 14 or less,and another is use in minSdkVersion 21.

thanks.

Getting this bug from older devices in my firebase crashlytics

slidetoact

Hey!
First of all, thank you for the amazing library. I sent you the stacktrace I am getting when the slidetoactview is used by the older devices (still supported version though).

This device was:
VIBE K6 Power with Android 6.0.1 version.

I was using SlideToActView 0.7.0 version.

Thank you

How to create the button programmatically and modify attributes like text, color, etc?

What kind of issue is this?

  • UI Bug. Please provide a Screenshot/Video/GIF of what's the problem. If you need help to record a video you can follow this guide

  • Functional Bug. Please describe the scenario of the bug. Furthermore, please spend the time to write a failing test.

  • Feature Request. Start by telling what's problem you’re trying to solve. A Pull request is welcome as well.

Details

In case of bug report, please don't forget to include also:

  • Library Version.
  • Android Version.
  • Emulator/Device specs.
  • Logs/Crash reports/Stacktraces.
  • Example Code/Link to repositories.

API 17: Resources$NotFoundException

android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/ic_call_white_24dp.png from xml type xml resource ID #0x7f0800ca

Refers to a line of code:
val parser = res.getXml(resId)
In the method parseVectorDrawableCompat

Physically, the picture res/drawable/ic_call_white_24dp.xml is present.

Enable
vectorDrawables.useSupportLibrary = true
it is not possible, the application crashes, you will have to redo much in the application code

There are no problems on API 21 and above.

Slide from right to left

Hi,

This is an awesome library! Thank you!

Is it possible to update the slider to remain active after you switched it on?
I would like to use it to start and stop an app.

It would be awesome if you can update it to work in the following way:

  1. Slide from left to right to activate the slider.
  2. After the Done animation the slider should appear again but in this case with an <- arrow.
  3. Slide from right to left to deactivate the slider.
  4. After the Done animation the slider should appear again with an -> arrow.

Thanks.

Text gravity attribute

First of all, thanks for your awesome button!
Could you please add text gravity attribute, it will help me a lot! Thanks

feature request: Attribute to change arrow icon DP

What kind of issue is this?

  • UI Bug. Please provide a Screenshot/Video/GIF of what's the problem. If you need help to record a video you can follow this guide

  • Functional Bug. Please describe the scenario of the bug. Furthermore, please spend the time to write a failing test.

  • Feature Request. Start by telling what's problem you’re trying to solve. A Pull request is welcome as well.

Details

I would like a attribute to manually set the DP for the icon arrow.
this would be awesome for lower value slider_height like 40dp.
c54711d1-4ad0-466d-95b2-33a1f6f75343 png

Unable to change colors at runtime.

What kind of issue is this?

  • UI Bug. Please provide a Screenshot/Video/GIF of what's the problem. If you need help to record a video you can follow this guide

  • Functional Bug. Please describe the scenario of the bug. Furthermore, please spend the time to write a failing test.

  • Feature Request. Start by telling what's problem you’re trying to solve. A Pull request is welcome as well.

Details

  • Library Version. 0.3.0
  • Android Version.
  • Emulator/Device specs. **LG Q6 Android 7.1.1 **
  • Logs/Crash reports/Stacktraces.
  • Example Code/Link to repositories.

I'm working on a java based android app.
Trying to integrate this view to the project I found a problem.
I don't seem to be able to change dynamically the outer colour nor the inner either.
The slider will be displayed with not even the xml defined colours but some weird defaults as shown in the screen shot.

alt text

Am I doing something wrong?

final SlideToActView actionSlider = (SlideToActView) rowView.findViewById(R.id.slider);
actionSlider.setOuterColor(R.color.slider_outer_color);
actionSlider.setInnerColor(R.color.slider_inner_color);
actionSlider.setLocked(false);

Small screen issue

  • ✅ UI Bug / Feature request
    Screenshot 2020-03-30 at 14 42 14

No control over text positioning. For longer texts and small screens, it is not possible to set the view to show all the text that is covered by the icon. It would be nice to set the text gravity / margin.

Code:

<com.ncorti.slidetoact.SlideToActView
        android:id="@+id/slideToStartTripSlider"
        style="@style/SlideToStartTrip"
        android:layout_marginStart="@dimen/material_baseline_grid_2.5x"
        android:layout_marginTop="@dimen/material_baseline_grid_2x"
        android:layout_marginEnd="@dimen/material_baseline_grid_2.5x"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/swipeToStartGuideline" />
<style name="SlideToStartTrip">
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">match_parent</item>
        <item name="area_margin">7dp</item>
        <item name="outer_color">@color/blue</item>
        <item name="inner_color">@color/white</item>
        <item name="border_radius">28dp</item>
        <item name="text_size">@dimen/text.medium</item>
        <item name="slider_height">60dp</item>
        <item name="slider_locked">false</item>
        <item name="slider_icon_color">@color/blue</item>
        <item name="text_appearance">@style/SliderTextAppearance</item>
    </style>
    <style name="SliderTextAppearance">
        <item name="android:textSize">18sp</item>
        <item name="android:textAllCaps">false</item>
    </style>
  • Version 0.7.0
  • Android Version: 9
  • Phones: Motorola G7 / Huawei P9

Keep slided to unlock

FeatureRequest

I would like to have an attribute so I can set a value of time (maybe milliseconds) to request the button to remain-slided (sorry for my English) so the action would be effective. Or maybe not a time value but an attribute with a default inner time (as the long click).

In other words if I just slide the button it would bump as if it was locked. But if I keep it in the slided position for a time (as a long pressed button) it will unlock and perform the action.

Am I clear? Thank you very much!

Cannot use custom Icons for API level < 23

Android cannot inflate custom icon drawable on API level <23.

Library Version: 'com.ncorti:slidetoact:0.7.0'
Android Version: 6 (API 23)

stacktrace:

android.view.InflateException: Binary XML file line #210: Binary XML file line #210: Error inflating class com.ncorti.slidetoact.SlideToActView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.bitcoin.mwallet.app.viper.ScreenView.onCreateView(ScreenView.kt:36)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2605)
....
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xhdpi-v4/ic_send.png from xml type xml resource ID #0x7f08018d
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2834)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2789)
at android.content.res.Resources.getXml(Resources.java:1221)
at com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat(SlideToActView.kt:332)
at com.ncorti.slidetoact.SlideToActView.(SlideToActView.kt:306)
at com.ncorti.slidetoact.SlideToActView.(SlideToActView.kt:39)

Target with the name "check" cannot be found in the VectorDrawable to be animated

force close when complete animate in android 8.1.0 (27)

java.lang.IllegalStateException: Target with the name "check" cannot be found in the VectorDrawable to be animated.
at android.graphics.drawable.AnimatedVectorDrawable$AnimatedVectorDrawableState.prepareLocalAnimator(AnimatedVectorDrawable.java:839)
at android.graphics.drawable.AnimatedVectorDrawable$AnimatedVectorDrawableState.prepareLocalAnimators(AnimatedVectorDrawable.java:817)
at android.graphics.drawable.AnimatedVectorDrawable.ensureAnimatorSet(AnimatedVectorDrawable.java:930)
at android.graphics.drawable.AnimatedVectorDrawable.start(AnimatedVectorDrawable.java:914)
at com.ncorti.slidetoact.SlideToActView.startTickAnimation(SlideToActView.kt:611)
at com.ncorti.slidetoact.SlideToActView.access$startTickAnimation(SlideToActView.kt:38)
at com.ncorti.slidetoact.SlideToActView$startAnimationComplete$5.onAnimationUpdate(SlideToActView.kt:473)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1522)
at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:654)
at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:617)
at android.animation.ValueAnimator.start(ValueAnimator.java:1046)
at android.animation.ValueAnimator.start(ValueAnimator.java:1065)
at android.animation.ValueAnimator.startWithoutPulsing(ValueAnimator.java:1058)
at android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1142)
at android.animation.AnimatorSet.doAnimationFrame(AnimatorSet.java:1046)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.-wrap2(Unknown Source:0)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:655)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

can i change complete icon?

Render Problem in android studio 3.3.1

i add this lib to my project and get render problem :

java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to 
android.graphics.drawable.VectorDrawable   at 
android.graphics.drawable.AnimatedVectorDrawable.inflate(
AnimatedVectorDrawable.java:546)   at 
android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(
DrawableInflater.java:142)   at 
android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)   at 
android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)   at 
android.graphics.drawable.Drawable.createFromXml(Drawable.java:1266)   at 
com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:338) 
  at android.content.res.Resources_Delegate.getDrawable(Resources_Delegate.java:186) 
  at android.content.res.Resources.getDrawable(Resources.java:827)   at 
com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:227)   at 
com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:37)   at 
com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:-1)   at 
java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at 
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)   at 
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)   at 
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at 
android.view.LayoutInflater.rInflate(LayoutInflater.java:837)   at 
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)   at 
android.view.LayoutInflater.inflate(LayoutInflater.java:515)   at 
android.view.LayoutInflater.inflate(LayoutInflater.java:394)

How can i increase animation time and make it quick?

In your documentation it is there -

val sta = (SlideToActView) findViewById(R.id.slider);
sta.animDuration(600)

But my code is in java and i do not know kotlin language, How can i call the same function in java?

Hi How to change outer color programmatically in slide to Act view

What kind of issue is this?

  • UI Bug. Please provide a Screenshot/Video/GIF of what's the problem. If you need help to record a video you can follow this guide

  • Functional Bug. Please describe the scenario of the bug. Furthermore, please spend the time to write a failing test.

  • Feature Request. Start by telling what's problem you’re trying to solve. A Pull request is welcome as well.

Details

In case of bug report, please don't forget to include also:

  • Library Version.
  • Android Version.
  • Emulator/Device specs.
  • Logs/Crash reports/Stacktraces.
  • Example Code/Link to repositories.

Suggestion | Same color for text and inner circle

What kind of issue is this? - Suggestion not an issue

Please provide the function to change the text color and inner circle color based on the value provided by the user. Having the same color for the inner circle and text color doesn't fulfill all requirements.

Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/*.png from xml type xml resource ID #

I am trying to apply custom icon for the slider but getting following crash. The resource is available in drawable folder.

Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/pointing_hand.png from xml type xml resource ID #0x7f0700ab
        at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1243)
        at android.content.res.Resources.loadXmlResourceParser(Resources.java:2172)
        at android.content.res.Resources.getXml(Resources.java:1221)
        at com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat(SlideToActView.kt:296)
2019-11-04 13:30:53.979 com.** E/AndroidRuntime:     at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:271)
        at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:40)
        at com.ncorti.slidetoact.SlideToActView.<init>(Unknown Source:6)
        	... 40 more
     Caused by: java.io.FileNotFoundException: Corrupt XML binary file
        at android.content.res.AssetManager.nativeOpenXmlAsset(Native Method)
        at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:1009)
        at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1227)
        	... 46 more

My xml:

        <com.ncorti.slidetoact.SlideToActView
            android:id="@+id/btn_swipe"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/home_screen"
            android:layout_margin="30dp"
            app:area_margin="0dp"
            app:elevation="8dp"
            app:slider_icon="@drawable/arrow_right"
            app:inner_color="@color/colorAccent"
            app:outer_color="@color/colorPrimary"
            app:slider_height="64dp"
            app:slider_locked="false"
            app:rotate_icon="true"
            app:text="SWIPE TO REFLECT"
            app:text_color="@android:color/white"
            app:text_size="16sp"
            app:text_style="bold" />

Tesing device:

Samsung A30 - Android version: Pie 9

Library Version:

implementation 'com.ncorti:slidetoact:0.7.0'

Full stacktrace:

2019-11-04 13:47:16.887 com.** E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.***, PID: 27796
    android.view.InflateException: Binary XML file line #41: Binary XML file line #41: Error inflating class com.ncorti.slidetoact.SlideToActView
    Caused by: android.view.InflateException: Binary XML file line #41: Error inflating class com.ncorti.slidetoact.SlideToActView
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:686)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:829)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:902)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:905)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:863)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:554)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:461)
        at com.**.general.HomeFragment.onCreateView(HomeFragment.java:49)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
        at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1395)
        at android.app.Activity.performStart(Activity.java:7348)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3147)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1957)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7099)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
     Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi-v4/arrow_right.png from xml type xml resource ID #0x7f07005e
        at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1243)
        at android.content.res.Resources.loadXmlResourceParser(Resources.java:2172)
        at android.content.res.Resources.getXml(Resources.java:1221)
        at com.ncorti.slidetoact.SlideToActView.parseVectorDrawableCompat(SlideToActView.kt:332)
2019-11-04 13:47:16.888 com.** E/AndroidRuntime:     at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:306)
        at com.ncorti.slidetoact.SlideToActView.<init>(SlideToActView.kt:39)
        at com.ncorti.slidetoact.SlideToActView.<init>(Unknown Source:6)
        	... 40 more
     Caused by: java.io.FileNotFoundException: Corrupt XML binary file
        at android.content.res.AssetManager.nativeOpenXmlAsset(Native Method)
        at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:1009)
        at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1227)
        	... 46 more

Gradle:

compileSdkVersion 29
    defaultConfig {
        applicationId "com.***.**"
        minSdkVersion 17
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }

Please let me know if you need more details.
Thanks for your support.

Change Icon Color and drawable icons request

I was thinking that could be useful to let users choose icon style.

We only need one parameter to override the line 87 on SlideToActView:

/** Outer color used by the slider (primary) */
    var outerColor: Int = 0
        set(value) {
            field = value
            mOuterPaint.color = value
            mDrawableArrow.setTint(value)  ->> This line should to be removed or at least have some other public function to modify it
            invalidate()
        }

I'll also use this issue to ask for a way to use icon's which are images, not drawable vectors, just drawables. Could be this possible? Thanks! :D

NullPointerException

Exception throw version 7
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: kz.orange.orangetaxi, PID: 25516
                  java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
                      at android.graphics.drawable.AnimatedVectorDrawable$VectorDrawableAnimatorRT.createRTAnimator(AnimatedVectorDrawable.java:1262)
                      at android.graphics.drawable.AnimatedVectorDrawable$VectorDrawableAnimatorRT.parseAnimatorSet(AnimatedVectorDrawable.java:1220)
                      at android.graphics.drawable.AnimatedVectorDrawable$VectorDrawableAnimatorRT.init(AnimatedVectorDrawable.java:1187)
                      at android.graphics.drawable.AnimatedVectorDrawable.ensureAnimatorSet(AnimatedVectorDrawable.java:851)
                      at android.graphics.drawable.AnimatedVectorDrawable.start(AnimatedVectorDrawable.java:834)
                      at com.ncorti.slidetoact.SlideToActView.startTickAnimation(SlideToActView.kt:589)
                      at com.ncorti.slidetoact.SlideToActView.access$startTickAnimation(SlideToActView.kt:40)
                      at com.ncorti.slidetoact.SlideToActView$startAnimationComplete$5.onAnimationUpdate(SlideToActView.kt:451)
                      at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1350)
                      at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:615)
                      at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:581)
                      at android.animation.ValueAnimator.start(ValueAnimator.java:1005)
                      at android.animation.ValueAnimator.start(ValueAnimator.java:1014)
                      at android.animation.AnimatorSet.start(AnimatorSet.java:678)
                      at android.animation.AnimatorSet.onChildAnimatorEnded(AnimatorSet.java:807)
                      at android.animation.AnimatorSet.-wrap1(AnimatorSet.java)
                      at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:784)
                      at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1153)
                      at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1313)
                      at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
                      at android.animation.AnimationHandler.-wrap2(AnimationHandler.java)
                      at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:872)
                      at android.view.Choreographer.doCallbacks(Choreographer.java:686)
                      at android.view.Choreographer.doFrame(Choreographer.java:618)
                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
                      at android.os.Handler.handleCallback(Handler.java:751)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6119)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

How to create EventHandler Method in Java and not in Kotlin

SlideToActView AmountNextBtn_slide = (SlideToActView)findViewById(R.id.AmountNextBtn_Slide);
        AmountNextBtn_slide.OnSlideCompleteListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(WhooshCheque.this, WhooshSent.class);
                intent.putExtra("Name", Name);
                intent.putExtra("Number", Number);
                intent.putExtra("whooshAmount", WhooshAmount);
                intent.putExtra("WhooshAmount_NumberWord", WhooshAmount_NumberWord);
                intent.putExtra("PostDate", PostDateSelected);
                startActivity(intent);
            }
        });

this code is suppose to help bring user to next activity but the EventHandler Syntax is not correct .. it does not bring me to the next activity . Please help me ! thank u

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.