Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation stops abruptly #18

Closed
aboutgaurav opened this issue Jun 19, 2018 · 12 comments · Fixed by #25
Closed

Animation stops abruptly #18

aboutgaurav opened this issue Jun 19, 2018 · 12 comments · Fixed by #25
Assignees
Labels

Comments

@aboutgaurav
Copy link

@MatteoBattilana
I have successfully implemented this library in my app. And its working flawlessly.
But animation of 'WeatherView' stops abruptly when i try to take the screenshot.

Layout file:

               <FrameLayout
                android:id="@+id/containerImagePreview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:background="@color/yellow_light">


                <!--Preview imageView-->
                <android.support.v7.widget.AppCompatImageView
                    android:id="@+id/image_preview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:scaleType="fitXY"
                    tools:src="@tools:sample/avatars" />

                <!--Snowfall and rain filter-->
                <com.github.matteobattilana.weather.WeatherView
                    android:id="@+id/whether_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="gone" />

            </FrameLayout>`

do you know this is happening?
Any guide and direction will be helpful.
Thanks

@MatteoBattilana
Copy link
Owner

@aboutgaurav
Thank you for being interested in WeatherView library.
I will investigate about this strange bug. Can you provide me your code?

@aboutgaurav
Copy link
Author

aboutgaurav commented Jun 20, 2018

@MatteoBattilana Thank you for quick response.

Snippet for screenshot:

      for(int i = 0; i < 12; i++) {

        frameLayout.setDrawingCacheEnabled(true)
        Bitmap bm = frameLayout.getDrawingCache();
        try {
            File file = new File(Environment.getExternalStorageDirectory().getPath() + 
            "/Cread/Short/short_pic" + i + ".jpg");
            file.getParentFile().mkdirs();

            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            FileOutputStream out = new FileOutputStream(file);
            bm.compress(Bitmap.CompressFormat.JPEG, 85, out);
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        //Disable drawing cache
        frameLayout.setDrawingCacheEnabled(false);
    }

Code for Snow and Rain animation:

                    //snow animation
                    whetherView.setWeatherData(PrecipType.SNOW);
                    
                    //rain aniamtion
                    whetherView.setWeatherData(PrecipType.RAIN);

@AvneeshKhanna
Copy link

AvneeshKhanna commented Jul 9, 2018

Facing the same bug. Especially, in rain mode, the rain doesn't appear in screenshots. Works fine in snow mode.

@MatteoBattilana

@magneticflux-
Copy link
Collaborator

@aboutgaurav @AvneeshKhanna
Could you provide the versions of Android, Android Support libraries, and WeatherView you are using?

@aboutgaurav
Copy link
Author

Android version: Jelly Bean (4.3.1)
Support Library: 26.1.0
WeatherView : 2.0.3

@magneticflux-
Copy link
Collaborator

I'm unable to reproduce this on an Android 4.3.1 emulator. What model of phone are you using to test?

@aboutgaurav
Copy link
Author

Tested on following devices:
-HM 1s xiaomi
-OnePlus 3t
-OnePlus 5

And i am using above mentioned code to take the screenshot.

@magneticflux-
Copy link
Collaborator

I am able to reproduce this behavior. It appears that the motion blur effect is responsible. Because the motion blur effect is based on the previous onDraw call, having it redraw instantly after a previous draw makes the raindrops have 0 length.

I'm working on a better method of rendering the particles with motion information.

@aboutgaurav
Copy link
Author

@magneticflux-
Thanks for the effort.
Let me know when you fix this.

@magneticflux-
Copy link
Collaborator

jinatonic/confetti#41 has been merged, so I'll update WeatherView with this fix as soon as they release a version that includes my contributions.

@aboutgaurav
Copy link
Author

Thanks

@MatteoBattilana
Copy link
Owner

@magneticflux-
The 1.1.2 confetti library release contains the pull request you opened time ago. Can you merge it and add the missing code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants