1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-20 07:21:40 +02:00

update GUI changes immediately via activity result

This commit is contained in:
OliE
2017-03-31 14:29:01 +02:00
parent 0c69e7087f
commit 9de48c7ec8
2 changed files with 18 additions and 20 deletions

View File

@@ -56,7 +56,7 @@ public class MainActivity extends ActionBarActivity implements
* becomes too memory intensive, it may be best to switch to a * becomes too memory intensive, it may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}. * {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/ */
public static SectionsPagerAdapter mSectionsPagerAdapter; private SectionsPagerAdapter mSectionsPagerAdapter;
private static boolean firstAppStart = true; private static boolean firstAppStart = true;
private static int bluetoothStatusIcon = R.drawable.bluetooth_disabled; private static int bluetoothStatusIcon = R.drawable.bluetooth_disabled;
@@ -149,7 +149,7 @@ public class MainActivity extends ActionBarActivity implements
if (id == R.id.action_general_settings) { if (id == R.id.action_general_settings) {
Intent intent = new Intent(this, SettingsActivity.class); Intent intent = new Intent(this, SettingsActivity.class);
startActivityForResult(intent, 0); startActivityForResult(intent, 1);
return true; return true;
} }
@@ -260,6 +260,14 @@ public class MainActivity extends ActionBarActivity implements
FragmentTransaction fragmentTransaction) { FragmentTransaction fragmentTransaction) {
} }
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
mSectionsPagerAdapter.notifyDataSetChanged();
}
}
/** /**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages. * one of the sections/tabs/pages.
@@ -323,6 +331,7 @@ public class MainActivity extends ActionBarActivity implements
@Override @Override
public void notifyDataSetChanged() { public void notifyDataSetChanged() {
super.notifyDataSetChanged(); super.notifyDataSetChanged();
tableFrag = new TableFragment(); tableFrag = new TableFragment();
graphFrag = new GraphFragment(); graphFrag = new GraphFragment();
overviewFrag = new OverviewFragment(); overviewFrag = new OverviewFragment();

View File

@@ -16,7 +16,6 @@
package com.health.openscale.gui; package com.health.openscale.gui;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.util.Log;
import com.health.openscale.R; import com.health.openscale.R;
@@ -25,7 +24,6 @@ import java.util.List;
public class SettingsActivity extends PreferenceActivity { public class SettingsActivity extends PreferenceActivity {
private static List<String> fragments = new ArrayList<String>(); private static List<String> fragments = new ArrayList<String>();
static int backPressed = 0;
@Override @Override
public void onBuildHeaders(List<Header> target) { public void onBuildHeaders(List<Header> target) {
@@ -41,13 +39,4 @@ public class SettingsActivity extends PreferenceActivity {
protected boolean isValidFragment(String fragmentName) { protected boolean isValidFragment(String fragmentName) {
return fragments.contains(fragmentName); return fragments.contains(fragmentName);
} }
public void onBackPressed() {
super.onBackPressed();
backPressed++;
if (backPressed == 1) {
MainActivity.mSectionsPagerAdapter.notifyDataSetChanged();
backPressed = 0;
}
}
} }