This file contains hidden or 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.example.testingcoroutines | |
import kotlinx.coroutines.CoroutineDispatcher | |
import kotlinx.coroutines.Dispatchers | |
interface DispatchersProvider { | |
fun main(): CoroutineDispatcher = Dispatchers.Main | |
fun default(): CoroutineDispatcher = Dispatchers.Default | |
fun io(): CoroutineDispatcher = Dispatchers.IO | |
fun unconfined(): CoroutineDispatcher = Dispatchers.Unconfined |
This file contains hidden or 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"?> | |
<android.support.design.widget.CoordinatorLayout | |
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:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<android.support.design.widget.AppBarLayout | |
android:layout_width="match_parent" |
This file contains hidden or 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 byte[] mapPayload(int toConvert) { | |
byte[] ret = new byte[4]; | |
ret[3] = (byte) (toConvert & 0xFF); | |
ret[2] = (byte) ((toConvert >> 8) & 0xFF); | |
ret[1] = (byte) ((toConvert >> 16) & 0xFF); | |
ret[0] = (byte) ((toConvert >> 24) & 0xFF); | |
return ret; | |
} | |
static int unmapPayload(byte[] payload) { |
This file contains hidden or 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.support.annotation.IntDef; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE; | |
import static android.support.design.widget.Snackbar.LENGTH_LONG; | |
import static android.support.design.widget.Snackbar.LENGTH_SHORT; |
This file contains hidden or 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 startBrowser(@NonNull final Context context, @NonNull final String url, @Nullable final Bundle animationBundle) { | |
final String preparedUrl = trimUrl(url); | |
final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(preparedUrl)); | |
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
context.startActivity(browserIntent, animationBundle); | |
} | |
private static String trimUrl(final String url) { | |
String toReturn = url; | |
if (!url.startsWith("http://") && !url.startsWith("https://")) { |
This file contains hidden or 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
/** | |
* Initiates a soft application restart. | |
* Clears the UI stack and opens the the entry class giving the impression of a new application start | |
* @param context the context the activity should be started from | |
* @param activity the activity which is declared as main entry point for the app | |
*/ | |
public static void restartSoft(@Nonnull final Context context, @NonNull final Class<? extends Activity> activity) { | |
context.startActivity(new Intent(context, activity).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK)); | |
} |