android - When using overridePendingTransition, modifying UI views in the called activity is very slow -


a few days ago, had problem updating action bar menu icon based on result of asynctask: updating action bar menu item due asynctask result without delay

now realized problem not @ related asynctask or action bar. problem occurs if want change textview or other view.

after time of trial , error realized problem caused overridependingtransition use in activity calls second activity (where want change icon):

first activity (in onitemclick method):

@override    public void onitemclick(view view, int position) {    ...    intent intent = new intent(getactivity(), secondactivity.class);    ...    startactivityforresult(intent, anyvalue);    getactivity().overridependingtransition(r.anim.slide_in_right, r.anim.no_animation); } 

the animation looks that:

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android">     <translate android:fromxdelta="100%p" android:toxdelta="0"             android:duration="@android:integer/config_shortanimtime"/> </set> 

and how asynctask (onpostexecute) of second activity looks like:

@override public void onpostexecute(string result) {    super.onpostexecute(result);    if (mmenu != null) {       if (result.equals("no favorite")) {       ...       mmenu.finditem(r.id.action_favorite).setvisible(false);       mmenu.finditem(r.id.action_no_favorite).setvisible(true);    } else {       ...       mmenu.finditem(r.id.action_favorite).setvisible(true);       mmenu.finditem(r.id.action_no_favorite).setvisible(false);    } } 

as explained, instead of switching between 2 menu icons, use 1 textview , setting text based on result - problem remains.

do know how can change animation without having weird delay in second activity?

check integer.xml file make value of config_shortanimtime smaller according needs. in milliseconds. prefer making 1000 (1 sec).


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -