diff --git a/library/src/main/java/com/lxj/xpopup/util/XPopupUtils.java b/library/src/main/java/com/lxj/xpopup/util/XPopupUtils.java index 524de489..7d743bfb 100644 --- a/library/src/main/java/com/lxj/xpopup/util/XPopupUtils.java +++ b/library/src/main/java/com/lxj/xpopup/util/XPopupUtils.java @@ -259,12 +259,12 @@ public static void moveUpToKeyboard(int keyboardHeight, BasePopupView pv) { if (focusEt != null && overflowHeight > 0) { dy = overflowHeight; } - }else if(isTopPartShadow(pv)){ + } else if (isTopPartShadow(pv)) { int overflowHeight = (focusBottom + keyboardHeight) - windowHeight; if (focusEt != null && overflowHeight > 0) { dy = overflowHeight; } - if(dy!=0){ + if (dy != 0) { pv.getPopupImplView().animate().translationY(-dy) .setDuration(200) .setInterpolator(new OvershootInterpolator(0)) @@ -296,7 +296,7 @@ public static void moveDown(BasePopupView pv) { pv.getPopupImplView().animate().translationY(0) .setInterpolator(new OvershootInterpolator(0)) .setDuration(200).start(); - }else { + } else { pv.getPopupContentView().animate().translationY(0) .setInterpolator(new OvershootInterpolator(0)) .setDuration(200).start(); @@ -346,22 +346,19 @@ public static void findAllEditText(ArrayList list, ViewGroup group) { } } - private static Context mContext; public static void saveBmpToAlbum(final Context context, final XPopupImageLoader imageLoader, final Object uri) { final Handler mainHandler = new Handler(Looper.getMainLooper()); final ExecutorService executor = Executors.newSingleThreadExecutor(); - mContext = context; executor.execute(new Runnable() { @Override public void run() { - File source = imageLoader.getImageFile(mContext, uri); + File source = imageLoader.getImageFile(context, uri); if (source == null) { mainHandler.post(new Runnable() { @Override public void run() { - Toast.makeText(mContext, "图片不存在!", Toast.LENGTH_SHORT).show(); - mContext = null; + Toast.makeText(context, "图片不存在!", Toast.LENGTH_SHORT).show(); } }); return; @@ -379,15 +376,14 @@ public void run() { //2. save writeFileFromIS(target, new FileInputStream(source)); //3. notify - MediaScannerConnection.scanFile(mContext, new String[]{target.getAbsolutePath()}, + MediaScannerConnection.scanFile(context, new String[]{target.getAbsolutePath()}, new String[]{"image/" + ext}, new MediaScannerConnection.OnScanCompletedListener() { @Override public void onScanCompleted(final String path, Uri uri) { mainHandler.post(new Runnable() { @Override public void run() { - Toast.makeText(mContext, "已保存到相册!", Toast.LENGTH_SHORT).show(); - mContext = null; + Toast.makeText(context, "已保存到相册!", Toast.LENGTH_SHORT).show(); } }); } @@ -397,8 +393,7 @@ public void run() { mainHandler.post(new Runnable() { @Override public void run() { - Toast.makeText(mContext, "没有保存权限,保存功能无法使用!", Toast.LENGTH_SHORT).show(); - mContext = null; + Toast.makeText(context, "没有保存权限,保存功能无法使用!", Toast.LENGTH_SHORT).show(); } }); }