Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
fixed bug causing crash when opening un-indexed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Winger committed Dec 23, 2014
1 parent cbe7572 commit a3bbdc9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package="ca.dracode.ais"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="0.6.0">
android:versionName="0.6.1">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.dracode</groupId>
<artifactId>ais</artifactId>
<version>0.6.0</version>
<version>0.6.1</version>
<packaging>apk</packaging>
<name>AndroidIndexingService</name>
<dependencies>
Expand Down
3 changes: 2 additions & 1 deletion src/ca/dracode/ais/indexer/FileIndexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import java.util.List;

public class FileIndexer {
private static final String TAG = "ca.dracode.ais.androidindexer.FileIndexer";
private static final String TAG = "ca.dracode.ais.indexer.FileIndexer";
private IndexWriter writer;
private FileSearcher searcher;

Expand Down Expand Up @@ -222,6 +222,7 @@ public int buildIndex(String filename, int pages) {
if(pages != -1) {
doc.add(new IntField("pages", pages, Field.Store.YES));
}
Log.w(TAG, "" + writer);
if(writer.getConfig().getOpenMode() == OpenMode.CREATE) {
writer.addDocument(doc);
} else {
Expand Down
17 changes: 11 additions & 6 deletions src/ca/dracode/ais/service/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,18 @@ public int buildIndex(int id, String filePath) {
if(!mIsBound){
doBindService();
}
while(!mIsBound){
while(!mIsBound || mBoundService == null){

}
mBoundService.createIndex(new File(filePath), this);
mBoundService.stopWhenReady();
unbindService(mConnection);
return waitForIndexer(new File(filePath));
try {
mBoundService.createIndex(new File(filePath), this);
mBoundService.stopWhenReady();
doUnbindService();
return waitForIndexer(new File(filePath));
} catch(Exception e){
Log.e(TAG, "Error: ", e);
}
return -1;
}

/**
Expand Down Expand Up @@ -266,7 +271,7 @@ private SearchResult find(int id, String term, String constrainValue, int maxRes
public int waitForIndexer(File content){
while(!this.builtIndexes.containsKey(content)){
try{
wait(5);
Thread.sleep(5);
} catch(InterruptedException e){
Log.e(TAG, "Error", e);
}
Expand Down

0 comments on commit a3bbdc9

Please sign in to comment.