Android Open Source - Android-Media-Helper Default File Creator






From Project

Back to project page Android-Media-Helper.

License

The source code is released under:

Apache License

If you think the Android project Android-Media-Helper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package mobi.sherif.imageuploader;
/*from w  w w.  ja v  a  2  s  .c  o  m*/
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import mobi.sherif.imageuploader.MediaEngine.FileCreator;
import android.os.Environment;

class DefaultFileCreator implements FileCreator {
  String defaultExt;

  public DefaultFileCreator(String ext) {
    this.defaultExt = ext;
  }

  @Override
  public File createFile(String ext) throws FileCreationException {
    if (ext == null) ext = defaultExt;
    try {
      String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
      String imageFileName = "Upload" + "_" + timeStamp;
      File image = File.createTempFile(imageFileName, "." + ext, getAlbumDir());
      return image;
    } catch (Exception e) {
      throw new FileCreationException(e);
    }
  }

  private File getAlbumDir( ) {
    File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Uploads");
    if ( !dir.exists()) dir.mkdirs();
    return dir;
  }
}




Java Source Code List

mobi.sherif.example.imageuploader.ActivityForFragmentSupportVideo.java
mobi.sherif.example.imageuploader.ActivityForFragmentSupport.java
mobi.sherif.example.imageuploader.ActivityForFragmentVideo.java
mobi.sherif.example.imageuploader.ActivityForFragment.java
mobi.sherif.example.imageuploader.ImageUploaderActivitySupportVideo.java
mobi.sherif.example.imageuploader.ImageUploaderActivitySupport.java
mobi.sherif.example.imageuploader.ImageUploaderActivityVideo.java
mobi.sherif.example.imageuploader.ImageUploaderActivity.java
mobi.sherif.example.imageuploader.ImageUploaderFragmentSupportVideo.java
mobi.sherif.example.imageuploader.ImageUploaderFragmentSupport.java
mobi.sherif.example.imageuploader.ImageUploaderFragmentVideo.java
mobi.sherif.example.imageuploader.ImageUploaderFragment.java
mobi.sherif.example.imageuploader.MainActivity.java
mobi.sherif.imageuploader.ActivityManager.java
mobi.sherif.imageuploader.DefaultFileCreator.java
mobi.sherif.imageuploader.DefaultImageFileCreator.java
mobi.sherif.imageuploader.DefaultVideoFileCreator.java
mobi.sherif.imageuploader.FileLoadTask.java
mobi.sherif.imageuploader.FragmentSupportYesNoDialog.java
mobi.sherif.imageuploader.FragmentYesNoDialogBuilder.java
mobi.sherif.imageuploader.FragmentYesNoDialog.java
mobi.sherif.imageuploader.MediaEngine.java