package org.stepic.droid.util;

import android.app.ProgressDialog;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;
import android.widget.ProgressBar;

public class ProgressHelper {
    public static void dismiss(ProgressBar mProgressLoogin) {

        if (mProgressLoogin != null && mProgressLoogin.getVisibility() != View.GONE) {
            mProgressLoogin.setVisibility(View.GONE);
        }
    }

    public static void activate(ProgressBar progressBar) {
        if (progressBar != null)
            progressBar.setVisibility(View.VISIBLE);
    }

    public static void dismiss(SwipeRefreshLayout swipeRefreshLayout) {
        if (swipeRefreshLayout != null)
            swipeRefreshLayout.setRefreshing(false);
    }

    public static void activate(SwipeRefreshLayout swipeRefreshLayout) {
        if (swipeRefreshLayout != null)
            swipeRefreshLayout.setRefreshing(true);
    }

    public static void activate(ProgressDialog progressDialog) {
        if (progressDialog != null)
            progressDialog.show();
    }

    public static void dismiss(ProgressDialog progressDialog) {
        if (progressDialog != null)
            progressDialog.dismiss();
    }
}

@@ -175,16 +175,58 @@
 ssBar;%0A%0A
+import com.yandex.metrica.YandexMetrica;%0A%0A
 public c
@@ -1209,47 +1209,227 @@
 null
-)%0A            progressDialog.dismiss();
+ && progressDialog.isShowing()) %7B%0A            try %7B%0A                progressDialog.dismiss();%0A            %7D catch (Exception ex) %7B%0A                YandexMetrica.reportError(%22progressDialog%22, ex);%0A            %7D%0A        %7D
 %0A   

fix bug when progress dialog was not attached to activity and try to dismiss.