This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.view.View | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.ListAdapter | |
import androidx.recyclerview.widget.RecyclerView | |
abstract class EmptyViewListAdapter<T, VH: RecyclerView.ViewHolder>(itemCallback: DiffUtil.ItemCallback<T>, | |
private val emptyView: View): ListAdapter<T, VH>(itemCallback) { | |
override fun onCurrentListChanged(previousList: MutableList<T>, currentList: MutableList<T>) { | |
if (currentList.size == 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.constraintlayout.motion.widget.MotionLayout | |
fun MotionLayout.doOnEnd(onEnd: () -> Unit) { | |
this.setTransitionListener(object: MotionLayout.TransitionListener { | |
override fun onTransitionTrigger( | |
p0: MotionLayout?, | |
p1: Int, | |
p2: Boolean, | |
p3: Float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class ListGenerator { | |
public static int[] generateList(int size, int upperBound) { | |
Random r = new Random(); | |
int[] array = new int[size]; | |
for (int i = 0; i < size; i++) { | |
int random = r.nextInt(upperBound); | |
array[i] = r.nextInt(upperBound); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final CompositeDisposable disposables = new CompositeDisposable(); | |
// START POLLING every 5 seconds, with a timeout of 5 seconds. | |
disposables.add(Observable.interval(0, 5, TimeUnit.SECONDS) | |
.flatMap((Function<Long, ObservableSource<?>>) aLong -> energyHiveService.getCurrentValuesSummary() | |
.takeUntil(Observable.timer(5, TimeUnit.SECONDS)) | |
) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(result -> { | |
// Use result, example below. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quick solution to solve question one of http://www.olympiad.org.uk/papers/2010/bio/bio-10-exam.pdf | |
package com.danielstone.alevels; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
public class Anagram { | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
Integer userInput = input.nextInt(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Call<T> call = retrofitService.apiCall(); | |
RetrofitLoader.load(this, getSupportLoaderManager(), id, call, new RetrofitLoader.RetrofitLoaderCallback<T>() { | |
@Override | |
public void onLoad(Response<T> result) { | |
Log.i(TAG, "onLoad: " + result.body()); | |
} | |
@Override | |
public void onFail(Throwable t) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* cRandomGen | |
* @param input | |
* @param inRender render object | |
* @returns {cRandomGen} | |
*/ | |
function cRandomGen(input, inRender) | |
{ | |
this.input = input; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.danielstone.energyhive.intro; | |
import android.content.SharedPreferences; | |
import android.net.Uri; | |
import android.os.AsyncTask; | |
import android.os.Build; | |
import android.os.Bundle; | |
import android.preference.PreferenceManager; | |
import android.support.design.widget.Snackbar; | |
import android.util.Log; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.evo.passwordgenerator"> | |
<application android:allowBackup="true" | |
android:label="@string/app_name" | |
android:icon="@mipmap/ic_launcher" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme" | |
android:fitsSystemWindows="true"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.evo.passwordgenerator"> | |
<application android:allowBackup="true" | |
android:label="@string/app_name" | |
android:icon="@mipmap/ic_launcher" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme" | |
android:fitsSystemWindows="true"> |
NewerOlder