Skip to content

Commit

Permalink
Final Checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
PatilShreyas committed Jun 10, 2019
1 parent 2badd65 commit b4e31c9
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ public void onDismiss(android.content.DialogInterface dialogInterface) {
});
}

/**
* @return {@link LottieAnimationView} from the Dialog.
*/
public LottieAnimationView getAnimationView() {
return mAnimationView;
}

private void showCallback() {
if (mOnShowListener != null) {
mOnShowListener.onShow(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,81 @@

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.shreyaspatil.MaterialDialog.BottomSheetMaterialDialog;
import com.shreyaspatil.MaterialDialog.MaterialDialog;
import com.shreyaspatil.MaterialDialog.interfaces.DialogInterface;
import com.shreyaspatil.MaterialDialog.interfaces.OnCancelListener;
import com.shreyaspatil.MaterialDialog.interfaces.OnDismissListener;
import com.shreyaspatil.MaterialDialog.interfaces.OnShowListener;

public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements View.OnClickListener {

private MaterialDialog mSimpleDialog;
private MaterialDialog mAnimatedDialog;
private BottomSheetMaterialDialog mSimpleBottomSheetDialog;
private BottomSheetMaterialDialog mAnimatedBottomSheetDialog;

private Button mButtonSimpleDialog;
private Button mButtonAnimatedDialog;
private Button mButtonBottomSheetDialog;
private Button mButtonAnimatedBottomSheetDialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mButtonSimpleDialog = findViewById(R.id.button_simple_dialog);
mButtonAnimatedDialog = findViewById(R.id.button_animated_dialog);
mButtonBottomSheetDialog = findViewById(R.id.button_simple_bottomsheet_dialog);
mButtonAnimatedBottomSheetDialog = findViewById(R.id.button_animated_bottomsheet_dialog);

// Simple Material Dialog
mSimpleDialog = new MaterialDialog.Builder(this)
.setTitle("Delete?")
.setMessage("Are you sure want to delete this file?")
.setCancelable(false)
.setPositiveButton("Delete", R.drawable.ic_delete, new MaterialDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(getApplicationContext(), "Deleted!", Toast.LENGTH_SHORT).show();
dialogInterface.dismiss();
}
})
.setNegativeButton("Cancel", R.drawable.ic_close, new MaterialDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
Toast.makeText(getApplicationContext(), "Cancelled!", Toast.LENGTH_SHORT).show();
dialogInterface.dismiss();
}
})
.build();

// Simple BottomSheet Material Dialog
mSimpleBottomSheetDialog = new BottomSheetMaterialDialog.Builder(this)
.setTitle("Delete?")
.setMessage("Are you sure want to delete this file?")
.setCancelable(false)
.setPositiveButton("Delete", R.drawable.ic_delete, new BottomSheetMaterialDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(getApplicationContext(), "Deleted!", Toast.LENGTH_SHORT).show();
dialogInterface.dismiss();
}
})
.setNegativeButton("Cancel", R.drawable.ic_close, new BottomSheetMaterialDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
Toast.makeText(getApplicationContext(), "Cancelled!", Toast.LENGTH_SHORT).show();
dialogInterface.dismiss();
}
})
.build();

// Animated Simple Material Dialog
final MaterialDialog alertDialog = new MaterialDialog.Builder(this)
mAnimatedDialog = new MaterialDialog.Builder(this)
.setTitle("Delete?")
.setMessage("Are you sure want to delete this file?")
.setCancelable(false)
Expand All @@ -43,7 +98,7 @@ public void onClick(DialogInterface dialogInterface, int which) {
.build();

// Animated BottomSheet Material Dialog
final BottomSheetMaterialDialog sheetDialog = new BottomSheetMaterialDialog.Builder(this)
mAnimatedBottomSheetDialog = new BottomSheetMaterialDialog.Builder(this)
.setTitle("Delete?")
.setMessage("Are you sure want to delete this file?")
.setCancelable(false)
Expand All @@ -64,39 +119,30 @@ public void onClick(DialogInterface dialogInterface, int which) {
.setAnimation("delete_anim.json")
.build();

findViewById(R.id.button_smdialog).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
alertDialog.show();
}
});

findViewById(R.id.button_bsdialog).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sheetDialog.show();
}
});

sheetDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
System.out.println("CANCELLED");
}
});

sheetDialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
System.out.println("SHOWED");
}
});

sheetDialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
System.out.println("DISMISS");
}
});
mButtonSimpleDialog.setOnClickListener(this);
mButtonBottomSheetDialog.setOnClickListener(this);
mButtonAnimatedDialog.setOnClickListener(this);
mButtonAnimatedBottomSheetDialog.setOnClickListener(this);
}

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.button_simple_dialog :
mSimpleDialog.show();
break;

case R.id.button_simple_bottomsheet_dialog :
mSimpleBottomSheetDialog.show();
break;

case R.id.button_animated_dialog :
mAnimatedDialog.show();
break;

case R.id.button_animated_bottomsheet_dialog :
mAnimatedBottomSheetDialog.show();
break;
}
}
}
29 changes: 26 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,47 @@
tools:context=".MainActivity">

<LinearLayout
android:padding="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">

<com.google.android.material.button.MaterialButton
android:id="@+id/button_smdialog"
android:id="@+id/button_simple_dialog"
android:layout_marginTop="16dp"
android:textAllCaps="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Simple Material Dialog" />

<com.google.android.material.button.MaterialButton
android:id="@+id/button_bsdialog"
android:id="@+id/button_simple_bottomsheet_dialog"
android:layout_marginTop="16dp"
android:textAllCaps="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Bottomsheet Material Dialog" />
android:text="Simple Bottomsheet Material Dialog" />

<com.google.android.material.button.MaterialButton
android:id="@+id/button_animated_dialog"
android:layout_marginTop="16dp"
android:textAllCaps="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Animated Material Dialog" />

<com.google.android.material.button.MaterialButton
android:id="@+id/button_animated_bottomsheet_dialog"
android:layout_marginTop="16dp"
android:textAllCaps="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Animated Bottomsheet Material Dialog" />
</LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 comments on commit b4e31c9

Please sign in to comment.