Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.neriel.imagetest;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.os.Environment;
- import android.util.Log;
- public class ImageOperationHelper {
- /** Get TAG for debugging messages */
- public static final boolean DEBUG = StartupActivity.DEBUG;
- /** Tag for LogCat */
- public static final String TAG = ImageOperationHelper.class.getSimpleName();
- private CharSequence fileName;
- boolean mExternalStorageAvailable = false;
- boolean mExternalStorageWriteable = false;
- ImageOperationHelper(CharSequence argfileName){
- this.fileName=argfileName;
- }
- //Gets Bitmap Test.png from storage if available
- private Bitmap getImage(){
- checkSDCardStatus();
- if (this.mExternalStorageAvailable) {
- if (DEBUG)
- Log.d(TAG, "Filename: " + this.fileName);
- Bitmap mBitmap = BitmapFactory.decodeFile((String)this.fileName);
- return mBitmap;
- }
- return null;
- }
- //@TODO
- public void drawLineOnBitMapAndSaveItOnSDCard(){
- Bitmap mBitmap; //do something with that bastard bitmap
- mBitmap = getImage();
- if(mBitmap!=null){
- //todo
- }
- if (mBitmap == null){
- Log.d(TAG,"File on storage available?");
- }
- }
- private void checkSDCardStatus() {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- // We can read and write the media
- mExternalStorageAvailable = mExternalStorageWriteable = true;
- } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
- // We can only read the media
- mExternalStorageAvailable = true;
- mExternalStorageWriteable = false;
- } else {
- // Something else is wrong. It may be one of many other states, but
- // all we need
- // to know is we can neither read nor write
- mExternalStorageAvailable = mExternalStorageWriteable = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement