{"id":20039982,"url":"https://github.com/tarikul711/android-studio-live-templates-file-templates-sample","last_synced_at":"2025-07-23T12:34:24.490Z","repository":{"id":107073281,"uuid":"298990772","full_name":"Tarikul711/android-studio-live-templates-file-templates-sample","owner":"Tarikul711","description":"Some example's about the android live template and file template. Using this template you can easily generate lots of boilerplate code that helps you to improve the coding ability.","archived":false,"fork":false,"pushed_at":"2021-05-29T07:11:02.000Z","size":38,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T05:12:35.108Z","etag":null,"topics":["android","android-application","android-development","android-studio","androidstudio","jetpack","jetpack-compose","livetemplate","recyclerview"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tarikul711.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-27T08:49:02.000Z","updated_at":"2024-01-10T00:35:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"63f83e9a-3c98-4a28-b8ab-2c964a903f06","html_url":"https://github.com/Tarikul711/android-studio-live-templates-file-templates-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Tarikul711/android-studio-live-templates-file-templates-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarikul711%2Fandroid-studio-live-templates-file-templates-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarikul711%2Fandroid-studio-live-templates-file-templates-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarikul711%2Fandroid-studio-live-templates-file-templates-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarikul711%2Fandroid-studio-live-templates-file-templates-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tarikul711","download_url":"https://codeload.github.com/Tarikul711/android-studio-live-templates-file-templates-sample/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tarikul711%2Fandroid-studio-live-templates-file-templates-sample/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266680275,"owners_count":23967791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-application","android-development","android-studio","androidstudio","jetpack","jetpack-compose","livetemplate","recyclerview"],"created_at":"2024-11-13T10:39:57.369Z","updated_at":"2025-07-23T12:34:24.471Z","avatar_url":"https://github.com/Tarikul711.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# android-file-template-live-template-sample\n\n## Android live templete for Intent\n\n```java\nfun get$PREFIX$Intent(context: Context, $PARAM1$: $DATATYPE1$, $PARAM2$: $DATATYPE2$): Intent {\n        Intent(context, $ACTIVITY$::class.java)\n        intent.`package` = context.packageName\n        intent.putExtra($NAME1$, $PARAM1$)\n        intent.putExtra($NAME2$, $PARAM2$)\n        return intent\n    }\n```\n\n## Jetpack all dependency file/live templete\n\n```java\n    implementation 'androidx.recyclerview:recyclerview:1.1.0'\n    implementation 'com.github.bumptech.glide:glide:4.11.0'\n    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'\n\n    // liveData-viewModel android jetpack\n    implementation 'androidx.lifecycle:lifecycle-common:2.2.0'\n    implementation 'androidx.lifecycle:lifecycle-runtime:2.2.0'\n    implementation 'android.arch.lifecycle:extensions:2.2.0'\n    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'\n    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'\n\n\n    //Retrofit\n    implementation 'com.squareup.retrofit2:retrofit:2.8.1'\n    implementation 'com.google.code.gson:gson:2.8.6'\n    implementation 'com.squareup.retrofit2:converter-gson:2.8.1'\n    implementation 'com.squareup.okhttp3:logging-interceptor:4.4.0'\n\n    // kotlin Coroutine\n    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'\n    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'\n    implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'\n\n    // room library\n    implementation \"androidx.room:room-runtime:2.2.5\"\n    kapt \"androidx.room:room-compiler:2.2.5\"\n    implementation \"androidx.room:room-ktx:2.2.5\"\n    androidTestImplementation \"androidx.room:room-testing:2.2.5\"\n```\n\n## Android RecyclerView Adapter live template / file template with dynamic data\n\n```java\n#if (${PACKAGE_NAME} \u0026\u0026 ${PACKAGE_NAME} != \"\")package ${PACKAGE_NAME};#end\n\nimport android.view.LayoutInflater\nimport android.view.View\nimport android.view.ViewGroup\n\n#parse(\"File Header.java\")\n\nclass ${NAME} (var items: MutableList\u003c${ITEM_CLASS}\u003e, val itemClick: (${ITEM_CLASS}) -\u003e Unit) : RecyclerView.Adapter\u003c${NAME}.${VIEWHOLDER_CLASS}\u003e() {\n\n    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ${VIEWHOLDER_CLASS} {\n        val view = LayoutInflater.from(parent.context).inflate(R.layout.${LAYOUT_RES_ID}, parent, false)\n        return ${VIEWHOLDER_CLASS}(view, itemClick)\n    }\n\n    override fun onBindViewHolder(holder: ${VIEWHOLDER_CLASS}, position: Int) {\n        holder.bindView(items[position])\n    }\n\n    override fun getItemCount(): Int = items.size\n\n    /*Private Methods - START*/\n    fun clear(){\n        this.items.clear()\n        notifyDataSetChanged()\n    }\n\n    fun replaceItems(items: MutableList\u003c${ITEM_CLASS}\u003e){\n        this.items.clear()\n        this.items = items\n        notifyDataSetChanged()\n    }\n\n    fun addItem(item: ${ITEM_CLASS}){\n        this.items.add(item)\n        notifyItemInserted(itemCount)\n    }\n\n    fun removeItem(item: ${ITEM_CLASS}) {\n        val position: Int? = this.items.indexOf(item)\n        position?.let { pos -\u003e\n            this.items.removeAt(pos)\n            notifyItemRemoved(pos)\n        } ?: run {\n            Log.e(\"${NAME}\", \"Item not found !\")\n        }\n    }\n    /*Private Methods - END*/\n\n    class ${VIEWHOLDER_CLASS}(val view: View, val itemClick: (${ITEM_CLASS}) -\u003e Unit) : RecyclerView.ViewHolder(view) {\n        // here comes all the views / variables from view.findViewById()\n        // Example: val textView = view.findViewById(R.id.textView1)\n        fun bindView(item: ${ITEM_CLASS}) {\n            with(item) {\n                // here you do all kind of assignments and logics..\n                // for Example: textView.text = item.name or just name\n                itemView.setOnClickListener { itemClick(this) }\n            }\n        }\n    }\n\n}\n```\n\n## Android RecyclerView Adapter live template / file template\n\n```java\n#if (${PACKAGE_NAME} \u0026\u0026 ${PACKAGE_NAME} != \"\")package ${PACKAGE_NAME}#end\n\nimport android.support.v7.widget.RecyclerView\nimport android.view.LayoutInflater\nimport android.view.View\nimport android.view.ViewGroup\nimport java.util.*\n\n#parse(\"File Header.java\")\nclass ${NAME} : RecyclerView.Adapter\u003c${ViewHolder_Class}\u003e() {\n\n    private var data: List\u003c${Model_Class}\u003e = ArrayList()\n\n    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ${ViewHolder_Class} {\n        return ${ViewHolder_Class}(\n            LayoutInflater.from(parent.context)\n                    .inflate(R.layout.${Item_Layout_ID}, parent, false)\n        )\n    }\n\n    override fun getItemCount() = data.size\n\n    override fun onBindViewHolder(holder: ${ViewHolder_Class}, position: Int) = holder.bind(data[position])\n\n    fun swapData(data: List\u003c${Model_Class}\u003e) {\n        this.data = data\n        notifyDataSetChanged()\n    }\n\n    class ${ViewHolder_Class}(itemView: View) : RecyclerView.ViewHolder(itemView) {\n        fun bind(item: ${Model_Class}) = with(itemView) {\n            // TODO: Bind the data with View\n            setOnClickListener {\n                // TODO: Handle on click\n            }\n        }\n    }\n}\n```\n\n## Android RecyclerView Adapter live template / file template with DiffUtil class\n\n```java\n#if (${PACKAGE_NAME} \u0026\u0026 ${PACKAGE_NAME} != \"\")package ${PACKAGE_NAME}#end\n\nimport androidx.recyclerview.widget.RecyclerView\nimport android.view.LayoutInflater\nimport android.view.View\nimport android.view.ViewGroup\nimport androidx.recyclerview.widget.DiffUtil\nimport java.util.*\n\n#parse(\"File Header.java\")\nclass ${NAME} : RecyclerView.Adapter\u003c${ViewHolder_Class}\u003e() {\n\n    private var data: List\u003c${Model_Class}\u003e = ArrayList()\n\n    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ${ViewHolder_Class} {\n        return ${ViewHolder_Class}(\n            LayoutInflater.from(parent.context)\n                    .inflate(R.layout.${Item_Layout_ID}, parent, false)\n        )\n    }\n\n    override fun getItemCount() = data.size\n\n    override fun onBindViewHolder(holder: ${ViewHolder_Class}, position: Int) = holder.bind(data[position])\n\n    fun swapData(data: List\u003c${Model_Class}\u003e) {\n    val diffUtil =\n                RecyclerDiffUtil(this.data, data)\n        val diffUtilResult = DiffUtil.calculateDiff(diffUtil)\n        this.data = data\n        diffUtilResult.dispatchUpdatesTo(this)\n    }\n\n\n    class ${ViewHolder_Class}(itemView: View) : RecyclerView.ViewHolder(itemView) {\n        fun bind(item: ${Model_Class}) = with(itemView) {\n            // TODO: Bind the data with View\n            setOnClickListener {\n                // TODO: Handle on click\n            }\n        }\n    }\n}\n```\n\n## Android Run Time Permission live template / file template\n\n```java\nif (ContextCompat.checkSelfPermission(this, $PERMISSION$)\n        != PackageManager.PERMISSION_GRANTED) {\n    // Permission is not granted\n    // Should we show an explanation?\n    if (ActivityCompat.shouldShowRequestPermissionRationale(this,\n            $PERMISSION$)) {\n        TODO(\"Show Explainantion if needed\")\n    } else {\n        // No explanation needed, we can request the permission.\n        ActivityCompat.requestPermissions(this,\n                arrayOf($PERMISSION$),\n                $REQUESTCODE$)\n    }\n} else {\n    // Permission has already been granted\n}\n```\n\n## Android Retrofit builder live template / file template\n\n```java\n#if (${PACKAGE_NAME} \u0026\u0026 ${PACKAGE_NAME} != \"\")package ${PACKAGE_NAME}#end\n\nimport okhttp3.*\nimport okhttp3.logging.HttpLoggingInterceptor\nimport retrofit2.Retrofit\nimport retrofit2.converter.gson.GsonConverterFactory\nimport java.util.concurrent.TimeUnit\n\n\n#parse(\"File Header.java\")\n\nobject RetrofitBuilder {\n    private const val BASE_URL = \"${api_base_url}\"\n\n    // Caching data from online\n    var cacheSize: Long = 5 * 1024 * 1024;\n    var HEADER_CACHE_CONTROL: String = \"Cache-Control\"\n    var HEADER_PRAGMA: String = \"Pragma\"\n\n\n    var httpClient =\n        OkHttpClient.Builder()\n            .cache(cache())\n            .addInterceptor(httpLoggingInterceptor())\n            .addNetworkInterceptor(NetworkInterceptor())\n            .addInterceptor(OfflineInterceptor())\n\n\n    private fun getRetrofit(): Retrofit {\n        return Retrofit.Builder()\n            .baseUrl(BASE_URL)\n           .client(httpClient.build())\n            .addConverterFactory(GsonConverterFactory.create())\n            .build()\n    }\n\n    val apiService: ${ApiService} = getRetrofit().create( ${ApiService}::class.java)\n\n    private fun cache(): Cache {\n        return Cache(MyApplication.instance.cacheDir, cacheSize)\n    }\n\n\n    private fun httpLoggingInterceptor(): HttpLoggingInterceptor { // will call in the offline mode\n        val httpLoggingInterceptor = HttpLoggingInterceptor()\n        httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.BODY\n        return httpLoggingInterceptor\n    }\n\n\n    class NetworkInterceptor : Interceptor {\n        override fun intercept(chain: Interceptor.Chain): Response {\n            val response = chain.proceed(chain.request())\n            val cacheControl = CacheControl.Builder()\n                .maxAge(5, TimeUnit.SECONDS)\n                .build()\n            return response.newBuilder()\n                .removeHeader(HEADER_PRAGMA)\n                .removeHeader(HEADER_CACHE_CONTROL)\n                .header(HEADER_CACHE_CONTROL, cacheControl.toString())\n                .build();\n        }\n    }\n\n    class OfflineInterceptor : Interceptor {\n        override fun intercept(chain: Interceptor.Chain): Response {\n            val request = chain.request()\n\n            if (!NetworkUtils.hasNetwork(MyApplication.instance.applicationContext)!!) {\n                val cacheControl: CacheControl = CacheControl.Builder()\n                    .maxStale(7, TimeUnit.DAYS).build()\n                request.newBuilder()\n                    .removeHeader(HEADER_PRAGMA)\n                    .removeHeader(HEADER_CACHE_CONTROL)\n                    .cacheControl(cacheControl)\n                    .build();\n            }\n\n            return chain.proceed(request)\n        }\n    }\n\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarikul711%2Fandroid-studio-live-templates-file-templates-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarikul711%2Fandroid-studio-live-templates-file-templates-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarikul711%2Fandroid-studio-live-templates-file-templates-sample/lists"}