Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated to latest Couchbase SDK

  • Loading branch information...
commit e49da081a847ee8c1835224ab19118e74a646267 1 parent bebabe2
Dale  Harvey authored
2  .classpath
@@ -4,4 +4,4 @@
4 4 <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
5 5 <classpathentry kind="lib" path="libs/commons-compress-1.0.jar"/>
6 6 <classpathentry kind="output" path="bin"/>
7   -<classpathentry kind="lib" path="libs/couchbase.jar"/></classpath>
  7 +<classpathentry kind="lib" path="libs/couchbase.jar"/><classpathentry kind="lib" path="libs/OtpErlang.jar"/></classpath>
BIN  Couchbase.zip
Binary file not shown
59 src/com/daleharvey/mobilefuton/MobileFutonActivity.java
@@ -15,7 +15,6 @@
15 15 import java.util.Enumeration;
16 16
17 17 import org.json.JSONException;
18   -import org.json.JSONObject;
19 18
20 19 import android.app.Activity;
21 20 import android.app.AlertDialog;
@@ -84,29 +83,12 @@ public void couchbaseStarted(String host, int port) {
84 83 }
85 84
86 85 @Override
87   - public void installing(int completed, int total) {
88   - ensureProgressDialog();
89   - installProgress.setTitle("Installing");
90   - installProgress.setProgress(completed);
91   - installProgress.setMax(total);
92   - }
93   -
94   - @Override
95 86 public void exit(String error) {
96 87 Log.v(TAG, error);
97 88 couchError();
98 89 }
99 90 };
100 91
101   - private void ensureProgressDialog() {
102   - if (installProgress == null) {
103   - installProgress = new ProgressDialog(MobileFutonActivity.this);
104   - installProgress.setTitle(" ");
105   - installProgress.setCancelable(false);
106   - installProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
107   - installProgress.show();
108   - }
109   - }
110 92
111 93 private void startCouch() {
112 94 CouchbaseMobile couch = new CouchbaseMobile(getBaseContext(), mCallback);
@@ -214,44 +196,15 @@ private void ensureDesignDoc(String dbName, String url) {
214 196
215 197 try {
216 198
217   - File hashCache = new File(CouchbaseMobile.dataPath() + "/couchapps/" + dbName + ".couchapphash");
218 199 String data = readAsset(getAssets(), dbName + ".json");
219   - String md5 = md5(data);
220   - String cachedHash;
221   - Boolean toUpdate;
222   -
223   - try {
224   - cachedHash = readFile(hashCache);
225   - toUpdate = !md5.equals(cachedHash);
226   - } catch (Exception e) {
227   - e.printStackTrace();
228   - toUpdate = true;
229   - }
230   -
231   - if (toUpdate == true) {
232   -
233   - String ddocUrl = url + dbName + "/_design/" + dbName;
234   -
235   - AndCouch req = AndCouch.get(ddocUrl);
236   -
237   - if (req.status == 404) {
238   - Log.v(TAG, "Installing Couchapp");
239   - AndCouch.put(url + dbName, null);
240   - AndCouch.put(ddocUrl, data);
241   - } else if (req.status == 200) {
242   - Log.v(TAG, "Couchapp Found, Updating");
243   - String rev = req.json.getString("_rev");
244   - JSONObject json = new JSONObject(data);
245   - json.put("_rev", rev);
246   - AndCouch.put(url + dbName, null);
247   - AndCouch.put(ddocUrl, json.toString());
248   - }
  200 + String ddocUrl = url + dbName + "/_design/" + dbName;
249 201
250   - new File(hashCache.getParent()).mkdirs();
251   - writeFile(hashCache, md5);
  202 + AndCouch req = AndCouch.get(ddocUrl);
252 203
253   - } else {
254   - Log.v(TAG, "Couchapp up to date");
  204 + if (req.status == 404) {
  205 + Log.v(TAG, "Installing Couchapp");
  206 + AndCouch.put(url + dbName, null);
  207 + AndCouch.put(ddocUrl, data);
255 208 }
256 209
257 210 } catch (IOException e) {

0 comments on commit e49da08

Please sign in to comment.
Something went wrong with that request. Please try again.