Skip to content

Instantly share code, notes, and snippets.

package com.plcoding.m3_bottomsheet
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.BottomSheetScaffold
import androidx.compose.material3.Button
@senamit2708
senamit2708 / readme.txt
Created September 3, 2023 04:40
chaining in constraint layout
To chain these seven CardViews in a ConstraintLayout with equal distance between them, you can use chains and guidelines. Here's how you can do it:
1. First, define horizontal guidelines to create equal spacing between the CardViews. Add these lines to your ConstraintLayout:
```xml
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
@senamit2708
senamit2708 / lambdafile.kt
Created July 18, 2023 07:43
lambda function learning
fun main(){
var fn: (a: Int, b: Int) -> Int = ::sum
var lambdaOne: (Int,Int)->Int = {x: Int, y: Int -> x+y }
multiLineLambda()
val singleParameter: (Int) -> (Int) = {x: Int -> x * x}
val simplifySingleParameter: (Int) -> (Int) = {it * it}
calculator(1, 2){a,b -> a +b} //if lambda expression is the last parameter of a function
//you can write that lamdba in above way also.
@senamit2708
senamit2708 / build.gradle(Module: app)
Created July 13, 2023 05:42
how to define library constant in gradle file
//navigation
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
//room database
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
@senamit2708
senamit2708 / ApiInterface.kt
Last active July 12, 2023 12:30
Retrofit with IgnoreError and continue with coroutine
package com.example.coroutinelearning.retrofits
import com.example.coroutinelearning.entity.Root
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Query
interface ApiInterface {
@GET("/api/users")
@senamit2708
senamit2708 / ApiInterface.kt
Created July 12, 2023 11:17
Retrofit: Parallel network call
package com.example.coroutinelearning.retrofits
import com.example.coroutinelearning.entity.Root
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Query
interface ApiInterface {
@GET("/api/users")
@senamit2708
senamit2708 / ApiInterface.kt
Created July 12, 2023 09:07
Retrofit with Series network call having coroutine and sealed class
package com.example.coroutinelearning.retrofits
import com.example.coroutinelearning.entity.Root
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Query
interface ApiInterface {
@GET("/api/users")
@senamit2708
senamit2708 / ApiInterface.kt
Created July 11, 2023 14:27
Retrofit with coroutine -> Advance One
package com.example.coroutinelearning.retrofits
import com.example.coroutinelearning.entity.Root
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Query
interface ApiInterface {
@GET("/api/users")
@senamit2708
senamit2708 / AndroidMainfest.xml
Created July 11, 2023 07:11
Retrofit Basic Learning
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@senamit2708
senamit2708 / NewUserEntryFragment.kt
Last active August 11, 2023 13:13
extension function
private fun saveUserDetailToDB() {
val name = binding.txtName.text.toString()
var mobNo = binding.txtMobNo.text.toString()
mobNo = mobNo.addMobileExtension() //extension function
var user = User(name = name, mobileNumber = mobNo)
user = user.firstLetterCapital() //extension function
userViewModel.saveUserDetail(user)
}