E
E
Egor Tolstoy2013-05-16 11:02:48
Java
Egor Tolstoy, 2013-05-16 11:02:48

FragmentTransaction lags?

Good day everyone!
Unforeseen problems occurred while coding an Android app. Let's start with the fact that this piece of code runs without problems:

CalendarDialogFagment dialog = new CalendarDialogFagment();
dialog.setTargetFragment(this, 0);
dialog.show(getActivity().getSupportFragmentManager(), "dialog_calendar");

But when you try to use it in a fragment (for the version for tablets), the application starts to lag very much, the data is loaded into the fragment several times longer than into the dialog box.
Actually, the code itself:
if (calendarContainer == null)
        calendarContainer = getActivity().findViewById(R.id.games_calendar_container);
        boolean isShown = calendarContainer.isShown();

        if (!isShown) {
            calendarContainer.setVisibility(View.VISIBLE);
            if (calendarFragment == null) {
                calendarFragment = new CalendarDialogFagment();
                calendarFragment.setTargetFragment(this, 0);

                FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
                ft.add(R.id.games_calendar, calendarFragment, "tag");
                ft.commit();
                getActivity().getSupportFragmentManager().executePendingTransactions();                 
            }
        }
        else{
            calendarContainer.setVisibility(View.GONE);
            calendarContainer = null;
        }
    }

XML file:
<LinearLayout
        android:id="@+id/games_calendar_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/stagelayout"
        android:orientation="vertical"
        android:visibility="gone"
        android:weightSum="100" >

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="95" />

        <LinearLayout
            android:id="@+id/games_calendar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="5"
            android:background="@color/dark_gray" >
        </LinearLayout>
    </LinearLayout>

I would be grateful for any advice!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question