Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BaseAsyncOperationFragment.java « base « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84b330841b1a2103cab68d0bd78cfdab7156587d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.mapswithme.maps.base;

import android.support.annotation.StringRes;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;

import com.mapswithme.maps.R;
import com.mapswithme.maps.dialog.ProgressDialogFragment;

import java.util.Objects;

public abstract class BaseAsyncOperationFragment extends BaseMwmFragment
{
  private static final String PROGRESS_DIALOG_TAG = "base_progress_dialog";

  protected void showProgress()
  {
    int resId = getProgressMessageId();
    String title = getString(resId);
    ProgressDialogFragment dialog = ProgressDialogFragment.newInstance(title);
    Objects.requireNonNull(getFragmentManager())
           .beginTransaction()
           .add(dialog, PROGRESS_DIALOG_TAG)
           .commitAllowingStateLoss();
  }

  @StringRes
  protected int getProgressMessageId()
  {
    return R.string.downloading;
  }

  protected void hideProgress()
  {
    FragmentManager fm = getFragmentManager();
    DialogFragment frag = (DialogFragment) Objects.requireNonNull(fm)
                                                  .findFragmentByTag(PROGRESS_DIALOG_TAG);
    if (frag != null)
      frag.dismissAllowingStateLoss();
  }
}