Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.support.annotation.NonNull;
import android.view.View;

import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;

public class Main {
    @NonNull
    private static AnimatorSet createDisappearAnim(View btnPanel, View recyclerView, View locationTxt,
            View headline) {
        AnimatorSet animAll = new AnimatorSet();

        Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 1, 0);
        Animator anim1_2 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 1, 0);
        Animator anim1_3 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 1, 0);
        Animator anim1_4 = ObjectAnimator.ofFloat(recyclerView, View.ALPHA, 1, 0);
        setBatchTiming(400, 0, anim1_1, anim1_2, anim1_3, anim1_4, anim1_4);
        animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4);

        Interpolator interpolator2 = new DecelerateInterpolator();
        Animator anim2_1 = ObjectAnimator.ofFloat(locationTxt, View.ALPHA, 1, 0);
        Animator anim2_2 = ObjectAnimator.ofFloat(locationTxt, View.SCALE_X, 1f, 2f);
        Animator anim2_3 = ObjectAnimator.ofFloat(locationTxt, View.SCALE_Y, 1f, 2f);
        anim2_1.setInterpolator(interpolator2);
        anim2_2.setInterpolator(interpolator2);
        anim2_3.setInterpolator(interpolator2);
        setBatchTiming(800, 0, anim2_1, anim2_2, anim2_3);
        animAll.play(anim2_1).with(anim2_2).with(anim2_3).after(anim1_1);
        return animAll;
    }

    @NonNull
    private static AnimatorSet createDisappearAnim(View startBtn, View pick1, View pick2, View image,
            View headline) {
        AnimatorSet animAll = new AnimatorSet();

        Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 1, 0);
        Animator anim1_2 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 1, 0);
        Animator anim1_3 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 1, 0);
        Animator anim1_4 = ObjectAnimator.ofFloat(pick1, View.ALPHA, 1, 0);
        Animator anim1_5 = ObjectAnimator.ofFloat(pick2, View.ALPHA, 1, 0);
        setBatchTiming(400, 0, anim1_1, anim1_2, anim1_3, anim1_4, anim1_5);
        animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4).with(anim1_5);

        Interpolator interpolator2 = new DecelerateInterpolator();
        Animator anim2_1 = ObjectAnimator.ofFloat(image, View.ALPHA, 1, 0);
        Animator anim2_2 = ObjectAnimator.ofFloat(image, View.SCALE_X, 1f, 2f);
        Animator anim2_3 = ObjectAnimator.ofFloat(image, View.SCALE_Y, 1f, 2f);
        anim2_1.setInterpolator(interpolator2);
        anim2_2.setInterpolator(interpolator2);
        anim2_3.setInterpolator(interpolator2);
        setBatchTiming(800, 0, anim2_1, anim2_2, anim2_3);
        animAll.play(anim2_1).with(anim2_2).with(anim2_3).after(anim1_1);
        return animAll;
    }

    private static void setBatchTiming(long millis, long startDelay, Animator... anims) {
        for (Animator a : anims) {
            a.setDuration(millis);
            a.setStartDelay(startDelay);
        }
    }
}