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.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;

public class Main {
    public static void startAnimation(View target, int aniResId) {
        startAnimation(target, aniResId, null);
    }

    public static void startAnimation(View target, int aniResId, int duration) {
        startAnimation(target, aniResId, duration, null);
    }

    public static void startAnimation(View target, int aniResId, AnimationListener listener) {
        if (target == null) {
            return;
        }

        Animation animation = AnimationUtils.loadAnimation(target.getContext(), aniResId);
        if (animation == null) {
            return;
        }

        if (listener != null) {
            animation.setAnimationListener(listener);
        }

        target.startAnimation(animation);
    }

    public static void startAnimation(View target, int aniResId, int duration, AnimationListener listener) {
        if (target == null) {
            return;
        }

        Animation animation = AnimationUtils.loadAnimation(target.getContext(), aniResId);

        if (animation == null) {
            return;
        }

        if (listener != null) {
            animation.setAnimationListener(listener);
        }

        animation.setDuration(duration);
        target.startAnimation(animation);
    }
}