Advertisement
Guest User

Untitled

a guest
Aug 10th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. buildscript {
  2. repositories {
  3. jcenter()
  4. mavenCentral()
  5. maven { url 'https://maven.fabric.io/public' }
  6. }
  7. dependencies {
  8. classpath 'com.android.tools.build:gradle:2.1.2'
  9. classpath "io.realm:realm-gradle-plugin:1.1.1"
  10. classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
  11. classpath 'com.jakewharton:butterknife-gradle-plugin:8.2.1'
  12. classpath 'io.fabric.tools:gradle:1.21.7'
  13. }
  14. }
  15.  
  16. allprojects {
  17. repositories {
  18. jcenter()
  19. maven { url 'https://maven.fabric.io/public' }
  20. }
  21. }
  22.  
  23. task clean(type: Delete) {
  24. delete rootProject.buildDir
  25. }
  26.  
  27. apply plugin: 'com.android.library'
  28. apply plugin: 'realm-android'
  29. apply plugin: 'com.jakewharton.butterknife'
  30. apply plugin: 'android-apt'
  31.  
  32. android {
  33.  
  34. compileSdkVersion 24
  35. buildToolsVersion "24.0.1"
  36.  
  37. defaultConfig {
  38. minSdkVersion 17
  39. targetSdkVersion 24
  40. versionCode 1
  41. versionName "0.1"
  42. }
  43.  
  44. buildTypes {
  45. release {
  46. minifyEnabled false
  47. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  48. }
  49. }
  50. }
  51.  
  52. dependencies {
  53. // Local
  54. compile fileTree(dir: 'libs', include: ['*.jar'])
  55.  
  56. ...
  57.  
  58. compile 'com.jakewharton:butterknife:8.2.1'
  59. }
  60.  
  61. apply plugin: 'com.android.application'
  62. apply plugin: 'realm-android'
  63. apply plugin: 'io.fabric'
  64. apply plugin: 'android-apt'
  65.  
  66. android {
  67.  
  68. compileSdkVersion 24
  69. buildToolsVersion "24.0.1"
  70.  
  71. defaultConfig {
  72. applicationId "..."
  73. minSdkVersion 17
  74. targetSdkVersion 24
  75. versionCode 1
  76. versionName "0.1"
  77. }
  78.  
  79. buildTypes {
  80. debug {
  81. applicationIdSuffix '.debug'
  82. }
  83. release {
  84. minifyEnabled false
  85. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  86. }
  87. }
  88. }
  89.  
  90. dependencies {
  91.  
  92. ...
  93.  
  94. // Butterknife
  95. compile 'com.jakewharton:butterknife:8.2.1'
  96. apt 'com.jakewharton:butterknife-compiler:8.2.1'
  97. }
  98.  
  99. import android.os.Bundle;
  100. import android.support.annotation.Nullable;
  101. import android.widget.Button;
  102. import android.widget.EditText;
  103.  
  104. import com.solbyte.colservicol.common.R;
  105. import com.solbyte.colservicol.common.R2;
  106.  
  107. import butterknife.BindView;
  108. import butterknife.OnClick;
  109.  
  110. public abstract class LoginActivity extends BaseActivity {
  111.  
  112. @BindView(R2.id.login_user_form)
  113. protected EditText user;
  114.  
  115. @BindView(R2.id.login_password_form)
  116. protected EditText password;
  117.  
  118. @BindView(R2.id.login_sign_in)
  119. protected Button signIn;
  120.  
  121. @Override
  122. protected void onCreate(@Nullable Bundle savedInstanceState) {
  123. super.onCreate(savedInstanceState);
  124. setContentView(R.layout.activity_login);
  125. ButterKnife.bind(this);
  126. }
  127.  
  128. @OnClick(R2.id.login_sign_in)
  129. protected void onSignInClick() {
  130. String user = this.user.toString();
  131. String password = this.password.getText().toString();
  132.  
  133. /* Fields validations ... */
  134.  
  135. tryLogin(user, password);
  136. }
  137.  
  138. protected abstract void tryLogin(String user, String password);
  139.  
  140. }
  141.  
  142. <LinearLayout
  143. xmlns:android="http://schemas.android.com/apk/res/android"
  144. android:layout_width="match_parent"
  145. android:layout_height="match_parent"
  146. android:focusableInTouchMode="true"
  147. android:orientation="vertical"
  148. android:padding="@dimen/activity_horizontal_margin">
  149.  
  150. <ImageView
  151. android:layout_width="wrap_content"
  152. android:layout_height="0dp"
  153. android:layout_gravity="center"
  154. android:layout_weight="0.4"
  155. android:scaleType="fitCenter"
  156. android:src="@drawable/brand" />
  157.  
  158. <LinearLayout
  159. android:layout_width="match_parent"
  160. android:layout_height="0dp"
  161. android:layout_weight="0.6"
  162. android:gravity="center_horizontal"
  163. android:orientation="vertical">
  164.  
  165. <android.support.design.widget.TextInputLayout
  166. android:layout_width="match_parent"
  167. android:layout_height="wrap_content">
  168.  
  169. <android.support.design.widget.TextInputEditText
  170. android:id="@+id/login_user_form"
  171. style="@style/LoginEditText" />
  172.  
  173. </android.support.design.widget.TextInputLayout>
  174.  
  175. <android.support.design.widget.TextInputLayout
  176. android:layout_width="match_parent"
  177. android:layout_height="wrap_content">
  178.  
  179. <android.support.design.widget.TextInputEditText
  180. android:id="@+id/login_password_form"
  181. style="@style/LoginEditText" />
  182.  
  183. </android.support.design.widget.TextInputLayout>
  184.  
  185. <Button
  186. android:id="@+id/login_sign_in"
  187. style="@style/LoginButton"
  188. android:text="@string/login_sign_in" />
  189.  
  190. </LinearLayout>
  191.  
  192. </LinearLayout>
  193.  
  194. import android.content.Intent;
  195. import android.os.Bundle;
  196. import android.support.annotation.Nullable;
  197.  
  198. import xxx.activity.LoginActivity;
  199.  
  200. import butterknife.ButterKnife;
  201.  
  202. public class AdminLoginActivity extends LoginActivity {
  203.  
  204. @Override
  205. protected void tryLogin(String user, String password) {
  206. // This is never called!!
  207. Toast.makeText(this, "Login in...", Toast.LENGTH_SHORT).show();
  208. }
  209.  
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement