Giter Site home page Giter Site logo

elevationimageview's People

Contributors

jlurena avatar qhutch avatar simoarpe 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

elevationimageview's Issues

Proguard issue

Add a section for proguard in ReadMe file. The application was crashing continuously because it wasn't there.

Here's the proguard required for this library.

#RenderScript
-keepclasseswithmembernames class * {
native <methods>;
}
-keep class androidx.renderscript.** { *; }

Glide compatibility?

Does it work with Glide?

Edit: I tried with the sample project and couldn't make it work. Tried with the standard way of using Glide:

 (Glide.with(this).load(some_url).into(imageview1) 

and with the bitmap option:

 Glide.with(this)
                .asBitmap()
                .load(some_url)
                .into(object : CustomTarget<Bitmap>(){
                    override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
                        imageview1.setImageBitmap(resource)
                    }
                    override fun onLoadCleared(placeholder: Drawable?) {
                    }
                })

In both cases I don't see the image

Drawing over the actionbar

In my layout the actionbar is transparent. When I set the clipBounds to false, the shadow draws over the actionbar in scrolling.
screenshot_1529309272

Renderscript breaks the preview

Renderscript breaks the preview window in AndroidStudio with the follow stacktrace:

android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: no rsjni in java.library.path Support lib API: 2301 at android.support.v8.renderscript.RenderScript.internalCreate(RenderScript.java:1402) at android.support.v8.renderscript.RenderScript.create(RenderScript.java:1587) at android.support.v8.renderscript.RenderScript.create(RenderScript.java:1537) at android.support.v8.renderscript.RenderScript.create(RenderScript.java:1513) at android.support.v8.renderscript.RenderScript.create(RenderScript.java:1500) at com.qhutch.elevationimageview.ElevationImageView.onAttachedToWindow(ElevationImageView.kt:107)

Solution is to wrap the onAttachedToWindow initialisation with an if !isInEditMode()

Android P Issue: java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed

As subject title states the following error occurs:
java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
When attempting to draw the ElevationImageView on Android P.

This is due to the following line:
canvas.clipRect(rect, Region.Op.REPLACE)

See the following issue on stackoverflow for a suggested replacement:
https://stackoverflow.com/questions/50231950/what-is-the-best-alternative-to-canvas-cliprect-with-region-op-replace

[Feature Request] Drop Shadow dx dy

It works well but I was hoping i can get it to look like the shadow in textview, a bit of dx and dy
Is that possible?

I have a layout where the text has shadow with dx, dy and radius, and i want the images to look the same.

Crash on initialisation if ImageView doesn't have a drawable yet

I want to use ElevationImageView for images I load from the network. The problem is that i get a crash in ElevationImageView.getBitmapFromDrawable if no drawable is currently on the ImageView. Logs:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.draw(android.graphics.Canvas)' on a null object reference
        at com.qhutch.elevationimageview.ElevationImageView.getBitmapFromDrawable(ElevationImageView.kt:167)
        at com.qhutch.elevationimageview.ElevationImageView.generateShadow(ElevationImageView.kt:143)
        at com.qhutch.elevationimageview.ElevationImageView.onDraw(ElevationImageView.kt:74)

Is there a way to have the shadow update/be creatd when setDrawable is called on the imageview?

Shadow is drawn over system UI

Issue is seen in the lower left corner of this GIF (recorded on a Nexus 5 running Marshmallow):
shadow_issue

The Ico icon there is an ElevationImageView with the following properties:

    <com.qhutch.elevationimageview.ElevationImageView
        android:id="@+id/articleLogo"
        android:layout_width="38dp"
        android:layout_height="38dp"
        android:layout_marginStart="@dimen/grid_space_2x"
        android:importantForAccessibility="no"
        android:scaleType="centerCrop"
        android:elevation="4dp"
        app:layout_constraintBottom_toTopOf="@id/articleTitle"
        app:layout_constraintStart_toStartOf="parent"
        tools:src="@sample/logos"/>

While, clipShadow="false" does fix this issue it means the view needs padding attached to it which the design does not permit. In any case, I don't believe the shadow should really be attempting to draw over the system UI. Is there anyway to fix this?

This issue is not present on a Pixel XL running Oreo

Crash when using in RecyclerView: NPE when calling Renderscript.validate()

I'm using an ElevationImageView in an item that's being shown in a RecyclerView (grid). I'm trying to implement a filter functionality and any time I try to filter the items (which triggers a DiffUtil to update the adapter) I get the following exception:

    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v8.renderscript.RenderScript.validate()' on a null object reference
        at android.support.v8.renderscript.BaseObj.getID(BaseObj.java:53)
        at android.support.v8.renderscript.Script.forEach(Script.java:269)
        at android.support.v8.renderscript.Script.forEach(Script.java:289)
        at com.qhutch.elevationimageview.ScriptC_convertToShadowAlpha.forEach_root(ScriptC_convertToShadowAlpha.java:77)
        at com.qhutch.elevationimageview.ScriptC_convertToShadowAlpha.forEach_root(ScriptC_convertToShadowAlpha.java:53)
        at com.qhutch.elevationimageview.ElevationImageView.getShadowBitmap(ElevationImageView.kt:116)
        at com.qhutch.elevationimageview.ElevationImageView.generateShadow(ElevationImageView.kt:132)
        at com.qhutch.elevationimageview.ElevationImageView.onDraw(ElevationImageView.kt:74)
        at android.view.View.draw(View.java:16184)
        at android.view.View.updateDisplayListIfDirty(View.java:15180)
        at android.view.View.draw(View.java:15954)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
...

I don't understand enough about renderscript to understand this but could it be due to the fact the ElevationImageView is being used in a recyclerview and it needs something to clear it's state when recycled?

[Crash] NPE when calling drawable.copyBounds()

When instantiating an ElevationImageView where the drawable isn't set at inflation time, it crashes with

java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Rect android.graphics.drawable.Drawable.copyBounds()' on a null object reference
        at com.qhutch.elevationimageview.ElevationImageView.onDraw(ElevationImageView.kt:92)

It seems the offending line is 92 in the following code

...
            val bounds = drawable.copyBounds()
            shadowBitmap?.let {
                canvas.save()
...

Perhaps the library should first check whether a drawable is present?

App crashing on Android 5.1

Here is the logs:

09-11 14:37:14.520 6585-6585/com.qhutch.shadowimageview E/art: Failed to register native method in androidx.renderscript.RenderScript in /data/app/com.qhutch.shadowimageview-2/base.apk: method name is null at index 0
09-11 14:37:14.520 6585-6585/com.qhutch.shadowimageview E/RenderScript_jni: Error loading RS jni library: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/com.qhutch.shadowimageview-2/lib/x86_64/librsjni_androidx.so"
09-11 14:37:14.520 6585-6585/com.qhutch.shadowimageview D/AndroidRuntime: Shutting down VM
09-11 14:37:14.521 6585-6585/com.qhutch.shadowimageview E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.qhutch.shadowimageview, PID: 6585
    androidx.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/com.qhutch.shadowimageview-2/lib/x86_64/librsjni_androidx.so" Support lib API: 2301
        at androidx.renderscript.RenderScript.internalCreate(RenderScript.java:1414)
        at androidx.renderscript.RenderScript.create(RenderScript.java:1599)
        at androidx.renderscript.RenderScript.create(RenderScript.java:1549)
        at androidx.renderscript.RenderScript.create(RenderScript.java:1525)
        at androidx.renderscript.RenderScript.create(RenderScript.java:1512)
        at com.qhutch.elevationimageview.ElevationImageView.onAttachedToWindow(ElevationImageView.kt:136)
        at android.view.View.dispatchAttachedToWindow(View.java:13525)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
        at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1299)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
        at android.view.Choreographer.doCallbacks(Choreographer.java:580)
        at android.view.Choreographer.doFrame(Choreographer.java:550)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        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)
09-11 14:37:20.339 6585-6596/com.qhutch.shadowimageview E/System: Uncaught exception thrown by finalizer
09-11 14:37:20.339 6585-6596/com.qhutch.shadowimageview E/System: androidx.renderscript.RSInvalidStateException: Calling RS with no Context active.
        at androidx.renderscript.RenderScript.validate(RenderScript.java:1237)
        at androidx.renderscript.RenderScript.nContextFinish(RenderScript.java:332)
        at androidx.renderscript.RenderScript.helpDestroy(RenderScript.java:1680)
        at androidx.renderscript.RenderScript.finalize(RenderScript.java:1714)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:191)
        at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:174)
        at java.lang.Thread.run(Thread.java:818)

[BUG]Strange white stripes, Android 7.0

libraryVersion: 2.1
Same applies for lower versions

<com.qhutch.elevationimageview.ElevationImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_weight="1" app:compatEvelation="20dp" app:srcCompat="@drawable/nav_button_right_white" />

What it is
image

What it should be
0

The white disappears and the shadow appears as it should on minimizing and maximizing the activity.

Stackoverflow issue

Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 17998

App crashes upon start. It only affects the HTC One which is running android Lollipop. I've tried with Sony Xperia mini running O and Samsung galaxy s8 running Oreo.

Found this on stack. Op suggest to disable hardware acceleration. I'm gonna try it out and se if I works if i do it only for specific views.

Issues of logo/icon

Hello,
Good Day, i make a logo icon for your project.Because there is no logo in your project. If you want to use this icon in your project, then comment below, I will give you the source file. And if you want a change, then tell me I will change.

elevationimageview

Thankyou.

Crash when using in RecyclerView: RSInvalidStateException in onDetachedFromWindow

Different issue from #2 but seems to have same cause - using this in a RecyclerView. Seems like blurScript is destroyed in onDetachedFromWindow and then when the view is detached again it's destroyed again triggering the error. Would the more appropriate behavior be to recreate the script in onAttachedToWindow every time?

android.support.v8.renderscript.RSInvalidStateException: Object already destroyed.
        at android.support.v8.renderscript.BaseObj.destroy(BaseObj.java:115)
        at com.qhutch.elevationimageview.ElevationImageView.onDetachedFromWindow(ElevationImageView.kt:101)
        at android.view.View.dispatchDetachedFromWindow(View.java:14561)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3063)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4603)
        at android.view.ViewGroup.removeViewAt(ViewGroup.java:4552)
        at android.support.v7.widget.RecyclerView$5.removeViewAt(RecyclerView.java:804)
        at android.support.v7.widget.ChildHelper.removeViewIfHidden(ChildHelper.java:386)
        at android.support.v7.widget.RecyclerView.removeAnimatingView(RecyclerView.java:1371)
        at android.support.v7.widget.RecyclerView$ItemAnimatorRestoreListener.onAnimationFinished(RecyclerView.java:12242)
        at android.support.v7.widget.RecyclerView$ItemAnimator.dispatchAnimationFinished(RecyclerView.java:12742)
        at android.support.v7.widget.SimpleItemAnimator.dispatchRemoveFinished(SimpleItemAnimator.java:279)
        at android.support.v7.widget.DefaultItemAnimator$4.onAnimationEnd(DefaultItemAnimator.java:213)
        at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1114)
        at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1239)
        at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:766)
        at android.animation.ValueAnimator$AnimationHandler$1.run(ValueAnimator.java:801)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
        at android.view.Choreographer.doCallbacks(Choreographer.java:670)
        at android.view.Choreographer.doFrame(Choreographer.java:603)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)

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.