Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
WFH

Prashant Wosti prashantwosti

🏠
WFH
View GitHub Profile
View BaseRepository.kt
open class BaseRepository{
suspend fun <T : Any> safeApiCall(call: suspend () -> Response<T>, errorMessage: String): T? {
val result : Result<T> = safeApiResult(call,errorMessage)
var data : T? = null
when(result) {
is Result.Success ->
data = result.data
@NickHolcombe
NickHolcombe / ListAdapterWithHeader.kt
Last active Jan 29, 2021
Example of a RecyclerView Adapter based on ListAdapter with a header
View ListAdapterWithHeader.kt
package example
import android.support.v7.recyclerview.extensions.AsyncDifferConfig
import android.support.v7.recyclerview.extensions.AsyncListDiffer
import android.support.v7.util.DiffUtil
import android.support.v7.util.ListUpdateCallback
import android.support.v7.widget.RecyclerView
/**
* {@link RecyclerView.Adapter RecyclerView.Adapter} base class based on
@oakkub
oakkub / DialogExtensions.kt
Last active Sep 25, 2020
Kotlin extension functions for creating AlertDialog in a DSL way
View DialogExtensions.kt
import android.annotation.SuppressLint
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.support.annotation.StringRes
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.TextView
@Pulimet
Pulimet / AdbCommands
Last active Feb 25, 2021
Adb useful commands list
View AdbCommands
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@alapshin
alapshin / ProxyBottomSheetBehavior.java
Created Mar 18, 2017
BottomSheetBehavior with support for multiple callbacks
View ProxyBottomSheetBehavior.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.util.AttributeSet;
import android.view.View;
import java.util.ArrayList;
/**
* Wrapper around {@link BottomSheetBehavior} with support for multiple callbacks.
View MainActivity.java
/*
* Copyright 2017 Google Inc.
*
* 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
View Effective_Engineer.md

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@pcqpcq
pcqpcq / shadow.xml
Created Aug 23, 2016 — forked from lecho/shadow.xml
Android shadow drawable xml.
View shadow.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
@li2
li2 / CenteredImageSpan.java
Last active Mar 20, 2018
使 ImageSpan 和 text 居中对齐 & 高度一致。ImageSpan 有一个构造器接收 drawable,所以可以根据 TextView 高度,设置 drawable.setBounds(0, 0, height, height),因此 CenteredImageSpan 也就没必要了。 #tags: android-view
View CenteredImageSpan.java
// From http://stackoverflow.com/questions/25628258/align-text-around-imagespan-center-vertical
public class CenteredImageSpan extends ImageSpan {
// Extra variables used to redefine the Font Metrics when an ImageSpan is added
private int initialDescent = 0;
private int extraSpace = 0;
public CenteredImageSpan(final Drawable drawable) {
this(drawable, entry, DynamicDrawableSpan.ALIGN_BOTTOM);
@ckurtm
ckurtm / TintActivity.java
Created Oct 29, 2015
Dynamically change color of a drawable using TintDrawables
View TintActivity.java
package com.peirra.tint;
import android.graphics.Color;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import java.util.Random;