I'm a bit new in android developement and have got issue with updating view which I cannot resolve myself.
What I've got is mapview, on the map I have sliding drawer with listview. The list view is build up by custom adapter which puts some texts and uses imageLoader object to load picture from url in backround. In the listview row layout I have got also progresloader placed in relative view on top of picture. This is default visible and is put GONE on imageloader backround thread when loaded picture is put to imageview.
So you get the idea, it is to show progres of loading picture and loading them on backround to have listview built up quickly.
To my problem. The sliding drawer is customized to show part of it (1 item from list + a little from next) when closed and full screen when opened. When user click on map icon where there are more items under it, it loads up listview in closed sliding drawer. The progres loader in it is not rotating, when I open sliding drawer, loading progresses are rotating, they are rotating also when moving drawer and they are rotating also when drawer is closed and there is any interaction with ui like moving map or so.
Was trying to figure out what to do, found out that when I add invalidate of content on dispatch draw on sliding drawer that makes it to refresh sliding drawer again and to fire dispatch draw again, loading progresses in lstview are rotating but this is not very good as basically I created infinite loop and updating sliding drawer forever, this uses up all cpu.
Updating sliding drawer or listview should be triggered by progress loaders but it is somehow not ;o( It does work well on open drawer and also on closed but I have to interact with UI than it fires dispatch draw on slider which redraws it children and porgresses ar erotating.
Can someone give me a clue how to make the drawer to update when loaders are there visible?
thanks a lot.
Related
I'm working on an Android app that uses a navigation drawer and multiple navigation menu items. Inflating the views and running onCreate() takes some time, which makes the drawer close animation very laggy. I'm already working on optimizing the fragment layout itself to reduce jank, but the animation is still laggy.
My quick fix was adding a drawer listener and calling getSupportFragmentManager().beginTransaction().replace(...).commit() on drawer close. However the problem with this is that the previous fragment still remains in the UI for a few milliseconds after the drawer is closed, which looks arguably worse than with the laggy animation.
How is it possible to ensure a smooth drawer close animation and concurrently load the new fragment - or is there another way to make the UI transitions look more natural?
I have used basic navigation drawer generated in android studio. I noticed my navigation slider slides off smooth and lag sometimes. I found that the lag cause of the LayoutInflater I used to inflate another layout on my fragment.
What I have done is,
ViewGroup myLayout = view.findViewById(R.id.current_layout);
View mayLayoutTwo = LayoutInflater.from(CurrentFragment.this.getActivity()).inflate(R.layout.cardview_to_inflate, myLayout, false);
myLayout.addView(mayLayoutTwo);
I want to know is that possible to avoid that lag on navigation drawer slide. Help me to fix this issue.
Navigation drawer with multiple fragments is common usage. So based on your fragments loading at onCreate() lifecycle stage, your Naviagtion drawer may not smooth while closing.
So solution 1 :
Avoid heavy loading at your fragment initiate state. (e.g loading data asynchronously.)
Solution 2 :
Display place holder view (e.g whit screen) while navigation drawer is closing. Once NV drawer is closed, show your fragment.
You can use animation for fragment transition to give the better UX, since the default one looks some kinda awkward transition so giving your own transition will make the user feel some more smoothness, and yes avoid making the larger async calls on initiating the fragment.
I'm making an app that uses a bottom navigation bar (BottomBar) on its MainActivity. A FrameLayout is positioned above the BottomBar. Every time an icon in the bottom bar is clicked, the tab's fragment is inserted into the FrameLayout using FragmentTransaction's replace() function. That inserted fragment contains ViewPager, which results in more fragment launching and caching. Right now, there is only one Activity but many Fragments. I haven't load any data and I'm already receiving a OutOfMemory Exception even after setting the maxHeapSize to 4gb.
What can I do to improve the performance without changing the UI (still have a bottom navigation bar and each tab contains a viewpager)?
I'm trying to make application.
If the button on page 1 is clicked the page goes to page 2 by sliding the page 1 and the background is not sliding too.
I've tried android:detachWallpaper="true" but its not working, it still moves the background.
I also have tried using FrameLayout and fragment but there's error when its trying to show messagebox and accessing another class.
the error log:
Unable to start activity ComponentInfo{com.example.myfirstapp/com.example.fragment.MainFragment}: java.lang.NullPointerException
Does anyone knows the best solution?
this totally depends upon your UI implementation there is no default guidelines for the same, below are the possible implementation scenarios through which this can be easily achieved.
Framelayout and fragment (you already tried)
ViewFlipper (set background to flipper, and keep flipping different views just like you want)
View Pager (Same as flipper but with adapter support)
I am implementing swipe refresh layout to my fragment. It works perfectly, but I want to pull the screen as animation not the indicator itself. I also want not to show the default indicator because I have my own custom progress bar.
Any help will be appriciated.
use this to hide the progress indicator
if (swipeLayout.isRefreshing()) {
swipeLayout.setRefreshing(false);
}
and for animating the activity, you can use transitions in android. Follow this link to get some cool transitions and just implement it to the root element of your activity.