package com.stu.assistant.uitls;

import android.app.Activity;
import android.app.Application;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


public class ShowClassNameCallBack implements Application.ActivityLifecycleCallbacks {
    @Override
    public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {

    }

    @Override
    public void onActivityStarted(@NonNull Activity activity) {
        if (activity == null) {
            return;
        }
        if (activity.getWindow() == null) {
            return;
        }
        if (activity.getWindow().getDecorView() == null) {
            return;
        }

        String activitySimpleName = activity.getClass().getSimpleName();

        Log.i("clazz",activity.getClass().getName());
        DragTextView textView = new DragTextView(activity);
        textView.setText(activitySimpleName);
        textView.setTextSize(18f);
        textView.setTextColor(Color.parseColor("#FF0000"));
        textView.setPadding(0, 50, 0, 0);

        textView.setClickable(true);
        View decorView= activity.getWindow().getDecorView();
        FrameLayout frameLayout= decorView.findViewById(android.R.id.content);
        textView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        textView.setGravity(Gravity.CENTER);
        frameLayout.addView(textView);
    }

    @Override
    public void onActivityResumed(@NonNull Activity activity) {

    }

    @Override
    public void onActivityPaused(@NonNull Activity activity) {

    }

    @Override
    public void onActivityStopped(@NonNull Activity activity) {

    }

    @Override
    public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {

    }

    @Override
    public void onActivityDestroyed(@NonNull Activity activity) {

    }
}
