Git Product home page Git Product logo

weatherview's Introduction

Android Arsenal Android Gems

Get it on Google Play Watch the demo video


WeatherView

WeatherView is an Android Library that helps you make a cool weather animation for your app.
This library is based on the confetti library.

Setup

Android Studio / Gradle

Add the following dependency in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        //...
        maven { url = 'https://jitpack.io' }
    }
}

Add the dependency:

dependencies {
    implementation 'com.github.MatteoBattilana:WeatherView:3.0.0'
}

Simple usage

Simple use cases will look something like this:

Kotlin

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
	
	weather_view.setWeatherData(PrecipType.RAIN)
     }
 }

Java

public class Main2Activity extends AppCompatActivity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WeatherView weatherView = findViewById(R.id.weather_view);
        weatherView.setWeatherData(PrecipType.RAIN);
    }
}
<com.github.matteobattilana.weather.WeatherView
    android:id="@+id/weather_view"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

For examples of usage, see the demo app.

Screenshots

License details

Copyright 2019 Matteo Battilana

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

The library is Free Software, you can use it, extended with no requirement to open source your changes. You can also make paid apps using it.

weatherview's People

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

weatherview's Issues

Abide by parent view clipping requests

Currently, the ParticleSystem is initialized inside of android.R.id.content, which is effectively the entire screen. This means that particles can stray outside of the parent view even when android:clipChildren="true" is set.

To alleviate this, the WeatherView class should extend FrameLayout so that the ParticleField can be inserted in it at runtime by Leonids. Then, this should be passed when creating a ParticleSystem.

Demo app doesn't run on API levels < 21

It looks like a bug in the support libraries possibly. The code that triggers the crash happens inside of the AppCompatActivity when it tests for vector drawable support.

Memory will continue to rise

I kept running my app and after an hour he quit on his own, then I checked the memory and I found that the app's memory kept increasing.

C:\Users\Administrator\Downloads>adb shell dumpsys meminfo com.test.demo
		Applications Memory Usage (kB):
		Uptime: 23167729 Realtime: 23167729

		** MEMINFO in pid 28468 [com.test.demo] **
		Pss  Private  Private  Swapped     Heap     Heap     Heap
		Total    Dirty    Clean    Dirty     Size    Alloc     Free
		------   ------   ------   ------   ------   ------   ------
		Native Heap        0        0        0        0    27472    27373       98
		Dalvik Heap    51611    51460        0        0    54136    45971     8165
		Dalvik Other     3978     3788        0        0
		Stack      172      172        0        0
		Other dev        5        0        4        0
		.so mmap     2220      824      324        0
		.apk mmap      435        0      256        0
		.ttf mmap     1076        0      692        0
		.dex mmap     8915      732     6788        0
		Other mmap     1004        4      916        0
		Unknown    25856    25832        0        0
		TOTAL    95272    82812     8980        0    81608    73344     8263

		Objects
		Views:      165         ViewRootImpl:        1
		AppContexts:        3           Activities:        1
		Assets:        2        AssetManagers:        2
		Local Binders:       16        Proxy Binders:       19
		Death Recipients:        0
		OpenSSL Sockets:        0

		SQL
		MEMORY_USED:        0
		PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0


		C:\Users\Administrator\Downloads>adb shell dumpsys meminfo com.test.demo
		Applications Memory Usage (kB):
		Uptime: 23432898 Realtime: 23432898

		** MEMINFO in pid 28468 [com.test.demo] **
		Pss  Private  Private  Swapped     Heap     Heap     Heap
		Total    Dirty    Clean    Dirty     Size    Alloc     Free
		------   ------   ------   ------   ------   ------   ------
		Native Heap        0        0        0        0    43840    43700      139
		Dalvik Heap    51611    51460        0        0    54136    45196     8940
		Dalvik Other     3982     3792        0        0
		Stack      164      164        0        0
		Other dev        5        0        4        0
		.so mmap     2220      824      324        0
		.apk mmap      435        0      256        0
		.ttf mmap     1076        0      692        0
		.dex mmap     8918      732     6792        0
		Other mmap      188        4      100        0
		Unknown    42196    42172        0        0
		TOTAL   110795    99148     8168        0    97976    88896     9079

		Objects
		Views:      165         ViewRootImpl:        1
		AppContexts:        3           Activities:        1
		Assets:        2        AssetManagers:        2
		Local Binders:       16        Proxy Binders:       19
		Death Recipients:        0
		OpenSSL Sockets:        0

		SQL
		MEMORY_USED:        0
		PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0


		C:\Users\Administrator\Downloads>adb shell
		root@Hi3798MV100:/ # adb shell top -d 2 | grep com.test.demo

		28468  1  30% R    32 497168K 167668K  fg u0_a19   com.test.demo
		28468  2  30% R    32 497300K 167932K  fg u0_a19   com.test.demo
		28468  1  29% R    32 497432K 167932K  fg u0_a19   com.test.demo

		28468  1  30% R    32 497564K 168196K  fg u0_a19   com.test.demo
		^C
		130|root@Hi3798MV100:/ # adb shell top -d 1 | grep com.test.demo
		28468  3  27% R    32 498224K 168724K  fg u0_a19   com.test.demo
		28468  2  30% R    32 498356K 168724K  fg u0_a19   com.test.demo
		28468  3  33% R    32 498356K 168988K  fg u0_a19   com.test.demo
		28468  3  29% R    32 498488K 168988K  fg u0_a19   com.test.demo
		28468  3  30% R    32 498488K 168988K  fg u0_a19   com.test.demo
		28468  3  30% R    32 498620K 168988K  fg u0_a19   com.test.demo
		^C
		130|root@Hi3798MV100:/ # adb shell top -d 5 | grep com.test.demo
		28468  2  30% R    32 499412K 170044K  fg u0_a19   com.test.demo
		28468  2  30% R    32 499808K 170308K  fg u0_a19   com.test.demo
		28468  0  30% R    32 500072K 170572K  fg u0_a19   com.test.demo
		28468  0  30% R    32 500336K 170836K  fg u0_a19   com.test.demo
		28468  2  30% R    31 499692K 171104K  fg u0_a19   com.test.demo
		28468  3  30% R    31 499956K 171368K  fg u0_a19   com.test.demo
		28468  1  30% R    30 499180K 171892K  fg u0_a19   com.test.demo
		28468  1  30% R    30 499576K 172156K  fg u0_a19   com.test.demo
		28468  1  30% R    30 499840K 172420K  fg u0_a19   com.test.demo
		28468  3  29% R    30 500104K 172684K  fg u0_a19   com.test.demo
		28468  2  31% R    30 500500K 172948K  fg u0_a19   com.test.demo
		28468  2  29% R    30 500764K 173212K  fg u0_a19   com.test.demo
		28468  2  31% R    30 501028K 173740K  fg u0_a19   com.test.demo
		28468  3  29% R    30 501424K 174004K  fg u0_a19   com.test.demo
		28468  3  31% R    30 501688K 174268K  fg u0_a19   com.test.demo
		28468  0  30% R    30 501952K 174532K  fg u0_a19   com.test.demo
		28468  0  30% R    30 502216K 174796K  fg u0_a19   com.test.demo
		28468  0  30% R    30 502612K 175060K  fg u0_a19   com.test.demo
		28468  1  30% R    30 502876K 175588K  fg u0_a19   com.test.demo
		28468  3  29% R    30 503140K 175852K  fg u0_a19   com.test.demo
		28468  3  30% R    30 503536K 176116K  fg u0_a19   com.test.demo
		28468  0  30% R    30 503800K 176380K  fg u0_a19   com.test.demo
		28468  3  30% R    30 504064K 176644K  fg u0_a19   com.test.demo
		28468  0  30% R    30 504460K 176908K  fg u0_a19   com.test.demo
		28468  0  30% R    30 504724K 177172K  fg u0_a19   com.test.demo
		28468  3  30% R    30 504988K 177700K  fg u0_a19   com.test.demo
		28468  3  30% R    30 505384K 177964K  fg u0_a19   com.test.demo
		28468  3  31% R    30 505648K 178228K  fg u0_a19   com.test.demo
		28468  0  29% R    30 505912K 178492K  fg u0_a19   com.test.demo
		28468  3  31% R    30 506308K 178756K  fg u0_a19   com.test.demo
		28468  1  29% R    30 506572K 179020K  fg u0_a19   com.test.demo
		28468  1  31% R    30 506836K 179548K  fg u0_a19   com.test.demo
		28468  3  30% R    30 507232K 179812K  fg u0_a19   com.test.demo
		28468  3  30% R    30 507496K 180076K  fg u0_a19   com.test.demo
		28468  3  30% R    30 507760K 180340K  fg u0_a19   com.test.demo
		28468  3  30% R    30 508156K 180604K  fg u0_a19   com.test.demo
		28468  0  30% R    30 508420K 180868K  fg u0_a19   com.test.demo
		28468  3  30% R    30 508684K 181396K  fg u0_a19   com.test.demo
		28468  1  30% R    30 509080K 181660K  fg u0_a19   com.test.demo
		28468  1  30% R    30 509344K 181924K  fg u0_a19   com.test.demo
		28468  1  30% R    30 509608K 182188K  fg u0_a19   com.test.demo
		28468  1  30% R    30 510004K 182452K  fg u0_a19   com.test.demo
		28468  1  30% R    30 510268K 182716K  fg u0_a19   com.test.demo
		28468  1  30% R    30 510532K 183244K  fg u0_a19   com.test.demo
		28468  1  31% R    30 510796K 183508K  fg u0_a19   com.test.demo
		28468  1  30% R    30 511192K 183772K  fg u0_a19   com.test.demo
		28468  1  31% R    30 511456K 184036K  fg u0_a19   com.test.demo
		28468  1  29% R    30 511720K 184300K  fg u0_a19   com.test.demo
		28468  1  31% R    30 512116K 184564K  fg u0_a19   com.test.demo
		28468  3  29% R    30 512380K 185092K  fg u0_a19   com.test.demo
		28468  3  31% R    30 512644K 185356K  fg u0_a19   com.test.demo
		28468  0  30% R    30 513040K 185620K  fg u0_a19   com.test.demo
		28468  1  30% R    30 513304K 185884K  fg u0_a19   com.test.demo
		28468  3  30% R    30 513568K 186148K  fg u0_a19   com.test.demo
		28468  0  30% R    30 513964K 186516K  fg u0_a19   com.test.demo
		28468  0  30% R    30 514228K 186776K  fg u0_a19   com.test.demo
		28468  2  30% R    30 514492K 187040K  fg u0_a19   com.test.demo
		28468  3  30% R    30 514888K 187568K  fg u0_a19   com.test.demo
		28468  1  30% R    30 515152K 187832K  fg u0_a19   com.test.demo
		28468  3  30% R    30 515548K 188096K  fg u0_a19   com.test.demo
		28468  3  30% R    30 515812K 188360K  fg u0_a19   com.test.demo
		28468  3  30% R    30 516076K 188624K  fg u0_a19   com.test.demo
		28468  2  29% R    30 516472K 188888K  fg u0_a19   com.test.demo
		28468  2  31% R    29 515696K 189412K  fg u0_a19   com.test.demo
		28468  3  29% R    29 515960K 189676K  fg u0_a19   com.test.demo
		28468  2  31% R    29 516356K 189940K  fg u0_a19   com.test.demo
		^C
		130|root@Hi3798MV100:/ #
		C:\Users\Administrator\Downloads>

Animation stops abruptly

@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

why did you switch from Leonids to Confetti?

is it just that Confetti has more active development (last commit in master is April 2019) over Leonids (last active in Sept 2018)? Or was it for performance reasons?

just curious, thanks!

Custom Rain or change droplet size?

Is there any way to change the rain droplet to a custom image or atleast change its size?they're only ~2 pixel on my 6 inch test devices.

Add Java example into README

Hy! my activity files are in java, and I am blank how to use weatherView in java (i am stuck in 2.0.3)
implementation 'com.github.MatteoBattilana:WeatherView:2.0.3'
weatherView.setWeather(Constants.WeatherStatus.RAIN) .setOrientationMode(Constants.OrientationStatus.ENABLE) .setRainParticles(60) .setCurrentLifeTime(8000) .startAnimation();
It would be great if you can and how to use this library in java

Originally posted by @snowf0x in #27 (comment)

All blank

    WeatherView weatherView = findViewById(R.id.weatherView);
    weatherView.setWeather(Constants.WeatherStatus.SUN);
    weatherView.setFPS(60);
    weatherView.startAnimation();

it shows only blank

Use Gradle dependency on Leonids library

Instead of including a .jar file, add the dependency in the build.gradle file using this line:
compile 'com.plattysoft.leonids:LeonidsLib:1.3.2'
This allows better dependency conflict resolution if a newer version of the library is already being used.

Bug with ViewPager2

Great stuff you've built here! ๐Ÿ‘

I figured that the WeatherView works very well when it is in a fragment hosted by viewpager. However, with the viewpager2, it acts a lot more differently. I have 2 fragments attached to the viewpager2 in question. When the app is launched, the WeatherView shows well for both fragments, but when you toggle between both fragments, neither of them will show the WeatherView anymore.

As I mentioned earlier, it works perfectly when it is viewpager. But we all know that is deprecated already.

Improvement: add gravity

It will be awesome to add gravity to each particle.
Changing angle is a quick idea but by adding an independant gravity using device sensor on each particle we will respond perfectly and the animation will also be perfect.

No wiki and also no proper guide to how to use.

No Wiki also I found no proper guide to how to start the animation and everything,
I can only implement the library after that I am blank.
I don't find any good guide on how to use this library also I have set the weather data still nothing working. please provide step by step guide on how to use this library.

[Library][Manifest] android:allowBackup="true"

Do you really need that line in your lib manifest? (see your full manifest here)

android:allowBackup="true"

On client app, could be nice to use android:allowBackup="false" too. For now, here the compilation error if the client app do not use allowBackup.

> Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:16:9-36
  	is also present at [com.github.MatteoBattilana:WeatherView:2.0.2] AndroidManifest.xml:12:9-35 value=(true).
  	Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:15:5-35:19 to override.

Thks a lot for your lib =)

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.