-
Notifications
You must be signed in to change notification settings - Fork 29
/
old_readme
1015 lines (770 loc) · 24 KB
/
old_readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<h1 align="center"> Android-Live-Templates </h1>
<div align="center">
<img src="https://awesome.re/badge.svg" alt="Awesome Badge"/>
<img src="https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99" alt="Star Badge"/>
<img src="https://img.shields.io/badge/Follow-%40code.fun-red?style=social&logo=instagram" alt="Instagram Badge"/>
</div>
<h3 align="center"> <i> Work in progress: New Live Templates are on the way </i> </h3>
<img alt="Poster" src="assets/cover_pic.png"> </img>
<div align="center">
<img src="https://badgen.net/github/stars/agamkoradiya/Android-Live-Templates" alt="Star Badge"/>
<img src="https://badgen.net/github/forks/agamkoradiya/Android-Live-Templates" alt="Fork Badge"/>
<img src="https://badgen.net/github/issues/agamkoradiya/Android-Live-Templates" alt="Issues Badge"/>
<img src="https://badgen.net/github/prs/agamkoradiya/Android-Live-Templates" alt="PR Badge"/>
<img src="https://badgen.net/github/contributors/agamkoradiya/Android-Live-Templates" alt="Contributors Badge"/>
<img src="https://badgen.net/github/license/agamkoradiya/Android-Live-Templates" alt="License Badge"/>
</div>
<h3 align="center"> <i> Checkout master branch for unzip folder </i> </h3>
<br>
# Content
- [What is live template? 😮](#what-is-live-template-)
- [Demo 💻](#demo-)
- [How to *import all live templates* in 1 minute? 💥](#how-to-import-all-live-templates-in-1-minute-)
- [CheatSheet for this repository 📄](#cheatsheet-)
- [Adapter](#-adapter)
- [adapter list](#adapter-list)
- [adapter normal](#adapter-normal)
- [View binding](#-view-binding)
- [binding activity](#binding-activity)
- [binding fragment](#binding-fragment)
- [Retrofit library](#-retrofit-library)
- [retofit instance](#retrofit-instance)
- [Room database](#-room-database)
- [room db](#room-db)
- [room db with singleton](#room-db-with-singleton)
- [room dao](#room-dao)
- [room converter for list of string](#room-converter-for-list-of-string)
- [room converter for date](#room-converter-for-date)
- [room converter for bitmap](#room-converter-for-bitmap)
- [Dependency Injection](#-dependency-injection)
- [di hilt app](#di-hilt-app)
- [di retrofit module](#di-retrofit-module)
- [di room module](#di-room-module)
- [Drawable](#-drawable)
- [shape bubble](#shape-bubble)
- [shape halfcircle](#shape-halfcircle)
- [shape line](#shape-line)
- [shape oval](#shape-oval)
- [shape ractangle](#shape-ractangle)
- [shape ring](#shape-ring)
- [shape round](#shape-round)
- [state list](#state-list)
- [XML](#-xml)
- [center_horizontal](#center-horizontal)
- [center_horizontal_parent](#center-horizontal-parent)
- [center_parent](#center-parent)
- [center_vartical](#center-vartical)
- [center_vartical_parent](#center-vartical-parent)
- [xml_menu](#xml-menu)
- [Util](#-util)
- [util resource](#util-resource)
- [util toast](#util-toast)
- [Gradle dependency](#-gradle-dependency)
- [How to create your own live templates? 💡](#how-to-create-your-own-live-templates-)
- [Suggest me! ✒️](#suggest-me)
- [Contribute ❤️](#contribute)
---
## What is live template? 😮
<samp> Live Templates are code snippets that you can insert into your code by typing their abbreviation and pressing tab.
By using them, you can quickly and intelligently add frequently used code patterns and constructs to your code, letting the IDE do the tedious work for you. </samp>
## Demo 💻
<img alt="How to import all live templates" src="assets/demoFirst.gif"> </img>
<img alt="How to import all live templates" src="assets/demoSecond.gif"> </img>
<br>
## How to import all live templates in 1 minute? 💥
1. Download AndroidLiveTemplates.zip file
2. Then follow below video tutorial
<br>
<img alt="How to import all live templates" src="assets/howToImport.gif"> </img>
<br>
## CheatSheet 📄
### 📌 Adapter
<br>
<div name="adapter-list">
> <samp> adapter list </samp>
```kotlin
class $FILE_NAME$ : androidx.recyclerview.widget.ListAdapter<$TYPE$, $FILE_NAME$.$HOLDER_NAME$ViewHolder>(DiffCallback()) {
override fun onCreateViewHolder(parent: android.view.ViewGroup, viewType: Int): $HOLDER_NAME$ViewHolder {
val binding =
$BINDING$.inflate(
android.view.LayoutInflater.from(parent.context),
parent,
false
)
return $HOLDER_NAME$ViewHolder(binding)
}
override fun onBindViewHolder(holder: $HOLDER_NAME$ViewHolder, position: Int) {
val currentItem = getItem(position)
}
inner class $HOLDER_NAME$ViewHolder(private val binding: $BINDING$) :
androidx.recyclerview.widget.RecyclerView.ViewHolder(binding.root) {}
class DiffCallback : androidx.recyclerview.widget.DiffUtil.ItemCallback<$TYPE$>() {
override fun areItemsTheSame(oldItem: $TYPE$, newItem: $TYPE$) =
oldItem.id == newItem.id
override fun areContentsTheSame(oldItem: $TYPE$, newItem: $TYPE$) =
oldItem == newItem
}
}
```
</div>
<br>
<div name="adapter-normal">
> <samp> adapter normal </samp>
```kotlin
class $FILE_NAME$ : androidx.recyclerview.widget.RecyclerView.Adapter<$FILE_NAME$.MyViewHolder>() {
class MyViewHolder(itemView: android.view.View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(itemView) {}
override fun onCreateViewHolder(parent: android.view.ViewGroup, viewType: Int): MyViewHolder {
return MyViewHolder(
android.view.LayoutInflater.from(parent.context).inflate(R.layout.$LAYOUT$, parent, false)
)
}
override fun getItemCount(): Int {
TODO("Not yet implemented")
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
TODO("Not yet implemented")
}
}
```
</div>
<br>
### 📌 View Binding
<br>
<div name="binding-activity">
> <samp> binding activity </samp>
```kotlin
class $FILE_NAME$ : androidx.appcompat.app.AppCompatActivity() {
private lateinit var binding: $BINDING_LAYOUT$
override fun onCreate(savedInstanceState: android.os.Bundle?) {
super.onCreate(savedInstanceState)
binding = $BINDING_LAYOUT$.inflate(layoutInflater)
val view = binding.root
setContentView(view)
}
}
```
</div>
<br>
<div name="binding-fragment">
> <samp> binding fragment </samp>
```kotlin
class $FILE_NAME$ : androidx.fragment.app.Fragment() {
private var _binding: $BINDING_LAYOUT$? = null
private val binding get() = _binding!!
override fun onCreateView(
inflater: android.view.LayoutInflater,
container: android.view.ViewGroup?,
savedInstanceState: android.os.Bundle?
): android.view.View {
_binding = $BINDING_LAYOUT$.inflate(inflater, container, false)
return binding.root
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
```
</div>
<br>
### 📌 Retrofit Library
<br>
<div name="retrofit-instance">
> <samp> retrofit instance </samp>
```kotlin
class $FILE_NAME$ {
companion object {
private val retrofit by lazy {
val logging = okhttp3.logging.HttpLoggingInterceptor()
logging.setLevel(okhttp3.logging.HttpLoggingInterceptor.Level.$TYPE$)
val client = okhttp3.OkHttpClient.Builder()
.addInterceptor(logging)
.build()
retrofit2.Retrofit.Builder()
.baseUrl($BASE_URL$)
.addConverterFactory(retrofit2.converter.gson.GsonConverterFactory.create())
.client(client)
.build()
}
val api by lazy {
retrofit.create($API_NAME$::class.java)
}
}
}
```
</div>
<br>
### 📌 Room Database
<br>
<div name="room-db">
> <samp> room db </samp>
```kotlin
@androidx.room.Database(
entities = [$TABLE_NAME$::class],
version = 1,
exportSchema = false
)
@androidx.room.TypeConverters($CONVERTER_NAME$::class)
abstract class $FILE_NAME$ : androidx.room.RoomDatabase() {
abstract fun $DAO_NAME$(): $DAO_TYPE$
}
```
</div>
<br>
<div name="room-db-with-singleton">
> <samp> room db with singleton </samp>
```kotlin
@androidx.room.Database(
entities = [$TABLE_NAME$::class],
version = 1,
exportSchema = false
)
@androidx.room.TypeConverters($CONVERTER_NAME$::class)
abstract class $FILE_NAME$ : androidx.room.RoomDatabase() {
abstract fun $DAO_NAME$(): $DAO_TYPE$
companion object {
@Volatile
private var INSTANCE: $FILE_NAME$? = null
private val LOCK = Any()
fun getDatabase(context: android.content.Context): $FILE_NAME$ =
INSTANCE ?: synchronized(LOCK) {
INSTANCE
?: buildDatabase(context).also { INSTANCE = it }
}
private fun buildDatabase(context: android.content.Context) =
androidx.room.Room.databaseBuilder(
context.applicationContext,
$FILE_NAME$::class.java, "$DB_NAME$.db"
).build()
}
}
```
</div>
<br>
<div name="room-dao">
> <samp> room dao </samp>
```kotlin
import androidx.room.*
@Dao
interface $FILE_NAME$ {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert$TABLE_NAME$($VAR_NAME$: $TABLE_NAME$)
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertAll$TABLE_NAME$(vararg $VAR_NAME$s: $TABLE_NAME$)
@Update
suspend fun update($VAR_NAME$: $TABLE_NAME$)
@Delete
suspend fun delete($VAR_NAME$: $TABLE_NAME$)
@Query("SELECT * FROM $VAR_NAME$")
fun getAll$TABLE_NAME$(): List<$TABLE_NAME$>
}
```
</div>
<br>
<div name="room-converter-for-list-of-string">
> <samp> room converter for list of string </samp>
```kotlin
// List<String> <-> String
@androidx.room.TypeConverter
fun fromList(list: List<String>): String {
return com.google.gson.Gson().toJson(list)
}
@androidx.room.TypeConverter
fun toList(string: String): List<String> {
return com.google.gson.Gson().fromJson(string, object : com.google.gson.reflect.TypeToken<List<String>>() {}.type)
}
```
</div>
<br>
<div name="room-converter-for-date">
> <samp> room converter for date </samp>
```kotlin
// Date <-> Long
@androidx.room.TypeConverter
fun fromTimestamp(value: Long?): java.util.Date? {
return value?.let { java.util.Date(it) }
}
@androidx.room.TypeConverter
fun dateToTimestamp(date: java.util.Date?): Long? {
return date?.time?.toLong()
}
```
</div>
<br>
<div name="room-converter-for-bitmap">
> <samp> room converter for bitmap </samp>
```kotlin
// Bitmap <-> ByteArray
@androidx.room.TypeConverter
fun fromBitmap(bitmap: android.graphics.Bitmap): ByteArray {
val outputStream = java.io.ByteArrayOutputStream()
bitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, outputStream)
return outputStream.toByteArray()
}
@androidx.room.TypeConverter
fun toBitmap(byteArray: ByteArray): android.graphics.Bitmap {
return android.graphics.BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size)
}
```
</div>
<br>
### 📌 Dependency Injection
<br>
<div name="di-hilt-app">
> <samp> di hilt app </samp>
```kotlin
@dagger.hilt.android.HiltAndroidApp
class $FILE_NAME$ : android.app.Application() {
}
```
</div>
<br>
<div name="di-retrofit-module">
> <samp> di retrofit module </samp>
```kotlin
@javax.inject.Singleton
@dagger.Provides
fun provideRetrofit(): retrofit2.Retrofit =
retrofit2.Retrofit.Builder()
.baseUrl($BASE_URL$)
.addConverterFactory(retrofit2.converter.gson.GsonConverterFactory.create())
.build()
@javax.inject.Singleton
@dagger.Provides
fun provide$API_NAME$(retrofit: retrofit2.Retrofit): $API$ =
retrofit.create($API$::class.java)
```
</div>
<br>
<div name="di-room-module">
> <samp> di room module </samp>
```kotlin
@javax.inject.Singleton
@dagger.Provides
fun provideDatabase(
@dagger.hilt.android.qualifiers.ApplicationContext context: android.content.Context
) = androidx.room.Room.databaseBuilder(
context,
$DATABASE_CLASS$::class.java,
"$DATABASE_NAME$"
).build()
@javax.inject.Singleton
@dagger.Provides
fun provideDao(database: $DATABASE_CLASS$) = database.$METHOD$
```
</div>
<br>
### 📌 Drawable
<br>
<div name="shape-bubble">
> <samp> shape bubble </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="10dp"
android:radius="40dp" />
<stroke
android:width="1dp"
android:color="@color/$STROKE_COLOR$" />
<size
android:width="50dp"
android:height="50dp" />
<solid android:color="@color/$SOLID_COLOR$" />
</shape>
```
</div>
<br>
<div name="shape-halfcircle">
> <samp> shape halfcircle </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="60dp"
android:topRightRadius="60dp" />
<size
android:width="120dp"
android:height="60dp" />
<solid android:color="@color/$SOLID_COLOR$" />
</shape>
```
</div>
<br>
<div name="shape-line">
> <samp> shape line </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="3dp"
android:color="@color/$STROKE_COLOR$" />
<size android:height="1dp" />
</shape>
```
</div>
<br>
<div name="shape-oval">
> <samp> shape oval </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="3dp"
android:color="@color/$STROKE_COLOR$" />
<solid android:color="@color/$SOLID_COLOR$" />
</shape>
```
</div>
<br>
<div name="shape-ractangle">
> <samp> shape ractangle </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<stroke
android:width="3dp"
android:color="@color/$STROKE_COLOR$" />
<solid android:color="@color/$SOLID_COLOR$" />
</shape>
```
</div>
<br>
<div name="shape-ring">
> <samp> shape ring </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:thickness="5dp"
android:useLevel="false">
<solid android:color="@color/$SOLID_COLOR$" />
</shape>
```
</div>
<br>
<div name="shape-round">
> <samp> shape round </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thickness="100dp"
android:useLevel="false">
<solid android:color="@color/$SOLID_COLOR$" />
</shape>
```
</div>
<br>
<div name="state-list">
> <samp> state list </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/$DRAWABLE1$" android:state_pressed="true" /> <!-- pressed -->
<item android:drawable="@drawable/$DRAWABLE2$" android:state_focused="true" /> <!-- focused -->
<item android:drawable="@drawable/$DRAWABLE3$" android:state_hovered="true" /> <!-- hovered -->
<item android:drawable="@drawable/$DRAWABLE4$" android:state_selected="true" /> <!-- selected -->
<item android:drawable="@drawable/$DRAWABLE5$" android:state_checkable="true" /> <!-- checkable -->
<item android:drawable="@drawable/$DRAWABLE6$" android:state_checked="true" /> <!-- checked -->
<item android:drawable="@drawable/$DRAWABLE7$" android:state_enabled="true" /> <!-- enabled -->
<item android:drawable="@drawable/$DRAWABLE8$" android:state_activated="true" /> <!-- activated -->
<item android:drawable="@drawable/$DRAWABLE9$" android:state_window_focused="true" /> <!-- window_focused -->
<item android:drawable="@drawable/$DRAWABLE$" /> <!-- default -->
</selector>
```
</div>
<br>
### 📌 XML
<br>
<div name="center-horizontal">
> <samp> center_horizontal </samp>
```kotlin
app:layout_constraintEnd_toStartOf="@+id/$VIEWIDSTART$"
app:layout_constraintStart_toEndOf="@+id/$VIEWIDEND$"
```
</div>
<br>
<div name="center-horizontal-parent">
> <samp> center_horizontal_parent </samp>
```kotlin
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
```
</div>
<br>
<div name="center-parent">
> <samp> center_parent </samp>
```kotlin
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
```
</div>
<br>
<div name="center-vartical">
> <samp> center_vartical </samp>
```kotlin
app:layout_constraintBottom_toTopOf="@+id/$VIEWIDTOP$"
app:layout_constraintTop_toBottomOf="@+id/$VIEWIDBOTTOM$"
```
</div>
<br>
<div name="center-vartical-parent">
> <samp> center_vartical_parent </samp>
```kotlin
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
```
</div>
<br>
<div name="xml-menu">
> <samp> xml_menu </samp>
```kotlin
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_$ID1$"
android:icon="@drawable/$ICON1$"
android:title="@string/$TITLE1$"
app:showAsAction="$ACTION1$" />
<item
android:id="@+id/menu_$ID2$"
android:icon="@drawable/$ICON2$"
android:title="@string/$TITLE2$"
app:showAsAction="$ACTION2$" />
<item
android:id="@+id/menu_$ID3$"
android:icon="@drawable/$ICON3$"
android:title="@string/$TITLE3$"
app:showAsAction="$ACTION3$" />
<item
android:id="@+id/menu_$ID4$"
android:icon="@drawable/$ICON4$"
android:title="@string/$TITLE4$"
app:showAsAction="$ACTION4$" />
<item
android:id="@+id/menu_$ID5$"
android:icon="@drawable/$ICON5$"
android:title="@string/$TITLE5$"
app:showAsAction="$ACTION5$" />
</menu>
```
</div>
<br>
### 📌 Util
<br>
<div name="util-resource">
> <samp> util resource </samp>
```kotlin
sealed class Resource<T>(val data: T?, val message: String?) {
class Success<T>(data: T) : Resource<T>(data, null)
class Error<T>(message: String) : Resource<T>(null, message)
}
```
</div>
<br>
<div name="util-toast">
> <samp> util toast </samp>
```kotlin
fun android.content.Context.toast(message: CharSequence) =
android.widget.Toast.makeText(this, message, android.widget.Toast.$LENGTH$).show()
```
</div>
<br>
### 📌 Gradle dependency
<br>
<div name="coil-depen">
> <samp> coil depen </samp>
```kotlin
// Coil Image Loading Library
implementation "io.coil-kt:coil:1.2.1"
```
</div>
<br>
<div name="coroutines-depen">
> <samp> coroutines depen </samp>
```kotlin
// Coroutines Dependency
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3"
```
</div>
<br>
<div name="data-binding">
> <samp> data binding </samp>
```kotlin
apply plugin: 'kotlin-kapt'
buildFeatures {
dataBinding true
}
```
</div>
<br>
<div name="datastore-depen">
> <samp> datastore depen </samp>
```kotlin
// Data store
// Typed DataStore (Typed API surface, such as Proto)
implementation "androidx.datastore:datastore:1.0.0-beta01"
// Preferences DataStore (SharedPreferences like APIs)
implementation "androidx.datastore:datastore-preferences:1.0.0-beta01"
```
</div>
<br>
<div name="easy-permission-depen">
> <samp> easy permission depen </samp>
```kotlin
// Easy permission library
implementation 'com.vmadalin:easypermissions-ktx:1.0.0'
```
</div>
<br>
<div name="glide-depen">
> <samp> glide depen </samp>
```kotlin
// Glide Image Loading Library
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
```
</div>
<br>
<div name="hilt-classpath">
> <samp> hilt classpath </samp>
```kotlin
classpath "com.google.dagger:hilt-android-gradle-plugin:2.35"
```
</div>
<br>
<div name="hilt depen">
> <samp> hilt depen </samp>
```kotlin
// Hilt Dependency Injection
implementation "com.google.dagger:hilt-android:2.35"
kapt "com.google.dagger:hilt-compiler:2.35"
```
</div>
<br>
<div name="hilt-plugin">
> <samp> hilt plugin </samp>
```kotlin
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
```
</div>
<br>
<div name="lifecycle-depen">
> <samp> lifecycle depen </samp>
```kotlin
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
// Lifecycles only (without ViewModel or LiveData)
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
// Saved state module for ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1"
// Annotation processor
kapt "androidx.lifecycle:lifecycle-compiler:2.3.1"
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation "androidx.lifecycle:lifecycle-common-java8:2.3.1"
```
</div>
<br>
<div name="navigation-depen">
> <samp> navigation depen </samp>
```kotlin
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
```
</div>
<br>
<div name="paging-depen">
> <samp> paging depen </samp>
```kotlin
// Paging 3
implementation "androidx.paging:paging-runtime-ktx:3.0.0"
```
</div>
<br>
<div name="retrofit-depen">
> <samp> retrofit depen </samp>
```kotlin
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.5.0"
```
</div>
<br>
<div name="room-depen">
> <samp> room depen </samp>
```kotlin
// Room
// kapt plugin: cut it and paste in plugins
id 'kotlin-kapt'
implementation "androidx.room:room-runtime:2.3.0"
// To use Kotlin annotation processing tool (kapt)
kapt "androidx.room:room-compiler:2.3.0"
// optional - Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:2.3.0"
```
</div>
<br>
<div name="safeargs-classpath">
> <samp> safeargs classpath </samp>
```kotlin
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
```
</div>
<br>
<div name="safeargs-plugin">
> <samp> safeargs plugin </samp>
```kotlin
id 'androidx.navigation.safeargs.kotlin'
```
</div>
<br>
<div name="view-and-data-binding">
> <samp> view and data binding </samp>
```kotlin
buildFeatures {
viewBinding true
dataBinding true
}
id 'kotlin-kapt'
```
</div>
<br>
<div name="view-binding">
> <samp> view binding </samp>
```kotlin
buildFeatures {
viewBinding true
}
```
</div>
<br>
## How to create your own live templates? 💡