/**
   * {@inheritDoc}
   *
   * @see org.emdev.ui.AbstractActivityController#onDestroy(boolean)
   */
  @Override
  public void onDestroy(final boolean finishing) {
    if (finishing) {
      if (BackupSettings.current().backupOnBookClose) {
        BackupManager.backup();
      }
      if (documentModel != null) {
        documentModel.recycle();
      }
      if (scheme != null && scheme.temporary) {
        CacheManager.clear(scheme.key);
      }
      SettingsManager.removeListener(this);
      BitmapManager.clear("on finish");
      ByteBufferManager.clear("on finish");

      EBookDroidApp.onActivityClose(finishing);
    }
  }
示例#2
0
 @Override
 public JSONObject backup() {
   final BookBackupType backupType = BackupSettings.current().bookBackup;
   final JSONObject root = new JSONObject();
   if (backupType == BookBackupType.NONE) {
     return root;
   }
   try {
     final JSONArray books = new JSONArray();
     root.put("books", books);
     final Map<String, BookSettings> m =
         backupType == BookBackupType.RECENT ? getRecentBooks(true) : getAllBooks();
     for (final BookSettings bs : m.values()) {
       final JSONObject obj = bs.toJSON();
       books.put(obj);
     }
   } catch (final JSONException ex) {
     SettingsManager.LCTX.e("Error on recent book backup: " + ex.getMessage());
   }
   return root;
 }
  /**
   * {@inheritDoc}
   *
   * @see android.app.Application#onCreate()
   */
  @Override
  public void onCreate() {
    super.onCreate();

    instance = this;
    version = EBookDroidVersion.get(APP_VERSION_CODE);

    SettingsManager.init(this);
    CacheManager.init(this);
    MediaManager.init(this);

    initFonts();

    preallocateHeap(AppSettings.current().heapPreallocate);

    SettingsManager.addListener(this);
    onAppSettingsChanged(null, AppSettings.current(), null);
    onBackupSettingsChanged(null, BackupSettings.current(), null);

    GLConfiguration.stencilRequired = !IS_EMULATOR;

    initialized.set();
  }