fix article timestamp in headlines displayed in UTC

use custom back button handling to prevent backstack idiocy
This commit is contained in:
Andrew Dolgov 2011-11-25 11:47:07 +03:00
parent 50810d0246
commit 8c19ec257c
2 changed files with 19 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.TimeZone;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
@ -26,7 +27,6 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ToggleButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
@ -339,6 +339,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener {
if (dv != null) { if (dv != null) {
Date d = new Date((long)article.updated * 1000); Date d = new Date((long)article.updated * 1000);
DateFormat df = new SimpleDateFormat("MMM dd, HH:mm"); DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
df.setTimeZone(TimeZone.getDefault());
dv.setText(df.format(d)); dv.setText(df.format(d));
} }

View File

@ -11,6 +11,7 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -175,6 +176,22 @@ public class MainActivity extends Activity implements FeedsFragment.OnFeedSelect
} }
} }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
Log.d(TAG, "Overriding back button");
if (m_selectedArticle != null) {
closeArticle();
} else {
finish();
}
return false;
}
return super.onKeyDown(keyCode, event);
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {