package de.philipphager.disclosure.feature.analyser.app;

import dalvik.system.DexFile;
import de.philipphager.disclosure.database.app.model.App;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import rx.Observable;

public class Apk {
  private final App app;

  public Apk(App app) throws IOException {
    this.app = app;
  }

  public App getApp() {
    return app;
  }

  public Observable<List<String>> getUsedClasses() throws IOException {
    File file = new File(app.sourceDir());
    List<String> classNames = new ArrayList<>();

    if (file.exists()) {
      DexFile dexFile = new DexFile(app.sourceDir());
      classNames.addAll(Collections.list(dexFile.entries()));
    }

    return Observable.from(classNames)
        .distinct()
        .toSortedList();
  }
}

@@ -335,16 +335,49 @@
 App app;
+%0A  private final DexFile dexFile;
 %0A%0A  publ
@@ -429,24 +429,83 @@
 .app = app;%0A
+    this.dexFile = new DexFile(new File(app.sourceDir()));%0A
   %7D%0A%0A  publi
@@ -597,203 +597,59 @@
 s() 
-throws IOException %7B%0A    File file = new File(app.sourceDir());%0A    List%3CString%3E classNames = new ArrayList%3C%3E();%0A%0A    if (file.exists()) %7B%0A      DexFile dexFile = new DexFile(app.sourceDir());%0A  
+%7B%0A    List%3CString%3E classNames = new ArrayList%3C%3E();%0A
     
@@ -707,14 +707,8 @@
 )));
-%0A    %7D
 %0A%0A  

Move DexFile loading in Apk constructor