package com.yyrh.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;
import android.widget.ImageView;

import com.yyrh.utils.ResourceUtil;
import com.yyrh.utils.YYLog;

public class GameSplashDialog extends Dialog {
    private static ImageView iv_bg;
    private static Bitmap bit = null;
    private Context context;
    public GameSplashDialog(Context context, int theme) {
        super(context, theme);
        this.context = context;
    }
    public GameSplashDialog(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(ResourceUtil.getLayoutId(context,
                "hnyy_show_splash_view"));
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
        iv_bg =  findViewById(ResourceUtil.getId(context, "iv_show_bg"));
        try {
            bit = BitmapFactory.decodeStream(context.getAssets().open("yyrh_start_image.jpg"));
            iv_bg.setImageBitmap(bit);
        } catch (Exception e) {
            // TODO: handle exception

        }
        if(bit != null){
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    onSplashStop();
                }
            }, 2500);
        }else{

            YYLog.i("No adding welcomeImage");
            onSplashStop();
        }
    }

    private void onSplashStop() {
        dismiss();

    }

}
