Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added use of camera + display picture (from camera) in ItemDetailFrag…
…ment (if available) + demo of Toast.
- Loading branch information
bart.blommaerts
committed
Nov 30, 2013
1 parent
81774bb
commit 4964c55
Showing
10 changed files
with
151 additions
and
18 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
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
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
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
52 changes: 52 additions & 0 deletions
52
Workshop/src/main/java/be/hp/workshop/util/CameraManipulation.java
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,52 @@ | ||
package be.hp.workshop.util; | ||
|
||
import android.net.Uri; | ||
import android.os.Environment; | ||
import android.util.Log; | ||
|
||
import java.io.File; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
/** | ||
* Created by bart on 11/30/13. | ||
*/ | ||
public class CameraManipulation { | ||
|
||
public static final int MEDIA_TYPE_IMAGE = 1; | ||
public static final int MEDIA_TYPE_VIDEO = 2; | ||
|
||
/** Create a file Uri for saving an image or video */ | ||
public static Uri getOutputMediaFileUri(int type){ | ||
return Uri.fromFile(getOutputMediaFile(type)); | ||
} | ||
|
||
/** Create a File for saving an image or video */ | ||
private static File getOutputMediaFile(int type){ | ||
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory( | ||
Environment.DIRECTORY_PICTURES), "Workshop"); | ||
|
||
// Create the storage directory if it does not exist | ||
if (! mediaStorageDir.exists()){ | ||
if (! mediaStorageDir.mkdirs()){ | ||
Log.d("Workshop", "failed to create directory"); | ||
return null; | ||
} | ||
} | ||
|
||
// Create a media file name | ||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); | ||
File mediaFile; | ||
if (type == MEDIA_TYPE_IMAGE){ | ||
mediaFile = new File(mediaStorageDir.getPath() + File.separator + | ||
"IMG_"+ timeStamp + ".jpg"); | ||
} else if(type == MEDIA_TYPE_VIDEO) { | ||
mediaFile = new File(mediaStorageDir.getPath() + File.separator + | ||
"VID_"+ timeStamp + ".mp4"); | ||
} else { | ||
return null; | ||
} | ||
|
||
return mediaFile; | ||
} | ||
} |
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