Skip to content

Instantly share code, notes, and snippets.

View LavishSwarnkar's full-sized avatar
💭
Living my life...

Lavish Swarnkar LavishSwarnkar

💭
Living my life...
View GitHub Profile
@LavishSwarnkar
LavishSwarnkar / Android-InAppUpdateHelper-v2.md
Last active October 11, 2025 07:35
Android InAppUpdateHelper v2

Android InAppUpdateHelper v2 (Direct)

Features

  • Uses GooglePlay API to declare an update as immediate / flexible
  • No need of 3rd party store like Firebase Remote Config
  • Shows a Floating Bubble for Flexible updates
  • Closes app if Immediate update is ignored
  • "Don't show again" for Flexible update
  • Simple Plug-n-play
@LavishSwarnkar
LavishSwarnkar / Android-CustomNavArg.md
Created November 3, 2024 05:15
This guide helps in passing custom nav args i.e. any class's object as argument to another class using Gson & Base64 encoding.

Step 1

Add necessary files

Copy the files NavArgsEncoding.kt and Base64Ext.kt to your project


Step 2

Define route in Screen class

@LavishSwarnkar
LavishSwarnkar / pet.json
Created September 3, 2024 04:56
JSON Test
{
"pet": {
"name": "Bella",
"breed": "German Shepherd",
"bcs": 5,
"gender": "Female",
"weight": 15.0,
"neuterStatus": "Neutered",
"activityLevel": "Active",
"dietPreference": "Mixed",

This Gist guides you to implement In-App Updates from the Play Store in your Android app.

  • RemoteConfig is used to fetch the minRequiredVersionCode (Int), shutdown (Boolean), shutdownMessage (String)
  • Latest version available on Play Store is fetched using Google Play App Update library
  • Based on the above two inputs, update (if available) type is decided i.e. Immediate or Flexible
  • In case of Immediate Update, Full Screen Update UI from Google Play App Update library is launched
  • In case of Flexible Update, a simple dialog with choice (whether to update) is displayed.
    • If agreed, Play Store page will be opened. (In app download progress is not shown)
    • User can also ignore the update to avoid seeing it again and again.
@LavishSwarnkar
LavishSwarnkar / ObjectClone.java
Created March 19, 2024 10:30
ObjectClone in Java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ObjectClone {
static class A {
ArrayList<String> list;
public A(ArrayList<String> list) {
package com.streamliners.myecom;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.streamliners.myecom.databinding.ListItemBinding;
N = int(input())
A = []
occ = {}
no_of_distinct = 0
for i in range(0, N):
A.append(int(input()))
if not A[i] in occ:
occ[A[i]] = 1
no_of_distinct += 1