Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buildscript {
- repositories {
- jcenter()
- mavenCentral()
- maven { url 'https://maven.fabric.io/public' }
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:2.1.2'
- classpath "io.realm:realm-gradle-plugin:1.1.1"
- classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
- classpath 'com.jakewharton:butterknife-gradle-plugin:8.2.1'
- classpath 'io.fabric.tools:gradle:1.21.7'
- }
- }
- allprojects {
- repositories {
- jcenter()
- maven { url 'https://maven.fabric.io/public' }
- }
- }
- task clean(type: Delete) {
- delete rootProject.buildDir
- }
- apply plugin: 'com.android.library'
- apply plugin: 'realm-android'
- apply plugin: 'com.jakewharton.butterknife'
- apply plugin: 'android-apt'
- android {
- compileSdkVersion 24
- buildToolsVersion "24.0.1"
- defaultConfig {
- minSdkVersion 17
- targetSdkVersion 24
- versionCode 1
- versionName "0.1"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
- dependencies {
- // Local
- compile fileTree(dir: 'libs', include: ['*.jar'])
- ...
- compile 'com.jakewharton:butterknife:8.2.1'
- }
- apply plugin: 'com.android.application'
- apply plugin: 'realm-android'
- apply plugin: 'io.fabric'
- apply plugin: 'android-apt'
- android {
- compileSdkVersion 24
- buildToolsVersion "24.0.1"
- defaultConfig {
- applicationId "..."
- minSdkVersion 17
- targetSdkVersion 24
- versionCode 1
- versionName "0.1"
- }
- buildTypes {
- debug {
- applicationIdSuffix '.debug'
- }
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
- dependencies {
- ...
- // Butterknife
- compile 'com.jakewharton:butterknife:8.2.1'
- apt 'com.jakewharton:butterknife-compiler:8.2.1'
- }
- import android.os.Bundle;
- import android.support.annotation.Nullable;
- import android.widget.Button;
- import android.widget.EditText;
- import com.solbyte.colservicol.common.R;
- import com.solbyte.colservicol.common.R2;
- import butterknife.BindView;
- import butterknife.OnClick;
- public abstract class LoginActivity extends BaseActivity {
- @BindView(R2.id.login_user_form)
- protected EditText user;
- @BindView(R2.id.login_password_form)
- protected EditText password;
- @BindView(R2.id.login_sign_in)
- protected Button signIn;
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_login);
- ButterKnife.bind(this);
- }
- @OnClick(R2.id.login_sign_in)
- protected void onSignInClick() {
- String user = this.user.toString();
- String password = this.password.getText().toString();
- /* Fields validations ... */
- tryLogin(user, password);
- }
- protected abstract void tryLogin(String user, String password);
- }
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:focusableInTouchMode="true"
- android:orientation="vertical"
- android:padding="@dimen/activity_horizontal_margin">
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="0dp"
- android:layout_gravity="center"
- android:layout_weight="0.4"
- android:scaleType="fitCenter"
- android:src="@drawable/brand" />
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="0.6"
- android:gravity="center_horizontal"
- android:orientation="vertical">
- <android.support.design.widget.TextInputLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <android.support.design.widget.TextInputEditText
- android:id="@+id/login_user_form"
- style="@style/LoginEditText" />
- </android.support.design.widget.TextInputLayout>
- <android.support.design.widget.TextInputLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <android.support.design.widget.TextInputEditText
- android:id="@+id/login_password_form"
- style="@style/LoginEditText" />
- </android.support.design.widget.TextInputLayout>
- <Button
- android:id="@+id/login_sign_in"
- style="@style/LoginButton"
- android:text="@string/login_sign_in" />
- </LinearLayout>
- </LinearLayout>
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.annotation.Nullable;
- import xxx.activity.LoginActivity;
- import butterknife.ButterKnife;
- public class AdminLoginActivity extends LoginActivity {
- @Override
- protected void tryLogin(String user, String password) {
- // This is never called!!
- Toast.makeText(this, "Login in...", Toast.LENGTH_SHORT).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement