Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

when changing theme, relaunch activity instead of trying to hack arou…

…nd it
  • Loading branch information...
commit 94f891b9093b296f39a6a8be7027515492610562 1 parent c528e3a
@talklittle authored
View
40 src/com/andrewshu/android/reddit/comments/CommentsListActivity.java
@@ -281,16 +281,25 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onResume() {
super.onResume();
- CookieSyncManager.getInstance().startSync();
-
int previousTheme = mSettings.getTheme();
+
mSettings.loadRedditPreferences(this, mClient);
- setRequestedOrientation(mSettings.getRotation());
- if (mSettings.getTheme() != previousTheme)
- resetUI(mCommentsAdapter);
- if (mSettings.isLoggedIn())
- new PeekEnvelopeTask(this, mClient, mSettings.getMailNotificationStyle()).execute();
+ if (mSettings.getTheme() != previousTheme) {
+ relaunchActivity();
+ }
+ else {
+ CookieSyncManager.getInstance().startSync();
+ setRequestedOrientation(mSettings.getRotation());
+
+ if (mSettings.isLoggedIn())
+ new PeekEnvelopeTask(this, mClient, mSettings.getMailNotificationStyle()).execute();
+ }
+ }
+
+ private void relaunchActivity() {
+ finish();
+ startActivity(getIntent());
}
@Override
@@ -446,16 +455,6 @@ public View getView(int position, View convertView, ViewGroup parent) {
view = mInflater.inflate(R.layout.more_comments_view, null);
}
- // Set colors based on theme
-// final TextView moreCommentsText = (TextView) view.findViewById(R.id.more_comments_text);
-// if (Util.isLightTheme(mSettings.theme)) {
-// view.setBackgroundResource(R.color.light_light_gray);
-// moreCommentsText.setBackgroundResource(R.color.white);
-// } else {
-// view.setBackgroundResource(R.color.dark_dark_gray);
-// moreCommentsText.setBackgroundResource(android.R.color.background_dark);
-// }
-
setCommentIndent(view, item.getIndent(), mSettings);
} else { // Regular comment
@@ -568,7 +567,6 @@ protected void onListItemClick(ListView l, View v, int position, long id) {
void resetUI(CommentsListAdapter commentsAdapter) {
int firstVisiblePosition = getListView().getFirstVisiblePosition();
- setTheme(mSettings.getTheme());
setContentView(R.layout.comments_list_content);
registerForContextMenu(getListView());
@@ -1327,11 +1325,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
break;
case R.id.light_dark_menu_id:
mSettings.setTheme(Util.getInvertedTheme(mSettings.getTheme()));
- resetUI(mCommentsAdapter);
- if (mCommentsAdapter != null) {
- markSubmitterComments();
- mCommentsAdapter.notifyDataSetChanged();
- }
+ relaunchActivity();
break;
case R.id.inbox_menu_id:
Intent inboxIntent = new Intent(getApplicationContext(), InboxActivity.class);
View
39 src/com/andrewshu/android/reddit/threads/ThreadsListActivity.java
@@ -214,20 +214,30 @@ else if (getIntent().getData() != null) {
@Override
protected void onResume() {
super.onResume();
- CookieSyncManager.getInstance().startSync();
- int previousTheme = mSettings.getTheme();
+ int previousTheme = mSettings.getTheme();
+
mSettings.loadRedditPreferences(this, mClient);
- setRequestedOrientation(mSettings.getRotation());
- if (mSettings.getTheme() != previousTheme)
- resetUI(mThreadsAdapter);
-
- updateNextPreviousButtons();
-
- if (mThreadsAdapter != null)
- jumpToThread();
-
- if (mSettings.isLoggedIn())
- new PeekEnvelopeTask(this, mClient, mSettings.getMailNotificationStyle()).execute();
+
+ if (mSettings.getTheme() != previousTheme) {
+ relaunchActivity();
+ }
+ else {
+ CookieSyncManager.getInstance().startSync();
+ setRequestedOrientation(mSettings.getRotation());
+
+ updateNextPreviousButtons();
+
+ if (mThreadsAdapter != null)
+ jumpToThread();
+
+ if (mSettings.isLoggedIn())
+ new PeekEnvelopeTask(this, mClient, mSettings.getMailNotificationStyle()).execute();
+ }
+ }
+
+ private void relaunchActivity() {
+ finish();
+ startActivity(getIntent());
}
@Override
@@ -605,7 +615,6 @@ protected void onListItemClick(ListView l, View v, int position, long id) {
* @param threadsAdapter A ThreadsListAdapter to use. Pass in null if you want a new empty one created.
*/
void resetUI(ThreadsListAdapter threadsAdapter) {
- setTheme(mSettings.getTheme());
setContentView(R.layout.threads_list_content);
registerForContextMenu(getListView());
@@ -1127,7 +1136,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
break;
case R.id.light_dark_menu_id:
mSettings.setTheme(Util.getInvertedTheme(mSettings.getTheme()));
- resetUI(mThreadsAdapter);
+ relaunchActivity();
break;
case R.id.inbox_menu_id:
Intent inboxIntent = new Intent(getApplicationContext(), InboxActivity.class);
Please sign in to comment.
Something went wrong with that request. Please try again.