Android Open Source - BoxSorter B S Application






From Project

Back to project page BoxSorter.

License

The source code is released under:

GNU General Public License

If you think the Android project BoxSorter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.silverhillapps.boxsorter;
/*from ww w.j av  a 2 s . c o  m*/
import android.annotation.TargetApi;
import android.app.Application;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.util.TypedValue;
import android.view.Display;
import android.view.WindowManager;

/**
 * Application class for wrapping global runtime variables
 * @author salva
 *
 */
public class BSApplication extends Application {
  
  private static Context mContext; // Application context for assets loading 
  private static int mScreenWidth; // Screen dimensions 
  private static int mScreenHeight;

  public void onCreate(){
    super.onCreate();
    BSApplication.mContext = getApplicationContext();
    getScreenDimensions();

  }

  /**
   * Method which returns the application context
   * @return the application context
   */
  public static Context getAppContext() {
    return BSApplication.mContext;
  }
  
  
  /**
   * This method return the effective screen width of the window
   * @return The calculated effective screen width in pixels
   */
  public static int getmScreenWidth() {
    return mScreenWidth;
  }

  /**
   * This method return the effective screen height of the window
   * @return The calculated effective screen height in pixels
   */
  public static int getmScreenHeight() {
    return mScreenHeight;
  }

  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
  private void getScreenDimensions(){
    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2){
      Point size = new Point();
      display.getSize(size);
      mScreenWidth = size.x;
      mScreenHeight = size.y;
    } else{
      mScreenWidth = display.getWidth();  
      mScreenHeight = display.getHeight();

    }
    mScreenHeight = mScreenHeight-actionBarHeight(); //we need to substract the action bar height to the screen dimensions

  }
  
  private int actionBarHeight(){
    int height = 0;
    TypedValue typeValue = new TypedValue();
    getTheme().resolveAttribute(android.R.attr.actionBarSize, typeValue, true);
    height = TypedValue.complexToDimensionPixelSize(typeValue.data,getResources().getDisplayMetrics());
    return height;
  }

}




Java Source Code List

com.silverhillapps.boxsorter.BSApplication.java
com.silverhillapps.boxsorter.BoxSorterActivity.java
com.silverhillapps.boxsorter.conf.Conf.java
com.silverhillapps.boxsorter.conf.Constants.java
com.silverhillapps.boxsorter.entities.Element.java
com.silverhillapps.boxsorter.entities.InitialPositionConfig.java
com.silverhillapps.boxsorter.gesture.BSGestureDetector.java
com.silverhillapps.boxsorter.gesture.BSMoveListener.java
com.silverhillapps.boxsorter.gesture.BSScaleDetector.java
com.silverhillapps.boxsorter.loader.InitialConfLoader.java
com.silverhillapps.boxsorter.loader.JsonAssetsInitialConfLoader.java
com.silverhillapps.boxsorter.loader.LoaderFactory.java
com.silverhillapps.boxsorter.loader.RandomInitialConfLoader.java
com.silverhillapps.boxsorter.subviews.Circle.java
com.silverhillapps.boxsorter.subviews.FigureFactory.java
com.silverhillapps.boxsorter.subviews.Figure.java
com.silverhillapps.boxsorter.subviews.Square.java
com.silverhillapps.boxsorter.utils.Utils.java
com.silverhillapps.boxsorter.views.BoxCanvasView.java