package com.uddream.plugin;

import android.os.Bundle;
import android.util.Log;

/**
 * Created by Glen on 2016/9/8.
 */
public abstract class LifeCycleDelegate<T> {
    protected final T target;

    public LifeCycleDelegate(T target) {
        this.target = target;
    }

    public abstract void onCreate(Bundle savedInstanceState);

    public abstract void onResume();

    public abstract void onPause();

    public abstract void onDestroy();

    public abstract void setUserVisibleHint(boolean isVisibleToUser);

    public abstract void onHiddenChanged(boolean hidden);

    public abstract void onSaveInstanceState(Bundle outState);

    public abstract void onRestoreInstanceState(Bundle savedInstanceState);

    @SuppressWarnings("unused")
    public static LifeCycleDelegate create(Object object) {
        return new Empty(object);
    }

    public static class Empty extends LifeCycleDelegate<Object> {

        public Empty(Object target) {
            super(target);
        }

        @Override
        public void onCreate(Bundle savedInstanceState) {
            Log.e("Delegate", "onCreate");
        }

        @Override
        public void onResume() {
            Log.e("Delegate", "onResume");
        }

        @Override
        public void onPause() {
            Log.e("Delegate", "onPause");
        }

        @Override
        public void onDestroy() {
            Log.e("Delegate", "onDestroy");
        }

        @Override
        public void setUserVisibleHint(boolean isVisibleToUser) {

        }

        @Override
        public void onHiddenChanged(boolean hidden) {

        }

        @Override
        public void onSaveInstanceState(Bundle outState) {

        }

        @Override
        public void onRestoreInstanceState(Bundle savedInstanceState) {

        }
    }
}