Android : Custom DialogFragment so slow to display
Asked Answered
S

1

8

I have a DialogFragment which serves as a popup. This DialogFragment has a ListView in it and that uses a BaseAdapter that has custom TableRow. My problem is, it takes about 2 seconds to display the popup fully. Is there any solution, or recommendation that you can give me to display this popup faster.

More details : The TableRow has 2 ImageViews and 3 custom TextViews. The BaseAdapter processes the View because it has to do some stuff like hiding other View, setting texts, etc.

Any help will be appreciated. Thanks! :D

Semiology answered 7/5, 2013 at 11:34 Comment(3)
Do less work on the main UI thread/improve the adapter.Kimbra
use lazy loading . try to load images in thread one by oneDeflection
Thanks for the fast reply. I am only displaying at 5 items on the ListView. Where is the lazy loading done?Semiology
F
5

I also had many issues with DialogFragment and in our company we decided to abandon it. The main problem is it needs some time to infiltrate and do Fragment stuff. But before it appears user can interact with screen. E.g. press button multiple times before the popup appears and may lead to unexpected behaviors, you have to consider in your code.

Instead use normal Dialog and set Content View - a custom layout and other parameters

    Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.progress_dialog);
    dialog.setCancelable(false);

    Window window = dialog.getWindow();
    if (window != null) {
        window.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    }

    dialog.show();

It helps avoid problems connected with Fragments, Fragment Transactions, State and many others.

Frump answered 4/12, 2017 at 11:32 Comment(2)
I will try to use Dialog instead of DialogFragment. Fragment transaction takes really long time to display, and so we cannot show the user progress before the actual progress ends.Iila
When you say not to use DialogFragment and instead use normal Dialog, does that mean you simply change the class from extending DialogFragment and make it extend Dialog?Palgrave

© 2022 - 2024 — McMap. All rights reserved.