Skip to content

Instantly share code, notes, and snippets.

View Audhil's full-sized avatar
🎯
Focusing

Mohammed Audhil Audhil

🎯
Focusing
View GitHub Profile
@Audhil
Audhil / primitives.java
Created July 26, 2020 18:32
memory required for each data type in Java
// https://blog.udemy.com/java-data-types/?utm_source=adwords&utm_medium=udemyads&utm_campaign=DSA_Catchall_la.EN_cc.INDIA&utm_content=deal4584&utm_term=_._ag_82569850245_._ad_437477497173_._kw__._de_c_._dm__._pl__._ti_dsa-449490803887_._li_9061910_._pd__._&matchtype=b&gclid=CjwKCAjw0_T4BRBlEiwAwoEiAd5tg5iZ8c_k9pQxw5pX5HJoQKHjCc21ylREUKzHurajr3l7v2u5LhoCvKsQAvD_BwE
public static void main(String[] args) {
byte d = 127; // 2^7 = -128 -> 2^7-1 = 127 - 8 bits = 1 byte
short sh = 32767; // 16 bits = 2 bytes
int in = 2147483647; // 32 bits = 4 bytes
long lo = 9223372036854775807L; // 64 bits = 8 bytes
float fl = 23.44f; // 32 bits = 4 bytes
double db = 342.4; // 64 bits = 8 bytes
char ch = 'a'; // 16 bits - 2 byte
boolean bool = false; // 1 bit
@Audhil
Audhil / MainActivity.kt
Created July 7, 2020 08:22
viewmodel creation - gist 8
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
// extn func from activity-ktx lib
val viewModel: MainViewModel by viewModels()
}
@Audhil
Audhil / MainViewModel.kt
Created July 7, 2020 08:18
viewmodel injection - dagger-hilt - gist 8
class MainViewModel
@ViewModelInject
constructor() : ViewModel()
@Audhil
Audhil / build.gradle
Created July 7, 2020 08:13
hilt viewmodel dependencies - gist 7
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha01"
kapt "androidx.hilt:hilt-compiler:1.0.0-alpha01"
@Audhil
Audhil / MainActivity.kt
Last active July 6, 2020 19:21
mainActivity - gist 5
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject
lateinit var dummyClass: DummyClass
}
@Audhil
Audhil / APIModule.kt
Created July 6, 2020 18:57
module - gist 5
@Module
@InstallIn(ApplicationComponent::class)
class APIModule {
@Provides
fun giveAPIService(): API = Retrofit.Builder().build().create(API::class.java)
}
@Audhil
Audhil / DummyClass.kt
Created July 6, 2020 18:46
DummyClass - gist 4
class DummyClass
@Inject
constructor()
@Audhil
Audhil / NewsApplication.kt
Last active July 6, 2020 18:38
application class - gist 3
@HiltAndroidApp
class NewsApplication : Application()
@Audhil
Audhil / build.gradle
Last active July 6, 2020 18:10
project level build.gradle - gist 2
// project level build.gradle
classpath 'com.google.dagger:hilt-android-gradle-plugin:{latest_version}'
@Audhil
Audhil / build.gradle
Last active July 6, 2020 18:10
dagger-hilt - dependencies - gist 1
// app/build.gradle
implementation "com.google.dagger:hilt-android:{latest_version}"
kapt "com.google.dagger:hilt-android-compiler:{latest_version}"