Skip to content

Instantly share code, notes, and snippets.

View sudeshim3's full-sized avatar
👨‍💻
Talk is cheap, show me the code.

sudesh sudeshim3

👨‍💻
Talk is cheap, show me the code.
View GitHub Profile
class DeleteScreenConfirmationBottomSheet : BottomSheetDialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.BottomSheetDialog)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
<style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/CustomBottomSheetStyle</item>
</style>
<style name="CustomBottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@android:color/transparent</item>
</style>
//UI Unit conversion.
fun Context.pxToDp(dimension: Int) = dimension / this.resources.displayMetrics.density
fun Context.pxToSp(dimension: Int) = dimension / this.resources.displayMetrics.scaledDensity
fun Context.dpToPx(dimension: Int) = dimension * this.resources.displayMetrics.density
fun Context.spToPx(dimension: Int) = dimension * this.resources.displayMetrics.scaledDensity
@sudeshim3
sudeshim3 / hexcolor
Last active September 24, 2019 02:53
class HexColor extends Color {
static int _getColorFromHex(String hexColor) {
hexColor = hexColor.toUpperCase().replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF" + hexColor;
}
return int.parse(hexColor, radix: 16);
}
HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
@sudeshim3
sudeshim3 / appbuild
Last active September 22, 2019 19:06
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.google.android.material:material:1.1.0-alpha10"
implementation "io.reactivex.rxjava2:rxjava:2.2.9" //RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' //RxAndroid
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.0' //kotlin coroutines
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0' //retrofit
implementation "io.reactivex.rxjava2:rxjava:2.2.9" //RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' //RxAndroid
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.0' //kotlin coroutines
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0' //retrofit
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" //retrofit gson converter.
implementation 'com.google.code.gson:gson:2.8.5' //gson
implementation 'joda-time:joda-time:2.10.2' //joda-time
@sudeshim3
sudeshim3 / rxsample.kt
Last active June 30, 2019 17:56
RxJava
Observable.just(1,2,3).subscribe(Subscriber<Integer>() {
@Override
public void onCompleted() {
Log.d("","all done. oncompleted called");
}
@Override
public void onError(Throwable e) {
}
@sudeshim3
sudeshim3 / activity_main.xml
Last active March 3, 2019 15:31
Android and flutter list
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_users"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"/>
@sudeshim3
sudeshim3 / MainActivity.kt
Last active September 29, 2018 14:22
Pie chart with minimal input required to create a poc.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val values = ArrayList<PieEntry>()
var colorList = listOf(Color.RED, Color.GREEN, Color.YELLOW);
// 1. Create an array list of pie chart values.