Skip to content

Commit

Permalink
Improve AutoSize#autoConvertDensity
Browse files Browse the repository at this point in the history
  • Loading branch information
JessYanCoding committed Nov 9, 2018
1 parent 5e02e64 commit 2777f25
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
11 changes: 0 additions & 11 deletions autosize/src/main/java/me/jessyan/autosize/AutoSize.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.app.Dialog;
import android.app.Fragment;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.util.DisplayMetrics;
Expand All @@ -37,7 +36,6 @@
import me.jessyan.autosize.internal.CustomAdapt;
import me.jessyan.autosize.utils.LogUtils;
import me.jessyan.autosize.utils.Preconditions;
import me.jessyan.autosize.utils.ScreenUtils;

/**
* ================================================
Expand Down Expand Up @@ -150,15 +148,6 @@ public static void autoConvertDensityBaseOnHeight(Activity activity, float desig
public static void autoConvertDensity(Activity activity, float sizeInDp, boolean isBaseOnWidth) {
Preconditions.checkNotNull(activity, "activity == null");

boolean isVertical = activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

if (isVertical != AutoSizeConfig.getInstance().isVertical()) {
AutoSizeConfig.getInstance().setVertical(isVertical);
int[] screenSize = ScreenUtils.getScreenSize(activity.getApplicationContext());
AutoSizeConfig.getInstance().setScreenWidth(screenSize[0]);
AutoSizeConfig.getInstance().setScreenHeight(screenSize[1]);
}

int screenSize = isBaseOnWidth ? AutoSizeConfig.getInstance().getScreenWidth()
: AutoSizeConfig.getInstance().getScreenHeight();
String key = sizeInDp + "|" + isBaseOnWidth + "|"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void onConfigurationChanged(Configuration newConfig) {
Resources.getSystem().getDisplayMetrics().scaledDensity;
LogUtils.d("initScaledDensity = " + mInitScaledDensity + " on ConfigurationChanged");
}
isVertical = application.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
isVertical = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT;
int[] screenSize = ScreenUtils.getScreenSize(application);
mScreenWidth = screenSize[0];
mScreenHeight = screenSize[1];
Expand Down

0 comments on commit 2777f25

Please sign in to comment.