package com.popalay.cardme.ui.base;

import android.app.Activity;
import android.support.annotation.NonNull;

import com.arellomobile.mvp.MvpAppCompatFragment;

public abstract class BaseFragment extends MvpAppCompatFragment implements BaseView {

    @NonNull
    public BaseActivity getBaseActivity() {
        final Activity activity = getActivity();
        if (activity != null && activity instanceof BaseActivity) {
            return (BaseActivity) activity;
        }
        throw new RuntimeException("BaseActivity is null");
    }

    protected void showLoadingDialog() {
        final BaseActivity baseActivity = getBaseActivity();
        baseActivity.showLoadingDialog();
    }

    protected void hideLoadingDialog() {
        final BaseActivity baseActivity = getBaseActivity();
        baseActivity.hideLoadingDialog();
    }

    @Override
    public void showError(String error) {
        final BaseActivity baseActivity = getBaseActivity();
        baseActivity.showError(error);
    }

    @Override
    public void showMessage(String message) {
        final BaseActivity baseActivity = getBaseActivity();
        baseActivity.showMessage(message);
    }

    @Override
    public void hideError() {

    }

    @Override
    public void hideMessage() {

    }

    @Override
    public void showProgress() {
        showLoadingDialog();
    }

    @Override
    public void hideProgress() {
        hideLoadingDialog();
    }

    @Override
    public void hideKeyboard() {
        final BaseActivity baseActivity = getBaseActivity();
        baseActivity.hideKeyboard();
    }

    @Override
    public void close() {
        final BaseActivity baseActivity = getBaseActivity();
        baseActivity.close();
    }
}

@@ -1648,88 +1648,80 @@
     
-final BaseActivity baseActivity = getBaseActivity();%0A        baseActivity.close(
+throw new UnsupportedOperationException(%22You can not close the fragment%22
 );%0A 

Throw exception when call close() on fragment