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.nabilhachicha.myapplication; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.os.StrictMode; | |
import android.util.Log; | |
import com.squareup.okhttp.Cache; | |
import com.squareup.okhttp.Interceptor; | |
import com.squareup.okhttp.OkHttpClient; |
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
static class Activity { | |
interface Listener {} | |
Service service; | |
Activity(Service service) { | |
this.service = service; | |
} | |
void onStart() { | |
service.registerListener(new Listener() {});//Listener hold a reference to Activity |
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
public void testLooperNotProcessingMessageTestWillNotExit () throws InterruptedException { | |
Handler handler = new Handler() { | |
@Override | |
public void handleMessage(Message msg) { | |
assertEquals(42, msg.what); | |
} | |
}; | |
boolean messageSent = handler.sendEmptyMessage(42); | |
assertTrue(messageSent); |
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
// ********************************************************************* // | |
// ************************** CountDownLatch ************************** // | |
// ********************************************************************* // | |
public class RandomIntAverage { | |
CountDownLatch controller = new CountDownLatch(NB_THREADS); | |
public void randomIntAvg() throws InterruptedException { | |
for (int i = 0; i < NB_THREADS; i++) { | |
new Thread(new Task()).start(); | |
} |
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
public static void dumpAllRealms() { | |
try { | |
StringBuilder report = | |
new StringBuilder("*******************************************************************************\n") | |
.append("********* D U M P I N G R E A L M I N S T A N C E S [ S T A R T ] **********\n") | |
.append("*******************************************************************************\n\n"); | |
int nbrRealm = 0; | |
Class<?> realmCacheClazz = Class.forName("io.realm.RealmCache"); | |
java.lang.reflect.Method getConfigurationMethod = realmCacheClazz.getMethod("getConfiguration"); |
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 sample | |
import kotlinx.cinterop.StableRef | |
import kotlinx.cinterop.toCPointer | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.ReceiveChannel | |
import kotlin.native.internal.GC | |
import kotlin.native.ref.WeakReference |