Skip to content

Commit

Permalink
Adding some changes from leoalekseyev and daniel-kullmann
Browse files Browse the repository at this point in the history
  • Loading branch information
matburt committed Jun 16, 2011
1 parent 98ea820 commit 261e34d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
3 changes: 2 additions & 1 deletion res/layout/simpletext.xml
Expand Up @@ -11,6 +11,7 @@
<TextView android:id="@+id/orgTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="all"/>
android:autoLink="all"
android:textSize="15sp"/>
</LinearLayout>
</ScrollView>
6 changes: 4 additions & 2 deletions src/com/matburt/mobileorg/MobileOrgActivity.java
Expand Up @@ -219,8 +219,10 @@ else if (e.editType.equals("heading")) {
private static final int OP_MENU_CAPTURE = 4;

private static final int RUN_PARSER = 3;

private static final String LT = "MobileOrg";

private int displayIndex;
private ProgressDialog syncDialog;
private MobileOrgDatabase appdb;
private ReportableError syncError;
Expand All @@ -231,7 +233,7 @@ public void run() {
postSynchronize();
}
};

@Override
public void onCreate(Bundle savedInstanceState)
{
Expand Down
14 changes: 14 additions & 0 deletions src/com/matburt/mobileorg/Synchronizers/DropboxSynchronizer.java
Expand Up @@ -17,6 +17,7 @@
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

public class DropboxSynchronizer extends Synchronizer {
private boolean hasToken = false;
Expand Down Expand Up @@ -107,6 +108,19 @@ public void pull() throws NotFoundException, ReportableError {
key,
newChecksums.get(key));
}

// the key-value semantics is switched: in getOrgFiles(), the HashMap has filenames as keys
// while in masterList (getOrgFilesFromMaster) the file aliases are keys
HashSet<String> filesInDb = new HashSet<String>(this.appdb.getOrgFiles().keySet());
HashSet<String> filesInIndexFile = new HashSet<String>(masterList.values());
filesInDb.removeAll(filesInIndexFile); //now contains stale DB files
if (filesInDb.size() > 0) {
Object[] arrObj = filesInDb.toArray();
for (int i = 0; i < arrObj.length; i++) {
Log.i(LT, "Orphaned file: " + (String)arrObj[i]);
removeFile((String)arrObj[i]);
}
}
}

private String getRootPath() throws ReportableError {
Expand Down
14 changes: 14 additions & 0 deletions src/com/matburt/mobileorg/Synchronizers/SDCardSynchronizer.java
Expand Up @@ -12,6 +12,7 @@
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

public class SDCardSynchronizer extends Synchronizer
{
Expand Down Expand Up @@ -158,6 +159,19 @@ public void pull() throws NotFoundException, ReportableError {
Log.d(LT, "Fetching: " + key + ": " + basePath + "/" + masterList.get(key));
this.appdb.addOrUpdateFile(masterList.get(key), key, newChecksums.get(key));
}

// the key-value semantics is switched: in getOrgFiles(), the HashMap has filenames as keys
// while in masterList (getOrgFilesFromMaster) the file aliases are keys
HashSet<String> filesInDb = new HashSet<String>(this.appdb.getOrgFiles().keySet());
HashSet<String> filesInIndexFile = new HashSet<String>(masterList.values());
filesInDb.removeAll(filesInIndexFile); //now contains stale DB files
if (filesInDb.size() > 0) {
Object[] arrObj = filesInDb.toArray();
for (int i = 0; i < arrObj.length; i++) {
Log.i(LT, "Orphaned file: " + (String)arrObj[i]);
removeFile((String)arrObj[i]);
}
}
}

private String readFile(String filePath) throws ReportableError,
Expand Down
14 changes: 14 additions & 0 deletions src/com/matburt/mobileorg/Synchronizers/WebDAVSynchronizer.java
Expand Up @@ -29,6 +29,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.regex.Pattern;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
Expand Down Expand Up @@ -127,6 +128,19 @@ public void pull() throws NotFoundException, ReportableError {
key,
newChecksums.get(key));
}

// the key-value semantics is switched: in getOrgFiles(), the HashMap has filenames as keys
// while in masterList (getOrgFilesFromMaster) the file aliases are keys
HashSet<String> filesInDb = new HashSet<String>(this.appdb.getOrgFiles().keySet());
HashSet<String> filesInIndexFile = new HashSet<String>(masterList.values());
filesInDb.removeAll(filesInIndexFile); //now contains stale DB files
if (filesInDb.size() > 0) {
Object[] arrObj = filesInDb.toArray();
for (int i = 0; i < arrObj.length; i++) {
Log.i(LT, "Orphaned file: " + (String)arrObj[i]);
removeFile((String)arrObj[i]);
}
}
}

public BufferedReader fetchOrgFile(String orgUrl) throws NotFoundException, ReportableError {
Expand Down

0 comments on commit 261e34d

Please sign in to comment.