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 { LitElement, html } from '@polymer/lit-element' | |
import { classMap } from 'lit-html/directives/classMap' | |
class MyDialog extends LitElement { | |
constructor () { | |
super() | |
this.opened = false | |
} |
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 SimpleService : Service() { | |
companion object { | |
@JvmStatic fun launchService(context: Context) { | |
context.startService(Intent(context, SimpleService::class.java)) | |
} | |
} | |
override fun onBind(intent: Intent?): IBinder { | |
return Binder() | |
} |
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
fun launchBackgroundJob(job: () -> Unit) { | |
thread { job() } | |
} |
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
internal class CoroutineLifecycleListener(private val deferred: Deferred<*>) : LifecycleObserver { | |
@OnLifecycleEvent(Lifecycle.Event.ON_STOP) | |
fun cancelCoroutine() { | |
deferred.cancel() | |
} | |
} | |
internal var POOL = newFixedThreadPoolContext(2, "loader") | |
fun <T> LifecycleOwner.load(loader: () -> T): Deferred<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
package se.hellsoft.twig | |
import android.util.Log | |
import se.hellsoft.kotlinhacks.BuildConfig | |
/** | |
* Verbose logging. Will be stripped from release builds. | |
*/ | |
inline fun <reified T> T.logv(error: Throwable? = null, m: () -> String) { | |
if (BuildConfig.DEBUG) { |
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 void subscribeToData() { | |
Flowable<List<Data>> dataLists = Flowable | |
.interval(0, 3, TimeUnit.SECONDS, Schedulers.computation()) | |
.map(val -> { | |
Log.d(TAG, "Shuffling original list..."); | |
return Data.shuffle(originalList).subList(0, (int) (0.8 * originalList.size())); | |
}) | |
.share(); | |
Flowable<List<Data>> startWith = dataLists |
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
Verifying that "erikhellman.id" is my Blockstack ID. https://onename.com/erikhellman |
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 se.hellsoft.handlerthreadingdemo; | |
import android.content.ComponentName; | |
import android.content.Intent; | |
import android.content.ServiceConnection; | |
import android.os.Handler; | |
import android.os.HandlerThread; | |
import android.os.IBinder; | |
import android.os.Looper; | |
import android.os.Message; |
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 class MainActivity extends AppCompatActivity { | |
private static final int MSG_LONG_RUNNING_OPERATION = 101; | |
private static final int MSG_UPDATE_UI = 102; | |
private static final long THRITY_SECONDS = 30000; | |
private Handler bgHandler; | |
private Handler uiHandler; | |
private Handler.Callback callback; | |
private boolean doAgain = false; |
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 final class RxGattWrapper { | |
private SerializedSubject<BluetoothGattEvent, BluetoothGattEvent> eventSubject = new SerializedSubject<>(PublishSubject.<BluetoothGattEvent>create()); | |
private BluetoothDevice bluetoothDevice; | |
private BluetoothGatt bluetoothGatt; | |
public RxGattWrapper(BluetoothDevice bluetoothDevice) { | |
this.bluetoothDevice = bluetoothDevice; | |
} | |
public void connect(Context context) { |