Skip to content

Instantly share code, notes, and snippets.

View happysingh23828's full-sized avatar
🎯
Focusing

Happy Singh happysingh23828

🎯
Focusing
View GitHub Profile
/**
Usage for extensions.
Initialize Moshi in your Converter class
*/
private val moshi: Moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
/**
* [Moshi] extension to transform a [List] to Json
class CurlInterceptor extends Interceptor {
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
try {
final qp = options.queryParameters;
final h = options.headers;
final d = options.data;
final curl =
'curl -X ${options.method} \'${options.baseUrl}${options.path}' +
(qp.length != 0 ? qp.keys.fold('', (value, key) => '$value${value.length == 0 ? '?' : '&'}$key=${qp[key]}\'') : '\'') +
@happysingh23828
happysingh23828 / install
Created January 4, 2021 07:09
Install Android bundle on connected device using bundletool.jar
// generate app-release.apks
java -jar bundletool-all-1.4.0.jar build-apks --local-testing --bundle=app-release.aab --output=app-release.apks --connected-device
// Install apk from genrated app-release apks
java -jar bundletool-all-1.4.0.jar install-apks --apks app-release.apks
@happysingh23828
happysingh23828 / Extensions.kt
Last active January 24, 2023 07:46
Kotlin extension for applying Spannable text on any textview and getting callback for onclick.
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.view.View
import androidx.appcompat.widget.AppCompatTextView
fun AppCompatTextView.highLightWord(word: String, onClick: () -> Unit) {
val ssBuilder = SpannableStringBuilder(this.text)
@happysingh23828
happysingh23828 / BaseSectionFragment.kt
Last active September 4, 2020 06:39
set view height when show soft keyboard is open
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater.inflate(R.layout.fragment_base_section, container, false)
KeyboardUtil(requireActivity(), mView.coordinatorLayout)
return mView
}
public class MySwipeToRefresh extends SwipeRefreshLayout {
private int mTouchSlop;
private float mPrevX;
public MySwipeToRefresh (Context context, AttributeSet attrs) {
super(context, attrs);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
@kaeawc
kaeawc / codecov.yml
Last active December 20, 2021 13:15
Jacoco settings for multi module multi flavor Kotlin Android app
codecov:
branch: master
bot: null
coverage:
precision: 2
round: down
range: "70...100"
status:
@umayr
umayr / recover-deleted-branch.sh
Created April 1, 2016 11:41
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
@lopspower
lopspower / README.md
Last active July 31, 2024 22:25
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@vasanthk
vasanthk / System Design.md
Last active July 30, 2024 00:17
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?