Skip to content

Instantly share code, notes, and snippets.

View sudansh's full-sized avatar
🎯
Focusing

Sudhanshu Singh sudansh

🎯
Focusing
View GitHub Profile
@sudansh
sudansh / sha256.txt
Last active February 1, 2022 12:05
SSL Pinning
Get the SHA256 pin to be used in okhttp
https://www.ssllabs.com/ssltest/analyze.html
Sha256 from PEM file
openssl x509 -in cert.pem -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
abstract class PaginationScrollListener : RecyclerView.OnScrollListener {
private val mLayoutManager: RecyclerView.LayoutManager
private val startingPageIndex = 0
private var visibleThreshold = 5
private var currentPage = 0
@sudansh
sudansh / collapsible.md
Last active September 26, 2019 15:55
CollapsibleToolbar

Collapse doesn't work when marginBottom is used in layout with appbar_scrolling_view_behavior. Instead use paddingBottom

@sudansh
sudansh / Ripple
Last active April 5, 2020 10:24
TextView
Ripple:
use `android:background="?attr/selectableItemBackground"`
the difference is that selectableItemBackground will keep the ripple within it's view size(width/height). selectableItemBackgroundBorderless will expand it's ripple over other views (like the official calculator app ripple)
@sudansh
sudansh / Nav Controller Queries
Last active February 26, 2019 15:24
Nav Controller Queries
1. //automatically handles back button
toolbar.setupWithNavController(navController)
2. //to make root fragment (or make back button gone in a particular fragment).
//This removes the back button and also disabled toolbar back button navigation (keyboard back button works)
private val rootIds = setOf(R.id.fragment1, R.id.fragment2....)
private val appBarConfiguration by lazy {AppBarConfiguration(rootIds)}
toolbar.setupWithNavController(navController,appBarConfiguration)
3. //for back button to work along with (2).
@sudansh
sudansh / view.xml
Created January 28, 2019 13:16
Wrap RecyclerView height inside another view
<RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
 android:layout_width="match_parent"
 android:layout_height="wrap_content" />
</RelativeLayout>