Skip to content

Instantly share code, notes, and snippets.

apply plugin: 'com.android.application'
android {
dataBinding {
enabled = true
}
compileSdkVersion 23
...
}
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.ObservableField;
import android.os.Handler;
import android.support.design.widget.Snackbar;
import android.transition.Visibility;
import android.view.View;
public class LoginViewModel extends BaseObservable {
private String email;
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable name="loginViewModel" type="dev.kevinle.exploremvvm.viewmodel.LoginViewModel"/>
<variable name="handler" type="dev.kevinle.exploremvvm.viewmodel.LoginViewModel" />
</data>
...
</layout>
<EditText
android:id="@+id/email"
...
android:text="@={loginViewModel.email}"/>
<EditText
android:id="@+id/password"
...
android:text="@={loginViewModel.password}"/>
package dev.kevinle.exploremvvm;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import dev.kevinle.exploremvvm.databinding.ActivityMainBinding;
import dev.kevinle.exploremvvm.viewmodel.LoginViewModel;
public class MainActivity extends AppCompatActivity {
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
...
<variable name="handler" type="specify class to be the handler" />
</data>
...
</layout>
@khle
khle / AppDelegate.swift
Created August 30, 2016 05:08 — forked from tfrank64/AppDelegate.swift
Swift UITabBar Programmatically
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var nav1 = UINavigationController()
var first = FirstViewController(nibName: nil, bundle: nil)
nav1.viewControllers = [first]
var second = SecondViewController(nibName: nil, bundle: nil)
var nav2 = UINavigationController()
@khle
khle / aad_access_and_refresh_tokens
Created September 3, 2016 13:29
Azure AD Access and refresh tokens
{
"token_type": "Bearer",
"scope": "user_impersonation",
"expires_in": "3599",
"ext_expires_in": "0",
"expires_on": "1472912660",
"not_before": "1472908760",
"resource": "http://yourapp.azurewebsites.net",
"access_token": "eyJ0eXAiOiJK...",
"refresh_token": "AQABAAAAAAB...",
curl --header "authorization: bearer eyJ0eXAiOiJK..." https://yourapp.azurewebsites.net/secured-resource
@khle
khle / SessionToken
Created September 3, 2016 15:02
SessionToken
public class SessionToken {
public long expires_on;
public String access_token;
public String refresh_token;
}