DisplayManagerCompat.java 2.73 KB
package android.support.v4.hardware.display;

import android.content.Context;
import android.hardware.display.DisplayManager;
import android.os.Build.VERSION;
import android.view.Display;
import android.view.WindowManager;
import java.util.WeakHashMap;

public abstract class DisplayManagerCompat
{
  public static final String DISPLAY_CATEGORY_PRESENTATION = "android.hardware.display.category.PRESENTATION";
  private static final WeakHashMap<Context, DisplayManagerCompat> a = new WeakHashMap();
  
  public static DisplayManagerCompat getInstance(Context paramContext)
  {
    synchronized (a)
    {
      DisplayManagerCompat localDisplayManagerCompat = (DisplayManagerCompat)a.get(paramContext);
      Object localObject = localDisplayManagerCompat;
      if (localDisplayManagerCompat == null)
      {
        if (Build.VERSION.SDK_INT >= 17)
        {
          localObject = new a(paramContext);
          a.put(paramContext, localObject);
        }
      }
      else {
        return (DisplayManagerCompat)localObject;
      }
      localObject = new b(paramContext);
    }
  }
  
  public abstract Display getDisplay(int paramInt);
  
  public abstract Display[] getDisplays();
  
  public abstract Display[] getDisplays(String paramString);
  
  static final class a
    extends DisplayManagerCompat
  {
    private final Object a;
    
    public a(Context paramContext)
    {
      this.a = paramContext.getSystemService("display");
    }
    
    public final Display getDisplay(int paramInt)
    {
      return ((DisplayManager)this.a).getDisplay(paramInt);
    }
    
    public final Display[] getDisplays()
    {
      return ((DisplayManager)this.a).getDisplays();
    }
    
    public final Display[] getDisplays(String paramString)
    {
      return ((DisplayManager)this.a).getDisplays(paramString);
    }
  }
  
  static final class b
    extends DisplayManagerCompat
  {
    private final WindowManager a;
    
    public b(Context paramContext)
    {
      this.a = ((WindowManager)paramContext.getSystemService("window"));
    }
    
    public final Display getDisplay(int paramInt)
    {
      Display localDisplay = this.a.getDefaultDisplay();
      if (localDisplay.getDisplayId() == paramInt) {
        return localDisplay;
      }
      return null;
    }
    
    public final Display[] getDisplays()
    {
      return new Display[] { this.a.getDefaultDisplay() };
    }
    
    public final Display[] getDisplays(String paramString)
    {
      if (paramString == null) {
        return getDisplays();
      }
      return new Display[0];
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/hardware/display/DisplayManagerCompat.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */