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
28 changes: 28 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.animatedimageproject"
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'
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.example.animatedimageproject;

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.example.animatedimageproject", 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.example.animatedimageproject">

<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,81 @@
package com.example.animatedimageproject;

import android.graphics.drawable.AnimatedImageDrawable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.Spinner;

public class MainActivity extends AppCompatActivity {

ImageView playButton;
ImageView gifView;
Spinner gifSelector;
boolean isPlayButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

gifSelector = findViewById(R.id.gif_selector);
playButton = findViewById(R.id.play_gif_button);
gifView = findViewById(R.id.imageView_gif);
isPlayButton = true;
playButton.setImageDrawable(getDrawable(R.drawable.avd_play_to_pause));

gifSelector.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
gifView.setImageDrawable(getDrawable(R.drawable.keanu));
break;
case 1:
gifView.setImageDrawable(getDrawable(R.drawable.cat));
break;
case 2:
gifView.setImageDrawable(getDrawable(R.drawable.super_dog));
}
}

@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});


playButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Drawable drawable = gifView.getDrawable();


isPlayButton = !isPlayButton;

if(!isPlayButton){
playButton.setImageDrawable(getDrawable(R.drawable.avd_pause_to_play));
if (drawable instanceof AnimatedImageDrawable) {
((AnimatedImageDrawable) drawable).start();
} else if (drawable instanceof AnimationDrawable) {
((AnimationDrawable) drawable).start();
}
}else{
playButton.setImageDrawable(getDrawable(R.drawable.avd_play_to_pause));
if (drawable instanceof AnimatedImageDrawable) {
((AnimationDrawable) drawable).stop();
} else if (drawable instanceof AnimationDrawable) {
((AnimationDrawable) drawable).stop();
}
}

}
});

}
}
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>
31 changes: 31 additions & 0 deletions app/src/main/res/drawable/avd_pause_to_play.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<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="288dp"
android:height="560dp"
android:viewportWidth="288"
android:viewportHeight="560">
<path
android:name="path"
android:pathData="M 174.31 229.45 L 174.31 283.16 L 200.08 283.16 L 199.81 223.81 C 191.28 225.55 182.78 227.43 174.31 229.45 Z M 199.55 164.51 L 199.47 145.73 L 174.32 145.73 L 174.32 158.57 C 182.91 159.68 191.27 161.93 199.55 164.51 Z M 174.31 168.6 L 174.31 219.17 C 182.76 217.18 191.25 215.35 199.77 213.63 L 199.6 174.99 C 191.32 172.29 182.93 169.8 174.31 168.6 Z M 134.45 162.57 L 134.38 146.09 L 109.23 146.09 L 109.23 186.15 C 117.6 178.26 126.01 170.39 134.45 162.57 Z M 134.75 227.94 L 134.52 176.14 C 126.06 184.02 117.64 191.94 109.23 199.88 L 109.23 237.86 C 117.51 234.08 126.08 230.8 134.75 227.94 Z M 127.66 240.82 C 121.42 243.12 115.25 245.71 109.23 248.62 L 109.23 283.51 L 135 283.51 L 134.8 238.33 C 132.4 239.13 130.02 239.95 127.66 240.82 Z"
android:fillColor="#000"
android:strokeColor="#000000"
android:strokeWidth="1"
android:strokeMiterLimit="10"/>
</vector>
</aapt:attr>
<target android:name="path">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="300"
android:valueFrom="M 174.31 168.6 L 174.31 168.6 L 174.31 219.17 C 182.76 217.18 191.25 215.35 199.77 213.63 C 199.713 200.75 199.657 187.87 199.6 174.99 C 191.32 172.29 182.93 169.8 174.31 168.6 M 125.997 146.09 L 117.613 146.09 L 109.23 146.09 C 109.23 159.443 109.23 172.797 109.23 186.15 C 117.6 178.26 126.01 170.39 134.45 162.57 C 134.45 162.57 134.45 162.57 134.45 162.57 C 134.427 157.077 134.403 151.583 134.38 146.09 C 131.586 146.09 128.791 146.09 125.997 146.09 M 135 283.51 L 109.23 283.51 L 109.23 248.62 C 115.25 245.71 121.42 243.12 127.66 240.82 C 127.66 240.82 127.66 240.82 127.66 240.82 C 130.02 239.95 132.4 239.13 134.8 238.33 C 134.867 253.39 134.933 268.45 135 283.51 M 174.31 283.16 L 174.31 229.45 C 174.31 229.45 174.31 229.45 174.31 229.45 C 182.78 227.43 191.28 225.55 199.81 223.81 C 199.9 243.593 199.99 263.377 200.08 283.16 L 174.31 283.16 M 174.32 158.57 C 182.91 159.68 191.27 161.93 199.55 164.51 L 199.55 164.51 C 199.543 162.945 199.537 161.38 199.53 159.815 C 199.523 158.25 199.517 156.685 199.51 155.12 L 199.49 150.425 C 199.483 148.86 199.477 147.295 199.47 145.73 L 174.32 145.73 C 174.32 150.01 174.32 154.29 174.32 158.57 M 134.75 227.94 C 134.712 219.307 134.673 210.673 134.635 202.04 L 134.52 176.14 C 126.06 184.02 117.64 191.94 109.23 199.88 C 109.23 202.412 109.23 204.944 109.23 207.476 L 109.23 215.072 C 109.23 217.604 109.23 220.136 109.23 222.668 L 109.23 230.264 C 109.23 232.796 109.23 235.328 109.23 237.86 C 117.51 234.08 126.08 230.8 134.75 227.94 C 134.75 227.94 134.75 227.94 134.75 227.94"
android:valueTo="M 180.09 198.14 L 180.09 198.14 L 216.99 216.52 C 203.163 223.373 189.337 230.227 175.51 237.08 C 175.36 226.73 175.71 216.37 177.87 206.27 C 178.46 203.5 179.21 200.79 180.09 198.14 M 130.23 173.31 L 71.59 144.11 L 71.86 208.14 C 73.48 207.7 75.09 207.2 76.67 206.66 C 76.67 206.66 76.67 206.66 76.67 206.66 C 86.69 203.25 96.03 197.99 104.87 192.22 C 109.295 189.33 113.595 186.275 117.809 183.106 C 122.022 179.938 126.15 176.655 130.23 173.31 M 81.62 283.62 L 81.62 283.62 L 72.21 288.29 C 72.133 270.49 72.057 252.69 71.98 234.89 C 83.05 234.58 94.25 235.38 104.64 239.5 C 105.44 239.82 106.23 240.15 107.01 240.5 C 98.42 254.79 90.05 269.22 81.62 283.62 M 97.94 275.54 L 132.34 258.49 C 127.22 253.53 121.79 248.98 115.84 245.24 C 112.815 250.26 109.817 255.3 106.838 260.353 C 103.858 265.405 100.895 270.47 97.94 275.54 L 97.94 275.54 M 169.45 198.58 C 165.54 212.67 165.29 227.38 165.63 241.97 L 141.6 253.88 C 135.23 247.48 128.46 241.58 120.94 236.8 C 124.63 230.77 128.36 224.76 132.18 218.8 L 132.18 218.8 C 139.43 207.5 146.97 196.41 154.98 185.64 L 170.95 193.59 C 170.39 195.32 169.89 196.99 169.45 198.58 M 123.55 213.76 C 130.68 202.65 138.09 191.74 145.94 181.14 L 140.01 178.19 C 127.31 188.77 114.25 198.91 99.81 207.02 C 91.05 211.94 81.7 216.11 71.9 218.43 L 71.93 224.85 C 82.49 224.42 93.41 225.28 103.37 228.47 L 103.37 228.47 C 106.43 229.45 109.36 230.63 112.19 231.96 C 114.055 228.91 115.93 225.865 117.821 222.83 C 119.713 219.795 121.62 216.77 123.55 213.76"
android:valueType="pathType"
android:interpolator="@android:anim/linear_interpolator"/>
</aapt:attr>
</target>
</animated-vector>
Loading