Added initial theme change checks
This commit is contained in:
parent
3acbd9a4c7
commit
687fe7b7c2
|
@ -24,6 +24,7 @@ Contact us at <joguitos+pluck@luca0n.com>.
|
||||||
package com.luca0n.joguitos.pluck.activities;
|
package com.luca0n.joguitos.pluck.activities;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
|
@ -39,6 +40,7 @@ import com.luca0n.joguitos.pluck.util.UiUtil;
|
||||||
|
|
||||||
@SuppressLint("Registered")
|
@SuppressLint("Registered")
|
||||||
public class BaseActivity extends AppCompatActivity {
|
public class BaseActivity extends AppCompatActivity {
|
||||||
|
public static final int REQUEST_ACTIVITY_CLOSED = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
@ -63,9 +65,24 @@ public class BaseActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent extras){
|
||||||
|
switch (requestCode){
|
||||||
|
case REQUEST_ACTIVITY_CLOSED:
|
||||||
|
if (resultCode == Activity.RESULT_OK){
|
||||||
|
// Check if the theme changed.
|
||||||
|
recreate();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
super.onActivityResult(requestCode, resultCode, extras);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void onSettings() {
|
private void onSettings() {
|
||||||
Intent intent = new Intent(this, SettingsActivity.class);
|
Intent intent = new Intent(this, SettingsActivity.class);
|
||||||
startActivity(intent);
|
startActivityForResult(intent, REQUEST_ACTIVITY_CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAbout() {
|
private void onAbout() {
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class MainActivity extends BaseActivity {
|
||||||
.category(category)
|
.category(category)
|
||||||
.difficulty(difficulty)
|
.difficulty(difficulty)
|
||||||
.build());
|
.build());
|
||||||
startActivity(intent);
|
startActivityForResult(intent, BaseActivity.REQUEST_ACTIVITY_CLOSED);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a String array that holds all options for spinnerNumber.
|
// Create a String array that holds all options for spinnerNumber.
|
||||||
|
@ -193,6 +193,10 @@ public class MainActivity extends BaseActivity {
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case BaseActivity.REQUEST_ACTIVITY_CLOSED:
|
||||||
|
// Check if the theme changed.
|
||||||
|
recreate();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
super.onActivityResult(requestCode, resultCode, extras);
|
super.onActivityResult(requestCode, resultCode, extras);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,6 +23,7 @@ Contact us at <joguitos+pluck@luca0n.com>.
|
||||||
|
|
||||||
package com.luca0n.joguitos.pluck.activities;
|
package com.luca0n.joguitos.pluck.activities;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
@ -98,6 +99,8 @@ public class TriviaGameActivity extends BaseActivity
|
||||||
setContentView(R.layout.activity_trivia_game);
|
setContentView(R.layout.activity_trivia_game);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
setResult(Activity.RESULT_OK);
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
if (actionBar != null)
|
if (actionBar != null)
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
|
@ -23,6 +23,7 @@ Contact us at <joguitos+pluck@luca0n.com>.
|
||||||
|
|
||||||
package com.luca0n.joguitos.pluck.settings;
|
package com.luca0n.joguitos.pluck.settings;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.replace(android.R.id.content, new SettingsFragment())
|
.replace(android.R.id.content, new SettingsFragment())
|
||||||
.commit();
|
.commit();
|
||||||
|
setResult(Activity.RESULT_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue