This file contains hidden or 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
fun Context?.isOnline(failBlock : () -> Unit = { globalIntenetFailBock() }, successBlock : () -> Unit ) { | |
this?.apply { | |
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
val b : Boolean = false | |
if (cm == null) b = false | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { | |
NetworkCapabilities cap = cm.getNetworkCapabilities(cm.getActiveNetwork()) | |
if (cap == null) b = false | |
b = cap.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) |
This file contains hidden or 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
private val GOOGLE_REQUEST_CODE: Int = 123 | |
val uriapp = Uri.Builder() | |
.scheme("upi") | |
.authority("pay") | |
.appendQueryParameter("pa", "merchant@bank") //VPA Name here | |
.appendQueryParameter("pn", "Merchant Name") //merchant name here | |
.appendQueryParameter("mc", "1234") //merchant code here | |
.appendQueryParameter("tr", "123456789") //transaction reference id here | |
.appendQueryParameter("tn", "For shopping") //transaction note here |
This file contains hidden or 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
val constraintSet = ConstraintSet() | |
constraintSet.clone(root_view_of_constaint_layout) | |
constraintSet.setMargin(view_which_we_apply_margin_on, top/bottom/start/end, int_dp) | |
constraintSet.applyTo(root_view_of_constaint_layout) |
This file contains hidden or 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
Three Sum | |
Have the function ThreeSum(arr) take the array of integers stored in arr, and determine if any three distinct numbers | |
(excluding the first element) in the array can sum up to the first element in the array. | |
For example: if arr is [8, 2, 1, 4, 10, 5, -1, -1] then there are actually three sets of triplets that sum to | |
the number 8: [2, 1, 5], [4, 5, -1] and [10, -1, -1]. | |
Your program should return the string true if 3 distinct elements sum to the first element, | |
otherwise your program should return the string false. The input array will always contain at least 4 elements. | |
Examples | |
Input: arrayOf(10, 2, 3, 1, 5, 3, 1, 4, -4, -3, -2) |
This file contains hidden or 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
@Preview | |
@Composable | |
fun ForSurface() { | |
Surface( | |
shape = MaterialTheme.shapes.medium, | |
elevation = 2.dp, | |
border = BorderStroke(1.dp, colorResource(id = R.color.black)), //apply border | |
color = colorResource(id = R.color.teal_200), //apply foreground color | |
contentColor = colorResource(id = R.color.white), //apply color to all child view | |
modifier = Modifier |
This file contains hidden or 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
@Preview | |
@Composable | |
private fun columnRecyclerView(names: List<String> = List(1000) { "$it" }) { | |
val context = LocalContext.current | |
Column( | |
modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
LazyColumn(modifier = Modifier.padding(vertical = 4.dp)) { | |
items(names) { name -> |
This file contains hidden or 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
FloatingActionButton(onClick = { }, backgroundColor = MaterialTheme.colors.secondary) { | |
Icon( | |
painter = painterResource(id = R.drawable.ic_baseline_arrow_upward_24), | |
contentDescription = "Go Up" | |
) |
This file contains hidden or 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
fun Modifier.baseLineToTop(firstBaselineToTop: Dp): Modifier { | |
return this.then( | |
layout { measurable, constraints -> | |
val placeable = measurable.measure(constraints = constraints) | |
// Check the composable has a first baseline | |
check(placeable[FirstBaseline] != AlignmentLine.Unspecified) | |
val firstBaseline = placeable[FirstBaseline] |
This file contains hidden or 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
@Preview(showSystemUi = true) | |
@Composable | |
fun ConstraintLayoutContentPreview() { | |
ComposeTheme { | |
ConstraintLayoutContent() | |
} | |
} | |
//(1)----------------------------------Basic------------------------------------ | |
@Composable | |
fun ConstraintLayoutContent() { |
This file contains hidden or 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
values/themes.xml | |
<resources> | |
<style name="Theme.ComposeTheming" parent="Theme.Material.DayNight.NoActionBar"> | |
<item name="android:statusBarColor">@color/status_bar</item> | |
</style> | |
<style name="Theme.Material.DayNight.NoActionBar" parent="@android:style/Theme.Material.Light.NoActionBar" /> | |
</resources> | |
-------------------------------------------------------------------------------------------------------------------------- |
OlderNewer