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 / ViewPagerAdapter.kt
Created July 6, 2021 11:08
ViewPager2 FragmentState Adapter
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
class ViewPagerAdapter(fa: FragmentActivity, private val listOfTitle: List<String>) :
FragmentStateAdapter(fa) {
@iamnaran
iamnaran / activity_main.xml
Created May 23, 2021 14:12
Bottom Sheet Above Bottom Navigation
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.MainActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
@iamnaran
iamnaran / item_bottom_sheet_container.xml
Last active May 23, 2021 14:04
Bottom Sheet Dialog Above Bottom Navigation UI
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@color/colorContainerBackground">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
@iamnaran
iamnaran / HomeActivity.kt
Created May 21, 2021 06:26
Nested RecyclerView Activity
package com.template.androidtemplate.ui.home.view
import android.os.Bundle
import android.util.Log
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.gson.Gson
import com.template.androidtemplate.R
@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 / ChildMembersAdapter.kt
Created May 21, 2021 06:06
Nested Recycler View Child Adapter
package com.template.androidtemplate.ui.home.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.template.androidtemplate.R
import com.template.androidtemplate.data.model.GameOfThrones
import kotlinx.android.synthetic.main.item_row_child.view.*
package com.template.androidtemplate.ui.home.viewmodel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.template.androidtemplate.data.helper.PreferencesHelper
import com.template.androidtemplate.data.model.GameOfThrones
import com.template.androidtemplate.data.model.Photos
import com.template.androidtemplate.data.repository.HomeRepository
@iamnaran
iamnaran / GameOfThrones.kt
Created May 20, 2021 17:03
GamesOfThrone Model
data class GameOfThrones(
@SerializedName("members")
var members: List<Member>,
@SerializedName("name")
var name: String,
@SerializedName("slug")
var slug: String
) {
data class Member(
@SerializedName("name")
@iamnaran
iamnaran / GameOfThrone.json
Created May 20, 2021 17:02
Game Of Thrones JSON
[
{
"slug":"stark",
"name":"House Stark of Winterfell",
"members":[
{
"name":"Jon Snow",
"slug":"jon"
},
{
@iamnaran
iamnaran / LocationPickerDialog.java
Last active May 15, 2021 14:22
Google Maps In Dialog Android. Display Maps In Android & Get Lat Lng
package com.template.bloomweather.ui.custom;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;