diff options
author | Andrew Dolgov <[email protected]> | 2017-05-31 16:24:33 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-05-31 16:24:33 +0300 |
commit | 6bec08951e165bb9031a968f4dbbb3ea1baf4cfa (patch) | |
tree | fc3ae8088a9027b8e6c78bc7d78c2142b71e2df9 /org.fox.ttrss/src/main | |
parent | 4d54d69378ce403c56e6f701dd45c203242c7af6 (diff) |
apiloader: cache results unless forced not to
Diffstat (limited to 'org.fox.ttrss/src/main')
-rw-r--r-- | org.fox.ttrss/src/main/java/org/fox/ttrss/ApiLoader.java | 17 | ||||
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java | 6 |
2 files changed, 20 insertions, 3 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiLoader.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiLoader.java index 66cbb674..d483129b 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiLoader.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ApiLoader.java @@ -42,6 +42,7 @@ public class ApiLoader extends AsyncTaskLoader<JsonElement> { protected String m_lastErrorMessage; protected ApiError m_lastError; protected HashMap<String,String> m_params; + protected JsonElement m_data; public ApiLoader(Context context, HashMap<String,String> params) { super(context); @@ -57,6 +58,22 @@ public class ApiLoader extends AsyncTaskLoader<JsonElement> { } + @Override + protected void onStartLoading() { + if (m_data != null) { + deliverResult(m_data); + } else { + forceLoad(); + } + } + + @Override + public void deliverResult(JsonElement data) { + m_data = data; + + super.deliverResult(data); + } + public int getErrorMessage() { switch (m_lastError) { case NO_ERROR: diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java index 9752d342..f7b64974 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedCategoriesFragment.java @@ -327,7 +327,7 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState != null) { m_selectedCat = savedInstanceState.getParcelable("selectedCat"); - m_cats = savedInstanceState.getParcelable("cats"); + //m_cats = savedInstanceState.getParcelable("cats"); } View view = inflater.inflate(R.layout.fragment_cats, container, false); @@ -376,7 +376,7 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt public void onResume() { super.onResume(); - getLoaderManager().initLoader(0, null, this).forceLoad(); + getLoaderManager().initLoader(0, null, this); m_activity.invalidateOptionsMenu(); } @@ -387,7 +387,7 @@ public class FeedCategoriesFragment extends BaseFeedlistFragment implements OnIt out.setClassLoader(getClass().getClassLoader()); out.putParcelable("selectedCat", m_selectedCat); - out.putParcelable("cats", m_cats); + //out.putParcelable("cats", m_cats); } public void refresh(boolean background) { |