package com.jarvislin.isitrainingnow;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

public abstract class BaseActivity<T extends Presenter> extends RxAppCompatActivity implements BaseView {
    protected T presenter;
//    protected GifLoadingDialog loadingDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        presenter = createPresenter();
//        loadingDialog = new GifLoadingDialog(this);
        // hide keyboard
        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        presenter.detachView();
        super.onDestroy();
    }

    protected abstract T createPresenter();

    @Override
    public Context getContext() {
        return this;
    }

    @Override
    public void showToast(@StringRes int stringRes) {
        showToast(getString(stringRes));
    }

    @Override
    public void showToast(String title) {
        runOnUiThread(() -> {
            Toast.makeText(this, title, Toast.LENGTH_SHORT).show();
        });
    }

    @Override
    public void showLoading() {
//        runOnUiThread(() -> loadingDialog.show());
    }

    @Override
    public void hideLoading() {
//        runOnUiThread(() -> loadingDialog.dismiss());
    }

}

@@ -32,16 +32,51 @@
 ngnow;%0A%0A
+import android.app.ProgressDialog;%0A
 import a
@@ -578,18 +578,16 @@
 senter;%0A
-//
     prot
@@ -592,26 +592,24 @@
 otected 
-GifLoading
+Progress
 Dialog l
@@ -791,61 +791,8 @@
 ();%0A
-//        loadingDialog = new GifLoadingDialog(this);
 %0A   
@@ -1639,34 +1639,32 @@
 showLoading() %7B%0A
-//
         runOnUiT
@@ -1688,22 +1688,66 @@
 ngDialog
-.show(
+ = ProgressDialog.show(this, %22%E8%AE%80%E5%8F%96%E4%B8%AD%22, %22%E8%AB%8B%E7%A8%8D%E5%80%99...%22, true
 ));%0A    
@@ -1795,18 +1795,16 @@
 ing() %7B%0A
-//
         
@@ -1827,31 +1827,119 @@
  -%3E 
-loadingDialog.dismiss()
+%7B%0A            if (loadingDialog.isShowing()) %7B%0A                loadingDialog.dismiss();%0A            %7D%0A        %7D
 );%0A 

complete the method of show/hideLoading()