-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update SetupDialog and MessageDialog
- Loading branch information
Showing
6 changed files
with
117 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
SJDialog/src/main/java/com/sjapps/library/customdialog/functions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.sjapps.library.customdialog; | ||
|
||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.content.res.Configuration; | ||
import android.content.res.Resources; | ||
import android.util.TypedValue; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public class functions { | ||
public static void SetDialogSize(@NonNull Context context, Dialog dialog, int maxWidth){ | ||
Configuration configuration = context.getResources().getConfiguration(); | ||
if (configuration.screenWidthDp > maxWidth) | ||
dialog.getWindow().setLayout(dpToPixels(context,maxWidth), ViewGroup.LayoutParams.WRAP_CONTENT); | ||
else dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); | ||
|
||
} | ||
private static int dpToPixels(@NonNull Context context, float dp) { | ||
Resources r = context.getResources(); | ||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.