package com.yyrh.ui.activity;




import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.KeyEvent;

import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;



import com.yyrh.ui.fragment.FragmentUtils;
import com.yyrh.utils.ResourceUtil;

import static com.yyrh.constant.SDKSettings.isLandscape;


public class UseLoginActivity extends BaseActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(ResourceUtil.getLayoutId(this,"hnyy_login_activity"));



        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            Window window = getWindow();
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            WindowManager.LayoutParams lp = getWindow().getAttributes();
            lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
            getWindow().setAttributes(lp);
        }



        initView(this);

   }
    private void initView(Context context){
        Intent intent = getIntent();

        int fragmentTag  =intent.getIntExtra("fragmentTag",FragmentUtils.SDK_REGISTER_TAG);
        int orientation  =intent.getIntExtra("orientation",FragmentUtils.SDK_REGISTER_TAG);

        Fragment mJmUserLoginFragment = FragmentUtils.getSdkFragment(context,fragmentTag);


        FrameLayout layout = findViewById(ResourceUtil.getId(this,"hnyy_content"));
        setRequestedOrientation(orientation);
        if (!isLandscape){
            layout.setScaleX(0.9f);
            layout.setScaleY(0.9f);
        }


        addFragmentToActivity(getFragmentManager(),mJmUserLoginFragment,layout.getId());
    }


    @Override
    public void finish() {
        super.finish();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return false;
    }
}
