Skip to content

nurujjamanpollob/Advanced-Dialog-View-Android-Customizable-Dialog-View

Repository files navigation

Advanced Dialog View Android - Customizable Dialog View


CodeFactor


This library is simplyfying Dialog Viewing experience inside your application. This simple library to help you save your time. Anyway, this library will be come with more extra features in future, if needed.


This library intended to show your designed layout resource file to show in dialog view with given parameter and control. Currently, it supports draw content from bottom, center, top with minimal typing and configurable options come out of box.


This Readme.md will be improved later. Anyway, in this project I have a sample app with some code to show it's feature, so be sure to check the app module.

Here is some basic comparison with standard AlertDialog class:

AlertDialog Class AdvancedDialogView Class
Has fixed direction Can be Flexible
Comes with pre-designed layout No pre-designed Layout
Never support draw Custom Layout Src View Has support
No Null pointer safety Designed to avoid Null Pointer
Never support View Animation Has support for Animation
Limited Customization Highly Customizable


So as far, it's good if you are looking for customizable Dialog View with full support for View Events. Okay, let's into the implementation:


Implementation:


Open project level build.gradle file, and add this following content:


 	
allprojects {
    repositories {
    ...
    maven { url 'https://jitpack.io' }
		
    }

}
  
 
 

Note:Newer gradle android project prefer settings.gradle repository configuration over project level build.gradle configuration. In that case, you should add following code in your settings.gradle file:



 
pluginManagement {
	repositories {
        ...
        maven { url 'https://jitpack.io' }
              
    }
}
 



Then, in your app module level build.gradle add this following content in dependencies:


 	
   dependencies {
	        
        implementation 'com.github.nurujjamanpollob:Advanced-Dialog-View-Android-Customizable-Dialog-View:1.3'
   
   }

  
 
 


So, your project configuration is done.


Now, you need to go your app module and create a layout file for draw on screen as a Dialog.
In this example, I will simply create a layout file named dialog_layout and add this following content:


<androidx.constraintlayout.widget.ConstraintLayout

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/black"
android:layout_height="wrap_content">


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:id="@+id/dialog_text"
    android:padding="20dp"
    android:textColor="@color/white"
    android:textSize="18sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />


Okay, open your activity where you gonna show your dialog,
And now I am gonna show you how I simply gonna create a dialog with this layout file :)

Add following import:

 
import dev.nurujjamanpollob.uicollection.advanceddialogview.AdvancedDialogView;
import dev.nurujjamanpollob.uicollection.advanceddialogview.DialogOptions;


Lets head to the method you gonna create this Dialog by. And then add following code:


AdvancedDialogView dialogView = new AdvancedDialogView(context);
dialogView.setDialogResourceByLayoutId(R.layout.dialog_view, DialogOptions.DIALOG_GRAVITY_BOTTOM, false);


This code is enough for draw a custom dialog with draw content from bottom.
Anyway, you can use DialogOptions.DIALOG_GRAVITY_TOP for draw content from top,
And DialogOptions.DIALOG_GRAVITY_CENTER for draw content in the center.


What if I need to interact with Layout Object Views?


This is simple. You need to add following code to your existing code, so the final code will be like this:



AdvancedDialogView dialogView = new AdvancedDialogView(context);
dialogView.setDialogResourceByLayoutId(R.layout.dialog_view, DialogOptions.DIALOG_GRAVITY_BOTTOM, false);
dialogView..setUILoadListener(new AdvancedDialogView.OnDialogUiLoadListener() {
            /**
             * This method will be invoked when the passed Layout File has been loaded
             */
            @Override
            public void onUiLoaded() {

                // Get textView, you can get your own view here :) that you have passed
                TextView dialogTextView = dialog.getViewByIdentity(R.id.dialog_text, new TextView(MainActivity.this));

                // Set the text
                dialogTextView.setText("Hello, isn't AdvancedDialogView simple and cool?");


            }
        });
	



Okay, how to dismiss the Dialog UI?

 dialogView.closeDialogView();


How to use dialog timeout?



dialogView.closeDialogUiAfterMillis(int timeoutAfterMillis);


For implementation guide, please see this sample Android activity file from here: MainActivity.Java

Demo


Documentation

Coming SOOOOOOOOOOOn!