From 4da78ec8ddd04f43ac20d99895f70c6c97ba0a3f Mon Sep 17 00:00:00 2001 From: nikhilchowdary Date: Fri, 20 Jan 2017 14:50:40 +0530 Subject: [PATCH] Fixes #400 Long toast queue toast related to recently clicked button is now displayed spontaneously in settings fragment --- .../toolkit/fragment/SettingsFragment.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/SettingsFragment.java b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/SettingsFragment.java index 67fabd0f..3239b1f4 100644 --- a/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/SettingsFragment.java +++ b/source-code/app/src/main/java/org/buildmlearn/toolkit/fragment/SettingsFragment.java @@ -37,6 +37,7 @@ public class SettingsFragment extends PreferenceFragment { private static final int REQUEST_PICK_APK = 9985; private Preference prefUsername; + private Toast mToast; private static float deleteDirectory(File file, float size) { if (file.exists()) { @@ -61,6 +62,7 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.fragment_settings); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); + mToast=Toast.makeText(getActivity()," ",Toast.LENGTH_SHORT); Preference deleteTempFiles = findPreference(getString(R.string.key_delete_temporary_files)); deleteTempFiles.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @@ -81,8 +83,10 @@ public boolean onPreferenceClick(Preference preference) { if(NetworkUtils.isNetworkAvailable(getActivity())) startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getActivity().getPackageName()))); - else - Toast.makeText(getActivity(), R.string.settings_network_unavailable,Toast.LENGTH_SHORT).show(); + else { + mToast.setText(R.string.settings_network_unavailable); + mToast.show(); + } return true; } }); @@ -319,7 +323,8 @@ protected void onPostExecute(Float size) { if (size != 0) { Toast.makeText(getActivity(), "Deleted " + size + " MB.", Toast.LENGTH_SHORT).show(); } else { - Toast.makeText(getActivity(), "No Temp Files Found!", Toast.LENGTH_SHORT).show(); + mToast.setText("No Temp Files Found!"); + mToast.show(); } } }