12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package com.edufound.android.xyyf.config;
- import android.app.Activity;
- import android.content.Context;
- import android.content.pm.ActivityInfo;
- import android.graphics.Color;
- import android.util.TypedValue;
- import android.view.Surface;
- import android.view.View;
- import android.widget.RelativeLayout;
- import android.widget.TextView;
- import com.edufound.android.xyyf.main.MainView;
- import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper;
- import static com.edufound.android.xyyf.config.AppUtils.dp2px;
- public abstract class BaseUIConfig implements AuthPageConfig {
- public Activity mActivity;
- public Context mContext;
- public PhoneNumberAuthHelper mAuthHelper;
- public int mScreenWidthDp;
- public int mScreenHeightDp;
- public static AuthPageConfig init(int type, Activity activity, PhoneNumberAuthHelper authHelper, MainView view) {
- switch (type) {
- case 0:
- return new DialogLandConfig(activity, authHelper, view);
- case 1:
- return new DialogLandConfigNoUI(activity, authHelper, view);
- }
- return null;
- }
- public BaseUIConfig(Activity activity, PhoneNumberAuthHelper authHelper, MainView view) {
- mActivity = activity;
- mContext = activity.getApplicationContext();
- mAuthHelper = authHelper;
- }
- protected void updateScreenSize(int authPageScreenOrientation) {
- int screenHeightDp = AppUtils.px2dp(mContext, AppUtils.getPhoneHeightPixels(mContext));
- int screenWidthDp = AppUtils.px2dp(mContext, AppUtils.getPhoneWidthPixels(mContext));
- int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
- if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_BEHIND) {
- authPageScreenOrientation = mActivity.getRequestedOrientation();
- }
- if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
- || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
- || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE) {
- rotation = Surface.ROTATION_90;
- } else if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
- || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
- || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT) {
- rotation = Surface.ROTATION_180;
- }
- switch (rotation) {
- case Surface.ROTATION_0:
- case Surface.ROTATION_180:
- mScreenWidthDp = screenWidthDp;
- mScreenHeightDp = screenHeightDp;
- break;
- case Surface.ROTATION_90:
- case Surface.ROTATION_270:
- mScreenWidthDp = screenHeightDp;
- mScreenHeightDp = screenWidthDp;
- break;
- default:
- break;
- }
- }
- /**
- * 在横屏APP弹竖屏一键登录页面或者竖屏APP弹横屏授权页时处理特殊逻辑
- * Android8.0只能启动SCREEN_ORIENTATION_BEHIND模式的Activity
- */
- public void onResume() {
- }
- public void release() {
- mAuthHelper.setAuthListener(null);
- mAuthHelper.setUIClickListener(null);
- mAuthHelper.removeAuthRegisterViewConfig();
- mAuthHelper.removeAuthRegisterXmlConfig();
- }
- }
|