Skip to content

Instantly share code, notes, and snippets.

@CMingTseng
CMingTseng / MVP + Interactor example.kt
Created July 24, 2018 15:19 — forked from marciogranzotto/MVP + Interactor example.kt
This is an example of Android development with MVP + Interactor in Kotlin
interface LoginContracts {
interface View {
fun presentHomeScreen(user: User)
fun showError(message: String)
}
interface Presenter {
fun onDestroy()
fun onLoginButtonPressed(username: String, password: String)
}
@CMingTseng
CMingTseng / VIPER Android Example.kt
Created July 24, 2018 15:21 — forked from marciogranzotto/VIPER Android Example.kt
This is an example of Android development with VIPER in Kotlin
interface LoginContracts {
interface View {
fun showError(message: String)
}
interface Presenter {
fun onDestroy()
fun onLoginButtonPressed(username: String, password: String)
}
/*
* BottomNavigationLayout library for Android
* Copyright (c) 2016. Nikola Despotoski (http://github.com/NikolaDespotoski).
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software

Cross to Back Arrow and reverse

An android animated vector drawable created using ShapeShifter

@CMingTseng
CMingTseng / HostSelectionInterceptor.java
Created August 8, 2018 04:38 — forked from swankjesse/HostSelectionInterceptor.java
This OkHttp application interceptor will replace the destination hostname in the request URL.
import java.io.IOException;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
/** An interceptor that allows runtime changes to the URL hostname. */
public final class HostSelectionInterceptor implements Interceptor {
private volatile String host;
import java.io.IOException;
import java.io.PrintStream;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.mockwebserver.Dispatcher;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
package main
import (
"fmt"
"net/http"
"sync"
)
var mu sync.Mutex
var count int
public class ApiClient {
private static final String URL = "";
private static Retrofit mRetrofit = null;
public static Retrofit getInstance() {
if (mRetrofit == null) {
mRetrofit = new Retrofit.Builder()
@CMingTseng
CMingTseng / CustomSSLSocketFactory.java
Created September 19, 2018 14:45 — forked from mannodermaus/CustomSSLSocketFactory.java
Android SSLSocketFactory for use with custom CA
package com.github.aurae.ssl;
import android.content.Context;
import android.support.annotation.RawRes;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.SecureRandom;
import java.security.cert.Certificate;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.Canvas;