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 fun setupEdgeToEdgeUI() { | |
WindowCompat.setDecorFitsSystemWindows(window, false) | |
ViewCompat.setOnApplyWindowInsetsListener(binding.overlayView) { v, insets -> | |
insets.getInsets(WindowInsetsCompat.Type.systemBars()).let { v.setPadding(it.left, it.top, it.right, it.bottom) } | |
WindowInsetsCompat.CONSUMED | |
} | |
} |
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
<application> | |
... | |
<meta-data | |
android:name="com.facebook.sdk.ApplicationId" | |
android:value="${facebook_app_id}" /> | |
<activity | |
android:name="com.facebook.FacebookActivity" | |
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" | |
android:label="@string/app_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
import java.util.* | |
import java.io.* | |
import java.nio.channels.FileChannel.MapMode | |
fun arrayIndexOutOfBound() { | |
val a = arrayOf<Int>()[-2] | |
} | |
fun negativeArraySize() { | |
val n = Array(-10, {0}) |
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
//app level config constants | |
object AppConfig { | |
const val compileSdk = 30 | |
const val minSdk = 21 | |
const val targetSdk = 30 | |
const val versionCode = 1 | |
const val versionName = "1.0.0" | |
const val buildToolsVersion = "29.0.3" | |
const val androidTestInstrumentation = "androidx.test.runner.AndroidJUnitRunner" |
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
<activity | |
android:name=".SplashActivity" | |
android:theme="@style/SplashTheme"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> |
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
// Moshi | |
implementation "com.squareup.moshi:moshi:1.11.0" | |
implementation "com.squareup.moshi:moshi-kotlin:1.11.0" | |
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.11.0") | |
// Retrofit | |
implementation "com.squareup.retrofit2:retrofit:2.9.0" | |
implementation "com.squareup.retrofit2:converter-moshi:2.6.0" | |
// Coroutines |
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 setTextInTextView(value: String?): ViewAction { | |
return object : ViewAction { | |
override fun getConstraints(): Matcher<View> { | |
return allOf(isDisplayed(), isAssignableFrom(TextView::class.java)) | |
} | |
override fun perform(uiController: UiController?, view: View) { | |
(view as TextView).text = value | |
} |
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
import androidx.fragment.app.Fragment | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.ViewModelProvider | |
/** | |
* An extension function that removes the need to write ViewModelFactory by creating a factory based on ViewModel arguments | |
* | |
* Example: | |
* private val viewModel: DailyForecastViewModel by DailyForecastViewModel(requireContext()).createViewModel(this) |
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
### SimpleDateFormat Patterns | |
*Year* | |
// yyyy or YYYY - Year | |
*Month* | |
MM - Month of the year (eg. 11) | |
MMM - Month of the year (eg. Nov) |
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 listOfAllCountries = arrayListOf("United States", "Canada", "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and/or Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Cook Islands", "Costa Rica", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecudaor", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islan |
NewerOlder