├── .github └── FUNDING.yml ├── .gitignore ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── vandana │ │ └── mvcexample │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── vandana │ │ │ └── mvcexample │ │ │ ├── LoginApi.java │ │ │ ├── LoginResultInterface.java │ │ │ ├── MainActivity.java │ │ │ └── UserModel.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── content_main.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── vandana │ └── mvcexample │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: vandanasri 4 | custom: https://paypal.me/vandanasri 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | /local.properties 3 | /.idea 4 | /.gradle 5 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.vandana.mvcexample" 7 | minSdkVersion 19 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'androidx.appcompat:appcompat:1.0.2' 24 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 25 | implementation 'com.google.android.material:material:1.0.0' 26 | testImplementation 'junit:junit:4.12' 27 | androidTestImplementation 'androidx.test:runner:1.1.1' 28 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/vandana/mvcexample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.vandana.mvcexample; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | 25 | assertEquals("com.vandana.mvcexample", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/vandana/mvcexample/LoginApi.java: -------------------------------------------------------------------------------- 1 | package com.vandana.mvcexample; 2 | 3 | import android.os.Handler; 4 | 5 | public class LoginApi { 6 | 7 | Handler handler; 8 | UserModel userModel; 9 | private String name; 10 | private String password; 11 | LoginResultInterface mLoginResultInterface; 12 | 13 | LoginApi(String userName, String password, LoginResultInterface loginResultInterface){ 14 | userModel = new UserModel(userName, password); 15 | 16 | handler= new Handler(); 17 | this.name = userName; 18 | this.password = password; 19 | this.mLoginResultInterface = loginResultInterface; 20 | } 21 | 22 | 23 | public void doLogin() { 24 | Boolean isLoginSuccess = true; 25 | final int code = userModel.checkUserValidity(name,password); 26 | System.out.println("@Code "+code); 27 | if (code!=0) 28 | isLoginSuccess = false; 29 | 30 | final Boolean result = isLoginSuccess; 31 | 32 | handler.postDelayed(new Runnable() { 33 | @Override 34 | public void run() { 35 | mLoginResultInterface.onLoginResult(result, code); 36 | } 37 | }, 5000); 38 | 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/vandana/mvcexample/LoginResultInterface.java: -------------------------------------------------------------------------------- 1 | package com.vandana.mvcexample; 2 | 3 | public interface LoginResultInterface { 4 | void onLoginResult(Boolean result, int code); 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/vandana/mvcexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.vandana.mvcexample; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.appcompat.app.AppCompatActivity; 6 | import androidx.appcompat.widget.Toolbar; 7 | 8 | import android.view.View; 9 | import android.widget.Button; 10 | import android.widget.EditText; 11 | import android.widget.ProgressBar; 12 | import android.widget.Toast; 13 | 14 | public class MainActivity extends AppCompatActivity implements LoginResultInterface { 15 | private EditText editUserName; 16 | private EditText editPassword; 17 | private Button btnLogin; 18 | private ProgressBar progressBar; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | initUI(); 25 | btnLogin.setOnClickListener(new View.OnClickListener() { 26 | @Override 27 | public void onClick(View view) { 28 | loginResult(); 29 | } 30 | }); 31 | 32 | 33 | } 34 | 35 | 36 | 37 | private void loginResult(){ 38 | progressBar.setVisibility(View.VISIBLE); 39 | String userName = editUserName.getText().toString(); 40 | String password = editPassword.getText().toString(); 41 | LoginApi login = new LoginApi(userName,password, this); 42 | login.doLogin(); 43 | } 44 | 45 | 46 | 47 | @Override 48 | public void onLoginResult(Boolean result, int code) { 49 | progressBar.setVisibility(View.INVISIBLE); 50 | if(result) { 51 | Toast.makeText(this,"Login Successful",Toast.LENGTH_SHORT).show(); 52 | } 53 | else{ 54 | Toast.makeText(this,"Login Fail",Toast.LENGTH_SHORT).show(); 55 | } 56 | } 57 | 58 | 59 | private void initUI(){ 60 | Toolbar toolbar = findViewById(R.id.toolbar); 61 | setSupportActionBar(toolbar); 62 | editUserName = (EditText) findViewById(R.id.et_name); 63 | editPassword = (EditText) findViewById(R.id.et_password); 64 | btnLogin = (Button) findViewById(R.id.bt_submit); 65 | progressBar = (ProgressBar) findViewById(R.id.progress_login); 66 | progressBar.setVisibility(View.INVISIBLE); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/vandana/mvcexample/UserModel.java: -------------------------------------------------------------------------------- 1 | package com.vandana.mvcexample; 2 | 3 | public class UserModel { 4 | private String username; 5 | private String password; 6 | 7 | public UserModel(String username, String password) { 8 | this.username = username; 9 | this.password = password; 10 | } 11 | 12 | 13 | public String getUsername() { 14 | return username; 15 | } 16 | 17 | public String getPassword() { 18 | return password; 19 | } 20 | 21 | public int checkUserValidity(String username, String password){ 22 | if (username.trim().equals("")||password.trim().equals("")){ 23 | return -1; 24 | }else{ 25 | return 0; 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 23 | 24 | 34 | 35 | 46 | 47 |