Commit 9269ffab authored by Marcus Sales's avatar Marcus Sales

Added showLoading and hideLoading methods along with a package for classes for constants and utility methods (show loading dialog).
parent 93243f7f
......@@ -12,6 +12,7 @@ import br.com.evologica.mvp.data.prefs.AppPreferencesHelper;
import br.com.evologica.mvp.data.prefs.PreferencesHelper;
import br.com.evologica.mvp.di.ApplicationContext;
import br.com.evologica.mvp.di.PreferenceInfo;
import br.com.evologica.mvp.utils.AppConstants;
import dagger.Module;
import dagger.Provides;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
......@@ -55,7 +56,7 @@ public class ApplicationModule {
@Provides
@PreferenceInfo
String providePreferenceName(){
return "whatever";
return AppConstants.PREF_NAME;
}
@Provides
......
package br.com.evologica.mvp.ui.base;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
......@@ -10,6 +11,7 @@ import br.com.evologica.mvp.MvpApp;
import br.com.evologica.mvp.di.component.ActivityComponent;
import br.com.evologica.mvp.di.component.DaggerActivityComponent;
import br.com.evologica.mvp.di.module.ActivityModule;
import br.com.evologica.mvp.utils.CommonUtils;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
/**
......@@ -20,6 +22,8 @@ public class BaseActivity extends AppCompatActivity implements MvpView, BaseFrag
private ActivityComponent mActivityComponent;
private ProgressDialog mProgressDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -50,12 +54,15 @@ public class BaseActivity extends AppCompatActivity implements MvpView, BaseFrag
@Override
public void showLoading() {
hideLoading();
mProgressDialog = CommonUtils.showLoadingDialog(this);
}
@Override
public void hideLoading() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.cancel();
}
}
@Override
......
package br.com.evologica.mvp.utils;
/**
* Created by marcussales on 02/03/2017.
*/
public final class AppConstants {
public static final String PREF_NAME = "pref";
private AppConstants(){
}
}
package br.com.evologica.mvp.utils;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import br.com.evologica.mvp.R;
/**
* Created by marcussales on 02/03/2017.
*/
public final class CommonUtils {
private static final String TAG = "CommonUtils";
private CommonUtils() {
// This utility class is not publicly instantiable
}
public static ProgressDialog showLoadingDialog(Context context) {
ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.show();
if (progressDialog.getWindow() != null) {
progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
progressDialog.setContentView(R.layout.progress_dialog);
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(true);
progressDialog.setCanceledOnTouchOutside(false);
return progressDialog;
}
}
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://mindorks.com/license/apache-v2
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent">
<ProgressBar
android:id="@+id/pb_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:progressDrawable="@color/black_effective" />
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment