BaseUIConfig.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. case 2:
  27. return new FullPortConfig(activity, authHelper, view);
  28. }
  29. return null;
  30. }
  31. public BaseUIConfig(Activity activity, PhoneNumberAuthHelper authHelper, MainView view) {
  32. mActivity = activity;
  33. mContext = activity.getApplicationContext();
  34. mAuthHelper = authHelper;
  35. }
  36. protected void updateScreenSize(int authPageScreenOrientation) {
  37. int screenHeightDp = AppUtils.px2dp(mContext, AppUtils.getPhoneHeightPixels(mContext));
  38. int screenWidthDp = AppUtils.px2dp(mContext, AppUtils.getPhoneWidthPixels(mContext));
  39. int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
  40. if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_BEHIND) {
  41. authPageScreenOrientation = mActivity.getRequestedOrientation();
  42. }
  43. if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
  44. || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
  45. || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE) {
  46. rotation = Surface.ROTATION_90;
  47. } else if (authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
  48. || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
  49. || authPageScreenOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT) {
  50. rotation = Surface.ROTATION_180;
  51. }
  52. switch (rotation) {
  53. case Surface.ROTATION_0:
  54. case Surface.ROTATION_180:
  55. mScreenWidthDp = screenWidthDp;
  56. mScreenHeightDp = screenHeightDp;
  57. break;
  58. case Surface.ROTATION_90:
  59. case Surface.ROTATION_270:
  60. mScreenWidthDp = screenHeightDp;
  61. mScreenHeightDp = screenWidthDp;
  62. break;
  63. default:
  64. break;
  65. }
  66. }
  67. /**
  68. * 在横屏APP弹竖屏一键登录页面或者竖屏APP弹横屏授权页时处理特殊逻辑
  69. * Android8.0只能启动SCREEN_ORIENTATION_BEHIND模式的Activity
  70. */
  71. public void onResume() {
  72. }
  73. public void release() {
  74. mAuthHelper.setAuthListener(null);
  75. mAuthHelper.setUIClickListener(null);
  76. mAuthHelper.removeAuthRegisterViewConfig();
  77. mAuthHelper.removeAuthRegisterXmlConfig();
  78. }
  79. }