BaseUIConfig.java 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package com.edufound.android.xyyf.config;
  2. import android.app.Activity;
  3. import android.content.Context;
  4. import android.content.pm.ActivityInfo;
  5. import android.graphics.Color;
  6. import android.util.TypedValue;
  7. import android.view.Surface;
  8. import android.view.View;
  9. import android.widget.RelativeLayout;
  10. import android.widget.TextView;
  11. import com.edufound.android.xyyf.main.MainView;
  12. import com.mobile.auth.gatewayauth.PhoneNumberAuthHelper;
  13. import static com.edufound.android.xyyf.config.AppUtils.dp2px;
  14. public abstract class BaseUIConfig implements AuthPageConfig {
  15. public Activity mActivity;
  16. public Context mContext;
  17. public PhoneNumberAuthHelper mAuthHelper;
  18. public int mScreenWidthDp;
  19. public int mScreenHeightDp;
  20. public static AuthPageConfig init(int type, Activity activity, PhoneNumberAuthHelper authHelper, MainView view) {
  21. switch (type) {
  22. case 0:
  23. return new DialogLandConfig(activity, authHelper, view);
  24. case 1:
  25. return new DialogLandConfigNoUI(activity, authHelper, view);
  26. }
  27. return null;
  28. }
  29. public BaseUIConfig(Activity activity, PhoneNumberAuthHelper authHelper, MainView view) {
  30. mActivity = activity;
  31. mContext = activity.getApplicationContext();
  32. mAuthHelper = authHelper;
  33. }
  34. protected void updateScreenSize(int authPageScreenOrientation) {
  35. int screenHeightDp = AppUtils.px2dp(mContext, AppUtils.getPhoneHeightPixels(mContext));
  36. int screenWidthDp = AppUtils.px2dp(mContext, AppUtils.getPhoneWidthPixels(mContext));
  37. int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
  38. if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_BEHIND) {
  39. authPageScreenOrientation = mActivity.getRequestedOrientation();
  40. }
  41. if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
  42. || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
  43. || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE) {
  44. rotation = Surface.ROTATION_90;
  45. } else if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
  46. || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
  47. || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT) {
  48. rotation = Surface.ROTATION_180;
  49. }
  50. switch (rotation) {
  51. case Surface.ROTATION_0:
  52. case Surface.ROTATION_180:
  53. mScreenWidthDp = screenWidthDp;
  54. mScreenHeightDp = screenHeightDp;
  55. break;
  56. case Surface.ROTATION_90:
  57. case Surface.ROTATION_270:
  58. mScreenWidthDp = screenHeightDp;
  59. mScreenHeightDp = screenWidthDp;
  60. break;
  61. default:
  62. break;
  63. }
  64. }
  65. /**
  66. * 在横屏APP弹竖屏一键登录页面或者竖屏APP弹横屏授权页时处理特殊逻辑
  67. * Android8.0只能启动SCREEN_ORIENTATION_BEHIND模式的Activity
  68. */
  69. public void onResume() {
  70. }
  71. public void release() {
  72. mAuthHelper.setAuthListener(null);
  73. mAuthHelper.setUIClickListener(null);
  74. mAuthHelper.removeAuthRegisterViewConfig();
  75. mAuthHelper.removeAuthRegisterXmlConfig();
  76. }
  77. }