deepaktwr / BitFrames

Frame of Bitmaps, Facebook like image sequence.
https://play.google.com/store/apps/details?id=proj.me.bitframedemo
Apache License 2.0
17 stars 4 forks source link

Get random crash when scroll #8

Open jays95jp opened 7 years ago

jays95jp commented 7 years ago

@deepaktwr hello, i got one random crash when i scroll fast up and down , or redirect other activity before load frame i put here log

FATAL EXCEPTION: main
Process: , PID: 19700
java.lang.IllegalArgumentException: Bitmap is not valid
at android.support.v7.graphics.Palette$Builder.<init>(Palette.java:587)
at android.support.v7.graphics.Palette.from(Palette.java:100)
at proj.me.bitframe.FrameHandler.handleMessage(FrameHandler.java:37)
at android.os.Handler.dispatchMessage(Handler.java:102)
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)

don't get why get this crash sometime.

deepaktwr commented 7 years ago

@jays95jp have got any other crash rather than this? or it's the only crash at the time of scrolling you have faced?

deepaktwr commented 7 years ago

Palette says..

...

        public Builder(Bitmap bitmap) {
            if (bitmap == null || bitmap.isRecycled()) {
                throw new IllegalArgumentException("Bitmap is not valid");
            }
            mBitmap = bitmap;
        }

...

it will only throw IllegalArgumentException when bitmap is null or recycled, are you recycling the bitmaps somewhere in your code?

jays95jp commented 7 years ago

@deepaktwr thanks for quick reply no, up to yet that's the only crash which i get. And one popUp open in recycler view when popUp dismiss than visible frame go for load which is already loaded. may be because of popup crash occur but not sure

if you need other info regarding this than please inform me , and please try to solve this crash as soon as possible little urgency :)

deepaktwr commented 7 years ago

Are you recycling the bitmap explicitly somewhere? or let me know if you have made any changes to the library code a/c to your requirements.

jays95jp commented 7 years ago

@deepaktwr yes i use catch memory which store by Piccaso. i just remove

  .memoryPolicy(MemoryPolicy.NO_STORE)
//                    .networkPolicy(NetworkPolicy.NO_STORE).placeholder()

from all place because after scroll it take too much time to load even one time all images loaded

deepaktwr commented 7 years ago

@jays95jp okay, i will try to solve both of your problems so that you don't need to attach extra code for this explicitly; i'll try to release it before tomorrow with some extra features.

deepaktwr commented 7 years ago

@jays95jp, New version is up. though it does't have some new features like placeholder drawables, which will go in next release. let me know if it has resolve your problem with crash.

compile 'com.github.deepaktwr:bitframe:0.1.4'

jays95jp commented 7 years ago

@deepaktwr thanks for responding quickly. 👍 i integrate new module if i get any crash than i inform you.

jays95jp commented 7 years ago

@deepaktwr not get any crash up to this if get any than inform you

jays95jp commented 7 years ago

@deepaktwr i done get click event in frame image privies , i get that click proper and use FrameType=FRAMED type now i use FrameType=UNFRAMED in recycler view

deepaktwr commented 7 years ago

Are you not getting frame image click events in

@Override
public void imageClicked(ImageType imageType, int imagePosition, String imageLink) {
.
.
.
}

callback method, in FrameCallback? preciously their was a toast which has been removed from the library, but events are still emitting.

jays95jp commented 7 years ago

yes in this method i don't get click event , some time i get and some time don't

jays95jp commented 7 years ago

@deepaktwr in public abstract class ImageShades this method call every time but not call get in interface where we pass as argument

    protected void imageClicked(ImageType imageType, int imagePosition, String imageLink) {
        imageCallback.imageClicked(imageType, imagePosition, imageLink);
    }
deepaktwr commented 7 years ago

The FrameCallback you are passing will process imageClicked method from ViewFrame's MyImageCallback inner class. Can you check if MyImageCallback's imageClicked method calling your FrameCallback's imageClicked method?

jays95jp commented 7 years ago

yes i this method is call when click event fire

   static class MyImageCallback implements ImageCallback{
........
@Override
        public void imageClicked(ImageType imageType, int imagePosition, String imageLink) {
            ViewFrame viewFrame = viewFrameSoftReference.get();
            if (viewFrame == null) return;

            FrameCallback frameCallback = frameCallbackSoftReference.get();
            if (frameCallback == null) return;

            int hashCode = (int) viewFrame.getTag(R.id.frame_tag);
            if (this.hashCode() != hashCode) return;

            Bundle imageBundle = new Bundle();

            ImageScrollParcelable imageScrollParcelable = new ImageScrollParcelable();
            imageScrollParcelable.setImageType(imageType);
            imageScrollParcelable.setImagePosition(imagePosition);
            imageScrollParcelable.setImageLink(imageLink);
            imageBundle.putParcelable("image_data", imageScrollParcelable);

            frameCallback.imageClick(imageType, imagePosition, imageLink);
        }
.......
}
deepaktwr commented 7 years ago

Check ViewFrames imageClicked, also can you post your recycler view adapter class implementation where you have passed FrameCallback?

deepaktwr commented 7 years ago
  static class MyImageCallback implements ImageCallback{
........
@Override
        public void imageClicked(ImageType imageType, int imagePosition, String imageLink) {
            ViewFrame viewFrame = viewFrameSoftReference.get();
            if (viewFrame == null) return;

            FrameCallback frameCallback = frameCallbackSoftReference.get();
            if (frameCallback == null) return;

            int hashCode = (int) viewFrame.getTag(R.id.frame_tag);
            if (this.hashCode() != hashCode) return;

            Bundle imageBundle = new Bundle();

            ImageScrollParcelable imageScrollParcelable = new ImageScrollParcelable();
            imageScrollParcelable.setImageType(imageType);
            imageScrollParcelable.setImagePosition(imagePosition);
            imageScrollParcelable.setImageLink(imageLink);
            imageBundle.putParcelable("image_data", imageScrollParcelable);

//------is it coming here?
            frameCallback.imageClick(imageType, imagePosition, imageLink);
        }
.......
}
jays95jp commented 7 years ago

yes

jays95jp commented 7 years ago

Using dataBinding

public class BindImage {
........................

@BindingAdapter({"multipleImage", "context"}) public static void setAllimage(ViewFrame viewFrame, List allImage, Context context) {

    List<BeanImage> beanImages = new ArrayList<>();
    allImage.remove(null);
    allImage.remove("");
    for (String s : allImage) {
        //change
        BeanBitFrame beanBitFrame = new BeanBitFrame();

        beanBitFrame.setWidth(200);
        beanBitFrame.setHeight(200);
        beanBitFrame.setImageLink(s);
        beanBitFrame.setLoaded(true);
        beanImages.add(beanBitFrame);
    }

    viewFrame.showBitFrame(beanImages, new FrameCallback() {
        @Override
        public void imageClick(ImageType imageType, int imagePosition, String imageLink) {
            Log.e("Call onclick listner in frame","Viewframe");
            Intent intent = new Intent(context, ImagePreviewActivity.class);
            ArrayList<String> strings = new ArrayList<String>();
            strings.addAll(allImage);
            intent.putExtra(context.getString(R.string.intent_pass_image_array_url), strings);
            context.startActivity(intent);
        }

        @Override
        public void frameResult(List<BeanBitFrame> beanBitFrameList) {

        }

        @Override
        public void addMoreClick() {
        }

        @Override
        public void containerAdded(int containerWidth, int containerHeight, boolean isAddInLayout) {
            viewFrame.setBackground(null);
        }

        @Override
        public void loadedFrameColors(int lastLoadedFrameColor, int mixedLoadedColor, int inverseMixedLoadedColor) {
        }
    }, FrameType.FRAMED);

    viewFrame.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.e("Call onclick listner","Viewframe");

// Intent intent = new Intent(context, ImagePreviewActivity.class); // ArrayList strings = new ArrayList(); // strings.addAll(allImage); // intent.putExtra(context.getString(R.string.intent_pass_image_array_url), strings); // context.startActivity(intent); } });

}

.......... }

Adapter code

private class HolderView extends RecyclerView.ViewHolder {

    AdapterDashBoardBinding adapterDashBoardBinding;

    HolderView(AdapterDashBoardBinding itemView) {
        super(itemView.getRoot());
        adapterDashBoardBinding = itemView;
    }

    public void bind(LoginBean bean, int position) {
  .....

// no code related FrameView
} }

XML <proj.me.bitframe.ViewFrame android:id="@+id/view_frame" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/_5sdp" android:background="@drawable/bg_img_placeholder" android:minHeight="@dimen/_130sdp" android:visibility="@{user.type.equalsIgnoreCase(@string/txt_image) ? View.VISIBLE : View.GONE}" app:context="@{context}" app:imageScaleType="centerCrop" app:multipleImage="@{user.pictures}" app:shouldShowComment="false" tools:visibility="gone" />

deepaktwr commented 7 years ago
@bindingadapter({"multipleImage", "context"})
public static void setAllimage(ViewFrame viewFrame, List allImage, Context context) {
.
.
.
}

will this method executes on every onBindViewHolder call of recycle view adapter?

deepaktwr commented 7 years ago

Check implementation of FrameAdapter in demo, is it kind of similar? As the showBitFrame need to be called on every onBindViewHolder call for, the only loss here would be the calculations, otherwise Picasso will cache those loaded images

jays95jp commented 7 years ago
@bindingadapter({"multipleImage", "context"})
public static void setAllimage(ViewFrame viewFrame, List allImage, Context context) {
.
.
.
}

yes this method call every time, even when we scroll up and down and if view come than again call this method

deepaktwr commented 7 years ago

@jays95jp please check your adapter implementation, as if

  static class MyImageCallback implements ImageCallback{
........
@Override
        public void imageClicked(ImageType imageType, int imagePosition, String imageLink) {
            ViewFrame viewFrame = viewFrameSoftReference.get();
            if (viewFrame == null) return;

            FrameCallback frameCallback = frameCallbackSoftReference.get();
            if (frameCallback == null) return;

            int hashCode = (int) viewFrame.getTag(R.id.frame_tag);
            if (this.hashCode() != hashCode) return;

            Bundle imageBundle = new Bundle();

            ImageScrollParcelable imageScrollParcelable = new ImageScrollParcelable();
            imageScrollParcelable.setImageType(imageType);
            imageScrollParcelable.setImagePosition(imagePosition);
            imageScrollParcelable.setImageLink(imageLink);
            imageBundle.putParcelable("image_data", imageScrollParcelable);

//------IS COMING HERE
            frameCallback.imageClick(imageType, imagePosition, imageLink);
        }
.......
}

then it will invoke your callback method until the last instance to FrameCallback has been changed.

jays95jp commented 7 years ago

yes, it's taking only one instance. so it's been working perfectly if there is one time on screen but not working if multiple view on screen.

Actually my requirement is not get click for every frame.. so is there way to disable that click ? so that whole view can get simple click.

deepaktwr commented 7 years ago

yes, it's taking only one instance. so it's been working perfectly if there is one time on screen but not working if multiple view on screen.

the last implementation of the library was not appropriate to the AdapterModel, now it is. BTW if there is one time on screen but not working if multiple view on screen what do you meant by this?

Actually my requirement is not get click for every frame.. so is there way to disable that click ? so that whole view can get simple click.

you may create an interface which will invoke one single method from your view frame as well as from the image click implementation for now, though it won't be good to give options for view frame click so every frame image click is given.

jays95jp commented 7 years ago

the last implementation of the library was not appropriate to the AdapterModel, now it is. BTW if there is one time on screen but not working if multiple view on screen what do you meant by this? if two frame with multiple images at time in screen than if you scroll down and go up than click event not perform

and for now i remove click event from Frame image XMl

deepaktwr commented 7 years ago

@jays95jp, okay, i will also try to find the problem in library implementation if any, will let you know by evening.

jays95jp commented 7 years ago

ok thanks @deepaktwr for nice support and quick response 💯