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;
{
"data": [{
"view_type": "viewpager",
"section_title": "New items",
"section_data": [{
"image": "https://dummyimage.com/600x400/000/fff"
}, {
"image": "https://dummyimage.com/600x400/000/fff"
}, {
"image": "https://dummyimage.com/600x400/000/fff"
@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 / androidx-artifact-mapping.csv
Created May 15, 2019 07:18
Migrate Android Support libraries to AndroidX. You will need the csv file androidx-artifact-mapping.csv and run python3 migrateAndroidX.py
Old build artifact AndroidX build artifact
android.arch.core:common androidx.arch.core:core-common:2.0.0-rc01
android.arch.core:core androidx.arch.core:core:2.0.0-rc01
android.arch.core:core-testing androidx.arch.core:core-testing:2.0.0-rc01
android.arch.core:runtime androidx.arch.core:core-runtime:2.0.0-rc01
android.arch.lifecycle:common androidx.lifecycle:lifecycle-common:2.0.0-rc01
android.arch.lifecycle:common-java8 androidx.lifecycle:lifecycle-common-java8:2.0.0-rc01
android.arch.lifecycle:compiler androidx.lifecycle:lifecycle-compiler:2.0.0-rc01
android.arch.lifecycle:extensions androidx.lifecycle:lifecycle-extensions:2.0.0-rc01
android.arch.lifecycle:livedata androidx.lifecycle:lifecycle-livedata:2.0.0-rc01
@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 / TimeTask.java
Created July 11, 2017 07:16
Get time differences between current time and future a date.
package com.girlathome.utilities;
import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/**
//Here is a better and less tightly coupled way to implement an OnClickListener for a RecyclerView.
//Snippet of usage:
RecyclerView recyclerView = findViewById(R.id.recycler);
recyclerView.addOnItemTouchListener(
new RecyclerItemClickListener(context, recyclerView ,new RecyclerItemClickListener.OnItemClickListener() {
@Override public void onItemClick(View view, int position) {
// do whatever
}
@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 / Problem.js
Created June 19, 2017 08:49
Navigation using react-native
/** index.android.js**/
//This code includes the stack navigation to different screens
import React, { Component } from 'react';
import {
AppRegistry,
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import SecondScreen from './src/SecondScreen';
import App from './src/App';