From 6d4e6a1b2e0c68dd373d84077b0235217a62531b Mon Sep 17 00:00:00 2001
From: Kevin088 <284904817@qq.com>
Date: Mon, 29 Jan 2018 17:58:16 +0800
Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=20=E5=9B=BE=E7=89=87?=
 =?UTF-8?q?=E9=A2=84=E8=A7=88=E4=BF=9D=E5=AD=98=E5=90=8E=20=E6=9B=B4?=
 =?UTF-8?q?=E6=96=B0=E7=B3=BB=E7=BB=9F=E5=9B=BE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../lib/PictureExternalPreviewActivity.java   | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/picture_library/src/main/java/com/luck/picture/lib/PictureExternalPreviewActivity.java b/picture_library/src/main/java/com/luck/picture/lib/PictureExternalPreviewActivity.java
index b648802df..4cfaa22da 100644
--- a/picture_library/src/main/java/com/luck/picture/lib/PictureExternalPreviewActivity.java
+++ b/picture_library/src/main/java/com/luck/picture/lib/PictureExternalPreviewActivity.java
@@ -1,15 +1,19 @@
 package com.luck.picture.lib;
 
 import android.Manifest;
+import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.PointF;
 import android.graphics.drawable.Drawable;
+import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.provider.MediaStore;
 import android.support.annotation.Nullable;
 import android.support.v4.view.PagerAdapter;
 import android.support.v4.view.ViewPager;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -46,6 +50,7 @@
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
@@ -397,6 +402,22 @@ public void handleMessage(Message msg) {
                 case 200:
                     String path = (String) msg.obj;
                     showToast(getString(R.string.picture_save_success) + "\n" + path);
+
+                    /**
+                     * 更新系统图库
+                     */
+                    String name="";
+                    if(!TextUtils.isEmpty(path)){
+                        name=path.substring(path.lastIndexOf("/"));
+                    }
+                    try {
+                        MediaStore.Images.Media.insertImage(getContentResolver(),
+                                path, name, null);
+                    } catch (FileNotFoundException e) {
+                        e.printStackTrace();
+                    }
+                    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + path)));
+
                     dismissDialog();
                     break;
             }