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
ext { | |
compileSDKVersionValue = 29 | |
minSDKVersionValue = 22 | |
targetSDKVersionValue = 29 | |
libraries = [ | |
cardView : 'androidx.cardview:cardview:1.0.0', | |
androidXLegacySupport : 'androidx.legacy:legacy-support-v4:1.0.0', | |
androidXAppCompat : 'androidx.appcompat:appcompat:1.1.0', |
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
class SetupViewModel @Inject constructor(private val setupRepository: SetupRepository) : ViewModel() { | |
//CoroutineContext: | |
private val completableJob = Job() | |
private val coroutineScope = CoroutineScope(Dispatchers.IO + completableJob) | |
//Other variables here | |
fun loadListOfCountries() { | |
//Fires in the IO thread. |
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
inline fun <reified T : ViewModel> Fragment.viewModel( | |
crossinline provider: (SavedStateHandle) -> T | |
) = viewModels<T> { | |
object : AbstractSavedStateViewModelFactory(this, fragment.arguments ?: Bundle()) { | |
override fun <T : ViewModel?> create(key: String, modelClass: Class<T>, handle: SavedStateHandle): T = | |
provider(handle) as T | |
} | |
} |
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
javaCompileOptions { | |
annotationProcessorOptions { | |
arguments = mapOf( | |
"room.schemaLocation" to "$projectDir/schemas", | |
"room.incremental" to "true", | |
"room.expandProjection" to "true" | |
) | |
} | |
} |
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
@ColumnInfo(name = "name") | |
val name: String? = "", |
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
Room.databaseBuilder(appContext, AppDatabase.class, "Sample.db") | |
.createFromAsset("database/myapp.db") | |
.build() |
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
class MainActivity : AppCompatActivity() { | |
private lateinit var viewPager: ViewPager2 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
viewPager = findViewById(R.id.my_view_pager) | |
val tabLayout = findViewById<TabLayout>(R.id.tabs) | |
val pagerAdapter = ScreenSlidePagerAdapter(this) |
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
TabLayoutMediator(tabLayout, viewPager) { tab, position -> | |
when (position) { | |
0 -> tab.text = "Home" | |
1 -> tab.text = "School" | |
} | |
}.attach() |
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
<androidx.viewpager2.widget.ViewPager2 | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/my_view_pager" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" /> |
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
compileSdkVersion(29) | |
defaultConfig { | |
applicationId = "com.sxhardha.someappName" | |
minSdkVersion(24) | |
targetSdkVersion(29) | |
versionCode = 1 | |
versionName = "1.0" | |
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | |
} |
NewerOlder