// Get the minimum image scaled rect which is fit to current screen
  Rect getMiniumCanvasRect(String strImagePath, int nMargin) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(displayMetrics);
    int nScreenWidth = displayMetrics.widthPixels - nMargin * 2;
    int nScreenHeight = displayMetrics.heightPixels - nMargin * 2;

    // Make more small for screen rotation T.T
    if (nScreenWidth < nScreenHeight) nScreenHeight = nScreenWidth;
    else nScreenWidth = nScreenHeight;

    int nImageWidth = nScreenWidth;
    int nImageHeight = nScreenHeight;

    float fResizeWidth = (float) nScreenWidth / nImageWidth;
    float fResizeHeight = (float) nScreenHeight / nImageHeight;
    float fResizeRatio;

    // Fit to height
    if (fResizeWidth > fResizeHeight) {
      fResizeRatio = fResizeHeight;
    }
    // Fit to width
    else {
      fResizeRatio = fResizeWidth;
    }

    return new Rect(0, 0, (int) (nImageWidth * fResizeRatio), (int) (nImageHeight * fResizeRatio));
  }
  // get real screen size
  private Point getRealScreenSize() {
    int heightPixels, widthPixels;
    Point screenResolution = null;
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display d = manager.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    d.getMetrics(metrics);
    // since SDK_INT = 1;
    heightPixels = metrics.heightPixels;
    widthPixels = metrics.widthPixels;
    // includes window decorations (statusbar bar/navigation bar)
    if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17)
      try {
        heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d);
        widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d);
      } catch (Exception ignored) {
      }
    // includes window decorations (statusbar bar/navigation bar)
    else if (Build.VERSION.SDK_INT >= 17)
      try {
        android.graphics.Point realSize = new android.graphics.Point();
        Display.class.getMethod("getRealSize", android.graphics.Point.class).invoke(d, realSize);
        heightPixels = realSize.y;
        widthPixels = realSize.x;
      } catch (Exception ignored) {

      }
    // Log.e("realHightPixels-heightPixels", heightPixels + "width");
    screenResolution = new Point(widthPixels, heightPixels);
    return screenResolution;
  }
Example #3
0
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    sHeight = getHeight();
    sWidth = getWidth();
    if (sHeight == 0 || sWidth == 0) {
      android.util.DisplayMetrics mMetrics = new android.util.DisplayMetrics();
      android.view.WindowManager wm =
          (android.view.WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
      wm.getDefaultDisplay().getMetrics(mMetrics);
      sHeight = mMetrics.heightPixels;
      sWidth = mMetrics.widthPixels;
    }

    if (sHeight < sWidth) {
      texY = 0;
      texX = (sWidth - sHeight) / 2;
      ;
      texWidth = sHeight;
    } else {
      texY = (sHeight - sWidth) / 2;
      texX = 0;
      texWidth = sWidth;
    }

    mBitmapViewWidth = (int) (sWidth / 2);
    mCenterX = mBitmapViewWidth;
    mCenterY = sHeight / 2;
    mScreenRadius = Math.min(mBitmapViewWidth, sHeight / 2);
    // mBitmap.getHeight()));
    setDrawingCacheBackgroundColor(Color.TRANSPARENT);
    setBitmap();
    drawIntoBitmap();
  }
 private void initView() {
   view = LayoutInflater.from(context).inflate(R.layout.floating_layout_list, null);
   RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler);
   recyclerView.setLayoutManager(
       new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
   recyclerView.setItemAnimator(new DefaultItemAnimator());
   setupBackground();
   hideRecycler();
   recyclerView.setAdapter(adapter);
   windowManager.addView(view, rParams);
   if (floatingImage == null) floatingImage = new ImageView(context);
   setupFloatingImage(false);
   floatingImage.setOnTouchListener(
       new View.OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           gestureDetector.onTouchEvent(event);
           return FloatingHorizontalLayout.this.onTouch(v, event);
         }
       });
   windowManager.addView(floatingImage, mParams);
   onMyAppsLoader = new MyPopupAppsLoader(context, this);
   onMyAppsLoader.registerListener(3, onLoadCompleteListener);
   onMyAppsLoader.startLoading();
   animateHidden();
 }
  @SuppressWarnings("deprecation")
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_scroll, container, false);
    ButterKnife.inject(this, rootView);

    initRollInformation(rootView);

    setOnclickListener();

    WindowManager wm = getActivity().getWindowManager();
    width = wm.getDefaultDisplay().getWidth();
    //        int leftMargin = width / 3;
    //        int caculateW = width - leftMargin;
    int dpW = ScreenUtil.dp2px(getActivity(), 100);

    int _width = (width - dpW) / mRow;

    // If we do this we need to uncomment the container on the xml layout
    createListBuddiesLayoutDinamically(rootView);
    // mImagesLeft.addAll(Arrays.asList(ImagesUrls.imageUrls_left));
    // mImagesRight.addAll(Arrays.asList(ImagesUrls.imageUrls_right));
    initData(_width);
    //		mListBuddies.setOnItemClickListener(this);
    return rootView;
  }
Example #6
0
  @Override
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {

    super.initialize(cordova, webView);

    WindowManager manager =
        ((WindowManager)
            cordova.getActivity().getApplicationContext().getSystemService(Context.WINDOW_SERVICE));

    WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
    localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    localLayoutParams.gravity = Gravity.TOP;
    localLayoutParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            |

            // this is to enable the notification to recieve touch events
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
            |

            // Draws over status bar
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

    localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    localLayoutParams.height =
        (int) (30 * cordova.getActivity().getResources().getDisplayMetrics().scaledDensity);
    localLayoutParams.format = PixelFormat.TRANSPARENT;

    CustomViewGroup view = new CustomViewGroup(cordova.getActivity().getApplicationContext());

    manager.addView(view, localLayoutParams);
  }
Example #7
0
 public static int getDisplayWidth(Context context) {
   DisplayMetrics displayMetrics = new DisplayMetrics();
   WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   wm.getDefaultDisplay().getMetrics(displayMetrics);
   int displayWidth = displayMetrics.widthPixels;
   return displayWidth;
 }
  public KamoflageLayout(
      Kamoflage.Widget _kContainer,
      String _title,
      Context context,
      boolean _horizontal,
      boolean _framed,
      boolean _scrollable) {
    super(context);

    kContainerParent = _kContainer;

    framed = _framed;
    scrollable = _scrollable;

    Activity act = (Activity) context;
    if (act != null) {
      WindowManager wm = act.getWindowManager();
      Display d = wm.getDefaultDisplay();
      screen_w = d.getWidth();
      screen_h = d.getHeight();
    }

    if (framed) {
      frame_view = new KamoflageLayoutFrame(context, _title);
      super.addView(frame_view);
      frame_view.setVisibility(View.VISIBLE);
    }

    title = _title;

    contained = new Vector<Contained>();
    expanded = new Vector<Contained>();

    horizontal = _horizontal;
  }
 /**
  * @param context the application context
  * @return Point containing the width and height
  * @brief methods for getting device window height and width via Point object
  */
 public static Point getWindowSize(Context context) {
   WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   Display display = windowManager.getDefaultDisplay();
   Point size = new Point();
   display.getSize(size);
   return size;
 }
 /**
  * 计算popupWindows的高宽
  *
  * @param context
  */
 private void calWidthAndHeight(Context context) {
   WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   DisplayMetrics outMetrics = new DisplayMetrics();
   manager.getDefaultDisplay().getMetrics(outMetrics);
   mWidth = outMetrics.widthPixels;
   mHeight = (int) (outMetrics.heightPixels * 0.7);
 }
Example #11
0
  public void removeNote() {
    if (config.notes.size() <= 0) return;

    boolean removing = false;

    int noteCount = 0;
    for (int i = 0; i < config.notes.size(); i++) {
      SteamHUDNote note = config.notes.get(i);
      if (!note.removing) {
        noteCount = config.notes.size() - i - 1;
        note.removing = true;
        break;
      } else if (i == config.notes.size() - 1) {
        return;
      }
    }

    WindowManager.LayoutParams params = (WindowManager.LayoutParams) getLayoutParams();
    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);

    params.height = (int) (74 * noteCount * config.scaleFactor) + 1;

    wm.updateViewLayout(this, params);

    config.hudRender.invalidate();
  }
Example #12
0
 public static int getScreenHeight(Context context) {
   WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   Display display = manager.getDefaultDisplay();
   DisplayMetrics metrics = new DisplayMetrics();
   display.getMetrics(metrics);
   return metrics.heightPixels;
 }
Example #13
0
  /** 学院 */
  private void showCademyDialog() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setTitle("学院")
        .setItems(
            R.array.cademys,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                // user.job = which;
                // action_done();
                curUser.setCademy(getResources().getStringArray(R.array.cademys)[which]);
                aq.id(R.id.et_mineinfo_cademy).text(curUser.getCademy());
              }
            });

    // builder.create().show();
    WindowManager m = getWindowManager();
    Display d = m.getDefaultDisplay();
    AlertDialog dialog = builder.create();
    dialog.show();
    WindowManager.LayoutParams p = dialog.getWindow().getAttributes();
    Point outSize = new Point();
    d.getSize(outSize);
    p.height = (int) (outSize.y * 0.6); // 高度设置为屏幕的0.6
    // p.width = (int) (d.getWidth() * 0.8);
    dialog.getWindow().setAttributes(p);
    dialogTitleLineColor(dialog);
  }
  // Get the minimum image scaled rect which is fit to current screen
  Rect getMaximumCanvasRect(int nMarginWidth, int nMarginHeight) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(displayMetrics);
    int nScreenWidth = displayMetrics.widthPixels - nMarginWidth;
    int nScreenHeight = displayMetrics.heightPixels - nMarginHeight;

    // rough image size estimation
    int nImageWidth = 640;
    int nImageHeight = 480;

    float fResizeWidth = (float) nScreenWidth / nImageWidth;
    float fResizeHeight = (float) nScreenHeight / nImageHeight;
    float fResizeRatio;

    // Fit to Height
    if (fResizeWidth > fResizeHeight) {
      fResizeRatio = fResizeHeight;
    }
    // Fit to Width
    else {
      fResizeRatio = fResizeWidth;
    }
    // return new Rect(0,0, (int)(nImageWidth*fResizeRatio), (int)(nImageHeight*fResizeRatio));
    // Adjust more detail
    int nResizeWidth = (int) (nImageWidth * fResizeRatio);
    int nResizeHeight = (int) (0.5 + (nResizeWidth * nImageHeight) / (float) nImageWidth);
    return new Rect(0, 0, nResizeWidth, nResizeHeight);
  }
Example #15
0
 // 获取屏幕的分辨率
 private void getViewSize(Context context) {
   DisplayMetrics metrics = new DisplayMetrics();
   WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   windowManager.getDefaultDisplay().getMetrics(metrics);
   this.screenHeight = metrics.heightPixels;
   this.screenWidth = metrics.widthPixels;
 }
Example #16
0
  public void init(HTextView hTextView, AttributeSet attrs, int defStyle) {
    mHTextView = hTextView;

    mText = "";
    mOldText = "";

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(textColor);
    paint.setStyle(Paint.Style.FILL);

    oldPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    oldPaint.setColor(textColor);
    oldPaint.setStyle(Paint.Style.FILL);

    backPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    backPaint.setColor(((ColorDrawable) mHTextView.getBackground()).getColor());
    backPaint.setStyle(Paint.Style.FILL);

    metrics = new DisplayMetrics();
    WindowManager windowManger =
        (WindowManager) hTextView.getContext().getSystemService(Context.WINDOW_SERVICE);
    windowManger.getDefaultDisplay().getMetrics(metrics);

    textSize = hTextView.getTextSize();

    sparkBitmap = BitmapFactory.decodeResource(hTextView.getResources(), R.drawable.fire);
  }
Example #17
0
 public static RectI getDeviceScreenSize(Context context, boolean useDeviceSize) {
   RectI rect = new RectI();
   WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   android.view.Display display = windowManager.getDefaultDisplay();
   DisplayMetrics metrics = new DisplayMetrics();
   display.getMetrics(metrics);
   int widthPixels = metrics.widthPixels;
   int heightPixels = metrics.heightPixels;
   if (!useDeviceSize) {
     rect.width = widthPixels;
     rect.height = heightPixels;
     return rect;
   }
   int buildInt = AndroidGame.getSDKVersion();
   if (buildInt >= 14 && buildInt < 17)
     try {
       widthPixels = (Integer) android.view.Display.class.getMethod("getRawWidth").invoke(display);
       heightPixels =
           (Integer) android.view.Display.class.getMethod("getRawHeight").invoke(display);
     } catch (Exception ignored) {
     }
   if (buildInt >= 17)
     try {
       android.graphics.Point realSize = new android.graphics.Point();
       android.view.Display.class
           .getMethod("getRealSize", android.graphics.Point.class)
           .invoke(display, realSize);
       widthPixels = realSize.x;
       heightPixels = realSize.y;
     } catch (Exception ignored) {
     }
   rect.width = widthPixels;
   rect.height = heightPixels;
   return rect;
 }
Example #18
0
  @Override
  public void onCreate() {
    super.onCreate();

    mContext = getApplicationContext();
    ImagePipelineConfig frescoConfig =
        ImagePipelineConfig.newBuilder(getApplicationContext())
            .setProgressiveJpegConfig(
                new ProgressiveJpegConfig() {
                  @Override
                  public int getNextScanNumberToDecode(int scanNumber) {
                    return scanNumber + 1;
                  }

                  @Override
                  public QualityInfo getQualityInfo(int scanNumber) {
                    boolean isGood = (scanNumber >= 3);
                    return ImmutableQualityInfo.of(scanNumber, isGood, false);
                  }
                })
            .build();
    Fresco.initialize(getApplicationContext(), frescoConfig);

    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(metrics);
    Configs.SCREEN_WIDTH = metrics.widthPixels;
    Configs.SCREEN_HEIGHT = metrics.heightPixels;
  }
Example #19
0
 private void setViewSize() {
   WindowManager m = getWindowManager();
   Display d = m.getDefaultDisplay();
   ViewGroup.LayoutParams params = previewImage.getLayoutParams();
   params.height = (int) (d.getHeight() * 0.3);
   previewImage.setLayoutParams(params);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_default_words, container, false);
    //            ((TextView) rootView.findViewById(android.R.id.text1)).setText(
    //                    getString(R.string.dummy_section_text, args.getInt(ARG_SECTION_NUMBER)));
    // Lookup the recyclerview in activity layout
    RecyclerView wordsTable = (RecyclerView) rootView.findViewById(R.id.words_table);
    // Create adapter passing in the sample user data
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    mAdapter = new DefaultWordsListAdapter(getContext(), null);
    mWordsTable = (RecyclerView) rootView.findViewById(R.id.words_table);
    //        // Set layout manager to position the items
    WindowManager wm = (WindowManager) getContext().getSystemService(getContext().WINDOW_SERVICE);

    reloadData();
    mWordsTable.setAdapter(mAdapter);

    // TODO: remove magic param from code(put inside xml configuration or find alternative way)
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    GridLayoutManager lmanager =
        new GridLayoutManager(getContext(), size.x / ((int) metrics.density * 180));
    mWordsTable.setLayoutManager(lmanager);
    return rootView;
  }
Example #21
0
  // create a new ImageView for each item referenced by the Adapter
  public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {
      // if it's not recycled, initialize some attributes
      imageView = new ImageView(mContext);
      WindowManager wm =
          (WindowManager) parent.getContext().getSystemService(Context.WINDOW_SERVICE);
      Display display = wm.getDefaultDisplay();
      Point size = new Point();
      display.getSize(size);
      int width = size.x;
      if (width < 1080) {
        imageView.setLayoutParams(new GridView.LayoutParams(250, 180));
      } else {
        imageView.setLayoutParams(new GridView.LayoutParams(350, 250));
      }
      imageView.setScaleType(ImageView.ScaleType.FIT_XY);
      imageView.setPadding(8, 8, 8, 8);
    } else {
      imageView = (ImageView) convertView;
    }

    imageView.setImageResource(mThumbIds[position]);
    return imageView;
  }
Example #22
0
  /**
   * 处理大图片工具方法,避免 OOM
   *
   * @param imgPath : 图片路径
   * @return : 返回缩放后的图片
   */
  @SuppressWarnings("deprecation")
  public static Bitmap zoomBitmap(Activity activity, String imgPath) {
    //  1. 获取屏幕的宽高信息
    WindowManager windowManager = activity.getWindowManager();
    int width = windowManager.getDefaultDisplay().getWidth();
    int height = windowManager.getDefaultDisplay().getHeight();
    //      	System.out.println("屏幕的宽 = " + width + "   高 = " + height);

    //  2.获取图片的宽高
    Options options = new BitmapFactory.Options(); // 解析位图的附加条件
    options.inJustDecodeBounds = true; // 只解析位图的头文件信息(图片的附加信息)
    BitmapFactory.decodeFile(imgPath, options);
    int bitmapWidth = options.outWidth;
    int bitmapHeight = options.outHeight;
    //      	System.out.println("图片的宽 = " + bitmapWidth + "   高 = " + bitmapHeight);

    //  3.计算图片的缩放比例
    int dx = bitmapWidth / width;
    int dy = bitmapHeight / height;

    int scale = 1;
    if (dx > dy && dy > 1) {
      scale = dx;
      //          System.out.println("按照水平方向绽放,缩放比例 = " + dx);
    }
    if (dy > dx && dx > 1) {
      scale = dy;
      //          System.out.println("按照垂直方法缩放,缩放比例 = " + dy);
    }

    //  4.返回缩放后的位图给调用者
    options.inSampleSize = scale;
    options.inJustDecodeBounds = false; // 解析全部图片
    return BitmapFactory.decodeFile(imgPath, options);
  }
Example #23
0
 public static int px2dip(Context ctx, int pxValue) {
   WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
   DisplayMetrics metrics = new DisplayMetrics();
   wm.getDefaultDisplay().getMetrics(metrics);
   float scale = metrics.density;
   return (int) (pxValue / scale + 0.5f);
 }
Example #24
0
  public GameLoopView(Context context) {
    super(context);

    // remember the context for finding resources
    this.context = context;

    score = 0;

    // want to know when the surface changes
    surfaceHolder = getHolder();
    surfaceHolder.addCallback(this);

    // set a fixed location

    location = new Location("FIXED POSITION");
    location.setLatitude(0);
    location.setAltitude(0);
    location.setLongitude(0);

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point p = new Point();
    display.getSize(p);
    screenWidth = p.x;
    screenHeight = p.y;

    // game loop thread
    thread = new GameLoopThread();
  }
Example #25
0
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 void GetScreenSizeJB(Point size, boolean real) {
   WindowManager w = getWindowManager();
   if (real) {
     w.getDefaultDisplay().getRealSize(size);
   }
 }
Example #26
0
  public static String getScreenWidthAndHeight(Context var0) {
    try {
      DisplayMetrics var1 = new DisplayMetrics();
      WindowManager var2 =
          (WindowManager) ((WindowManager) var0.getSystemService(Context.WINDOW_SERVICE));
      var2.getDefaultDisplay().getMetrics(var1);
      int var3 = -1;
      int var4 = -1;
      if ((var0.getApplicationInfo().flags & 8192) == 0) {
        var3 = getDisplayMetricsFiled((Object) var1, (String) "noncompatWidthPixels");
        var4 = getDisplayMetricsFiled((Object) var1, (String) "noncompatHeightPixels");
      }

      if (var3 == -1 || var4 == -1) {
        var3 = var1.widthPixels;
        var4 = var1.heightPixels;
      }

      StringBuffer var5 = new StringBuffer();
      var5.append(var3);
      var5.append("*");
      var5.append(var4);
      return var5.toString();
    } catch (Exception var6) {
      YLog.e(TAG, "read resolution fail--->" + var6);
      return "Unknown";
    }
  }
Example #27
0
 /**
  * 取得手机屏幕高度px
  *
  * @param context 上下文
  * @return 屏幕高度px
  */
 public static int getScreenHeightPx(Context context) {
   WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
   DisplayMetrics dm = new DisplayMetrics();
   manager.getDefaultDisplay().getMetrics(dm);
   int screenHeight = dm.heightPixels;
   return screenHeight;
 }
Example #28
0
File: c.java Project: KilFer/miband
 public static String b(Context paramContext) {
   try {
     if (b == null) {
       WindowManager localWindowManager = (WindowManager) paramContext.getSystemService("window");
       DisplayMetrics localDisplayMetrics = new DisplayMetrics();
       localWindowManager.getDefaultDisplay().getMetrics(localDisplayMetrics);
       StringBuilder localStringBuilder = new StringBuilder();
       localStringBuilder.append("imei=").append(a(paramContext)).append('&');
       localStringBuilder.append("model=").append(Build.MODEL).append('&');
       localStringBuilder.append("os=").append(Build.VERSION.RELEASE).append('&');
       localStringBuilder.append("apilevel=").append(Build.VERSION.SDK_INT).append('&');
       localStringBuilder
           .append("display=")
           .append(localDisplayMetrics.widthPixels)
           .append('*')
           .append(localDisplayMetrics.heightPixels)
           .append('&');
       localStringBuilder.append("manu=").append(Build.MANUFACTURER).append("&");
       b = localStringBuilder.toString();
     }
     String str = b;
     return str;
   } catch (Exception localException) {
   }
   return null;
 }
Example #29
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_post_layout);

    WindowManager mWm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    mWm.getDefaultDisplay().getMetrics(dm);

    /*TextView textview_city = (TextView)findViewById(R.id.textcity_item);
    LayoutParams laParams0 = (LayoutParams)textview_city.getLayoutParams();
    laParams0.height=dm.heightPixels - dm.widthPixels;
    laParams0.width = dm.widthPixels;
    textview_city.setPadding(0, 0, 100, 200);*/
    // textview_city.setLayoutParams(laParams0);

    // ����mContext

    mPoscalCodList = new ArrayList<String>();

    // ��ȡ���
    readPostalCodeList();

    mCheckArray = new boolean[mPoscalCodList.size()];
    for (int i = 0; i < mCheckArray.length; i++) {
      mCheckArray[i] = false;
    }

    mgridview = (GridView) findViewById(R.id.grid_citys);
    mgridview.requestFocus();
    mcitysAdapter = new citysAdapter(this);
    mgridview.setAdapter(mcitysAdapter);

    WeatherReceiver.setEditHandler(mHandler);
  }
 private void initAvatarSize() {
   WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
   Display display = windowManager.getDefaultDisplay();
   // 要获取屏幕的宽和高等参数,首先需要声明一个DisplayMetrics对象,屏幕的宽高等属性存放在这个对象中
   DisplayMetrics DM = new DisplayMetrics();
   // 获取窗口管理器,获取当前的窗口,调用getDefaultDisplay()后,其将关于屏幕的一些信息写进DM对象中,最后通过getMetrics(DM)获取
   windowManager.getDefaultDisplay().getMetrics(DM);
   displayWidth = DM.widthPixels;
   displayHeight = DM.heightPixels;
   // 使用display.getOrientation() 判断横竖屏不准确
   if (displayWidth > displayHeight) {
     displayWidth = DM.heightPixels;
     displayHeight = DM.widthPixels;
   }
   DisplayMetrics metrics = new DisplayMetrics();
   display.getMetrics(metrics);
   density = metrics.density;
   densityDpi = metrics.densityDpi;
   if (densityDpi <= DisplayMetrics.DENSITY_LOW) {
   } else if (densityDpi <= DisplayMetrics.DENSITY_MEDIUM) {
   } else if (densityDpi <= DisplayMetrics.DENSITY_HIGH
       && displayWidth <= Constants.DISPLAY_HDPI_WIDTH) {
   } else {
   }
   if (BuildConfig.DEBUG) {
     Log.v("Display Width: ", " " + displayWidth);
     Log.v("Display Height: ", " " + displayHeight);
     Log.v("Display Density: ", " " + densityDpi);
     Log.d(TAG, "initAvatarSize Finish : " + System.currentTimeMillis() / 1000);
   }
 }