io.vov.vitamio.utils.IOUtils Java Examples

The following examples show how to use io.vov.vitamio.utils.IOUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Vitamio.java    From react-native-android-vitamio with MIT License 6 votes vote down vote up
private static boolean extractLibs(Context ctx, int rawID) {
  long begin = System.currentTimeMillis();
  final int version = ContextUtils.getVersionCode(ctx);
  Log.d("loadLibs start " + version);
  File lock = new File(getLibraryPath() + LIBS_LOCK);
  if (lock.exists())
    lock.delete();
  String libPath = copyCompressedLib(ctx, rawID, "libarm.so");
  Log.d("copyCompressedLib time: " + (System.currentTimeMillis() - begin) / 1000.0);
  boolean inited = native_initializeLibs(libPath, getLibraryPath(), String.valueOf(Vitamio.getVitamioType()));
  new File(libPath).delete();
  FileWriter fw = null;
  try {
    lock.createNewFile();
    fw = new FileWriter(lock);
    fw.write(String.valueOf(version));
    return true;
  } catch (IOException e) {
    Log.e("Error creating lock file", e);
  } finally {
    Log.d("initializeNativeLibs: " + inited);
    Log.d("loadLibs time: " + (System.currentTimeMillis() - begin) / 1000.0);
    IOUtils.closeSilently(fw);
  }
  return false;
}
 
Example #2
Source File: Vitamio.java    From Vitamio with Apache License 2.0 6 votes vote down vote up
private static boolean extractLibs(Context ctx, int rawID) {
  long begin = System.currentTimeMillis();
  final int version = ContextUtils.getVersionCode(ctx);
  Log.d("loadLibs start " + version);
  File lock = new File(getLibraryPath() + LIBS_LOCK);
  if (lock.exists())
    lock.delete();
  String libPath = copyCompressedLib(ctx, rawID, "libarm.so");
  Log.d("copyCompressedLib time: " + (System.currentTimeMillis() - begin) / 1000.0);
  boolean inited = native_initializeLibs(libPath, getLibraryPath(), String.valueOf(Vitamio.getVitamioType()));
  new File(libPath).delete();
  FileWriter fw = null;
  try {
    lock.createNewFile();
    fw = new FileWriter(lock);
    fw.write(String.valueOf(version));
    return true;
  } catch (IOException e) {
    Log.e("Error creating lock file", e);
  } finally {
    Log.d("initializeNativeLibs: " + inited);
    Log.d("loadLibs time: " + (System.currentTimeMillis() - begin) / 1000.0);
    IOUtils.closeSilently(fw);
  }
  return false;
}
 
Example #3
Source File: Vitamio.java    From BambooPlayer with Apache License 2.0 6 votes vote down vote up
private static boolean extractLibs(Context ctx, int rawID) {
  long begin = System.currentTimeMillis();
  final int version = ContextUtils.getVersionCode(ctx);
  Log.d("loadLibs start " + version);
  File lock = new File(getLibraryPath() + LIBS_LOCK);
  if (lock.exists())
    lock.delete();
  String libPath = copyCompressedLib(ctx, rawID, "libarm.so");
  Log.d("copyCompressedLib time: " + (System.currentTimeMillis() - begin) / 1000.0);
  boolean inited = native_initializeLibs(libPath, getLibraryPath(), String.valueOf(Vitamio.getVitamioType()));
  new File(libPath).delete();
  FileWriter fw = null;
  try {
    lock.createNewFile();
    fw = new FileWriter(lock);
    fw.write(String.valueOf(version));
    return true;
  } catch (IOException e) {
    Log.e("Error creating lock file", e);
  } finally {
    Log.d("initializeNativeLibs: " + inited);
    Log.d("loadLibs time: " + (System.currentTimeMillis() - begin) / 1000.0);
    IOUtils.closeSilently(fw);
  }
  return false;
}