Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- GoogleLoginFragment, MainActivity,
PhotoDetailsActivity.PhotoDetailsUiFragment, SyncUploadFragment,
UploadActivity.UploadUiFragment: currentInstance now is nulled in
onDestroy only if it equals to destroying fragment such as in some cases
it is possible that 2 instance of the fragment will be in memory at the
time
- PhotoDetailsActivity.PhotoDetailsUiFragment: updated date format in
photo details to be locale specified
- PhotoDetailsActivity.PhotoDetailsUiFragment: replaced
mImageWorker2.loadImage call with the one with less parameters
- CommonUtils: added formatDateTime method
  • Loading branch information
httpdispatch committed May 27, 2013
1 parent ec6d5ca commit 9e298d0
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 10 deletions.
14 changes: 13 additions & 1 deletion app/src/com/trovebox/android/app/GoogleLoginFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,19 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onDestroy() {
super.onDestroy();
currentInstance = null;
if (currentInstance != null)
{
if (currentInstance.get() == GoogleLoginFragment.this
|| currentInstance.get() == null)
{
CommonUtils.debug(TAG, "Nullify current instance");
currentInstance = null;
} else
{
CommonUtils.debug(TAG,
"Skipped nullify of current instance, such as it is not the same");
}
}
}

@Override
Expand Down
14 changes: 13 additions & 1 deletion app/src/com/trovebox/android/app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,19 @@ protected void onPostCreate(Bundle sSavedInstanceState) {
protected void onDestroy()
{
super.onDestroy();
currentInstance = null;
if (currentInstance != null)
{
if (currentInstance.get() == MainActivity.this
|| currentInstance.get() == null)
{
CommonUtils.debug(TAG, "Nullify current instance");
currentInstance = null;
} else
{
CommonUtils.debug(TAG,
"Skipped nullify of current instance, such as it is not the same");
}
}
if (purchaseController != null)
purchaseController.dispose();
purchaseController = null;
Expand Down
22 changes: 16 additions & 6 deletions app/src/com/trovebox/android/app/PhotoDetailsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package com.trovebox.android.app;

import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;

Expand Down Expand Up @@ -217,7 +216,19 @@ public void onCreate(Bundle savedInstanceState) {

@Override
public void onDestroy() {
currentInstance = null;
if (currentInstance != null)
{
if (currentInstance.get() == PhotoDetailsUiFragment.this
|| currentInstance.get() == null)
{
CommonUtils.debug(TAG, "Nullify current instance");
currentInstance = null;
} else
{
CommonUtils.debug(TAG,
"Skipped nullify of current instance, such as it is not the same");
}
}
super.onDestroy();
}

Expand Down Expand Up @@ -472,18 +483,17 @@ void photoSelected(final Photo photo)
{
ActionBar actionBar = ((Activity) getSupportActivity())
.getSupportActionBar();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String title = photo.getTitle();
if (TextUtils.isEmpty(title))
{
title = photo.getFilenameOriginal();
}
actionBar.setTitle(getString(R.string.details_title_and_date_header, title,
df.format(photo.getDateTaken())));
CommonUtils.formatDateTime(photo.getDateTaken())));

titleText.setText(title);

dateText.setText(df.format(photo.getDateTaken()));
dateText.setText(CommonUtils.formatDateTime(photo.getDateTaken()));

privateBtn.setVisibility(photo.isPrivate() ? View.VISIBLE : View.GONE);

Expand Down Expand Up @@ -875,7 +885,7 @@ public View getView(final Photo photo, View convertView, ViewGroup parent)
@Override
public void run(Photo photo) {
String url = photo.getUrl(thumbSize.toString());
mImageWorker2.loadImage(url, imageView, null);
mImageWorker2.loadImage(url, imageView);
}
}, null);
return view;
Expand Down
14 changes: 13 additions & 1 deletion app/src/com/trovebox/android/app/SyncUploadFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,19 @@ public void onSaveInstanceState(Bundle outState) {
@Override
public void onDestroy() {
super.onDestroy();
currentInstance = null;
if (currentInstance != null)
{
if (currentInstance.get() == SyncUploadFragment.this
|| currentInstance.get() == null)
{
CommonUtils.debug(TAG, "Nullify current instance");
currentInstance = null;
} else
{
CommonUtils.debug(TAG,
"Skipped nullify of current instance, such as it is not the same");
}
}
}

@Override
Expand Down
14 changes: 13 additions & 1 deletion app/src/com/trovebox/android/app/UploadActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,19 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onDestroy() {
super.onDestroy();
currentInstance = null;
if (currentInstance != null)
{
if (currentInstance.get() == UploadUiFragment.this
|| currentInstance.get() == null)
{
CommonUtils.debug(TAG, "Nullify current instance");
currentInstance = null;
} else
{
CommonUtils.debug(TAG,
"Skipped nullify of current instance, such as it is not the same");
}
}
}

FeatherFragment getFeatherFragment()
Expand Down
20 changes: 20 additions & 0 deletions app/src/com/trovebox/android/app/util/CommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
package com.trovebox.android.app.util;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.Locale;

import android.os.Bundle;
import android.os.Environment;
import android.text.format.DateUtils;
import android.util.Log;

import com.trovebox.android.app.BuildConfig;
Expand Down Expand Up @@ -76,6 +78,24 @@ public static String format(Number number)
{
return DecimalFormat.getInstance().format(number);
}

/**
* Format date time accordingly to specified user locale
*
* @param date
* @return
*/
public static String formatDateTime(Date date)
{
if(date == null)
{
return null;
}
return DateUtils.formatDateTime(TroveboxApplication.getContext(),
date.getTime(),
DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE
| DateUtils.FORMAT_SHOW_TIME);
}
/**
* Write message to the verbose log
*
Expand Down

0 comments on commit 9e298d0

Please sign in to comment.