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
class HellowWorldRepository { | |
interface Listener { | |
void onSomethingDone(String result); | |
} | |
public void doSomething(Listener listener) { | |
new Thread(new Runnable(){ // this is the worst way to do threading, google "android threading" | |
@Override | |
public void run() { | |
// do some stuff |
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
<!-- Begin Mailchimp Signup Form --> | |
<style type="text/css"> | |
#mc_embed_signup { border: none; text-align: center; width: 100%; } /* Signup form container */ | |
.mc-field-group { display: inline-block; } /* positions input field horizontally */ | |
#mce-EMAIL { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1em; ; border:none; border-bottom: 2px solid #000; color: #343434; background-color: transparent; padding: .7em 30em .7em 1em; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; display: inline-block; margin: 0; } /* Input Styles */ | |
.clear { display: inline-block; } /* positions button horizontally in line with 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
Stream<String> a = Stream.of("one", "three", "five"); | |
Stream<String> b = Stream.of("two", "four", "six"); | |
Stream<String> out = interleave(a, b); | |
/** | |
* https://stackoverflow.com/questions/53307682/how-to-interleave-merge-two-java-8-streams | |
**/ | |
public static <T> Stream<T> interleave(Stream<T> streamA, Stream<T> streamB) { | |
return zip(streamA, streamB, (o1, o2) -> Stream.of(o1, o2)).flatMap(s -> s); |
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
Runnable somethingIWannaDo = new Runnable() { | |
@Override | |
public void run() { | |
Log.d("EZ", "I got ran"); | |
} | |
}; | |
// In Android Activity onCreate: | |
RunnableButton.create("BCM21", somethingIWannaDo).onCreateInjectInto(this); |
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
#!/bin/bash | |
sp="/-\|" | |
sc=0 | |
spin() { | |
printf "\b${sp:sc++:1}" | |
((sc==${#sp})) && sc=0 | |
} | |
endspin() { | |
printf "\r" | |
} |
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.concurrent.Executor; | |
import java.util.concurrent.Executors; | |
import kaaes.spotify.webapi.android.SpotifyApi; | |
import retrofit.android.MainThreadExecutor; | |
final class SpotifyApiBuilder { | |
private Executor executeExecutor; | |
private Executor callbackExecutor; |
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.app.Activity; | |
import android.app.Application; | |
import android.os.Bundle; | |
import java.util.Locale; | |
public class UniqueActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks { | |
private final String activityName; | |
private final Application.ActivityLifecycleCallbacks lifecycleCallbacks; |
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 Vector<ContentValues> parseJson(String jsonStr) { | |
Vector<ContentValues> cVVector = new Vector<ContentValues>(); | |
try { | |
JSONObject json = new JSONObject(jsonStr); | |
JSONObject data = json.getJSONObject("data"); | |
JSONArray items = data.getJSONArray("items"); | |
for (int i = 0; i < items.length(); i++) { | |
// Get the JSON object representing the day | |
JSONObject videoDetails = items.getJSONObject(i); |
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
/** | |
* https://gist.github.com/JakeWharton/0a251d67649305d84e8a | |
* <p/> | |
* Then modified to : | |
* not scale the foreground to the ImageView size | |
* draw the foreground centered | |
*/ | |
public class ForegroundImageView extends ImageView { | |
private Drawable foreground; |
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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.blundell.myapplication"> | |
<application> | |
<activity | |
android:name=".SecondActivity" | |
android:permission="perm.foo.bar" /> | |
</application> |
NewerOlder