-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from dilix/dev/gallerypath/0
Several new methods to support many pictures per screen.
- Loading branch information
Showing
7 changed files
with
304 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu Sep 08 12:02:41 CEST 2016 | ||
#Fri Jun 30 14:03:37 MSK 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.mvc.imagepicker; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Created by Anatol on 11/12/2016. | ||
*/ | ||
|
||
public final class ImageUtils { | ||
|
||
private static final String BASE_IMAGE_NAME = "i_prefix_"; | ||
|
||
private ImageUtils() { | ||
} | ||
|
||
public static String savePicture(Context context, Bitmap bitmap, String imageSuffix) { | ||
File savedImage = getTemporalFile(context, imageSuffix + ".jpeg"); | ||
FileOutputStream fos = null; | ||
if (savedImage.exists()) { | ||
savedImage.delete(); | ||
} | ||
try { | ||
fos = new FileOutputStream(savedImage.getPath()); | ||
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, fos); | ||
} catch (java.io.IOException e) { | ||
e.printStackTrace(); | ||
} finally { | ||
if (!bitmap.isRecycled()) { | ||
bitmap.recycle(); | ||
} | ||
if (fos != null) { | ||
try { | ||
fos.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
return savedImage.getAbsolutePath(); | ||
} | ||
|
||
public static File getTemporalFile(Context context, String payload) { | ||
return new File(context.getExternalCacheDir(), BASE_IMAGE_NAME + payload); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.