Skip to content

Instantly share code, notes, and snippets.

View SteveKamau72's full-sized avatar

Steve Kamau SteveKamau72

View GitHub Profile
@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" />
@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 / 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 / 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';
@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;

/**
//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 / 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;
/**
@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 / 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 / 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 {