new plotter

This commit is contained in:
Sergey Solovyev
2013-01-05 22:56:52 +04:00
parent 5f7ee1e64e
commit 2c0803da74
24 changed files with 932 additions and 655 deletions

View File

@@ -5,8 +5,16 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Environment;
import android.util.Log;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* User: Solovyev_S
* Date: 03.10.12
@@ -55,4 +63,43 @@ public final class AndroidUtils2 {
int componentEnabledSetting = pm.getComponentEnabledSetting(new ComponentName(context, componentClass));
return componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
}
public static String saveBitmap(@NotNull Bitmap bitmap,
@NotNull String path,
@NotNull String fileName) {
final File sdcardPath = Environment.getExternalStorageDirectory();
final File filePath = new File(sdcardPath, path);
filePath.mkdirs();
final String fullFileName = fileName + "_" + System.currentTimeMillis() + ".png";
final File file = new File(path, fullFileName);
if (!file.exists()) {
final String name = file.getAbsolutePath();
FileOutputStream fos = null;
try {
fos = new FileOutputStream(name);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
} catch (FileNotFoundException e) {
Log.e("AndroidUtils", e.getMessage(), e);
} catch (IOException e) {
Log.e("AndroidUtils", e.getMessage(), e);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
Log.e("AndroidUtils", e.getMessage(), e);
}
}
}
return name;
}
return null;
}
}