Skip to content

Commit 7f195af

Browse files
authored
Fix refresh button (spaceapi-community#5)
Previously the data was loaded from cache, even if the refresh button was pressed.
1 parent 28c9a8b commit 7f195af

File tree

1 file changed

+6
-6
lines changed
  • app/src/main/java/io/spaceapi/myhackerspace

1 file changed

+6
-6
lines changed

app/src/main/java/io/spaceapi/myhackerspace/Main.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void onCreate(Bundle savedInstanceState) {
129129
Log.d(TAG, "onCreate() intent=" + getIntent().toString());
130130
setCache();
131131
getHsList();
132-
showHsInfo(getIntent());
132+
showHsInfo(getIntent(), true);
133133
} else {
134134
showError(getString(R.string.error_title) + getString(R.string.error_network_title),
135135
getString(R.string.error_network_msg));
@@ -140,7 +140,7 @@ public void onCreate(Bundle savedInstanceState) {
140140
@UiThread
141141
protected void onNewIntent(Intent intent) {
142142
Log.d(TAG, "onNewIntent()=" + intent);
143-
showHsInfo(intent);
143+
showHsInfo(intent, false);
144144
}
145145

146146
@Override
@@ -170,7 +170,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
170170
final int id = item.getItemId();
171171
if (id == R.id.menu_refresh) {
172172
if (hasNetwork()) {
173-
showHsInfo(getIntent());
173+
showHsInfo(getIntent(), true);
174174
} else {
175175
showError(getString(R.string.error_title) + getString(R.string.error_network_title),
176176
getString(R.string.error_network_msg));
@@ -339,7 +339,7 @@ private void getHsList() {
339339
/**
340340
* Fetch the endpoint and update the `mApiUrl` and `mResultHs` variables.
341341
*/
342-
private void showHsInfo(@Nullable Intent intent) {
342+
private void showHsInfo(@Nullable Intent intent, boolean skipCache) {
343343
final Bundle data = (Bundle) getLastNonConfigurationInstance();
344344

345345
// Get space endpoint URL
@@ -368,7 +368,7 @@ private void showHsInfo(@Nullable Intent intent) {
368368
finishApi = true;
369369
mResultHs = (HashMap<String, String>) data.getSerializable(STATE_HS);
370370
populateDataHs();
371-
} else if(mResultHs.containsKey(mApiUrl)) {
371+
} else if(mResultHs.containsKey(mApiUrl) && !skipCache) {
372372
Log.d(TAG, "showHsInfo(data from cache)");
373373
finishApi = true;
374374
populateDataHs();
@@ -512,7 +512,7 @@ protected void onPostExecute(String result) {
512512
dismissLoading();
513513
if (mErrorMsg == null) {
514514
mResultHs.put(mUrl, result);
515-
showHsInfo(getIntent());
515+
showHsInfo(getIntent(), false);
516516
} else {
517517
setViewVisibility(false);
518518
showError(mErrorTitle, mErrorMsg);

0 commit comments

Comments
 (0)