Skip to content

Instantly share code, notes, and snippets.

View mkrupal09's full-sized avatar
🎯
Focusing

Krupal mkrupal09

🎯
Focusing
View GitHub Profile
@mkrupal09
mkrupal09 / gist:9db9aa38b25fe2ff4be65c7e5fcf26b4
Created May 24, 2018 11:27
Download File using retrofit
private void downloadFile(String downloadPath) {
RetrofitUtils.getWebServices().downloadFile(downloadPath)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map(new Function<ResponseBody, File>() {
@Override
public File apply(ResponseBody responseBody) {
File file = new File("");
writeResponseBodyToDisk(responseBody,file );
return file;
@mkrupal09
mkrupal09 / BaseRecyclerViewAdapter.java
Created January 8, 2018 13:27
BaseRecyclerView adapter including databinding
public abstract class BaseRecyclerViewAdapter<T extends BaseRecyclerViewAdapter.BaseHolder, X>
extends RecyclerView.Adapter<T> {
private RecyclerViewListener recyclerViewListener;
private List<X> data;
public BaseRecyclerViewAdapter(List<X> data) {
this.data = data;
}
public class RoundedButton extends android.support.v7.widget.AppCompatTextView {
public RoundedButton(Context context) {
super(context);
init(null);
}
public RoundedButton(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
@mkrupal09
mkrupal09 / RxAsyncTask.java
Last active January 8, 2018 13:12
Rxjava as Async task
public abstract class RxAsyncTask<T> implements LifecycleObserver {
private Disposable disposable;
private Lifecycle lifecycleOwner;
private Lifecycle.State event = Lifecycle.State.DESTROYED;
public abstract Observable<T> doInBackGround();
public void onPreExecute() {
}