I have written a common class for finding display sizes in pre-honeycomb and for latest versions of android. Could anyone review my code and suggest me possible modifications in this code. I would love to do follow beautiful coding standards.
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.view.Display;
import android.view.WindowManager;
public class DisplayManager {
private Display mDisplay;
private WindowManager mWindowManager;
public DisplayManager(Context mContext) {
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
mDisplay = mWindowManager.getDefaultDisplay();
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public int getDisplayHeight() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
return mDisplay.getHeight();
} else {
Point size = new Point();
mDisplay.getSize(size);
return size.y;
}
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public int getDisplayWidth() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
return mDisplay.getWidth();
} else {
Point size = new Point();
mDisplay.getSize(size);
return size.x;
}
}
}