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
MyFragment fragment = MyFragment.newInstance(index); | |
FragmentTransaction ft = getFragmentManager().beginTransaction(); | |
ft.replace(R.id.parent, fragment); | |
ft.commit(); |
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
MyCustomView customView = new MyCustomView(context); | |
parentView.removeAllViews(); | |
parentView.add(customView); |
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
<fragment android:name="my.package.MyFragment" | |
android:id="@+id/my_fragment" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" /> |
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
<my.package.MyCustomView | |
android:id="@+id/my_view" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" /> |
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
object SignalrSocket { | |
private lateinit var broadcaster: FlowableEmitter<String> | |
private lateinit var disposable: Disposable | |
private val flowable = Flowable.create(FlowableOnSubscribe<String> { emitter -> broadcaster = emitter }, BackpressureStrategy.BUFFER) | |
private lateinit var mHubConnection: HubConnection | |
private lateinit var mHubProxy: HubProxy | |
@Throws(InterruptedException::class, ExecutionException::class) |
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
object WebSocket : WebSocketListener() { | |
private lateinit var broadcaster: FlowableEmitter<String> | |
private lateinit var disposable: Disposable | |
private lateinit var webSocket: WebSocket | |
private val flowable = Flowable.create(FlowableOnSubscribe<String> { emitter -> broadcaster = emitter }, BackpressureStrategy.BUFFER) | |
fun subscribe(): Flowable<String> { | |
val client = OkHttpClient.Builder() | |
.readTimeout(0, TimeUnit.MILLISECONDS) |
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.support.annotation.IdRes | |
import android.support.v7.widget.SearchView | |
import android.support.v7.widget.Toolbar | |
import android.view.MenuItem | |
@DslMarker | |
annotation class ToolbarSearchDsl | |
@ToolbarSearchDsl |
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.TimeUnit; | |
import okhttp3.OkHttpClient; | |
import okhttp3.Request; | |
import okhttp3.Response; | |
import okhttp3.WebSocket; | |
import okhttp3.WebSocketListener; | |
import rx.Observable; | |
public class RxSocketConnection extends WebSocketListener { |
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.text.Spanned | |
import android.text.style.ImageSpan | |
import android.graphics.drawable.ColorDrawable | |
import android.text.SpannableString | |
import android.text.SpannableStringBuilder | |
import android.widget.TextView | |
import java.util.concurrent.atomic.AtomicBoolean | |
fun TextView.justify() { |
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.io.ByteArrayOutputStream | |
import java.io.File | |
import java.nio.charset.StandardCharsets.UTF_8 | |
import java.util.zip.GZIPInputStream | |
import java.util.zip.GZIPOutputStream | |
fun String.gzip(): ByteArray { | |
val bos = ByteArrayOutputStream() | |
GZIPOutputStream(bos).bufferedWriter(UTF_8).use { it.write(this) } | |
return bos.toByteArray() |