Skip to content

Instantly share code, notes, and snippets.

View iamnaran's full-sized avatar
🐧
git gitlich

Narayan Panthi iamnaran

🐧
git gitlich
View GitHub Profile
@iamnaran
iamnaran / AuthNavGraph.kt
Last active March 17, 2024 09:18
Nested Navigation with Multiple Back Stack Android Jetpack Compose
fun NavGraphBuilder.authNavGraph(navController: NavHostController) {
navigation(
startDestination = AppScreen.Auth.Login.route,
route = AppScreen.Auth.route
) {
composable(route = AppScreen.Auth.Login.route) {
LoginScreen(
navigateToHome = {
navController.navigate(AppScreen.Main.route) {
@iamnaran
iamnaran / CurrencyOffsetMapping.kt
Created January 27, 2024 08:51 — forked from damianpetla/CurrencyOffsetMapping.kt
Transforming EditText value into currency
import androidx.compose.ui.text.input.OffsetMapping
class CurrencyOffsetMapping(originalText: String, formattedText: String) : OffsetMapping {
private val originalLength: Int = originalText.length
private val indexes = findDigitIndexes(originalText, formattedText)
private fun findDigitIndexes(firstString: String, secondString: String): List<Int> {
val digitIndexes = mutableListOf<Int>()
var currentIndex = 0
for (digit in firstString) {
@iamnaran
iamnaran / activity_layout.xml
Last active September 20, 2023 17:21
Layout And RecyclerView Animation Android (Made Simple with XML only)
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/layout_animation"
android:orientation="vertical">
</ScrollView>
@iamnaran
iamnaran / nepal_address_provinces_list.json
Created April 19, 2023 16:05
Nepal Address - Province with its District & Municipalities
[
{
"allDistrictList": [
{
"area_sq_km": "1507",
"headquarter": "Bhojpur",
"id": 1,
"municipalityList": [
{
"area_sq_km": "241.15",
@iamnaran
iamnaran / HostSelectionInterceptor.java
Last active February 12, 2023 07:13
Host Selection Interceptor Retrofit Android
/*
* Created by NaRan on 9/2/21, 3:44 PM
* Last modified 9/2/21, 3:44 PM
* Copyright (c) 2021 .
* All rights reserved.
*
*/
import org.jetbrains.annotations.NotNull;
@iamnaran
iamnaran / layout.xml
Created October 26, 2022 15:53
Layout of Upload Documents
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
@iamnaran
iamnaran / MediaPreviewModel.java
Created October 26, 2022 15:47
MediaPreviewModel
public class MediaPreviewModel implements Serializable {
public enum MediaPickedType {
TYPE_CAMERA,
TYPE_PHOTOS,
}
private String mediaId;
//file uri
@iamnaran
iamnaran / ParentHouseAdapter.kt
Created May 21, 2021 06:14
Nested Recycler View Adapter Parent
package com.template.androidtemplate.ui.home.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.template.androidtemplate.R
import com.template.androidtemplate.data.model.GameOfThrones
import kotlinx.android.synthetic.main.item_row_parent.view.*
@iamnaran
iamnaran / NetModule.java
Last active September 4, 2021 08:54
NetModule injected at SingletonComponent - Hilt Retrofit
/*
* Created by NaRan on 8/18/21, 2:39 PM
* Last modified 8/18/21, 2:39 PM
* Copyright (c) 2021 .
* All rights reserved.
*
*/
import android.content.Context;
import com.google.gson.Gson;
@iamnaran
iamnaran / With Png
Last active July 7, 2021 13:51
Splash Drawable Background Android with SVG and PNG
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/white" />
</shape>
</item>
<item>
<bitmap
android:gravity="center"