예제 #1
0
 /**
  * 获取屏幕宽高
  *
  * @param activity
  * @return
  */
 public static int[] getScreenSize() {
   int[] screens;
   // if (Constants.screenWidth > 0) {
   // return screens;
   // }
   DisplayMetrics dm = new DisplayMetrics();
   dm = MyApplication.getInstance().getResources().getDisplayMetrics();
   screens = new int[] {dm.widthPixels, dm.heightPixels};
   return screens;
 }
예제 #2
0
  /**
   * 短时间显示Toast消息,并保证运行在UI线程中
   *
   * @param activity Activity
   * @param message 消息内容
   */
  public static void show(final Context context, final String message) {
    final String msg = msgFilter != null ? msgFilter.filter(message) : message;
    MyApplication.getInstance()
        .getTopActivity()
        .runOnUiThread(
            new Runnable() {

              public void run() {
                // Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
                Toast toast =
                    ToastFactory.getToast(MyApplication.getInstance().getTopActivity(), message);
                toast.setGravity(Gravity.BOTTOM, 0, 0);
                toast.show();
              }
            });
  }