Skip to content

Instantly share code, notes, and snippets.

View nyamwaya's full-sized avatar

Alex Nyamwaya nyamwaya

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/login_root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorGrey"
tools:context=".ui.views.login.LoginActivity">
@nyamwaya
nyamwaya / Histogram.kt
Last active June 9, 2019 17:13
Android Histogram using GraphView in Kotlin
//This method takes as parameters the bincount; which is the number of bins you want your histogram to have
//and your data in the form of a double array.
//Based on this SO answer "https://stackoverflow.com/questions/10786465/how-to-generate-bins-for-histogram-using-apache-math-3-0-in-java"
private fun displayHistogram(binCount: Int, data: DoubleArray) {
val histogram = DoubleArray(binCount)
val distribution = org.apache.commons.math3.random.EmpiricalDistribution(binCount)
distribution.load(data)
//Not sure what this variable K does to be honest.
var k = 0
@nyamwaya
nyamwaya / MainActivity.java
Created May 8, 2019 15:47 — forked from granoeste/MainActivity.java
[Android] Button background change for state. (selector)
package com.example.sellectorsample;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
/**
* Tracks the number of calories a person consumes in a given meal.
* Has helper method to get the day's total.
*/
public class Meal {
public enum Type {
BREAKFAST,
LUNCH,
DINER,
testCompile 'junit:junit:4.12'
testCompile('org.robolectric:robolectric:3.0-rc2'){
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
//After creating your class extend, RobolectricTestRunner
//Create a cunstructor
//then inside your constructer, put this code inside it
super(testClass);
String buildVariant = (BuildConfig.FLAVOR.isEmpty()
? "" : BuildConfig.FLAVOR+ "/") + BuildConfig.BUILD_TYPE;
String intermediatesPath = BuildConfig.class.getResource("")
.toString().replace("file:", "");
intermediatesPath = intermediatesPath