Skip to content

Instantly share code, notes, and snippets.

@DipaliShah
DipaliShah / CustomDateAdapter.kt
Created November 14, 2019 06:08
A custom Date formatter to format dates coming from Server in Moshi Way. An alternative to GSON builder .setDateFormat method as there is no resembling method in Moshi we need to create Adapter for this.
// Custom Type Adapters for Moshi
val userMoshi = Moshi.Builder().add(CustomDateAdapter()).add(T).build()
//add Moshi builder in Converter Facrory
val retrofit = Retrofit.Builder()
.baseUrl("https://dl.dropboxusercontent.com/")
.addConverterFactory(MoshiConverterFactory.create(userMoshi))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
@DipaliShah
DipaliShah / ParallaxScrollView.kt
Created November 13, 2019 09:26
Add ParallaxVertical Imageview inside in Simple ScrollView
1. A Custom ScrollView Class to listen to scroll changes
class ParallaxScrollView : ScrollView {
private var scrollViewListener: ScrollViewListener? = null
interface ScrollViewListener {
fun onScrollChanged(scrollView: TestScrollView, x: Int, y: Int, oldx: Int, oldy: Int)
}
@DipaliShah
DipaliShah / RoundedImageView
Created August 19, 2019 05:08
Rounded Corner ImageView - using Android Clipping, written in kotlin
class RoundedImageView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AppCompatImageView(
context, attrs, defStyleAttr
) {
private var rectF: RectF? = null
private val path = Path()
@DipaliShah
DipaliShah / RoundedRelativeLayout
Created August 14, 2019 06:15
Android Clipping to round corners of ViewGroup :- Rounded Corner Layout
public class RoundedRelativeLayout extends RelativeLayout {
private RectF rectF;
private Path path = new Path();
private float cornerRadius = 20;
public RoundedRelativeLayout(Context context) {
super(context);
}