Getting Started
Layouts
Gradle
RecyclerView onClickListeners
NavigationView
Intent
JSON handling with org.json
Android Studio
Resources
Data Binding Library
Exceptions
Getting Calculated View Dimensions
AsyncTask
SharedPreferences
Emulator
Material Design
Lint Warnings
Service
Storing Files in Internal and External Storage
WebView
Project SDK versions
RecyclerView
Google Maps
PorterDuff Mode
9-Patch images
Android NDK
RecyclerView Decorations
Camera 2 API
ViewPager
CardView
HttpURLConnection
SQLite
ADB Android Debug Bridge
ButterKnife
Supporting different screen resolutions
Glide
Retrofit2
Dialog
ACRA
GreenDAO
Formatting Strings
Notifications
AlarmManager
Fragments
Handler
Creating Custom Views
BroadcastReceiver
Activity
Snackbar
Runtime Permissions in API-23
Logging and using Logcat
VectorDrawable and AnimatedVectorDrawable
Tools Attributes
Toast
Interfaces
Animators
Location
Theme Style Attribute
The Manifest File
Parcelable
MediaPlayer
Multidex and the Dex Method Limit
Data Synchronization with Sync Adapter
Menu
Instant Run in Android Studio
Picasso
Bluetooth LE API
RoboGuice
Memory Leaks
Universal Image Loader
Volley
Widgets
Date and Time Pickers
Integrate Google Sign In
In-app billing
FloatingActionButton
ContentProvider
Dagger 2
Realm
Unit testing in Android with JUnit
Android Versions
Wi-Fi Connections
SensorManager
Localization with resources
ProgressBar
Custom Fonts
Vibration
Google Awarness APIs
Text to Speech (TTS)
UI Lifecycle
Spinner
Data Encryption / Decryption
Testing UI with Espresso
Writing UI tests
GreenRobot EventBus
OkHttp
Enhancing Performance Using Icon Fonts
Handling Depp Links
Canvas drawing using SurfaceView
Firebase
Crash Reporting Tools
Check Internet Connectivity
Facebook SDK
Unzip File
Android Places API
Creating your own libraries
Handling JSON with Gson
Device Display Metrics
TextView
ListView
Building Backwards Compatible Apps
Loader
ProGuard - Obfuscating and Shrinking your code
Detect Shake Event
Typedef Annotations
Capturing Screenshots
MVP Architecture
Orientation Changes
Xposed
Security
PackageManager
ImageView
Gesture Detection
Doze Mode
Android Sound and Media
SearchView
Camera and Gallery
Callback URL
Twitter APIs
SqlCipher integration
Drawables
Colors
ConstraintLayout
RenderScript
Fresco
Swipe to Refresh
AutoCompleteTextView
Installing apps with ADB
IntentService
AdMob
Implicit Intents
Publish to Play Store
Firebase Realtime Database
Image Compression
Email Validation
Keyboard
Button
TextInputLayout
Bottom Sheets
CoordinatorLayout and Behaviors
EditText
Paypal Gateway Integration
Firebase App Indexing
Firebase Crash Reporting
Displaying Google Ads
Vk SDK
Localized DateTime
Count Down Timer
Reading Barcode and QR codes
Otto Event Bus
TransitionDrawable
Port Mapping using Cling
Creating Overlay always-on-top Windows
ExoPlayer
Inter-app UI testing with UIAutomator
MediaSession
Speech to Text Conversion
FileProvider
Publish .aar file to Apache Archive with Gradle
XMPP
Authenticator
RecyclerView and LayoutManagers
AudioManager
Job Scheduling
Accounts and AccountManager
OpenCV
Split Screen Multi-Screen Activities
Threads
MediaStore
Time Utils
Touch Events
Fingerprint API
MVVM Architecture
BottomNavigationView
ORMLite
YouTube API
TabLayout
Retrofit2 with RxJava
DayNight Theme AppCompat
ShortcutManager
LruCache
Using Jenkins CI
Zip files
Vector Drawables
Fastlane
Define step value for RangeSeekBar
Getting started with OpenGL ES 2.0
Check Data Connection
Java Native Interface (JNI)
FileIO
Perfomance Optimization
Robolectric
Moshi
Strick Mode Policy
Internalization and localization
Retrolambda
SparseArray
Firebase Cloud Messaging
Shared Element Transitions
Android Things
VideoView
ViewFlipper
Dependency Injection with Dagger 2
Formatting phone numbers
Storing password securely
Android Kernel Optimization
Paint
AudioTrack
ProGuard
Create Android Custom ROMs
Java on Android
Pagination in RecyclerVi
Genymotion for Android
Handling touch and motion events
Creating Splash screen
ConstraintSet
CleverTap
Publish library to Maven repositories
ADB shell
Ping ICMP
AIDL
Using Kotlin
Autosizing TextView
Signing apps for release
Context
Activity Recognition
Secure SharedPreferences
Secure SharedPreferences
Bitmap Cache
Android x86 in VirtualBox
JCodec
Design Patterns
Okio
Google SignIn integration
TensorFlow
Game developmen
Notification Channel
Bluetooth Low Energy (LE)
Leak Canary
FuseView
SQLite using ContentValues
Enhancing Alert Dialogs
Hardware Button Events, Intents PTT
SpannableString
Looper
Optimized VideoView
Google Drive API
Animated AlertDialog Box
Annotation Processor
SyncAdapter with periodically do sync of data
Singleton Class for Toast Message
Fastjson
Android Architecture Components
Jackson
Play Store
Loading Bitmaps Effectively
Getting system font names
Smartcard
Convert vietnamese string to english
Contributors

Creating Custom Progress Dialog

suggest change

By Creating Custom Progress Dialog class, the dialog can be used to show in UI instance, without recreating the dialog.

First Create a Custom Progress Dialog Class.

CustomProgress.java
public class CustomProgress {

   public static CustomProgress customProgress = null;
   private Dialog mDialog;

   public static CustomProgress getInstance() {
       if (customProgress == null) {
           customProgress = new CustomProgress();
       }
       return customProgress;
   }

   public void showProgress(Context context, String message, boolean cancelable) {
       mDialog = new Dialog(context);
    // no tile for the dialog
       mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
       mDialog.setContentView(R.layout.prograss_bar_dialog);
       mProgressBar = (ProgressBar) mDialog.findViewById(R.id.progress_bar);
    //  mProgressBar.getIndeterminateDrawable().setColorFilter(context.getResources()
    // .getColor(R.color.material_blue_gray_500), PorterDuff.Mode.SRC_IN);
       TextView progressText = (TextView) mDialog.findViewById(R.id.progress_text);
       progressText.setText("" + message);
       progressText.setVisibility(View.VISIBLE);
       mProgressBar.setVisibility(View.VISIBLE);
    // you can change or add this line according to your need
       mProgressBar.setIndeterminate(true);
       mDialog.setCancelable(cancelable);
       mDialog.setCanceledOnTouchOutside(cancelable);
       mDialog.show();
   }

   public void hideProgress() {
       if (mDialog != null) {
           mDialog.dismiss();
           mDialog = null;
       }
   }
}

Now creating the custom progress layout

prograss_bar_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="65dp"
    android:background="@android:color/background_dark"
    android:orientation="vertical">

    <TextView
        android:id="@+id/progress_text"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:layout_above="@+id/progress_bar"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:background="@android:color/transparent"
        android:gravity="center_vertical"
        android:text=""
        android:textColor="@android:color/white"
        android:textSize="16sp"
        android:visibility="gone" />

    <-- Where the style can be changed to any kind of ProgressBar -->

    <ProgressBar
        android:id="@+id/progress_bar"
        style="@android:style/Widget.DeviceDefault.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_gravity="center"
        android:background="@color/cardview_dark_background"
        android:maxHeight="20dp"
        android:minHeight="20dp" />

</RelativeLayout>

This is it. Now for calling the Dialog in Code

CustomProgress customProgress = CustomProgress.getInstance();

// now you have the instance of CustomProgres
// for showing the ProgressBar

customProgress.showProgress(#Context, getString(#StringId), #boolean);

// for hiding the ProgressBar

customProgress.hideProgress();

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents