diff options
author | Andrew Dolgov <[email protected]> | 2017-11-03 10:23:53 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-11-03 10:23:53 +0300 |
commit | c4c698976b4501d41c771023e67b83989fd6eba9 (patch) | |
tree | 7bd95b3191e096ec7dcf76531efec0faf57dd98f | |
parent | 119b777377ff1a8fe852e3542a2d068bdd40e372 (diff) |
add some WIP glide clear memory placebo (?) code which might help with OOMs on garbage devices
4 files changed, 33 insertions, 3 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java index 6374704b..db5703ad 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java @@ -33,6 +33,8 @@ import android.view.View; import android.widget.CheckBox; import android.widget.Toast; +import com.bumptech.glide.Glide; + import org.fox.ttrss.util.DatabaseHelper; import org.fox.ttrss.widget.SmallWidgetProvider; import org.jsoup.Jsoup; @@ -482,5 +484,19 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc } } + @Override + public void onTrimMemory(int level) { + super.onTrimMemory(level); + Log.d(TAG, "onTrimMemory called"); + Glide.get(this).trimMemory(level); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + Log.d(TAG, "onLowMemory called"); + Glide.get(this).clearMemory(); + } + } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index e814de67..287d9051 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -288,6 +288,8 @@ public class HeadlinesFragment extends Fragment { super.onCreate(savedInstanceState); setRetainInstance(true); + + Glide.get(getContext()).clearMemory(); } @Override @@ -1145,6 +1147,8 @@ public class HeadlinesFragment extends Fragment { holder.flavorVideoView.setVisibility(View.GONE); holder.headlineHeader.setBackgroundDrawable(null); + Glide.clear(holder.flavorImageView); + // this is needed if our flavor image goes behind base listview element holder.headlineHeader.setOnClickListener(new OnClickListener() { @Override @@ -1220,8 +1224,8 @@ public class HeadlinesFragment extends Fragment { holder.flavorImageView.setVisibility(View.VISIBLE); - holder.flavorImageView.setMaxHeight((int)(m_screenHeight * 0.8f)); - holder.flavorProgressTarget.setModel(article.flavorImageUri); + holder.flavorImageView.setMaxHeight((int)(m_screenHeight * 0.8f)); + holder.flavorProgressTarget.setModel(article.flavorImageUri); if (article.flavorViewHeight > 0) { RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) holder.flavorImageView.getLayoutParams(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java index 5d46460d..0dd714b0 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java @@ -586,4 +586,5 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList req.execute(map); } + } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index 2d701d62..13dd3bb1 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -310,7 +310,16 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis e.printStackTrace(); } } - + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setRetainInstance(true); + + Glide.get(getContext()).clearMemory(); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |