Skip to content

Commit

Permalink
minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Murphy committed Jan 29, 2012
1 parent 02a0ed6 commit 12ef2df
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 32 deletions.
5 changes: 2 additions & 3 deletions WIMM/QRCodeKeeper/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
android:label="@string/app_name">
<uses-library
android:name="com.wimm.framework"
android:required="false"/>
android:required="true"/>

<activity
android:name=".QRCodeKeeperActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light">
android:label="@string/app_name">
<meta-data
android:name="com.wimm.app.peekview"
android:resource="@layout/peekview"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ protected void onPostExecute(Bitmap bitmap) {

if (ex!=null) {
Log.e("ImageLoadTask", "Exception loading image", ex);
// listener.handleError(ex);
}
}

public interface Listener {
void handleResult(Bitmap bitmap);
void handleError(Exception ex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public JSONLoadTask(Context ctxt, Listener listener) {
this.listener=listener;
}

/**
* Runs on a worker thread, loading in our data.
*/
@Override
public JSONObject doInBackground(String... path) {
JSONObject json=null;
Expand Down Expand Up @@ -66,7 +63,6 @@ protected void onPostExecute(JSONObject json) {

public interface Listener {
void handleResult(JSONObject json);

void handleError(Exception ex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,26 @@ public void onCreate(Bundle savedInstanceState) {
tray.setCanLoop(true);

NetworkService network=new NetworkService(this);

if (SyncService.iCanHasData(this)) {
loadEntries();
}
else {
noCanDo=true;
}

if (SyncService.isSyncNeeded(this, prefs)
&& network.isNetworkAvailable()) {
startService(new Intent(this, SyncService.class));
}
else {
network.requestNetworkConnection();

if (SyncService.isSyncNeeded(this, prefs)) {
if (network.isNetworkAvailable()) {
startService(new Intent(this, SyncService.class));
}
else {
network.requestNetworkConnection();
}
}

if (noCanDo) {
AlertDialog dlg=new AlertDialog(this);

dlg.setButton(getText(R.string.close), this);
dlg.setMessage(getText(R.string.no_can_do));
dlg.show();
Expand All @@ -82,7 +83,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onResume() {
super.onResume();

if (!noCanDo) {
registerReceiver(statusReceiver,
new IntentFilter(SyncService.ACTION_SYNC_STATUS));
Expand All @@ -94,7 +95,7 @@ public void onPause() {
if (!noCanDo) {
unregisterReceiver(statusReceiver);
}

super.onPause();
}

Expand Down Expand Up @@ -127,16 +128,16 @@ public void handleError(Exception ex) {

@Override
public void onClick(DialogInterface dialog, int which) {
finish();
finish();
}

private void loadEntries() {
new JSONLoadTask(this, this).execute("codes.json");
new JSONLoadTask(this, this).execute(SyncService.SYNC_LOCAL_FILE);
}

private void goBlooey(Exception ex) {
AlertDialog dlg=new AlertDialog(this);

dlg.setButton(getText(R.string.close), this);
dlg.setMessage(ex.getMessage());
dlg.show();
Expand Down Expand Up @@ -170,7 +171,6 @@ public View getView(int position, View convertView, ViewGroup parent) {
new File(getFilesDir(), getItem(position).getFilename());

new ImageLoadTask(qrCode).execute(image.getAbsolutePath());
// qrCode.setImageBitmap(BitmapFactory.decodeFile(image.getAbsolutePath()));
}
catch (Exception ex) {
Log.e("QRCodeKeeper", "Exception interpreting JSON", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class SyncService extends IntentService {
private static final String TAG="QRCodeKeeper-SyncService";
private static final String SYNC_URL=
"http://misc.commonsware.com/codes.json";
private static final String SYNC_LOCAL_FILE="codes.json";
static final String SYNC_LOCAL_FILE="codes.json";
private static final String KEY_SYNC_TIME="sync_time";
private static final long SYNC_PERIOD=900000L; // 15 min
private AtomicBoolean inProgress=new AtomicBoolean(false);
Expand Down Expand Up @@ -140,7 +140,6 @@ protected void onHandleIntent(Intent intent) {
AppUtils.cleanup(this);
}
finally {

inProgress.set(false);
broadcastStatus();
syncCompleted();
Expand Down

0 comments on commit 12ef2df

Please sign in to comment.