Skip to content

Instantly share code, notes, and snippets.

package com.nesterchung.chart
import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.text.format.DateUtils
import android.util.Log
import android.view.WindowManager
import com.github.mikephil.charting.charts.BarChart
import com.github.mikephil.charting.components.AxisBase
@CMingTseng
CMingTseng / CodeActivity.java
Created June 10, 2018 13:10 — forked from ianbarber/CodeActivity.java
Example of handling both client and server sign in with GoogleAuthUtil and GoogleApiClient
package com.google.plus.sample.ShareTest;
import android.accounts.AccountManager;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
@CMingTseng
CMingTseng / CalendarGson.java
Created June 13, 2018 14:34 — forked from jromero/CalendarGson.java
DateDeserializer for Gson based on different SimpleDateFormats
package org.dallasmakerspace.kiosk.data.calendar;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.dallasmakerspace.kiosk.gson.DateDeserializer;
import java.text.SimpleDateFormat;
import java.util.Date;
@CMingTseng
CMingTseng / expand-collapse.java
Created July 5, 2018 06:17 — forked from ZkHaider/expand-collapse.java
Simple Expand / Collapse RecyclerView Item
public static class ExampleViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener {
private int originalHeight = 0;
private boolean isViewExpanded = false;
private YourCustomView yourCustomView
public ExampleViewHolder(View v) {
super(v);
v.setOnClickListener(this);
@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;