Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.os.Environment;

import android.util.Log;
import java.io.File;

import java.io.IOException;

public class Main {
    private static final String TAG = "BitmapUtils";
    private static final String THUMB_FORMAT_EXTENSION = ".jpg";

    /**
     * Creates a thumbnail file starting from an image/video file
     *
     * @param original_file original file path
     * @param video         true if the file is a video. false if the file is a picture
     * @return a file
     */
    private static File generateThumbnailFileForFile(File original_file, boolean video) {
        // Create an image file name
        try {
            String imageFileName = "thumb" + original_file.getName();
            Log.d(TAG, original_file.getName());
            File storageDir = Environment.getExternalStoragePublicDirectory(
                    video ? Environment.DIRECTORY_MOVIES : Environment.DIRECTORY_PICTURES);
            return File.createTempFile(imageFileName, /* prefix */
                    THUMB_FORMAT_EXTENSION, /* suffix */
                    storageDir /* directory */
            );
        } catch (IOException e) {
            Log.d(TAG, "Error", e);
        }
        return null;

    }
}