Skip to content

Commit

Permalink
Optimize BannerUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
zhpanvip committed Dec 28, 2019
1 parent 8ee9aa6 commit 86ba63e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/example/zhpan/circleviewpager/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Application;

import com.zhpan.bannerview.utils.BannerUtils;
import com.zhpan.idea.utils.Utils;

/**
Expand All @@ -16,5 +17,6 @@ public class App extends Application {
public void onCreate() {
super.onCreate();
Utils.init(getApplicationContext());
BannerUtils.setDebugMode(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@
*/
public class BannerUtils {

private static final boolean DEBUG = true;
private static boolean debugMode = false;

public float density;
public static void setDebugMode(boolean isDebug) {
debugMode = isDebug;
}

public BannerUtils() {
this.density = Resources.getSystem().getDisplayMetrics().density;
public static boolean isDebugMode() {
return debugMode;
}

public static int dp2px(float dpValue) {
return (int) (0.5F + dpValue * Resources.getSystem().getDisplayMetrics().density);
}

public static void log(String tag, String msg) {
if (DEBUG) {
if (debugMode) {
Log.e(tag, msg);
}
}

public static void log(String msg) {
if (DEBUG) {
if (debugMode) {
Log.e("BannerView", msg);
}
}
Expand Down

0 comments on commit 86ba63e

Please sign in to comment.