I'm building an Android app whose navigation is similar to Instagram, which has multiple tabs and each tab has its own history.
Implementation
I implemented this navigation by using ViewPager
with FragmentPagerAdapter
. When navigating down each tab, I replace the FrameLayout
's content by executing following code
getChildFragmentManager.beginTransaction().addToBackStack(null).replace(R.id.container, newFragment).commit()
and execute getChildFragmentManager.popBackStackImmediate()
for back button press event.
I use facebook fresco's SimpleDraweeView
and load image by executing SimpleDraweeView.setImageURI(Uri.parse(str))
.
The application uses MapView
and creates custom markers, which has icon that is created by Picasso.with(context).with(url).into(new MarkerTarget(...))
class MarkerTarget implements Target {
private Marker marker;
public MarkerTarget(Marker marker) {
this.marker = marker;
}
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
try {
marker.setIcon(BitmapDescriptorFactory.fromBitmap(bitmap));
marker.setVisible(true);
} catch(Exception e) {
}
}
...
}
}
Most of the fragments have ListView
, an extenstion of BaseAdapter
, and a presenter.
Problem
It seemed to work but the problem is that when I navigate down in a tab, OOM Error occurs. How does Instagram keeps history of (possibly) infinite numbers.
Allocation Tracker Result (Screenshot)
Question
How can I implement instagram like navigation on Android platform ?