Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.jakeesveld.android_animatedimages"
minSdkVersion 28
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.jakeesveld.android_animatedimages;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.jakeesveld.android_animatedimages", appContext.getPackageName());
}
}
21 changes: 21 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jakeesveld.android_animatedimages">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.jakeesveld.android_animatedimages;

import android.graphics.drawable.AnimatedImageDrawable;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.support.constraint.ConstraintLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;

public class MainActivity extends AppCompatActivity {

ImageView imageView;
RadioButton buttonGif;
RadioButton buttonAnimation;
RadioButton buttonVector;
ConstraintLayout parentLayout;
Boolean pickup;
ImageView imageViewBubble;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.image_view);
buttonAnimation = findViewById(R.id.button_animation);
buttonGif = findViewById(R.id.button_gif);
buttonVector = findViewById(R.id.button_vector);
parentLayout = findViewById(R.id.parent_layout);
imageViewBubble = findViewById(R.id.image_view_bubble);
imageViewBubble.setVisibility(View.GONE);

imageView.setImageDrawable(getDrawable(R.drawable.snoop_dogg));
parentLayout.setBackground(getDrawable(R.drawable.compton_background));
buttonGif.setChecked(true);
refreshAnimation();
pickup = false;

buttonGif.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageViewBubble.setVisibility(View.GONE);
buttonGif.setChecked(true);
buttonAnimation.setChecked(false);
buttonVector.setChecked(false);
imageView.setImageDrawable(getDrawable(R.drawable.snoop_dogg));
parentLayout.setBackground(getDrawable(R.drawable.compton_background));
refreshAnimation();
}
});

buttonAnimation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageViewBubble.setVisibility(View.GONE);
buttonAnimation.setChecked(true);
buttonVector.setChecked(false);
buttonGif.setChecked(false);
imageView.setImageDrawable(getDrawable(R.drawable.goat));
parentLayout.setBackground(getDrawable(R.drawable.pasture_background));
refreshAnimation();
}
});

buttonVector.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
buttonGif.setChecked(false);
buttonVector.setChecked(true);
buttonAnimation.setChecked(false);
if (pickup) {
imageView.setImageDrawable(getDrawable(R.drawable.avd_anim_ring_pickup));
imageViewBubble.setVisibility(View.VISIBLE);
} else {
imageView.setImageDrawable(getDrawable(R.drawable.avd_anim_pickup_ring));
}
parentLayout.setBackground(getDrawable(R.drawable.office_background));
refreshAnimation();
}
});


}

public void refreshAnimation() {
final Drawable drawable = imageView.getDrawable();
if (drawable instanceof AnimatedImageDrawable) {
((AnimatedImageDrawable) drawable).start();
} else if (drawable instanceof AnimationDrawable) {
((AnimationDrawable) drawable).start();
} else if (drawable instanceof AnimatedVectorDrawable) {
((AnimatedVectorDrawable) drawable).start();
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (buttonVector.isChecked()) {
if (pickup) {
imageView.setImageDrawable(getDrawable(R.drawable.avd_anim_pickup_ring));
imageViewBubble.setVisibility(View.GONE);
} else {
imageView.setImageDrawable(getDrawable(R.drawable.avd_anim_ring_pickup));
imageViewBubble.setVisibility(View.VISIBLE);
}
Drawable current = imageView.getDrawable();
((AnimatedVectorDrawable) current).start();
pickup = !pickup;
}
}
});

}
}


}
34 changes: 34 additions & 0 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
29 changes: 29 additions & 0 deletions app/src/main/res/drawable/avd_anim_pickup_ring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="path"
android:pathData="M 6.62 10.79 C 8.06 13.62 10.38 15.93 13.21 17.38 L 15.41 15.18 C 15.68 14.91 16.08 14.82 16.43 14.94 C 17.55 15.31 18.76 15.51 20 15.51 C 20.55 15.51 21 15.96 21 16.51 L 21 20 C 21 20.55 20.55 21 20 21 C 10.61 21 3 13.39 3 4 C 3 3.45 3.45 3 4 3 L 7.5 3 C 8.05 3 8.5 3.45 8.5 4 C 8.5 5.25 8.7 6.45 9.07 7.57 C 9.18 7.92 9.1 8.31 8.82 8.59 L 6.62 10.79 Z"
android:fillColor="#000"
android:strokeWidth="1"/>
</vector>
</aapt:attr>
<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="300"
android:valueFrom="M 14.169 19.974 C 14.034 19.925 13.9 19.874 13.767 19.821 C 7.461 17.336 3 11.19 3 4 C 3 3.45 3.45 3 4 3 C 5.167 3 6.333 3 7.5 3 C 8.05 3 8.5 3.45 8.5 4 C 8.5 5.25 8.7 6.45 9.07 7.57 C 9.086 7.62 9.098 7.671 9.105 7.722 C 9.113 7.773 9.117 7.825 9.118 7.876 C 9.118 8.134 9.02 8.39 8.82 8.59 C 8.087 9.323 7.353 10.057 6.62 10.79 L 6.62 10.79 C 8.06 13.62 10.38 15.93 13.21 17.38 C 13.943 16.647 14.677 15.913 15.41 15.18 C 15.68 14.91 16.08 14.82 16.43 14.94 C 17.55 15.31 18.76 15.51 20 15.51 C 20.55 15.51 21 15.96 21 16.51 C 21 17.673 21 18.837 21 20 C 21 20.55 20.55 21 20 21 C 18.245 21 16.553 20.734 14.96 20.241 C 14.814 20.195 14.669 20.148 14.524 20.099 C 14.405 20.059 14.286 20.017 14.169 19.974 M 18.675 7.33 L 18.675 7.33 C 18.675 7.33 18.675 7.33 18.675 7.33 L 18.675 7.33 L 18.675 7.33 L 18.675 7.33 M 12 4.5 L 12 4.5 L 12 4.5 L 12 4.5 L 12 4.5 L 12 4.5 M 4.704 6.704 L 4.704 6.704 L 4.704 6.704 L 4.704 6.704 C 4.704 6.704 4.704 6.704 4.704 6.704 L 4.704 6.704"
android:valueTo="M 7.4 14.73 C 8.85 14.25 10.4 14 12 14 C 13.6 14 15.15 14.25 16.6 14.72 C 16.6 15.753 16.6 16.787 16.6 17.82 C 16.6 18.21 16.83 18.56 17.16 18.72 C 18.14 19.21 19.03 19.84 19.82 20.57 C 20 20.75 20.25 20.85 20.52 20.85 C 20.8 20.85 21.05 20.74 21.23 20.56 C 22.057 19.733 22.883 18.907 23.71 18.08 C 23.89 17.9 24 17.65 24 17.37 C 24 17.1 23.89 16.85 23.71 16.67 L 23.71 16.67 C 20.66 13.78 16.54 12 12 12 C 7.46 12 3.34 13.78 0.29 16.67 C 0.11 16.85 0 17.1 0 17.38 C 0 17.66 0.11 17.91 0.29 18.09 C 1.117 18.917 1.943 19.743 2.77 20.57 C 2.95 20.75 3.2 20.86 3.48 20.86 C 3.75 20.86 4 20.75 4.18 20.58 C 4.97 19.84 5.87 19.22 6.84 18.73 C 7.17 18.57 7.4 18.23 7.4 17.83 C 7.4 16.797 7.4 15.763 7.4 14.73 M 21.16 6.26 L 21.16 6.26 C 21.05 6.29 17.6 9.81 17.6 9.81 L 16.19 8.4 L 19.75 4.85 L 21.16 6.26 M 13 2 L 11 2 L 11 7 L 13 7 L 13 2 L 13 2 M 6.4 9.81 L 7.81 8.4 L 4.26 4.84 L 2.84 6.26 C 2.95 6.29 6.4 9.81 6.4 9.81 L 6.4 9.81"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
</animated-vector>
Loading