Android Open Source - InfoWallpaper Screen






From Project

Back to project page InfoWallpaper.

License

The source code is released under:

MIT License

If you think the Android project InfoWallpaper 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.andreashedin.infowallpaper;
//  w w  w  . j av a 2s .  c  o m
import android.util.DisplayMetrics;
import android.util.Log;

public class Screen {
  private int mWidth = 0;
  private int mHeight = 0;
  private int mDensity = 0;
  private int mFormat = 0;
  private float mOffsetX = -1.0f;
  private float mOffsetY = -1.0f;
  private float mStepX = -1.0f;
  private float mStepY = -1.0f;
  private int mPixelsX = -1;
  private int mPixelsY = -1;
  private boolean mLocked = false;
  
  public Screen() {
    DisplayMetrics metrics = new DisplayMetrics();
    mDensity = metrics.densityDpi;
    metrics = null;
  }
  
  public int numberOfScreens() {
    if(mStepX <= 0.0f)
      return 0;
    
    return ((int)(1.0f / mStepX) + 1);
  }
  
  public float getPosOfScreen(int screen) {
    if(mPixelsX < 0 || mStepX < 0.0f || screen < 0) {
      return -1.0f;
    }
    
    int screens = (int)(1.0f / mStepX) + 1;
    
    float pos = mPixelsX / screens; 
    
    return pos;
  }
  
  public void updateWindow(int width, int height, int format) {
    mWidth = width;
    mHeight = height;
    mFormat = format;
  }
  
  public void setOffset(float offsetX, float offsetY, float stepX, float stepY, int pixelsX, int pixelsY) {
    if(stepX == 0.0f)
      return;
    
    mOffsetX = offsetX;
    mOffsetY = offsetY;
    mStepX = stepX;
    mStepY = stepY;
    mPixelsX = pixelsX;
    mPixelsY = pixelsY;
  }
  
  public int getOffsetXInPixels() {
    return mPixelsX;
  }
  
  public float getOffsetX() {
    return mOffsetX;
  }
  
  public float getStepX() { 
    return mStepX;
  }
  
  public boolean isLocked() {
    return mLocked;
  }
  
  public void locked(boolean locked) {
    mLocked = locked;
  }
  
  public float current() {
    return (mOffsetX / mStepX);
  }
  
  public int getWidth() {
    return mWidth;
  }
  
  public int getHeight() {
    return mHeight;
  }
  
  public int getDensity() {
    return mDensity;
  }
}




Java Source Code List

com.andreashedin.general.ColorPickerDialog.java
com.andreashedin.general.CustomizeInfoDialog.java
com.andreashedin.general.EnterStringDialog.java
com.andreashedin.general.PickItemDialog.java
com.andreashedin.general.PositionInfosDialog.java
com.andreashedin.general.SelectConfigurationDialog.java
com.andreashedin.general.TextSizeDialog.java
com.andreashedin.general.WeatherSettingsDialog.java
com.andreashedin.infowallpaper.Background.java
com.andreashedin.infowallpaper.BatteryDataCollector.java
com.andreashedin.infowallpaper.ColorHandler.java
com.andreashedin.infowallpaper.ConfigHandler.java
com.andreashedin.infowallpaper.CurrentSongDataCollector.java
com.andreashedin.infowallpaper.DataCollector.java
com.andreashedin.infowallpaper.DateTimeDataCollector.java
com.andreashedin.infowallpaper.DisplayValuePair.java
com.andreashedin.infowallpaper.InfoData.java
com.andreashedin.infowallpaper.InfoItem.java
com.andreashedin.infowallpaper.LiveInfoSettings.java
com.andreashedin.infowallpaper.LiveInfoWallpaper.java
com.andreashedin.infowallpaper.PhoneStatusDataCollector.java
com.andreashedin.infowallpaper.Phone.java
com.andreashedin.infowallpaper.SaveLoadData.java
com.andreashedin.infowallpaper.Screen.java
com.andreashedin.infowallpaper.WeatherDataCollector.java
com.andreashedin.infowallpaper.WeatherHandler.java