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

Not work in RecyclerView #3

Closed jays95jp closed 7 years ago

jays95jp commented 7 years ago

@deepaktwr hello, i use your view in recycler View but only last view get display in other view indicate only loader. and get below error log: E/MAX_WIDTH: 1038.0 E/MAX_HEIGHT: 1194.0 E/MIN_WIDTH: 312.0 E/MIN_HIGHT: 358.0 E/getWidth1 :: 1024 E/getHeight1 :: 268 E/getWidth2 :: 1024 E/getHeight2 :: 268 E/getWidth3 :: 1024 E/getHeight3 :: 268 E/getWidth4 :: 1024 E/getHeight4 :: 268 E/Start: ++++++++++++++++++++++++++++++++++++Start E/getWidth1 :: 1038 E/getHeight1 :: 268 E/getWidth2 :: 1038 E/getHeight2 :: 268 E/getWidth3 :: 519 E/getHeight3 :: 268 E/getWidth4 :: 519 E/getHeight4 :: 268 E/image order :: FIRST E/image order :: SECOND E/image order :: THIRD E/image order :: FOURTH E/layoutType :: VERT_DOUBLE E/End: ++++++++++++++++++++++++++++++++++++End

deepaktwr commented 7 years ago

Hi @jays95jp ,

the test cases are running fine for your case too,. Error logs has been given for calculation details and framing type, should have been in info though.

Can you give some more details about how you are attaching them to recycler view?

deepaktwr commented 7 years ago

You must have getting verbose logs too, like 'IMAGE_LOADING success' and others, can you paste them here for more details?

jays95jp commented 7 years ago

@deepaktwr thanks for reply here is full log 06-07 12:51:13.225 8213-8269/ V/Bit_Frame: transforming1024 h268 06-07 12:51:13.225 8213-8269/ I/Bit_Frame: width : 288 height : 331 06-07 12:51:13.225 8213-8269/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:13.225 8213-8269/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:13.325 2212-8392/com.google.android.gms D/DropBoxEntryAddedChimeraService: User is not opted-in to Usage & Diagnostics or Lockbox. 06-07 12:51:13.509 8213-8213/ I/Bit_Frame: Came image loaded -> 0bit width = 1024 height 268 06-07 12:51:13.509 8213-8213/ V/Bit_Frame: LADING AS : server image https://*****/20170606174814752942003.jpg 06-07 12:51:14.112 8213-8267/ V/Bit_Frame: transforming1024 h268 06-07 12:51:14.113 8213-8267/ I/Bit_Frame: width : 288 height : 331 06-07 12:51:14.113 8213-8267/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:14.113 8213-8267/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:16.748 8213-8268/ V/Bit_Frame: transforming1024 h268 06-07 12:51:16.748 8213-8268/ I/Bit_Frame: width : 288 height : 331 06-07 12:51:16.748 8213-8268/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:16.748 8213-8268/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:17.060 8213-8213/ I/Bit_Frame: Came image loaded -> 1bit width = 1024 height 268 06-07 12:51:17.060 8213-8213/ V/Bit_Frame: LADING AS : server image https://*****/20170606174814752942003.jpg 06-07 12:51:18.353 2102-2114/com.google.process.gapps W/art: Suspending all threads took: 7.890ms 06-07 12:51:18.644 1523-1539/system_process W/ActivityManager: Launch timeout has expired, giving up wake lock! 06-07 12:51:19.405 8213-8242/ V/FA: Session started, time: 3803262 06-07 12:51:19.407 8213-8242/ I/FA: Tag Manager is not found and thus will not be used 06-07 12:51:19.407 8213-8242/ D/FA: Logging event (FE): _s, Bundle[{_o=auto, _sc=TempActivity, _si=1740631661636161717}] 06-07 12:51:19.437 8213-8242/ V/FA: Using measurement service 06-07 12:51:19.437 8213-8242/ V/FA: Connecting to remote service 06-07 12:51:19.438 8213-8242/ W/GooglePlayServicesUtil: Google Play services out of date. Requires 10298000 but found 9452470 06-07 12:51:19.481 8213-8213/ W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null} 06-07 12:51:24.937 8213-8269/ V/Bit_Frame: transforming1024 h268 06-07 12:51:24.937 8213-8269/ I/Bit_Frame: width : 288 height : 331 06-07 12:51:24.937 8213-8269/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:24.937 8213-8269/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:25.276 8213-8213/ I/Bit_Frame: Came image loaded -> 2bit width = 1024 height 268 06-07 12:51:25.276 8213-8213/ V/Bit_Frame: LADING AS : server image https://*****/20170606174814752942003.jpg 06-07 12:51:28.814 2212-2221/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/metrics.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. 06-07 12:51:28.815 2212-2221/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/help_responses.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. 06-07 12:51:28.816 2212-2221/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/auto_complete_suggestions.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. 06-07 12:51:32.466 8213-8267/ V/Bit_Frame: transforming1024 h268 06-07 12:51:32.466 8213-8267/ I/Bit_Frame: width : 288 height : 331 06-07 12:51:32.466 8213-8267/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:32.466 8213-8267/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:32.845 8213-8213/ I/Bit_Frame: Came image loaded -> 3bit width = 1024 height 268 06-07 12:51:32.845 8213-8213/ V/Bit_Frame: LADING AS : server image https://*****/20170606174814752942003.jpg 06-07 12:51:32.876 8213-8213/ I/Bit_Frame: going to load 4 06-07 12:51:32.876 8213-8213/ E/MAX_WIDTH: 1038.0 06-07 12:51:32.876 8213-8213/ E/MAX_HEIGHT: 1194.0 06-07 12:51:32.876 8213-8213/ E/MIN_WIDTH: 312.0 06-07 12:51:32.876 8213-8213/ E/MIN_HIGHT: 358.0 06-07 12:51:32.876 8213-8213/ E/getWidth1 :: 1024 06-07 12:51:32.876 8213-8213/ E/getHeight1 :: 268 06-07 12:51:32.877 8213-8213/ E/getWidth2 :: 1024 06-07 12:51:32.877 8213-8213/ E/getHeight2 :: 268 06-07 12:51:32.877 8213-8213/ E/getWidth3 :: 1024 06-07 12:51:32.877 8213-8213/ E/getHeight3 :: 268 06-07 12:51:32.877 8213-8213/ E/getWidth4 :: 1024 06-07 12:51:32.877 8213-8213/ E/getHeight4 :: 268 06-07 12:51:32.877 8213-8213/ E/Start: ++++++++++++++++++++++++++++++++++++Start 06-07 12:51:32.877 8213-8213/ E/getWidth1 :: 1038 06-07 12:51:32.877 8213-8213/ E/getHeight1 :: 268 06-07 12:51:32.877 8213-8213/ E/getWidth2 :: 1038 06-07 12:51:32.877 8213-8213/ E/getHeight2 :: 268 06-07 12:51:32.877 8213-8213/ E/getWidth3 :: 519 06-07 12:51:32.877 8213-8213/ E/getHeight3 :: 268 06-07 12:51:32.877 8213-8213/ E/getWidth4 :: 519 06-07 12:51:32.877 8213-8213/ E/getHeight4 :: 268 06-07 12:51:32.878 8213-8213/ E/image order :: FIRST 06-07 12:51:32.878 8213-8213/ E/image order :: SECOND 06-07 12:51:32.878 8213-8213/ E/image order :: THIRD 06-07 12:51:32.878 8213-8213/ E/image order :: FOURTH 06-07 12:51:32.878 8213-8213/ E/layoutType :: VERT_DOUBLE 06-07 12:51:32.878 8213-8213/ E/End: ++++++++++++++++++++++++++++++++++++End 06-07 12:51:32.885 8213-8213/ V/Bit_Frame: going to add view 06-07 12:51:32.937 8213-8218/ I/art: Compiler allocated 8MB to compile void proj.me.bitframe.shading_four.ImageShadingFour.updateFrameUi(java.util.List, java.util.List, boolean) 06-07 12:51:33.003 8213-8224/ W/art: Suspending all threads took: 9.017ms 06-07 12:51:33.010 8213-8224/ I/art: Background sticky concurrent mark sweep GC freed 8436(530KB) AllocSpace objects, 13(724KB) LOS objects, 10% free, 13MB/14MB, paused 9.863ms total 32.203ms 06-07 12:51:33.034 8213-8213/ I/Bit_Frame: vibrant pop = 0 muted pop316 06-07 12:51:33.034 8213-8213/ I/Bit_Frame: vibrant pop = 0 muted pop316 06-07 12:51:33.034 8213-8213/ I/Bit_Frame: vibrant pop = 0 muted pop316 06-07 12:51:33.062 8213-8213/ I/Bit_Frame: vibrant pop = 0 muted pop316 06-07 12:51:33.062 8213-8213/ V/Bit_Frame: colors came 06-07 12:51:33.062 8213-8213/ V/Bit_Frame: frame result came 06-07 12:51:41.132 8213-8268/ V/Bit_Frame: transforming1024 h268 06-07 12:51:41.132 8213-8268/ I/Bit_Frame: width : 288 height : 331 06-07 12:51:41.132 8213-8268/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:41.132 8213-8268/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:41.478 8213-8213/ I/Bit_Frame: Came image loaded -> 4bit width = 1024 height 268 06-07 12:51:41.478 8213-8213/ V/Bit_Frame: LADING AS : server image https://***/20170606174814752942003.jpg 06-07 12:51:41.680 8213-8213/ V/Bit_Frame: frame result came 06-07 12:51:41.680 8213-8213/ V/Bit_Frame: exppp pallet width 1024 height 268 06-07 12:51:48.598 8213-8269/ V/Bit_Frame: transforming1024 h268 06-07 12:51:48.598 8213-8269/ I/Bit_Frame: width : 288 height : 331 06-07 12:51:48.598 8213-8269/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:48.598 8213-8269/ I/Bit_Frame: width : 1024 height : 268 06-07 12:51:49.043 8213-8213/ I/Bit_Frame: Came image loaded -> 5bit width = 1024 height 268 06-07 12:51:49.214 8213-8213/ V/Bit_Frame: frame result came 06-07 12:51:49.214 8213-8213/ V/Bit_Frame: exppp pallet width 1024 height 268

jays95jp commented 7 years ago

void bindTo(String tag, int position) {

        ArrayList<BeanImage> beanImages = new ArrayList<>();

        for (int i = 0; i < 6; i++) {
            BeanImage beanImage = new BeanImage();
            beanImage.setImageLink("https://s3-us-west-1.amazonaws.com/pro-manager/images/20170606174814752942003.jpg");
            beanImages.add(beanImage);
        }
        viewFrame.showBitFrame(beanImages, new FrameCallback() {
            @Override
            public void imageClick(ImageType imageType, int imagePosition, String imageLink) {
            }

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

            }

            @Override
            public void addMoreClick() {

            }

            @Override
            public void containerAdded(int containerWidth, int containerHeight, boolean isAddInLayout) {

            }

            @Override
            public void loadedFrameColors(int lastLoadedFrameColor, int mixedLoadedColor, int inverseMixedLoadedColor) {

            }
        }, FrameType.UNFRAMED);
    }

@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { ((TextViewHolder) holder).bindTo("", position);

}

i use this code in adapter here is screen shot : http://prntscr.com/fgvu8y

jays95jp commented 7 years ago
` void bindTo(String tag, int position) {

            ArrayList<BeanImage> beanImages = new ArrayList<>();

            for (int i = 0; i < 6; i++) {
                BeanImage beanImage = new BeanImage();
                beanImage.setImageLink("https://s3-us-west-1.amazonaws.com/pro-manager/images/20170606174814752942003.jpg");
                beanImages.add(beanImage);
            }
            viewFrame.showBitFrame(beanImages, new FrameCallback() {
                @Override
                public void imageClick(ImageType imageType, int imagePosition, String imageLink) {
                }

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

                }

                @Override
                public void addMoreClick() {

                }

                @Override
                public void containerAdded(int containerWidth, int containerHeight, boolean isAddInLayout) {

                }

                @Override
                public void loadedFrameColors(int lastLoadedFrameColor, int mixedLoadedColor, int inverseMixedLoadedColor) {

                }
            }, FrameType.UNFRAMED);
        }

 @Override
   public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) 
{
       ((TextViewHolder) holder).bindTo("", position);

    } `
jays95jp commented 7 years ago

Code.zip

deepaktwr commented 7 years ago

Hi @jays95jp,

Loading problem is because of two reasons:

the the new object of UnframedPicassoTargetNew.java class could not be created and previously created targets has been either removed or cancelled due to completion or error.

@Override
    public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
        targets.remove(this);
        ...
        ...
        ...
    }
 @Override
    public void onBitmapFailed(Drawable errorDrawable) {
        targets.remove(this);
        ...
        ...
        ...
    }

Targets also gets removed when new request came for the same position adapter view, then all last targets has been cancelled and new goes into processing.

https://github.com/square/picasso/issues/1291 https://issuetracker.google.com/issues/37068521

These now has been solved in these commits:

https://github.com/deepaktwr/BitFrames/commit/8a7a66aa8475d79603afeefa4097ef61c3ed1896 and https://github.com/deepaktwr/BitFrames/commit/a5d0ea68fd53a1f6ec8552467a0917b2322ebc8e

Please upgrade your gradle to latest version to resolve your problem.

Let me know if you got any problem in that.

deepaktwr commented 7 years ago

Latest Gradle:

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

jays95jp commented 7 years ago

@deepaktwr Thanks bro, Now it's working. and very nice library for multiple image display as single view look like FaceBook (y)

jays95jp commented 7 years ago

@deepaktwr hello , i have one question related this Can we display PlaceHolder at time of loading frame ? and i replace this code in ImageShading.java :

currentFramePicasso.load(beanImage.getImageLink()).memoryPolicy(MemoryPolicy.NO_STORE)
                    .networkPolicy(NetworkPolicy.NO_STORE)
                    .noPlaceholder()
                    .transform(new ScaleTransformation(frameModel.getMaxContainerWidth(),
                            frameModel.getMaxContainerHeight(), totalImages, beanImage.getImageLink(),
                            beanImage, this))
                    .into(target);

with

currentFramePicasso.load(beanImage.getImageLink())
//                    .memoryPolicy(MemoryPolicy.NO_STORE)
//                    .networkPolicy(NetworkPolicy.NO_STORE)
                    .placeholder(R.drawable.bg_img_placeholder)
                    .error(R.drawable.bg_img_placeholder)
//                    .noPlaceholder()
                    .transform(new ScaleTransformation(frameModel.getMaxContainerWidth(),
                            frameModel.getMaxContainerHeight(), totalImages, beanImage.getImageLink(),
                            beanImage, this))
                    .into(target);

is it ok? because every time it go for load image and not store in caches

deepaktwr commented 7 years ago

The NO_STORE enum type should be used when we only need to load the image once as it should be done in case of UNFRAMED type.

For both Memory and Network policy, the NO_STORE is used in case of UNFRAMED images because of ScaleTransformation has been applied on bitmaps.In case of UNFRAMED images, all image links (either from local or network) need to be transformed and the bitmap manipulation needed. though it is sequential and last Uri gets invalidated before every call to load new Uri from Picasso you might get OOM in case of loading multiple images in a single frame(as invalidate of last Uri and new load from Picasso might not be sequential).

Also the NO_STORE has been used so that once user pass UNFRAMED type user will get BeanBitFrame in FrameCallback with additions details(like pallet and mixed colours). You may pass UNFRAMED first time and after getting result you may add the result properties for that position adapter to model from the result (BeanBitFrame) and can go with FRAMED type, this way your both problem can be solved:

Also for error drawable you may use:

frame:errorDrawable (or from the instance method of ViewFrame)

You may use extra attributes from Attributes Section

*For now the at the time of loading images, Progress loader has been shown.Surely in future releases one placeholder would be their at the time to load multiple images in a frame.