Skip to content

Instantly share code, notes, and snippets.

View SteveKamau72's full-sized avatar

Steve Kamau SteveKamau72

View GitHub Profile
@SteveKamau72
SteveKamau72 / ImageDownloadManager.java
Created October 6, 2020 13:54 — forked from bpr10/ImageDownloadManager.java
This is a simple ImageDownloader which uses Picasso do download images and write them to a folder.
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.squareup.picasso.MemoryPolicy;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.RequestCreator;
@SteveKamau72
SteveKamau72 / RxBroadcastReceiver.java
Created January 14, 2020 12:28 — forked from magillus/RxBroadcastReceiver.java
RxJava2.0 Broadcast Receiver for getting intent broadcasts as Observable<Intent>
/**
* RxJava based broadcast reciever that registers its local BroadcastReceiver until end of subscription.
* Listens for update and passes Intent to the Stream (Subscriber).
*
* Copyright 2016 Mateusz Perlak - http://www.apache.org/licenses/LICENSE-2.0
* Created on 11/18/16.
*/
public class RxBroadcastReceiver implements ObservableOnSubscribe<Intent> {
protected final WeakReference<Context> contextWeakReference;
@SteveKamau72
SteveKamau72 / CustomSetter.java
Created October 25, 2019 19:32 — forked from elvismetaphor/CustomSetter.java
Show how to implement MVVM with Data Binding while using Glide
package edu.self.binding;
import android.databinding.BindingAdapter;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
public class CustomSetter {
@SteveKamau72
SteveKamau72 / checkGooglePlayServicesAvailable.java
Created August 15, 2018 06:40
Android: Check whether Google Play Services are installed and current
/**
* Check whether Google Play Services are available.
*
* If not, then display dialog allowing user to update Google Play Services
*
* @return true if available, or false if not
*/
private boolean checkGooglePlayServicesAvailable()
{
final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
@SteveKamau72
SteveKamau72 / GridSpacingItemDecoration.md
Created June 23, 2017 06:40 — forked from cxyxlxdm/GridSpacingItemDecoration.md
Add column spacing in RecyclerView with GridLayoutManager

Android Recyclerview GridLayoutManager column spacing Here is the question, the first answer does not work well in my project,and it makes the spacing bigger between item and item. the second answer is quite perfect.But if RecyclerView has headers,it does not work well. Then I fixed it.

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
@SteveKamau72
SteveKamau72 / MainActivity.java
Created January 4, 2017 18:15 — forked from rajiv-singaseni/MainActivity.java
An android activity which demonstrates picking a photo from gallery and uploading it to a remote server.
package com.webile.upload;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.util.Date;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
@SteveKamau72
SteveKamau72 / MyRecyclerViewAdapter.java
Created December 18, 2016 13:44 — forked from faruktoptas/MyRecyclerViewAdapter.kt
Simple RecyclerView Adapter
public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewAdapter.ViewHolder> {
private final List<MyModel> mMyModelList;
public MyRecyclerViewAdapter(List<MyModel> myModelList) {
mMyModelList = myModelList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
@SteveKamau72
SteveKamau72 / AndroidManifest.xml
Created July 25, 2016 22:43 — forked from vikrum/AndroidManifest.xml
Firebase+Android sample app with background Service + local notifications.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bgfirebaseapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="17" />