Skip to content

Instantly share code, notes, and snippets.

View swapnildroid's full-sized avatar
🎯
Focusing

Swapnil Khare swapnildroid

🎯
Focusing
  • Bengaluru, India
  • 08:02 (UTC +05:30)
View GitHub Profile
@sirdarthvader
sirdarthvader / total_amount_calculator.js
Last active June 6, 2023 19:36
A minimal script to check overall spend till date on Zomato and Swiggy
/**
The below snippets will help you find total money spent on Zomato and Swiggy so far by any individual.
For Zomato:
Step 1: Go to Zomato.com,
Step 2: Go to "Profiles", click on "Order History"
Step 3: Scroll to the very bottom and click on "Load More", until the option disappears.
Step 4: Do a right click anywhere on the screen and click on "Inspect", in the inspector,
go to console copy and paste the below snippet and press enter.
*****IMPORTANT****
Make sure all the steps till step 3 is followed before doing the step 4.
@sebaslogen
sebaslogen / MyCustomView.kt
Created March 3, 2018 10:34
Kotlin Android CustomView without default parameters
class MyCustomView : View {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, attributeSetId: Int) : super(context, attrs, attributeSetId)
}
@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active July 8, 2024 12:48
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@maxost
maxost / SmsReceiver.kt
Created September 5, 2017 02:40
Kotlin: sms receiver and rx bus in Android
data class Sms(val phone: String, val text: String)
object SmsBus {
private val bus by lazy { PublishSubject.create<Sms>() }
fun incomingSms(): Observable<Sms> = bus
fun postSms(sms: Sms) = bus.onNext(sms)
}
@wszdwp
wszdwp / hideSoftKeyBoard.java
Created July 3, 2017 15:16
Hide soft keyboard in android
private void hideSoftKeyBoard() {
final View myCurrentFocusView = getCurrentFocus();
myCurrentFocusView.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myCurrentFocusView.getWindowToken(), 0);
}
},100);
@nikhiljha
nikhiljha / AddCookiesInterceptor.java
Created July 29, 2016 04:35
Retrofit2/OkHttp3 Cookies (Drag and Drop, One Size Fits 99%)
// Original written by tsuharesu
// Adapted to create a "drop it in and watch it work" approach by Nikhil Jha.
// Just add your package statement and drop it in the folder with all your other classes.
import android.content.Context;
import android.preference.PreferenceManager;
import android.util.Log;
import java.io.IOException;
import java.util.HashSet;
@lynas
lynas / ankoFragment.java
Last active February 18, 2019 15:38
android fragment using anko
class MyFragment: Fragment(){
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return UI {
linearLayout{
editText()
button("OK")
}
}.view
}
}
@marcusmotill
marcusmotill / BitmapUtils.kt
Created March 12, 2016 18:36
Image compression for Android in Kotlin
class BitmapUtils {
companion object
}
fun BitmapUtils.Companion.getCompressedImage(pathName: String, scalingLogic: ImageView.ScaleType): String {
val options = BitmapFactory.Options()
options.inJustDecodeBounds = true
BitmapFactory.decodeFile(pathName, options)
options.inJustDecodeBounds = false
val dstWidth: Double = ((options.outWidth.toDouble() / (options.outWidth.toDouble() * options.outHeight.toDouble())) * 1000) * options.outWidth.toDouble()
@lopspower
lopspower / KeyboardUtils.java
Last active July 6, 2023 13:35
Force Hide Keyboard Android
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class KeyboardUtils {
public static void hideKeyboard(Activity activity) {
View view = activity.findViewById(android.R.id.content);
@williamwebb
williamwebb / BindingRecyclerView.java
Last active January 20, 2023 13:05
RecyclerView & Adapter init in XML
We couldn’t find that file to show.