Skip to content

Commit

Permalink
Add fade and rotate samples
Browse files Browse the repository at this point in the history
  • Loading branch information
skoric committed May 1, 2018
1 parent d263317 commit 94454fe
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 15 deletions.
11 changes: 8 additions & 3 deletions vangogh-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ android {
compileSdkVersion 27
buildToolsVersion "27.0.3"


defaultConfig {
applicationId "com.example.vangogh"
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
Expand All @@ -16,6 +15,11 @@ android {

}

lintOptions {
abortOnError false
}


buildTypes {
release {
minifyEnabled false
Expand All @@ -28,7 +32,8 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.pspdfkit-labs:vangogh:0.2.0'
testCompile 'junit:junit:4.12'
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
Expand Down
3 changes: 2 additions & 1 deletion vangogh-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
</intent-filter>
</activity>

<activity android:name=".samples.SingleAnimation"/>
<activity android:name=".samples.SingleRotateAnimationActivity"/>
<activity android:name=".samples.SingleFadeAnimationActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

import com.example.vangogh.menu.MainMenuAdapter;
import com.example.vangogh.menu.MainMenuItem;
import com.example.vangogh.samples.SingleAnimation;
import com.example.vangogh.samples.SingleAnimationActivity;
import com.example.vangogh.samples.SingleFadeAnimationActivity;
import com.example.vangogh.samples.SingleRotateAnimationActivity;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -37,7 +39,8 @@ public void onMainMenuItemClicked(@NonNull MainMenuItem item) {
@NonNull
public List<MainMenuItem> getMainMenuItems() {
List<MainMenuItem> items = new ArrayList<>();
items.add(new MainMenuItem("Single animation", "Showcases how single animations are executed", new SingleAnimation()));
items.add(new MainMenuItem("Fade animation", "Showcases the fade in/out animation", new SingleFadeAnimationActivity()));
items.add(new MainMenuItem("Rotate animation", "Showcases the rotation animation", new SingleRotateAnimationActivity()));
return items;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.vangogh.samples;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.example.vangogh.R;

public abstract class SingleAnimationActivity extends AppCompatActivity {

private FloatingActionButton fab;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_animation);
fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onFabClicked(fab);
}
});
}

protected abstract void onFabClicked(FloatingActionButton fab);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.vangogh.samples;

import android.support.design.widget.FloatingActionButton;
import android.view.View;

import io.reactivex.functions.Consumer;

import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeIn;
import static com.pspdfkit.labs.vangogh.api.FadeAnimations.fadeOut;

public class SingleFadeAnimationActivity extends SingleAnimationActivity {

@Override
protected void onFabClicked(final FloatingActionButton fab) {
fadeOut(fab)
.doOnAnimationStart(new Consumer<View>() {
@Override
public void accept(View view) throws Exception {
fab.setEnabled(false);
}
})
.doOnAnimationEnd(new Consumer<View>() {
@Override
public void accept(View view) throws Exception {
fab.setEnabled(true);
}
})
.andThen(fadeIn(fab))
.subscribe();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.vangogh.samples;

import android.support.design.widget.FloatingActionButton;
import android.view.View;

import io.reactivex.functions.Consumer;

import static com.pspdfkit.labs.vangogh.api.RotateAnimations.rotateBy;

public class SingleRotateAnimationActivity extends SingleAnimationActivity {

@Override
protected void onFabClicked(final FloatingActionButton fab) {
rotateBy(fab, 360)
.doOnAnimationStart(new Consumer<View>() {
@Override
public void accept(View view) throws Exception {
fab.setEnabled(false);
}
})
.doOnAnimationEnd(new Consumer<View>() {
@Override
public void accept(View view) throws Exception {
fab.setEnabled(true);
}
})
.andThen(rotateBy(fab, -360))
.subscribe();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M7,2v11h3v9l7,-12h-4l4,-8z"
android:fillColor="#FFFFFF"/>
</vector>
5 changes: 2 additions & 3 deletions vangogh-sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -11,4 +10,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</android.support.constraint.ConstraintLayout>
</FrameLayout>
23 changes: 23 additions & 0 deletions vangogh-sample/src/main/res/layout/activity_single_animation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_flash_on_white_24px"
app:elevation="4dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="12dp"
android:text="Click on the button to start the animation."/>

</RelativeLayout>

0 comments on commit 94454fe

Please sign in to comment.