├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── fonts │ │ ├── Roboto-Black.ttf │ │ ├── Roboto-BlackItalic.ttf │ │ ├── Roboto-Bold.ttf │ │ ├── Roboto-BoldItalic.ttf │ │ ├── Roboto-Italic.ttf │ │ ├── Roboto-Light.ttf │ │ ├── Roboto-LightItalic.ttf │ │ ├── Roboto-Medium.ttf │ │ ├── Roboto-MediumItalic.ttf │ │ ├── Roboto-Regular.ttf │ │ ├── Roboto-Thin.ttf │ │ ├── Roboto-ThinItalic.ttf │ │ ├── RobotoCondensed-Bold.ttf │ │ ├── RobotoCondensed-BoldItalic.ttf │ │ ├── RobotoCondensed-Italic.ttf │ │ ├── RobotoCondensed-Light.ttf │ │ ├── RobotoCondensed-LightItalic.ttf │ │ └── RobotoCondensed-Regular.ttf │ ├── java │ └── com │ │ └── chintansoni │ │ └── android │ │ └── masterproject │ │ ├── activity │ │ ├── HomeActivity.java │ │ ├── LoginActivity.java │ │ └── SplashActivity.java │ │ ├── base │ │ ├── BaseAppCompatActivity.java │ │ ├── BaseBottomSheetDialogFragment.java │ │ ├── BaseConstants.java │ │ ├── BaseDialogFragment.java │ │ ├── BaseFragment.java │ │ ├── BaseNavigationDrawerActivity.java │ │ ├── BaseRecyclerAdapter.java │ │ ├── BaseSingleSelectRecyclerAdapter.java │ │ ├── BaseToolBarActivity.java │ │ └── BaseViewHolder.java │ │ ├── bottomsheet │ │ └── SelectImageUsingBottomSheet.java │ │ ├── customview │ │ ├── RobotoAutoCompleteTextView.java │ │ ├── RobotoButton.java │ │ ├── RobotoCheckBox.java │ │ ├── RobotoRadioButton.java │ │ ├── RobotoTextInputEditText.java │ │ └── RobotoTextView.java │ │ ├── fragment │ │ └── HomeImportFragment.java │ │ ├── service │ │ ├── ApiService.java │ │ ├── BaseApi.java │ │ ├── OkClientFactory.java │ │ └── api │ │ │ ├── CitiesApi.java │ │ │ ├── LoginApi.java │ │ │ ├── NotificationsDeleteApi.java │ │ │ └── UploadImageApi.java │ │ └── util │ │ ├── DialogUtils.java │ │ ├── DpPxUtils.java │ │ ├── File │ │ ├── FileUtils.java │ │ └── LocalStorageProvider.java │ │ ├── FormValidationUtils.java │ │ ├── LogUtils.java │ │ ├── NetworkUtils.java │ │ ├── ProgressDialogUtils.java │ │ ├── SharedPreferencesUtils.java │ │ ├── SnackBarUtils.java │ │ └── VerticalSpaceItemDecoration.java │ └── res │ ├── drawable │ ├── divider.xml │ ├── ic_camera.xml │ ├── ic_gallery.xml │ ├── ic_image.xml │ ├── ic_menu_camera.xml │ ├── ic_menu_gallery.xml │ ├── ic_menu_manage.xml │ ├── ic_menu_send.xml │ ├── ic_menu_share.xml │ ├── ic_menu_slideshow.xml │ ├── ic_provider.xml │ ├── layer_list_cold_start.xml │ └── side_nav_bar.xml │ ├── layout │ ├── activity_home.xml │ ├── activity_login.xml │ ├── activity_splash.xml │ ├── app_bar_home.xml │ ├── bottom_sheet_select_image_using.xml │ ├── content_home.xml │ ├── content_login.xml │ ├── content_splash.xml │ ├── fragment_import.xml │ ├── layout_divider.xml │ ├── layout_frame.xml │ ├── layout_frame_sub.xml │ ├── layout_toolbar.xml │ └── nav_header_home.xml │ ├── menu │ ├── activity_home_drawer.xml │ └── menu_splash.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 │ ├── base_values.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml │ └── xml │ └── file_paths.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-Master-Project 2 | This is a starter project when starting any fresh project. 3 | 4 | ## Note: 5 | 6 | - This project does not follow any Design Architectutral Patterns. I can assure you that you will love to use it. Its just a normal way to start any project, but comes with lots of shortcuts and that can reduce your huge amount of Code. 7 | * Re-usability and Abstraction has been implemented at my best 8 | * This architecture assumes that your activity's root layout is CoordinatorLayout with Id as "coordinatorLayout". I have considered this so that I can leverage the power of Material Design specifications 9 | 10 | ## Whats new about this architecture: 11 | 12 | * BaseXXX classes: 13 | - Variety of BaseXXX classes to extend your Android Components like: 14 | - **BaseAppCompatActivity.java**: Every Activity class will be extending this class. Example: SplashActivity.java extends BaseAppCompatActivity.java 15 | - **BaseToolBarActivity.java**: This class itself extends BaseAppCompatActivity.java Every BaseAppComaptActivity that uses toolbar should extend this class. Example: LoginActivity.java extends BaseToolBarActivity.java 16 | - **BaseNavigationDrawerActivity.java**: This class itself extends BaseToolBarActivity.java. Any Activity that uses Navigation Drawer in its layout should extend this class. Example: HomeActivity.java extends BaseNavigationDrawerActivity.java 17 | - **BaseFragment.java**: Every Fragment should extend this class. 18 | - **BaseDialogFragment.java**: Every DaialogFragment should extend this class. 19 | - **BaseRecyclerAdapter.java**: This is a generic adapter I have created so that I dont have to create and manage separate files for different types of adapter. [Demo is shown here](https://gist.github.com/chintansoni202/3c61aea787ae4bd49f26adee9dd40a08). 20 | - Shorthand methods: 21 | - Launch Activity 22 | - Load Fragment 23 | - Make a network Call 24 | - Show Toasts / Snackbars 25 | - Show / Hide Progress Dialog 26 | - Show AlertDialog / ConfirmDialog 27 | - logXXX methods 28 | - Hide Keyboard 29 | - Start Service 30 | - Save / Retrieve SharedPreferences 31 | - Finishing Activities with (w/o) Sending Result 32 | - Searchng a fragment 33 | - And all of these shorthand methods can be accessed from different BaseXXX Android Components also. 34 | 35 | * Network Calls: 36 | - All the Network Calls happen on Android's Service Component which helps in keeping activities, fragments fat-free. 37 | - Separation of Concerns: All the things related to a particular Api Call is encapsulated in one file. 38 | 39 | * Uses latest libraries: 40 | - Support Library: 25.3.0 41 | - Butterknife: 8.5.1 42 | - Glide: 3.7.1 43 | - Easy Permissions: 0.2.1 44 | - Retrofit: 2.1.0 45 | - OKHttp: 3.4.1 46 | - EventBus: 3.0.0 47 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.jakewharton.butterknife' 3 | 4 | android { 5 | compileSdkVersion 25 6 | buildToolsVersion "25.0.2" 7 | defaultConfig { 8 | applicationId "com.chintansoni.android.masterproject" 9 | minSdkVersion 19 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | vectorDrawables { 14 | useSupportLibrary true 15 | } 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | def SUPPORT_LIBRARY_VERSION = "25.3.0" 26 | def GLIDE_VERSION = "2.0.1" 27 | def BUTTER_KNIFE_VERSION = "8.5.1" 28 | def EASY_PERMISSIONS_VERSION = "0.2.1" 29 | def OK_HTTP_VERSION = "3.4.1" 30 | def RETROFIT_VERSION = "2.1.0" 31 | def GSON_VERSION = "2.7" 32 | def EVENT_BUS_VERSION = "3.0.0" 33 | 34 | dependencies { 35 | compile fileTree(dir: 'libs', include: ['*.jar']) 36 | // Android Support Library 37 | compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION" 38 | compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION" 39 | // Field and method binding for Android views 40 | compile "com.jakewharton:butterknife:$BUTTER_KNIFE_VERSION" 41 | annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTER_KNIFE_VERSION" 42 | // Image Loading Library 43 | compile "jp.wasabeef:glide-transformations:$GLIDE_VERSION" 44 | // Permission Library 45 | compile "pub.devrel:easypermissions:$EASY_PERMISSIONS_VERSION" 46 | // Networking Library 47 | compile "com.squareup.okhttp3:okhttp:$OK_HTTP_VERSION" 48 | compile "com.squareup.okhttp3:logging-interceptor:$OK_HTTP_VERSION" 49 | compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION" 50 | compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION" 51 | compile "com.google.code.gson:gson:$GSON_VERSION" 52 | // Event Bus Library 53 | compile "org.greenrobot:eventbus:$EVENT_BUS_VERSION" 54 | } 55 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/chintan/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 35 | 36 | 37 | 42 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-Black.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-BlackItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-Bold.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-BoldItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-Italic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-Light.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-LightItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-MediumItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-Thin.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/Roboto-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/Roboto-ThinItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/RobotoCondensed-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/RobotoCondensed-Bold.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/RobotoCondensed-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/RobotoCondensed-BoldItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/RobotoCondensed-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/RobotoCondensed-Italic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/RobotoCondensed-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/RobotoCondensed-Light.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/RobotoCondensed-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/RobotoCondensed-LightItalic.ttf -------------------------------------------------------------------------------- /app/src/main/assets/fonts/RobotoCondensed-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/assets/fonts/RobotoCondensed-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/activity/HomeActivity.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import com.chintansoni.android.masterproject.R; 8 | import com.chintansoni.android.masterproject.base.BaseNavigationDrawerActivity; 9 | import com.chintansoni.android.masterproject.fragment.HomeImportFragment; 10 | 11 | public class HomeActivity extends BaseNavigationDrawerActivity { 12 | 13 | public static Intent getActivityIntent(Context context) { 14 | return new Intent(context, HomeActivity.class); 15 | } 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | 21 | loadDefaultFragment(); 22 | } 23 | 24 | private void loadDefaultFragment() { 25 | replaceFragment(HomeImportFragment.getFragment()); 26 | } 27 | 28 | @Override 29 | protected int getLayoutResource() { 30 | return R.layout.activity_home; 31 | } 32 | 33 | @Override 34 | protected int getMenuResource() { 35 | return RESOURCE_NO_MENU; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/activity/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.activity; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | 8 | import com.chintansoni.android.masterproject.R; 9 | import com.chintansoni.android.masterproject.R2; 10 | import com.chintansoni.android.masterproject.base.BaseAppCompatActivity; 11 | import com.chintansoni.android.masterproject.customview.RobotoTextInputEditText; 12 | import com.chintansoni.android.masterproject.service.BaseApi; 13 | import com.chintansoni.android.masterproject.service.api.LoginApi; 14 | import com.chintansoni.android.masterproject.util.FormValidationUtils; 15 | import com.google.gson.Gson; 16 | 17 | import org.greenrobot.eventbus.Subscribe; 18 | import org.greenrobot.eventbus.ThreadMode; 19 | 20 | import butterknife.BindView; 21 | import butterknife.OnClick; 22 | 23 | public class LoginActivity extends BaseAppCompatActivity { 24 | 25 | @BindView(R2.id.tiet_login_email) 26 | RobotoTextInputEditText mRobotoTextInputEditTextEmail; 27 | 28 | @BindView(R2.id.tiet_login_password) 29 | RobotoTextInputEditText mRobotoTextInputEditTextPassword; 30 | 31 | public static Intent getActivityIntent(Context context) { 32 | return new Intent(context, LoginActivity.class); 33 | } 34 | 35 | @OnClick(R2.id.btn_login_login) 36 | void onLoginClick() { 37 | if (FormValidationUtils.isEmpty(mRobotoTextInputEditTextEmail, "Please enter email")) 38 | return; 39 | if (!FormValidationUtils.isEmailValid(mRobotoTextInputEditTextEmail, "Please enter valid email")) 40 | return; 41 | if (FormValidationUtils.isEmpty(mRobotoTextInputEditTextPassword, "Please enter password")) 42 | return; 43 | 44 | launchActivity(HomeActivity.getActivityIntent(this)); 45 | // startApiService(LoginApi.getServiceIntent(this, mRobotoTextInputEditTextEmail.getText().toString().trim(), mRobotoTextInputEditTextPassword.getText().toString())); 46 | } 47 | 48 | @OnClick(R2.id.btn_login_register) 49 | void onRegisterClick() { 50 | 51 | } 52 | 53 | @Override 54 | protected int getLayoutResource() { 55 | return R.layout.activity_login; 56 | } 57 | 58 | @Override 59 | public void onResume() { 60 | super.onResume(); 61 | registerEventBus(); 62 | } 63 | 64 | @Override 65 | protected void onPause() { 66 | super.onPause(); 67 | unRegisterEventBus(); 68 | } 69 | 70 | @Subscribe(threadMode = ThreadMode.MAIN) 71 | public void onMessageEvent(BaseApi.EventBusMessage eventBusMessage) { 72 | if (eventBusMessage.event.equals(BaseApi.EventBusMessage.EVENT_SHOW_PROGRESS_DIALOG)) 73 | showProgressDialog(); 74 | else if (eventBusMessage.event.equals(BaseApi.EventBusMessage.EVENT_HIDE_PROGRESS_DIALOG)) 75 | hideProgressDialog(); 76 | else { 77 | if (eventBusMessage.object instanceof LoginApi.ApiResponse) 78 | parseSuccessResponse((LoginApi.ApiResponse) eventBusMessage.object); 79 | else if (eventBusMessage.object instanceof BaseApi.DefaultErrorResponse) { 80 | parseErrorResponse((BaseApi.DefaultErrorResponse) eventBusMessage.object); 81 | } 82 | } 83 | } 84 | 85 | private void parseSuccessResponse(LoginApi.ApiResponse apiResponse) { 86 | launchActivity(HomeActivity.getActivityIntent(this), true); 87 | } 88 | 89 | private void parseErrorResponse(BaseApi.DefaultErrorResponse defaultErrorResponse) { 90 | showSnackBar(defaultErrorResponse.getMessage()); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/activity/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.activity; 2 | 3 | import android.os.Handler; 4 | 5 | import com.chintansoni.android.masterproject.R; 6 | import com.chintansoni.android.masterproject.base.BaseAppCompatActivity; 7 | import com.chintansoni.android.masterproject.util.SharedPreferencesUtils; 8 | 9 | public class SplashActivity extends BaseAppCompatActivity { 10 | 11 | private final int SPLASH_TIMEOUT = 1000; 12 | private Handler mHandler = new Handler(); 13 | private Runnable mRunnable = new Runnable() { 14 | @Override 15 | public void run() { 16 | launchActivity(isUserLoggedIn() ? HomeActivity.getActivityIntent(SplashActivity.this) : LoginActivity.getActivityIntent(SplashActivity.this), true); 17 | } 18 | }; 19 | 20 | @Override 21 | protected void onResume() { 22 | super.onResume(); 23 | mHandler.postDelayed(mRunnable, SPLASH_TIMEOUT); 24 | } 25 | 26 | @Override 27 | protected int getLayoutResource() { 28 | return R.layout.activity_splash; 29 | } 30 | 31 | private boolean isUserLoggedIn() { 32 | return getBoolean(SharedPreferencesUtils.PREFERENCE_IS_USER_LOGGED_IN); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseAppCompatActivity.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.design.widget.CoordinatorLayout; 9 | import android.support.v4.app.DialogFragment; 10 | import android.support.v4.app.Fragment; 11 | import android.support.v4.app.FragmentTransaction; 12 | import android.support.v7.app.AppCompatActivity; 13 | import android.support.v7.app.AppCompatDialogFragment; 14 | import android.view.View; 15 | import android.view.inputmethod.InputMethodManager; 16 | import android.widget.Toast; 17 | 18 | import com.chintansoni.android.masterproject.R; 19 | import com.chintansoni.android.masterproject.activity.LoginActivity; 20 | import com.chintansoni.android.masterproject.util.DialogUtils; 21 | import com.chintansoni.android.masterproject.util.LogUtils; 22 | import com.chintansoni.android.masterproject.util.ProgressDialogUtils; 23 | import com.chintansoni.android.masterproject.util.SharedPreferencesUtils; 24 | import com.chintansoni.android.masterproject.util.SnackBarUtils; 25 | 26 | import org.greenrobot.eventbus.EventBus; 27 | 28 | import butterknife.BindView; 29 | import butterknife.ButterKnife; 30 | 31 | /** 32 | * Created by Chintan Soni - Senior Software Engineer (Android). 33 | */ 34 | 35 | public abstract class BaseAppCompatActivity extends AppCompatActivity { 36 | 37 | public int DEFAULT_REQUEST_CODE = 100; 38 | 39 | @BindView(R.id.coordinatorLayout) 40 | CoordinatorLayout mCoordinatorLayout; 41 | 42 | private int FRAGMENT_TRANSACTION_ADD = 200; 43 | private int FRAGMENT_TRANSACTION_REPLACE = 300; 44 | 45 | @Override 46 | protected void onCreate(@Nullable Bundle savedInstanceState) { 47 | super.onCreate(savedInstanceState); 48 | setContentView(getLayoutResource()); 49 | ButterKnife.bind(this); 50 | } 51 | 52 | protected abstract int getLayoutResource(); 53 | 54 | public void showSnackBar(int message) { 55 | SnackBarUtils.show(mCoordinatorLayout, message); 56 | } 57 | 58 | public void showSnackBar(String message) { 59 | SnackBarUtils.show(mCoordinatorLayout, message); 60 | } 61 | 62 | public void showSnackBar(int message, int duration) { 63 | SnackBarUtils.show(mCoordinatorLayout, message, duration); 64 | } 65 | 66 | public void showSnackBar(String message, int duration) { 67 | SnackBarUtils.show(mCoordinatorLayout, message, duration); 68 | } 69 | 70 | public void showProgressDialog() { 71 | ProgressDialogUtils.getInstance().show(this); 72 | } 73 | 74 | public void showProgressDialog(String title) { 75 | ProgressDialogUtils.getInstance().show(this, title); 76 | } 77 | 78 | public void showProgressDialog(String title, String message) { 79 | ProgressDialogUtils.getInstance().show(this, title, message); 80 | } 81 | 82 | public void hideProgressDialog() { 83 | ProgressDialogUtils.getInstance().hide(); 84 | } 85 | 86 | public void showAlertDialog(int title, int message, DialogInterface.OnClickListener onPositiveButtonClickListener) { 87 | DialogUtils.alert(this, title, message, R.string.default_alert_dialog_button_title, onPositiveButtonClickListener); 88 | } 89 | 90 | public void showAlertDialog(String title, String message, DialogInterface.OnClickListener onPositiveButtonClickListener) { 91 | DialogUtils.alert(this, title, message, R.string.default_alert_dialog_button_title, onPositiveButtonClickListener); 92 | } 93 | 94 | public void showConfirmDialog(int title, int message, int positiveButtonTitle, DialogInterface.OnClickListener onPositiveButtonClickListener, int negativeButtonTitle, DialogInterface.OnClickListener onNegativeButtonClickListener) { 95 | DialogUtils.confirm(this, title, message, positiveButtonTitle, onPositiveButtonClickListener, negativeButtonTitle, onNegativeButtonClickListener); 96 | } 97 | 98 | public void logError(Class tag, String message) { 99 | LogUtils.error(tag, message); 100 | } 101 | 102 | public void logInformation(Class tag, String message) { 103 | LogUtils.information(tag, message); 104 | } 105 | 106 | public void logDebug(Class tag, String message) { 107 | LogUtils.debug(tag, message); 108 | } 109 | 110 | public void logWarning(Class tag, String message) { 111 | LogUtils.warning(tag, message); 112 | } 113 | 114 | public void logVerbose(Class tag, String message) { 115 | LogUtils.verbose(tag, message); 116 | } 117 | 118 | public void logWTF(Class tag, String message) { 119 | LogUtils.wtf(tag, message); 120 | } 121 | 122 | public void launchActivity(Intent intent) { 123 | launchActivity(intent, false); 124 | } 125 | 126 | public void launchActivity(Intent intent, boolean finishCurrent) { 127 | launchActivity(intent, DEFAULT_REQUEST_CODE, finishCurrent); 128 | } 129 | 130 | public void launchActivity(Intent intent, int requestCode, boolean finishCurrent) { 131 | if (requestCode != DEFAULT_REQUEST_CODE) { 132 | startActivityForResult(intent, requestCode); 133 | } else { 134 | if (finishCurrent) { 135 | finish(); 136 | } 137 | startActivity(intent); 138 | } 139 | } 140 | 141 | public void addFragment(Fragment fragment) { 142 | addFragment(fragment, false); 143 | } 144 | 145 | public void addFragment(Fragment fragment, boolean addToBackStack) { 146 | loadFragment(fragment, FRAGMENT_TRANSACTION_ADD, addToBackStack); 147 | } 148 | 149 | public void replaceFragment(Fragment fragment) { 150 | replaceFragment(fragment, false); 151 | } 152 | 153 | public void replaceFragment(Fragment fragment, boolean addToBackStack) { 154 | loadFragment(fragment, FRAGMENT_TRANSACTION_REPLACE, addToBackStack); 155 | } 156 | 157 | private void loadFragment(Fragment fragment, int transactionType) { 158 | loadFragment(fragment, transactionType, false); 159 | } 160 | 161 | private void loadFragment(Fragment fragment, int transactionType, boolean addToBackStack) { 162 | loadFragment(fragment, R.id.frameLayout, transactionType, addToBackStack); 163 | } 164 | 165 | void loadFragment(Fragment fragment, int containerId, int transactionType, boolean addToBackStack) { 166 | String fragmentName = fragment.getClass().getSimpleName(); 167 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 168 | if (addToBackStack) { 169 | fragmentTransaction.addToBackStack(fragmentName); 170 | } 171 | if (transactionType == FRAGMENT_TRANSACTION_ADD) { 172 | fragmentTransaction.add(containerId, fragment, fragmentName); 173 | } else { 174 | fragmentTransaction.replace(containerId, fragment, fragmentName); 175 | } 176 | fragmentTransaction.commit(); 177 | } 178 | 179 | public void showDialogFragment(AppCompatDialogFragment appCompatDialogFragment) { 180 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 181 | fragmentTransaction.add(appCompatDialogFragment, appCompatDialogFragment.getClass().getSimpleName()); 182 | fragmentTransaction.commitAllowingStateLoss(); 183 | } 184 | 185 | public void showDialogFragment(BaseFragment targetFragment, DialogFragment appCompatDialogFragment, int requestCode) { 186 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 187 | appCompatDialogFragment.setTargetFragment(targetFragment, requestCode); 188 | fragmentTransaction.add(appCompatDialogFragment, appCompatDialogFragment.getClass().getSimpleName()); 189 | fragmentTransaction.commitAllowingStateLoss(); 190 | } 191 | 192 | public void showDialogFragment(BaseDialogFragment targetFragment, DialogFragment appCompatDialogFragment, int requestCode) { 193 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); 194 | appCompatDialogFragment.setTargetFragment(targetFragment, requestCode); 195 | fragmentTransaction.add(appCompatDialogFragment, appCompatDialogFragment.getClass().getSimpleName()); 196 | fragmentTransaction.commitAllowingStateLoss(); 197 | } 198 | 199 | protected void hideKeyboard() { 200 | View view = this.getCurrentFocus(); 201 | if (view != null) { 202 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 203 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 204 | } 205 | } 206 | 207 | public void showToast(int resourceId) { 208 | Toast.makeText(this, resourceId, Toast.LENGTH_SHORT).show(); 209 | } 210 | 211 | public void showToast(String resource) { 212 | Toast.makeText(this, resource, Toast.LENGTH_SHORT).show(); 213 | } 214 | 215 | public void showToast(int resourceId, int toastLong) { 216 | Toast.makeText(this, resourceId, toastLong).show(); 217 | } 218 | 219 | public void showToast(String resource, int toastLong) { 220 | Toast.makeText(this, resource, toastLong).show(); 221 | } 222 | 223 | public void startApiService(Intent intent) { 224 | startService(intent); 225 | } 226 | 227 | public void saveString(String key, String value) { 228 | SharedPreferencesUtils.getInstance(this).setString(key, value); 229 | } 230 | 231 | public void saveInt(String key, int value) { 232 | SharedPreferencesUtils.getInstance(this).setInt(key, value); 233 | } 234 | 235 | public String getString(String key) { 236 | return SharedPreferencesUtils.getInstance(this).getString(key); 237 | } 238 | 239 | public int getInt(String key) { 240 | return SharedPreferencesUtils.getInstance(this).getInt(key); 241 | } 242 | 243 | public void clearPreference(String key) { 244 | SharedPreferencesUtils.getInstance(this).clearKey(key); 245 | } 246 | 247 | protected void saveBoolean(String key, boolean value) { 248 | SharedPreferencesUtils.getInstance(this).setBoolean(key, value); 249 | } 250 | 251 | protected boolean getBoolean(String key) { 252 | return SharedPreferencesUtils.getInstance(this).getBoolean(key); 253 | } 254 | 255 | public void clearPreferences() { 256 | SharedPreferencesUtils.getInstance(this).clearPreferences(); 257 | } 258 | 259 | public void finishWithResultOk() { 260 | finishWithResultOk(null); 261 | } 262 | 263 | protected void finishWithResultOk(Intent intent) { 264 | if (intent == null) 265 | setResult(RESULT_OK); 266 | else 267 | setResult(RESULT_OK, intent); 268 | finish(); 269 | } 270 | 271 | protected void finishWithResultCancel() { 272 | finishWithResultCancel(null); 273 | } 274 | 275 | protected void finishWithResultCancel(Intent intent) { 276 | if (intent == null) 277 | setResult(RESULT_CANCELED); 278 | else 279 | setResult(RESULT_CANCELED, intent); 280 | finish(); 281 | } 282 | 283 | protected void registerEventBus() { 284 | EventBus.getDefault().register(this); 285 | } 286 | 287 | protected void unRegisterEventBus() { 288 | EventBus.getDefault().unregister(this); 289 | } 290 | 291 | public void logout() { 292 | clearPreferences(); 293 | Intent intent = LoginActivity.getActivityIntent(this); 294 | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); 295 | launchActivity(intent, true); 296 | } 297 | 298 | protected Fragment findFragment(Class fragment) { 299 | Fragment fragment1 = getSupportFragmentManager().findFragmentByTag(fragment.getSimpleName()); 300 | if (fragment1 != null && fragment1.isVisible()) 301 | return fragment1; 302 | else 303 | return null; 304 | } 305 | } 306 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseBottomSheetDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.app.Dialog; 4 | import android.os.Bundle; 5 | import android.support.design.widget.BottomSheetDialog; 6 | 7 | public abstract class BaseBottomSheetDialogFragment extends BaseDialogFragment { 8 | 9 | @Override 10 | public Dialog onCreateDialog(Bundle savedInstanceState) { 11 | return new BottomSheetDialog(getContext(), getTheme()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseConstants.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | public class BaseConstants { 4 | // Permission Constants 5 | public static final int REQUEST_CODE_PERMISSION_STORAGE = 100; 6 | public static final int REQUEST_CODE_SETTINGS_PERMISSION_STORAGE = 101; 7 | 8 | // Implicit Intent Constants 9 | public static final int REQUEST_CODE_CAPTURE_IMAGE = 200; 10 | public static final int REQUEST_CODE_PICK_IMAGE = 201; 11 | 12 | // Explicit Intent Constants 13 | public static final int REQUEST_CODE_SELECT_CITY = 300; 14 | public static final int REQUEST_CODE_SEARCH_COURT_INPUTS = 301; 15 | public static final int REQUEST_CODE_ADD_PLAYER = 302; 16 | 17 | public static final int RC_READ_EXTERNAL_STORAGE = 501; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v4.app.DialogFragment; 9 | import android.support.v7.app.AppCompatDialogFragment; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | 14 | import org.greenrobot.eventbus.EventBus; 15 | 16 | import butterknife.ButterKnife; 17 | 18 | public abstract class BaseDialogFragment extends AppCompatDialogFragment { 19 | 20 | private BaseAppCompatActivity mBaseAppCompatActivity; 21 | 22 | @Nullable 23 | @Override 24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 25 | View view = inflater.inflate(getLayoutResource(), null); 26 | ButterKnife.bind(this, view); 27 | return view; 28 | } 29 | 30 | @Override 31 | public void onAttach(Context context) { 32 | super.onAttach(context); 33 | mBaseAppCompatActivity = (BaseAppCompatActivity) context; 34 | } 35 | 36 | protected abstract int getLayoutResource(); 37 | 38 | protected void hideKeyBoard() { 39 | ((BaseAppCompatActivity) getActivity()).hideKeyboard(); 40 | } 41 | 42 | public void showDialogFragment(AppCompatDialogFragment appCompatDialogFragment) { 43 | mBaseAppCompatActivity.showDialogFragment(appCompatDialogFragment); 44 | } 45 | 46 | public void showDialogFragment(BaseDialogFragment targetFragment, DialogFragment appCompatDialogFragment) { 47 | mBaseAppCompatActivity.showDialogFragment(targetFragment, appCompatDialogFragment, ((BaseAppCompatActivity) getActivity()).DEFAULT_REQUEST_CODE); 48 | } 49 | 50 | public void launchActivity(Intent intent, int requestCode) { 51 | mBaseAppCompatActivity.launchActivity(intent, requestCode, false); 52 | } 53 | 54 | public void showToast(int resourceId) { 55 | mBaseAppCompatActivity.showToast(resourceId); 56 | } 57 | 58 | protected void showProgressDialog() { 59 | mBaseAppCompatActivity.showProgressDialog(); 60 | } 61 | 62 | protected void hideProgressDialog() { 63 | mBaseAppCompatActivity.hideProgressDialog(); 64 | } 65 | 66 | protected void registerEventBus() { 67 | EventBus.getDefault().register(this); 68 | } 69 | 70 | protected void unRegisterEventBus() { 71 | EventBus.getDefault().unregister(this); 72 | } 73 | 74 | public void saveString(String key, String value) { 75 | mBaseAppCompatActivity.saveString(key, value); 76 | } 77 | 78 | public void saveInt(String key, int value) { 79 | mBaseAppCompatActivity.saveInt(key, value); 80 | } 81 | 82 | public String getString(String key) { 83 | return mBaseAppCompatActivity.getString(key); 84 | } 85 | 86 | public int getInt(String key) { 87 | return mBaseAppCompatActivity.getInt(key); 88 | } 89 | 90 | public void clearPreference(String key) { 91 | mBaseAppCompatActivity.clearPreference(key); 92 | } 93 | 94 | protected void saveBoolean(String key, boolean value) { 95 | mBaseAppCompatActivity.saveBoolean(key, value); 96 | } 97 | 98 | protected boolean getBoolean(String key) { 99 | return mBaseAppCompatActivity.getBoolean(key); 100 | } 101 | 102 | public void clearPreferences() { 103 | mBaseAppCompatActivity.clearPreferences(); 104 | } 105 | 106 | protected void startApiService(Intent intent) { 107 | mBaseAppCompatActivity.startApiService(intent); 108 | } 109 | 110 | public void showSnackBar(String message) { 111 | mBaseAppCompatActivity.showSnackBar(message); 112 | } 113 | 114 | public void showAlertDialog(int title, int message, DialogInterface.OnClickListener onClickListener) { 115 | mBaseAppCompatActivity.showAlertDialog(title, message, onClickListener); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v4.app.DialogFragment; 9 | import android.support.v4.app.Fragment; 10 | import android.support.v7.app.AppCompatDialogFragment; 11 | import android.view.LayoutInflater; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | 15 | 16 | import com.chintansoni.android.masterproject.R; 17 | 18 | import org.greenrobot.eventbus.EventBus; 19 | 20 | import butterknife.ButterKnife; 21 | 22 | public abstract class BaseFragment extends Fragment { 23 | 24 | protected BaseAppCompatActivity mBaseAppCompatActivity; 25 | 26 | private int FRAGMENT_TRANSACTION_ADD = 200; 27 | private int FRAGMENT_TRANSACTION_REPLACE = 300; 28 | 29 | @Nullable 30 | @Override 31 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 32 | super.onCreateView(inflater, container, savedInstanceState); 33 | View view = inflater.inflate(getResourceLayout(), container, false); 34 | ButterKnife.bind(this, view); 35 | return view; 36 | } 37 | 38 | protected abstract int getResourceLayout(); 39 | 40 | protected void setTitle(String title) { 41 | mBaseAppCompatActivity.getSupportActionBar().setTitle(title); 42 | } 43 | 44 | @Override 45 | public void onAttach(Context context) { 46 | super.onAttach(context); 47 | mBaseAppCompatActivity = (BaseAppCompatActivity) context; 48 | } 49 | 50 | protected void launchActivity(Intent intent) { 51 | mBaseAppCompatActivity.launchActivity(intent); 52 | } 53 | 54 | public void launchActivity(Intent intent, boolean finishCurrent) { 55 | launchActivity(intent, mBaseAppCompatActivity.DEFAULT_REQUEST_CODE, finishCurrent); 56 | } 57 | 58 | protected void launchActivity(Intent intent, int requestCode, boolean finishCurrent) { 59 | // mBaseAppCompatActivity.launchActivity(intent, requestCode, finishCurrent); 60 | startActivityForResult(intent, requestCode); 61 | } 62 | 63 | public void showSnackBar(String message) { 64 | mBaseAppCompatActivity.showSnackBar(message); 65 | } 66 | 67 | public void showDialogFragment(AppCompatDialogFragment appCompatDialogFragment) { 68 | mBaseAppCompatActivity.showDialogFragment(appCompatDialogFragment); 69 | } 70 | 71 | public void showDialogFragment(BaseFragment targetFragment, DialogFragment appCompatDialogFragment) { 72 | mBaseAppCompatActivity.showDialogFragment(targetFragment, appCompatDialogFragment, mBaseAppCompatActivity.DEFAULT_REQUEST_CODE); 73 | } 74 | 75 | public void showConfirmDialog(int title, int message, int positiveButtonTitle, DialogInterface.OnClickListener onPositiveButtonClickListener, int negativeButtonTitle, DialogInterface.OnClickListener onNegativeButtonClickListener) { 76 | mBaseAppCompatActivity.showConfirmDialog(title, message, positiveButtonTitle, onPositiveButtonClickListener, negativeButtonTitle, onNegativeButtonClickListener); 77 | } 78 | 79 | public void clearPreferences() { 80 | mBaseAppCompatActivity.clearPreferences(); 81 | } 82 | 83 | protected void showProgressDialog() { 84 | mBaseAppCompatActivity.showProgressDialog(); 85 | } 86 | 87 | protected void hideProgressDialog() { 88 | mBaseAppCompatActivity.hideProgressDialog(); 89 | } 90 | 91 | protected void saveString(String key, String value) { 92 | mBaseAppCompatActivity.saveString(key, value); 93 | } 94 | 95 | protected String getString(String key) { 96 | return mBaseAppCompatActivity.getString(key); 97 | } 98 | 99 | protected void saveBoolean(String key, boolean value) { 100 | mBaseAppCompatActivity.saveBoolean(key, value); 101 | } 102 | 103 | protected void showToast(String message) { 104 | mBaseAppCompatActivity.showToast(message); 105 | } 106 | 107 | //----------------------------- [Start] Sub Fragment Operations ---------------------------------------- 108 | 109 | public void addSubFragment(Fragment fragment) { 110 | addSubFragment(fragment, false); 111 | } 112 | 113 | public void addSubFragment(Fragment fragment, boolean addToBackStack) { 114 | loadSubFragment(fragment, FRAGMENT_TRANSACTION_ADD, addToBackStack); 115 | } 116 | 117 | public void replaceSubFragment(Fragment fragment) { 118 | replaceSubFragment(fragment, false); 119 | } 120 | 121 | public void replaceSubFragment(Fragment fragment, boolean addToBackStack) { 122 | loadSubFragment(fragment, FRAGMENT_TRANSACTION_REPLACE, addToBackStack); 123 | } 124 | 125 | private void loadSubFragment(Fragment fragment, int transactionType) { 126 | loadSubFragment(fragment, transactionType, false); 127 | } 128 | 129 | private void loadSubFragment(Fragment fragment, int transactionType, boolean addToBackStack) { 130 | mBaseAppCompatActivity.loadFragment(fragment, R.id.frameLayoutSub, transactionType, addToBackStack); 131 | } 132 | 133 | //----------------------------- [End] Sub Fragment Operations ---------------------------------------- 134 | 135 | //----------------------------- [Start] Fragment Operations ---------------------------------------- 136 | 137 | public void addFragment(Fragment fragment) { 138 | addFragment(fragment, false); 139 | } 140 | 141 | public void addFragment(Fragment fragment, boolean addToBackStack) { 142 | loadFragment(fragment, FRAGMENT_TRANSACTION_ADD, addToBackStack); 143 | } 144 | 145 | public void replaceFragment(Fragment fragment) { 146 | replaceFragment(fragment, false); 147 | } 148 | 149 | public void replaceFragment(Fragment fragment, boolean addToBackStack) { 150 | loadFragment(fragment, FRAGMENT_TRANSACTION_REPLACE, addToBackStack); 151 | } 152 | 153 | private void loadFragment(Fragment fragment, int transactionType) { 154 | loadFragment(fragment, transactionType, false); 155 | } 156 | 157 | private void loadFragment(Fragment fragment, int transactionType, boolean addToBackStack) { 158 | loadFragment(fragment, R.id.frameLayout, transactionType, addToBackStack); 159 | } 160 | 161 | private void loadFragment(Fragment fragment, int containerId, int transactionType, boolean addToBackStack) { 162 | mBaseAppCompatActivity.loadFragment(fragment, containerId, transactionType, addToBackStack); 163 | } 164 | 165 | //----------------------------- [Start] Fragment Operations ---------------------------------------- 166 | 167 | protected void registerEventBus() { 168 | EventBus.getDefault().register(this); 169 | } 170 | 171 | protected void unRegisterEventBus() { 172 | EventBus.getDefault().unregister(this); 173 | } 174 | 175 | public void logError(Class tag, String message) { 176 | mBaseAppCompatActivity.logError(tag, message); 177 | } 178 | 179 | public void logInformation(Class tag, String message) { 180 | mBaseAppCompatActivity.logInformation(tag, message); 181 | } 182 | 183 | public void logDebug(Class tag, String message) { 184 | mBaseAppCompatActivity.logDebug(tag, message); 185 | } 186 | 187 | public void logWarning(Class tag, String message) { 188 | mBaseAppCompatActivity.logWarning(tag, message); 189 | } 190 | 191 | public void logVerbose(Class tag, String message) { 192 | mBaseAppCompatActivity.logVerbose(tag, message); 193 | } 194 | 195 | public void logWTF(Class tag, String message) { 196 | mBaseAppCompatActivity.logWTF(tag, message); 197 | } 198 | 199 | protected void startApiService(Intent intent) { 200 | mBaseAppCompatActivity.startApiService(intent); 201 | } 202 | 203 | protected void finishWithResultOk() { 204 | mBaseAppCompatActivity.finishWithResultOk(); 205 | } 206 | 207 | public void showAlertDialog(int title, int message, DialogInterface.OnClickListener onClickListener) { 208 | mBaseAppCompatActivity.showAlertDialog(title, message, onClickListener); 209 | } 210 | 211 | public void showAlertDialog(String title, String message, DialogInterface.OnClickListener onClickListener) { 212 | mBaseAppCompatActivity.showAlertDialog(title, message, onClickListener); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseNavigationDrawerActivity.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | import android.support.annotation.Nullable; 6 | import android.support.design.widget.NavigationView; 7 | import android.support.v4.view.GravityCompat; 8 | import android.support.v4.widget.DrawerLayout; 9 | import android.support.v7.app.ActionBarDrawerToggle; 10 | import android.view.MenuItem; 11 | 12 | import com.chintansoni.android.masterproject.R; 13 | import com.chintansoni.android.masterproject.R2; 14 | 15 | import butterknife.BindView; 16 | 17 | public abstract class BaseNavigationDrawerActivity extends BaseToolBarActivity implements NavigationView.OnNavigationItemSelectedListener { 18 | 19 | @BindView(R2.id.dl_home) 20 | protected DrawerLayout mDrawerLayout; 21 | 22 | @BindView(R2.id.nv_home) 23 | NavigationView mNavigationView; 24 | 25 | @Override 26 | protected void onCreate(@Nullable Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | 29 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( 30 | this, 31 | mDrawerLayout, 32 | getmToolbar(), 33 | R.string.navigation_drawer_open, 34 | R.string.navigation_drawer_close); 35 | mDrawerLayout.addDrawerListener(toggle); 36 | toggle.syncState(); 37 | 38 | mNavigationView.setNavigationItemSelectedListener(this); 39 | } 40 | 41 | @Override 42 | public void onBackPressed() { 43 | if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { 44 | mDrawerLayout.closeDrawer(GravityCompat.START); 45 | } else { 46 | super.onBackPressed(); 47 | } 48 | } 49 | 50 | @SuppressWarnings("StatementWithEmptyBody") 51 | @Override 52 | public boolean onNavigationItemSelected(@NonNull MenuItem item) { 53 | // Handle navigation view item clicks here. 54 | int id = item.getItemId(); 55 | mDrawerLayout.closeDrawer(GravityCompat.START); 56 | return true; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import java.lang.reflect.Constructor; 9 | import java.lang.reflect.InvocationTargetException; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public abstract class BaseRecyclerAdapter extends RecyclerView.Adapter { 14 | 15 | private int mModelLayout; 16 | private Class mViewHolderClass; 17 | private List mList = new ArrayList<>(); 18 | 19 | public BaseRecyclerAdapter(Class viewHolderClass, int modelLayout) { 20 | mModelLayout = modelLayout; 21 | mViewHolderClass = viewHolderClass; 22 | } 23 | 24 | public void setmList(ArrayList mList) { 25 | this.mList = mList; 26 | } 27 | 28 | @Override 29 | public int getItemCount() { 30 | return mList.size(); 31 | } 32 | 33 | public T getItem(int position) { 34 | return mList.get(position); 35 | } 36 | 37 | @Override 38 | public VH onCreateViewHolder(ViewGroup parent, int viewType) { 39 | ViewGroup view = (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false); 40 | try { 41 | Constructor constructor = mViewHolderClass.getConstructor(View.class); 42 | return constructor.newInstance(view); 43 | } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { 44 | throw new RuntimeException(e); 45 | } 46 | } 47 | 48 | @Override 49 | public void onBindViewHolder(VH viewHolder, int position) { 50 | T model = getItem(position); 51 | populateViewHolder(viewHolder, model, position); 52 | } 53 | 54 | @Override 55 | public int getItemViewType(int position) { 56 | return mModelLayout; 57 | } 58 | 59 | abstract protected void populateViewHolder(VH viewHolder, T model, int position); 60 | 61 | public void addItem(T t) { 62 | int index = mList.size(); 63 | mList.add(index, t); 64 | notifyItemInserted(index); 65 | } 66 | 67 | public void updateItem(int position, T t) { 68 | mList.set(position, t); 69 | notifyItemChanged(position); 70 | } 71 | 72 | public void removeItem(int position) { 73 | mList.remove(position); 74 | // notifyItemRemoved(position); 75 | notifyDataSetChanged(); 76 | } 77 | 78 | public void setItems(List items) { 79 | mList = items; 80 | notifyDataSetChanged(); 81 | } 82 | } -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseSingleSelectRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import java.lang.reflect.Constructor; 9 | import java.lang.reflect.InvocationTargetException; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public abstract class BaseSingleSelectRecyclerAdapter extends RecyclerView.Adapter { 14 | 15 | private int mModelLayout; 16 | private Class mViewHolderClass; 17 | private List mList = new ArrayList<>(); 18 | private int mSelectedPosition = -1; 19 | 20 | public BaseSingleSelectRecyclerAdapter(Class viewHolderClass, int modelLayout) { 21 | mModelLayout = modelLayout; 22 | mViewHolderClass = viewHolderClass; 23 | } 24 | 25 | public int getmSelectedPosition() { 26 | return mSelectedPosition; 27 | } 28 | 29 | public void setmList(ArrayList mList) { 30 | this.mList = mList; 31 | } 32 | 33 | @Override 34 | public int getItemCount() { 35 | return mList.size(); 36 | } 37 | 38 | public T getItem(int position) { 39 | return mList.get(position); 40 | } 41 | 42 | @Override 43 | public VH onCreateViewHolder(ViewGroup parent, int viewType) { 44 | ViewGroup view = (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false); 45 | try { 46 | Constructor constructor = mViewHolderClass.getConstructor(View.class); 47 | return constructor.newInstance(view); 48 | } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | 53 | @Override 54 | public void onBindViewHolder(VH viewHolder, int position) { 55 | T model = getItem(position); 56 | populateViewHolder(viewHolder, model, position); 57 | } 58 | 59 | @Override 60 | public int getItemViewType(int position) { 61 | return mModelLayout; 62 | } 63 | 64 | abstract protected void populateViewHolder(VH viewHolder, T model, int position); 65 | 66 | public void addItem(T t) { 67 | int index = mList.size(); 68 | mList.add(index, t); 69 | notifyItemInserted(index); 70 | } 71 | 72 | public void updateItem(int position, T t) { 73 | mList.set(position, t); 74 | notifyItemChanged(position); 75 | } 76 | 77 | public void removeItem(int position) { 78 | mList.remove(position); 79 | notifyItemRemoved(position); 80 | } 81 | 82 | public void setItems(List items) { 83 | mList = items; 84 | notifyDataSetChanged(); 85 | } 86 | 87 | public void setSelectedItem(int position) { 88 | notifyItemChanged(mSelectedPosition); 89 | mSelectedPosition = position; 90 | notifyItemChanged(mSelectedPosition); 91 | } 92 | } -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseToolBarActivity.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.Menu; 7 | 8 | import com.chintansoni.android.masterproject.R2; 9 | 10 | import butterknife.BindView; 11 | 12 | public abstract class BaseToolBarActivity extends BaseAppCompatActivity { 13 | 14 | protected static final int RESOURCE_NO_MENU = 0; 15 | @BindView(R2.id.toolbar) 16 | public Toolbar mToolbar; 17 | 18 | public Toolbar getmToolbar() { 19 | return mToolbar; 20 | } 21 | 22 | @Override 23 | protected void onCreate(@Nullable Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setToolBar(); 26 | } 27 | 28 | public void setToolBar() { 29 | setSupportActionBar(mToolbar); 30 | } 31 | 32 | protected abstract int getMenuResource(); 33 | 34 | @Override 35 | public boolean onCreateOptionsMenu(Menu menu) { 36 | if (getMenuResource() == RESOURCE_NO_MENU) 37 | return super.onCreateOptionsMenu(menu); 38 | else { 39 | getMenuInflater().inflate(getMenuResource(), menu); 40 | return true; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/base/BaseViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.base; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.View; 5 | 6 | import butterknife.ButterKnife; 7 | 8 | public class BaseViewHolder extends RecyclerView.ViewHolder { 9 | public BaseViewHolder(View itemView) { 10 | super(itemView); 11 | ButterKnife.bind(this, itemView); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/bottomsheet/SelectImageUsingBottomSheet.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.bottomsheet; 2 | 3 | import android.content.Context; 4 | 5 | import com.chintansoni.android.masterproject.R; 6 | import com.chintansoni.android.masterproject.base.BaseBottomSheetDialogFragment; 7 | 8 | import butterknife.OnClick; 9 | 10 | public class SelectImageUsingBottomSheet extends BaseBottomSheetDialogFragment { 11 | 12 | private OnSelectUsingListener mOnSelectUsingListener; 13 | 14 | public void setmOnSelectUsingListener(OnSelectUsingListener mOnSelectUsingListener) { 15 | this.mOnSelectUsingListener = mOnSelectUsingListener; 16 | } 17 | 18 | @Override 19 | public void onAttach(Context context) { 20 | super.onAttach(context); 21 | if (context instanceof OnSelectUsingListener) 22 | mOnSelectUsingListener = (OnSelectUsingListener) context; 23 | } 24 | 25 | @OnClick(R.id.btn_bottom_sheet_select_image_using_camera) 26 | void onCameraClick() { 27 | if (mOnSelectUsingListener != null) 28 | mOnSelectUsingListener.onCameraClick(); 29 | dismiss(); 30 | } 31 | 32 | @OnClick(R.id.btn_bottom_sheet_select_image_using_gallery) 33 | void onGalleryClick() { 34 | if (mOnSelectUsingListener != null) 35 | mOnSelectUsingListener.onGalleryClick(); 36 | dismiss(); 37 | } 38 | 39 | @Override 40 | protected int getLayoutResource() { 41 | return R.layout.bottom_sheet_select_image_using; 42 | } 43 | 44 | public interface OnSelectUsingListener { 45 | void onCameraClick(); 46 | 47 | void onGalleryClick(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/customview/RobotoAutoCompleteTextView.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.customview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Typeface; 6 | import android.support.v7.widget.AppCompatAutoCompleteTextView; 7 | import android.util.AttributeSet; 8 | 9 | import com.chintansoni.android.masterproject.R; 10 | 11 | /** 12 | * Created by Chintan Soni - Senior Software Engineer (Android). 13 | */ 14 | 15 | public class RobotoAutoCompleteTextView extends AppCompatAutoCompleteTextView { 16 | public RobotoAutoCompleteTextView(Context context) { 17 | super(context); 18 | } 19 | 20 | public RobotoAutoCompleteTextView(Context context, AttributeSet attrs) { 21 | super(context, attrs); 22 | setFont(attrs); 23 | } 24 | 25 | public RobotoAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) { 26 | super(context, attrs, defStyleAttr); 27 | setFont(attrs); 28 | } 29 | 30 | public void setFont(AttributeSet attributeSet) { 31 | if (attributeSet != null) { 32 | TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.roboto); 33 | int font = typedArray.getInteger(R.styleable.roboto_font, 9); 34 | Typeface myTypeface = Typeface 35 | .createFromAsset( 36 | getContext().getAssets(), 37 | "fonts/" + getResources().getStringArray(R.array.roboto_fonts)[font] 38 | ); 39 | setTypeface(myTypeface); 40 | typedArray.recycle(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/customview/RobotoButton.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.customview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Typeface; 6 | import android.support.v7.widget.AppCompatButton; 7 | import android.util.AttributeSet; 8 | 9 | import com.chintansoni.android.masterproject.R; 10 | 11 | /** 12 | * Created by Chintan Soni - Senior Software Engineer (Android). 13 | */ 14 | public class RobotoButton extends AppCompatButton { 15 | public RobotoButton(Context context) { 16 | super(context); 17 | } 18 | 19 | public RobotoButton(Context context, AttributeSet attrs) { 20 | super(context, attrs); 21 | setFont(attrs); 22 | } 23 | 24 | public RobotoButton(Context context, AttributeSet attrs, int defStyleAttr) { 25 | super(context, attrs, defStyleAttr); 26 | setFont(attrs); 27 | } 28 | 29 | public void setFont(AttributeSet attributeSet) { 30 | if (attributeSet != null) { 31 | TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.roboto); 32 | int font = typedArray.getInteger(R.styleable.roboto_font, 9); 33 | Typeface myTypeface = Typeface 34 | .createFromAsset( 35 | getContext().getAssets(), 36 | "fonts/" + getResources().getStringArray(R.array.roboto_fonts)[font] 37 | ); 38 | setTypeface(myTypeface); 39 | typedArray.recycle(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/customview/RobotoCheckBox.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.customview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Typeface; 6 | import android.support.v7.widget.AppCompatCheckBox; 7 | import android.util.AttributeSet; 8 | 9 | import com.chintansoni.android.masterproject.R; 10 | 11 | /** 12 | * Created by Chintan Soni - Senior Software Engineer (Android). 13 | */ 14 | 15 | public class RobotoCheckBox extends AppCompatCheckBox { 16 | public RobotoCheckBox(Context context) { 17 | super(context); 18 | } 19 | 20 | public RobotoCheckBox(Context context, AttributeSet attrs) { 21 | super(context, attrs); 22 | setFont(attrs); 23 | } 24 | 25 | public RobotoCheckBox(Context context, AttributeSet attrs, int defStyleAttr) { 26 | super(context, attrs, defStyleAttr); 27 | setFont(attrs); 28 | } 29 | 30 | public void setFont(AttributeSet attributeSet) { 31 | if (attributeSet != null) { 32 | TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.roboto); 33 | int font = typedArray.getInteger(R.styleable.roboto_font, 9); 34 | Typeface myTypeface = Typeface 35 | .createFromAsset( 36 | getContext().getAssets(), 37 | "fonts/" + getResources().getStringArray(R.array.roboto_fonts)[font] 38 | ); 39 | setTypeface(myTypeface); 40 | typedArray.recycle(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/customview/RobotoRadioButton.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.customview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Typeface; 6 | import android.support.v7.widget.AppCompatRadioButton; 7 | import android.util.AttributeSet; 8 | 9 | import com.chintansoni.android.masterproject.R; 10 | 11 | /** 12 | * Created by Chintan Soni - Senior Software Engineer (Android). 13 | */ 14 | 15 | public class RobotoRadioButton extends AppCompatRadioButton { 16 | public RobotoRadioButton(Context context) { 17 | super(context); 18 | } 19 | 20 | public RobotoRadioButton(Context context, AttributeSet attrs) { 21 | super(context, attrs); 22 | setFont(attrs); 23 | } 24 | 25 | public RobotoRadioButton(Context context, AttributeSet attrs, int defStyleAttr) { 26 | super(context, attrs, defStyleAttr); 27 | setFont(attrs); 28 | } 29 | 30 | public void setFont(AttributeSet attributeSet) { 31 | if (attributeSet != null) { 32 | TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.roboto); 33 | int font = typedArray.getInteger(R.styleable.roboto_font, 9); 34 | Typeface myTypeface = Typeface 35 | .createFromAsset( 36 | getContext().getAssets(), 37 | "fonts/" + getResources().getStringArray(R.array.roboto_fonts)[font] 38 | ); 39 | setTypeface(myTypeface); 40 | typedArray.recycle(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/customview/RobotoTextInputEditText.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.customview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Typeface; 6 | import android.support.design.widget.TextInputEditText; 7 | import android.util.AttributeSet; 8 | 9 | import com.chintansoni.android.masterproject.R; 10 | 11 | /** 12 | * Created by Chintan Soni - Senior Software Engineer (Android). 13 | */ 14 | 15 | public class RobotoTextInputEditText extends TextInputEditText { 16 | public RobotoTextInputEditText(Context context) { 17 | super(context); 18 | } 19 | 20 | public RobotoTextInputEditText(Context context, AttributeSet attrs) { 21 | super(context, attrs); 22 | setFont(attrs); 23 | } 24 | 25 | public RobotoTextInputEditText(Context context, AttributeSet attrs, int defStyleAttr) { 26 | super(context, attrs, defStyleAttr); 27 | setFont(attrs); 28 | } 29 | 30 | public void setFont(AttributeSet attributeSet) { 31 | if (attributeSet != null) { 32 | TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.roboto); 33 | int font = typedArray.getInteger(R.styleable.roboto_font, 9); 34 | Typeface myTypeface = Typeface 35 | .createFromAsset( 36 | getContext().getAssets(), 37 | "fonts/" + getResources().getStringArray(R.array.roboto_fonts)[font] 38 | ); 39 | setTypeface(myTypeface); 40 | typedArray.recycle(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/customview/RobotoTextView.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.customview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Typeface; 6 | import android.support.v7.widget.AppCompatTextView; 7 | import android.util.AttributeSet; 8 | 9 | import com.chintansoni.android.masterproject.R; 10 | 11 | /** 12 | * Created by Chintan Soni - Senior Software Engineer (Android). 13 | */ 14 | 15 | public class RobotoTextView extends AppCompatTextView { 16 | public RobotoTextView(Context context) { 17 | super(context); 18 | } 19 | 20 | public RobotoTextView(Context context, AttributeSet attrs) { 21 | super(context, attrs); 22 | setFont(attrs); 23 | } 24 | 25 | public RobotoTextView(Context context, AttributeSet attrs, int defStyleAttr) { 26 | super(context, attrs, defStyleAttr); 27 | setFont(attrs); 28 | } 29 | 30 | public void setFont(AttributeSet attributeSet) { 31 | if (attributeSet != null) { 32 | TypedArray typedArray = getContext().obtainStyledAttributes(attributeSet, R.styleable.roboto); 33 | int font = typedArray.getInteger(R.styleable.roboto_font, 9); 34 | Typeface myTypeface = Typeface 35 | .createFromAsset( 36 | getContext().getAssets(), 37 | "fonts/" + getResources().getStringArray(R.array.roboto_fonts)[font] 38 | ); 39 | setTypeface(myTypeface); 40 | typedArray.recycle(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/fragment/HomeImportFragment.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.fragment; 2 | 3 | import android.Manifest; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.os.Environment; 8 | import android.provider.MediaStore; 9 | import android.support.v4.app.Fragment; 10 | import android.support.v4.content.FileProvider; 11 | import android.support.v7.widget.AppCompatImageView; 12 | 13 | import com.bumptech.glide.Glide; 14 | import com.chintansoni.android.masterproject.R; 15 | import com.chintansoni.android.masterproject.R2; 16 | import com.chintansoni.android.masterproject.base.BaseConstants; 17 | import com.chintansoni.android.masterproject.base.BaseFragment; 18 | import com.chintansoni.android.masterproject.bottomsheet.SelectImageUsingBottomSheet; 19 | import com.chintansoni.android.masterproject.util.File.FileUtils; 20 | 21 | import java.io.File; 22 | import java.io.IOException; 23 | import java.text.SimpleDateFormat; 24 | import java.util.Date; 25 | import java.util.List; 26 | import java.util.Locale; 27 | 28 | import butterknife.BindView; 29 | import butterknife.OnClick; 30 | import pub.devrel.easypermissions.AppSettingsDialog; 31 | import pub.devrel.easypermissions.EasyPermissions; 32 | 33 | /** 34 | * Created by Chintan Soni - Senior Software Engineer (Android). 35 | */ 36 | 37 | public class HomeImportFragment extends BaseFragment implements EasyPermissions.PermissionCallbacks, SelectImageUsingBottomSheet.OnSelectUsingListener { 38 | 39 | @BindView(R2.id.iv_import) 40 | AppCompatImageView mAppCompatImageView; 41 | 42 | private String mCurrentPhotoPath; 43 | 44 | public static Fragment getFragment() { 45 | return new HomeImportFragment(); 46 | } 47 | 48 | @OnClick(R2.id.iv_import) 49 | void onImageClick() { 50 | checkStoragePermission(); 51 | } 52 | 53 | @Override 54 | protected int getResourceLayout() { 55 | return R.layout.fragment_import; 56 | } 57 | 58 | private void checkStoragePermission() { 59 | String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}; 60 | if (EasyPermissions.hasPermissions(getContext(), perms)) { 61 | // Already have permission, do the thing 62 | initializeSelectImage(); 63 | } else { 64 | // Do not have permissions, request them now 65 | EasyPermissions.requestPermissions(this, getString(R.string.rationale_storage), BaseConstants.REQUEST_CODE_PERMISSION_STORAGE, perms); 66 | } 67 | } 68 | 69 | @Override 70 | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { 71 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); 72 | 73 | // Forward results to EasyPermissions 74 | EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this); 75 | } 76 | 77 | @Override 78 | public void onPermissionsGranted(int requestCode, List perms) { 79 | initializeSelectImage(); 80 | } 81 | 82 | @Override 83 | public void onPermissionsDenied(int requestCode, List perms) { 84 | if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) { 85 | new AppSettingsDialog.Builder(this, getString(R.string.rationale_never_ask_storage)) 86 | .setTitle(getString(R.string.title_settings_dialog)) 87 | .setPositiveButton(getString(R.string.title_settings_button_setting)) 88 | .setNegativeButton(getString(R.string.title_settings_button_cancel), null /* click listener */) 89 | .setRequestCode(BaseConstants.REQUEST_CODE_SETTINGS_PERMISSION_STORAGE) 90 | .build() 91 | .show(); 92 | } 93 | } 94 | 95 | public void initializeSelectImage() { 96 | SelectImageUsingBottomSheet selectImageUsingBottomSheet = new SelectImageUsingBottomSheet(); 97 | selectImageUsingBottomSheet.setmOnSelectUsingListener(this); 98 | showDialogFragment(selectImageUsingBottomSheet); 99 | } 100 | 101 | public void pickImage() { 102 | Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); 103 | intent.addCategory(Intent.CATEGORY_OPENABLE); 104 | intent.setType("image/*"); 105 | startActivityForResult(intent, BaseConstants.REQUEST_CODE_PICK_IMAGE); 106 | } 107 | 108 | @Override 109 | public void onCameraClick() { 110 | captureImage(); 111 | } 112 | 113 | @Override 114 | public void onGalleryClick() { 115 | pickImage(); 116 | } 117 | 118 | private void captureImage() { 119 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 120 | // Ensure that there's a camera activity to handle the intent 121 | if (takePictureIntent.resolveActivity(getContext().getPackageManager()) != null) { 122 | // Create the File where the photo should go 123 | File photoFile = null; 124 | try { 125 | photoFile = createImageFile(); 126 | } catch (IOException ex) { 127 | // Error occurred while creating the File 128 | 129 | } 130 | // Continue only if the File was successfully created 131 | if (photoFile != null) { 132 | Uri photoURI = FileProvider.getUriForFile(getContext(), getContext().getPackageName() + ".fileprovider", photoFile); 133 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); 134 | startActivityForResult(takePictureIntent, BaseConstants.REQUEST_CODE_CAPTURE_IMAGE); 135 | } 136 | } 137 | } 138 | 139 | private File createImageFile() throws IOException { 140 | // Create an image file name 141 | String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); 142 | String imageFileName = "JPEG_" + timeStamp + "_"; 143 | File storageDir = getContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES); 144 | File image = File.createTempFile( 145 | imageFileName, /* prefix */ 146 | ".jpg",/* suffix */ 147 | storageDir/* directory */ 148 | ); 149 | 150 | // Save a file: path for use with ACTION_VIEW intents 151 | mCurrentPhotoPath = image.getAbsolutePath(); 152 | return image; 153 | } 154 | 155 | private void galleryAddPic() { 156 | Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); 157 | File f = new File(mCurrentPhotoPath); 158 | Uri contentUri = Uri.fromFile(f); 159 | mediaScanIntent.setData(contentUri); 160 | mBaseAppCompatActivity.sendBroadcast(mediaScanIntent); 161 | } 162 | 163 | @Override 164 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 165 | if (requestCode == BaseConstants.REQUEST_CODE_CAPTURE_IMAGE && resultCode == Activity.RESULT_OK) { 166 | galleryAddPic(); 167 | Glide.with(getContext()) 168 | .load(mCurrentPhotoPath) 169 | .into(mAppCompatImageView); 170 | } else if (requestCode == BaseConstants.REQUEST_CODE_SETTINGS_PERMISSION_STORAGE) { 171 | checkStoragePermission(); 172 | } else if (requestCode == BaseConstants.REQUEST_CODE_PICK_IMAGE && resultCode == Activity.RESULT_OK) { 173 | if (data != null) { 174 | mCurrentPhotoPath = FileUtils.getFile(getContext(), data.getData()).getAbsolutePath(); 175 | Glide.with(getContext()) 176 | .load(mCurrentPhotoPath) 177 | .into(mAppCompatImageView); 178 | } 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/service/ApiService.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.service; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | 7 | import com.chintansoni.android.masterproject.service.api.CitiesApi; 8 | import com.chintansoni.android.masterproject.service.api.LoginApi; 9 | import com.chintansoni.android.masterproject.service.api.NotificationsDeleteApi; 10 | import com.chintansoni.android.masterproject.service.api.UploadImageApi; 11 | import com.chintansoni.android.masterproject.util.NetworkUtils; 12 | 13 | import okhttp3.OkHttpClient; 14 | import retrofit2.Retrofit; 15 | import retrofit2.converter.gson.GsonConverterFactory; 16 | 17 | public class ApiService extends Service { 18 | 19 | // TODO: Replace with your base URL 20 | public static final String BASE_URL = ""; 21 | 22 | private static final String API_URL = BASE_URL + "api/"; 23 | 24 | private OkHttpClient mOkHttpClient; 25 | 26 | public ApiService() { 27 | } 28 | 29 | @Override 30 | public IBinder onBind(Intent intent) { 31 | return null; 32 | } 33 | 34 | @Override 35 | public void onCreate() { 36 | super.onCreate(); 37 | mOkHttpClient = OkClientFactory.provideOkHttpClient(getApplication()); 38 | } 39 | 40 | @Override 41 | public int onStartCommand(Intent intent, int flags, int startId) { 42 | if (intent == null) 43 | return super.onStartCommand(intent, flags, startId); 44 | 45 | // This is the only place we need to check for internet connection 46 | if (!NetworkUtils.isInternetAvailable(this)) 47 | return super.onStartCommand(intent, flags, startId); 48 | 49 | String action = intent.getAction(); 50 | switch (action) { 51 | case LoginApi.ACTION: 52 | LoginApi.fire(provideRestAdapter(API_URL), intent.getExtras()); 53 | break; 54 | case CitiesApi.ACTION: 55 | CitiesApi.fire(provideRestAdapter(API_URL)); 56 | break; 57 | case NotificationsDeleteApi.ACTION: 58 | NotificationsDeleteApi.fire(provideRestAdapter(API_URL), intent.getExtras()); 59 | break; 60 | case UploadImageApi.ACTION: 61 | UploadImageApi.fire(this, provideRestAdapter(API_URL), intent.getExtras()); 62 | break; 63 | } 64 | 65 | return super.onStartCommand(intent, flags, startId); 66 | } 67 | 68 | private Retrofit provideRestAdapter(String url) { 69 | return new Retrofit.Builder() 70 | .baseUrl(url) 71 | .addConverterFactory(GsonConverterFactory.create()) 72 | .client(mOkHttpClient) 73 | .build(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/service/BaseApi.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.service; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.JsonObject; 5 | import com.google.gson.annotations.Expose; 6 | import com.google.gson.annotations.SerializedName; 7 | 8 | import org.greenrobot.eventbus.EventBus; 9 | 10 | import java.io.IOException; 11 | import java.lang.annotation.Annotation; 12 | 13 | import okhttp3.ResponseBody; 14 | import retrofit2.Converter; 15 | import retrofit2.Response; 16 | import retrofit2.Retrofit; 17 | 18 | /** 19 | * Created by darshan on 22/2/17. 20 | */ 21 | 22 | public abstract class BaseApi { 23 | 24 | protected static Retrofit mRetrofit; 25 | 26 | public static void showProgressDialog() { 27 | postEvent(EventBusMessage.EVENT_SHOW_PROGRESS_DIALOG, null); 28 | } 29 | 30 | public static void hideProgressDialog() { 31 | postEvent(EventBusMessage.EVENT_HIDE_PROGRESS_DIALOG, null); 32 | } 33 | 34 | public static void postEvent(String event, Object object) { 35 | EventBus.getDefault().post(new EventBusMessage(event, object)); 36 | } 37 | 38 | public static void parseResponse(Response response, Class type) { 39 | if (response.isSuccessful()) { 40 | if (isSuccessResponse(response.body())) { 41 | postEvent(EventBusMessage.EVENT_RESPONSE, new Gson().fromJson(response.body(), type)); 42 | } else 43 | postEvent(EventBusMessage.EVENT_RESPONSE, new Gson().fromJson(response.body(), DefaultErrorResponse.class)); 44 | } else { 45 | parseError(response); 46 | } 47 | } 48 | 49 | private static void parseError(Response response) { 50 | if (response.code() == 400) { 51 | Converter converterDefault = mRetrofit.responseBodyConverter(DefaultErrorResponse.class, new Annotation[0]); 52 | try { 53 | DefaultErrorResponse defaultErrorResponse = converterDefault.convert(response.errorBody()); 54 | postEvent(EventBusMessage.EVENT_RESPONSE, defaultErrorResponse); 55 | } catch (IOException e1) { 56 | e1.printStackTrace(); 57 | } 58 | } else if (response.code() == 500) { 59 | Converter converter500 = mRetrofit.responseBodyConverter(Error500Response.class, new Annotation[0]); 60 | try { 61 | Error500Response error500Response = converter500.convert(response.errorBody()); 62 | postEvent(EventBusMessage.EVENT_RESPONSE, error500Response); 63 | } catch (IOException e) { 64 | e.printStackTrace(); 65 | } 66 | } 67 | 68 | 69 | // ResponseBody responseBody = response.errorBody(); 70 | // try { 71 | // JsonObject jsonObject = (JsonObject) new JsonParser().parse(response.errorBody().string()); 72 | // jsonObject.get 73 | // } catch (IOException e) { 74 | // e.printStackTrace(); 75 | // } 76 | } 77 | 78 | // TODO: to change the success / error parsing when apis get fixed 79 | public static boolean isSuccessResponse(JsonObject jsonObject) { 80 | if (jsonObject.get("status_code") != null) { 81 | if (jsonObject.get("status_code").getAsInt() == 200) { 82 | if (jsonObject.get("status") != null) { 83 | try { 84 | return !(jsonObject.get("status").getAsInt() == 0); 85 | } catch (Exception exception) { 86 | exception.printStackTrace(); 87 | try { 88 | return jsonObject.get("status").getAsString().equals("ok"); 89 | } catch (Exception ex) { 90 | ex.printStackTrace(); 91 | return false; 92 | } 93 | } 94 | } else { 95 | return false; 96 | } 97 | } else 98 | return false; 99 | } else { 100 | if (jsonObject.get("status") != null) { 101 | try { 102 | return !(jsonObject.get("status").getAsInt() == 0); 103 | } catch (Exception exception) { 104 | exception.printStackTrace(); 105 | try { 106 | return jsonObject.get("status").getAsString().equals("ok"); 107 | } catch (Exception ex) { 108 | ex.printStackTrace(); 109 | return false; 110 | } 111 | } 112 | } else { 113 | try { 114 | return jsonObject.get("data") != null; 115 | } catch (Exception exception) { 116 | exception.printStackTrace(); 117 | try { 118 | return jsonObject.get("data").getAsJsonArray() != null; 119 | } catch (Exception exception1) { 120 | exception.printStackTrace(); 121 | return false; 122 | } 123 | } 124 | } 125 | } 126 | } 127 | 128 | public static class EventBusMessage { 129 | 130 | public static final String EVENT_SHOW_PROGRESS_DIALOG = "ShowProgressDialog"; 131 | public static final String EVENT_HIDE_PROGRESS_DIALOG = "HideProgressDialog"; 132 | public static final String EVENT_RESPONSE = "Response"; 133 | public String event; 134 | public Object object; 135 | 136 | public EventBusMessage(String event, Object object) { 137 | this.event = event; 138 | this.object = object; 139 | } 140 | } 141 | 142 | public static class DefaultErrorResponse { 143 | @SerializedName("status") 144 | @Expose 145 | private long status; 146 | @SerializedName("message") 147 | @Expose 148 | private String message; 149 | 150 | public long getStatus() { 151 | return status; 152 | } 153 | 154 | public void setStatus(long status) { 155 | this.status = status; 156 | } 157 | 158 | public String getMessage() { 159 | return message; 160 | } 161 | 162 | public void setMessage(String message) { 163 | this.message = message; 164 | } 165 | } 166 | 167 | public static class Error500Response { 168 | @SerializedName("error") 169 | @Expose 170 | private Error error; 171 | 172 | public Error getError() { 173 | return error; 174 | } 175 | 176 | public void setError(Error error) { 177 | this.error = error; 178 | } 179 | 180 | public class Error { 181 | 182 | @SerializedName("message") 183 | @Expose 184 | private String message; 185 | @SerializedName("status_code") 186 | @Expose 187 | private int statusCode; 188 | 189 | public String getMessage() { 190 | return message; 191 | } 192 | 193 | public void setMessage(String message) { 194 | this.message = message; 195 | } 196 | 197 | public int getStatusCode() { 198 | return statusCode; 199 | } 200 | 201 | public void setStatusCode(int statusCode) { 202 | this.statusCode = statusCode; 203 | } 204 | 205 | } 206 | } 207 | 208 | public static class Error422Response { 209 | 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/service/OkClientFactory.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.service; 2 | 3 | import android.app.Application; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.chintansoni.android.masterproject.BuildConfig; 7 | 8 | import java.io.File; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | import okhttp3.Cache; 12 | import okhttp3.OkHttpClient; 13 | import okhttp3.logging.HttpLoggingInterceptor; 14 | 15 | public class OkClientFactory { 16 | 17 | private static final Class TAG = OkClientFactory.class; 18 | 19 | // Cache size for the OkHttpClient 20 | private static final int DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50MB 21 | 22 | private OkClientFactory() { 23 | } 24 | 25 | @NonNull 26 | public static OkHttpClient provideOkHttpClient(Application application) { 27 | // Install an HTTP cache in the application cache directory. 28 | File cacheDir = new File(application.getCacheDir(), "https"); 29 | Cache cache = new Cache(cacheDir, DISK_CACHE_SIZE); 30 | 31 | OkHttpClient.Builder builder = new OkHttpClient.Builder().cache(cache); 32 | builder.connectTimeout(60, TimeUnit.SECONDS) 33 | .writeTimeout(60, TimeUnit.SECONDS) 34 | .readTimeout(60, TimeUnit.SECONDS); 35 | 36 | if (BuildConfig.DEBUG) { 37 | HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); 38 | loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); 39 | builder.addInterceptor(loggingInterceptor); 40 | } 41 | 42 | return builder.build(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/service/api/CitiesApi.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.service.api; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import com.chintansoni.android.masterproject.service.ApiService; 7 | import com.chintansoni.android.masterproject.service.BaseApi; 8 | import com.google.gson.JsonObject; 9 | import com.google.gson.annotations.Expose; 10 | import com.google.gson.annotations.SerializedName; 11 | 12 | import java.util.List; 13 | 14 | import retrofit2.Call; 15 | import retrofit2.Callback; 16 | import retrofit2.Response; 17 | import retrofit2.Retrofit; 18 | import retrofit2.http.GET; 19 | 20 | public class CitiesApi extends BaseApi { 21 | 22 | public static final String ACTION = "Cities"; 23 | // Login Api parameters 24 | public static final String URL = "cities"; 25 | public static boolean isRunning = false; 26 | 27 | public static void fire(Retrofit retrofit) { 28 | if (isRunning) { 29 | showProgressDialog(); 30 | } else { 31 | mRetrofit = retrofit; 32 | showProgressDialog(); 33 | isRunning = true; 34 | Service service = retrofit.create(Service.class); 35 | Call call = service.cities(); 36 | call.enqueue(new Callback() { 37 | @Override 38 | public void onResponse(Call call, Response response) { 39 | isRunning = false; 40 | parseResponse(response, ApiResponse.class); 41 | hideProgressDialog(); 42 | } 43 | 44 | @Override 45 | public void onFailure(Call call, Throwable t) { 46 | isRunning = false; 47 | hideProgressDialog(); 48 | } 49 | }); 50 | } 51 | } 52 | 53 | public static Intent getServiceIntent(Context context) { 54 | Intent intent = new Intent(context, ApiService.class); 55 | intent.setAction(ACTION); 56 | return intent; 57 | } 58 | 59 | interface Service { 60 | @GET(URL) 61 | Call cities(); 62 | } 63 | 64 | public class ApiResponse { 65 | @SerializedName("status") 66 | @Expose 67 | private String status; 68 | @SerializedName("data") 69 | @Expose 70 | private List data = null; 71 | 72 | public String getStatus() { 73 | return status; 74 | } 75 | 76 | public void setStatus(String status) { 77 | this.status = status; 78 | } 79 | 80 | public List getData() { 81 | return data; 82 | } 83 | 84 | public void setData(List data) { 85 | this.data = data; 86 | } 87 | 88 | public class Datum { 89 | 90 | @SerializedName("id") 91 | @Expose 92 | private int id; 93 | @SerializedName("sort_order") 94 | @Expose 95 | private int sortOrder; 96 | @SerializedName("created_at") 97 | @Expose 98 | private String createdAt; 99 | @SerializedName("created_by_id") 100 | @Expose 101 | private Object createdById; 102 | @SerializedName("updated_at") 103 | @Expose 104 | private Object updatedAt; 105 | @SerializedName("updated_by_id") 106 | @Expose 107 | private Object updatedById; 108 | @SerializedName("slug") 109 | @Expose 110 | private String slug; 111 | @SerializedName("live") 112 | @Expose 113 | private int live; 114 | @SerializedName("name") 115 | @Expose 116 | private String name; 117 | 118 | public int getId() { 119 | return id; 120 | } 121 | 122 | public void setId(int id) { 123 | this.id = id; 124 | } 125 | 126 | public int getSortOrder() { 127 | return sortOrder; 128 | } 129 | 130 | public void setSortOrder(int sortOrder) { 131 | this.sortOrder = sortOrder; 132 | } 133 | 134 | public String getCreatedAt() { 135 | return createdAt; 136 | } 137 | 138 | public void setCreatedAt(String createdAt) { 139 | this.createdAt = createdAt; 140 | } 141 | 142 | public Object getCreatedById() { 143 | return createdById; 144 | } 145 | 146 | public void setCreatedById(Object createdById) { 147 | this.createdById = createdById; 148 | } 149 | 150 | public Object getUpdatedAt() { 151 | return updatedAt; 152 | } 153 | 154 | public void setUpdatedAt(Object updatedAt) { 155 | this.updatedAt = updatedAt; 156 | } 157 | 158 | public Object getUpdatedById() { 159 | return updatedById; 160 | } 161 | 162 | public void setUpdatedById(Object updatedById) { 163 | this.updatedById = updatedById; 164 | } 165 | 166 | public String getSlug() { 167 | return slug; 168 | } 169 | 170 | public void setSlug(String slug) { 171 | this.slug = slug; 172 | } 173 | 174 | public int getLive() { 175 | return live; 176 | } 177 | 178 | public void setLive(int live) { 179 | this.live = live; 180 | } 181 | 182 | public String getName() { 183 | return name; 184 | } 185 | 186 | public void setName(String name) { 187 | this.name = name; 188 | } 189 | 190 | @Override 191 | public String toString() { 192 | return this.name; 193 | } 194 | } 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/service/api/LoginApi.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.service.api; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import com.chintansoni.android.masterproject.service.ApiService; 8 | import com.chintansoni.android.masterproject.service.BaseApi; 9 | import com.google.gson.JsonObject; 10 | import com.google.gson.annotations.Expose; 11 | import com.google.gson.annotations.SerializedName; 12 | 13 | import retrofit2.Call; 14 | import retrofit2.Callback; 15 | import retrofit2.Response; 16 | import retrofit2.Retrofit; 17 | import retrofit2.http.Field; 18 | import retrofit2.http.FormUrlEncoded; 19 | import retrofit2.http.POST; 20 | 21 | public class LoginApi extends BaseApi { 22 | 23 | public static final String ACTION = "Login"; 24 | public static final String ARG_EMAIL = "Email"; 25 | public static final String ARG_PASSWORD = "Password"; 26 | 27 | // Login Api parameters 28 | public static final String URL = "auth/login"; 29 | public static final String FORM_DATA_EMAIL = "email"; 30 | public static final String FORM_DATA_PASSWORD = "password"; 31 | 32 | public static boolean isRunning = false; 33 | 34 | public static void fire(Retrofit retrofit, Bundle bundle) { 35 | if (isRunning) { 36 | showProgressDialog(); 37 | } else { 38 | mRetrofit = retrofit; 39 | showProgressDialog(); 40 | isRunning = true; 41 | String email = bundle.getString(ARG_EMAIL); 42 | String password = bundle.getString(ARG_PASSWORD); 43 | Service service = retrofit.create(Service.class); 44 | Call call = service.login(email, password); 45 | call.enqueue(new Callback() { 46 | 47 | @Override 48 | public void onResponse(Call call, Response response) { 49 | isRunning = false; 50 | parseResponse(response, ApiResponse.class); 51 | hideProgressDialog(); 52 | } 53 | 54 | @Override 55 | public void onFailure(Call call, Throwable t) { 56 | isRunning = false; 57 | hideProgressDialog(); 58 | } 59 | }); 60 | } 61 | } 62 | 63 | public static Intent getServiceIntent(Context context, String email, String password) { 64 | Intent intent = new Intent(context, ApiService.class); 65 | intent.setAction(ACTION); 66 | Bundle bundle = new Bundle(); 67 | bundle.putString(ARG_EMAIL, email); 68 | bundle.putString(ARG_PASSWORD, password); 69 | intent.putExtras(bundle); 70 | return intent; 71 | } 72 | 73 | interface Service { 74 | @FormUrlEncoded 75 | @POST(URL) 76 | Call login(@Field(FORM_DATA_EMAIL) String email, @Field(FORM_DATA_PASSWORD) String password); 77 | } 78 | 79 | public class ApiResponse { 80 | @SerializedName("status") 81 | @Expose 82 | private String status; 83 | @SerializedName("status_code") 84 | @Expose 85 | private long statusCode; 86 | @SerializedName("message") 87 | @Expose 88 | private String message; 89 | @SerializedName("token") 90 | @Expose 91 | private String token; 92 | @SerializedName("data") 93 | @Expose 94 | private Data data; 95 | 96 | public String getStatus() { 97 | return status; 98 | } 99 | 100 | public void setStatus(String status) { 101 | this.status = status; 102 | } 103 | 104 | public long getStatusCode() { 105 | return statusCode; 106 | } 107 | 108 | public void setStatusCode(long statusCode) { 109 | this.statusCode = statusCode; 110 | } 111 | 112 | public String getMessage() { 113 | return message; 114 | } 115 | 116 | public void setMessage(String message) { 117 | this.message = message; 118 | } 119 | 120 | public String getToken() { 121 | return token; 122 | } 123 | 124 | public void setToken(String token) { 125 | this.token = token; 126 | } 127 | 128 | public Data getData() { 129 | return data; 130 | } 131 | 132 | public void setData(Data data) { 133 | this.data = data; 134 | } 135 | 136 | public class Data { 137 | 138 | @SerializedName("id") 139 | @Expose 140 | private long id; 141 | @SerializedName("sort_order") 142 | @Expose 143 | private long sortOrder; 144 | @SerializedName("created_at") 145 | @Expose 146 | private String createdAt; 147 | @SerializedName("created_by_id") 148 | @Expose 149 | private Object createdById; 150 | @SerializedName("updated_at") 151 | @Expose 152 | private String updatedAt; 153 | @SerializedName("updated_by_id") 154 | @Expose 155 | private Object updatedById; 156 | @SerializedName("deleted_at") 157 | @Expose 158 | private Object deletedAt; 159 | @SerializedName("email") 160 | @Expose 161 | private String email; 162 | @SerializedName("username") 163 | @Expose 164 | private String username; 165 | @SerializedName("password") 166 | @Expose 167 | private String password; 168 | @SerializedName("display_name") 169 | @Expose 170 | private String displayName; 171 | @SerializedName("first_name") 172 | @Expose 173 | private Object firstName; 174 | @SerializedName("last_name") 175 | @Expose 176 | private Object lastName; 177 | @SerializedName("activated") 178 | @Expose 179 | private long activated; 180 | @SerializedName("enabled") 181 | @Expose 182 | private long enabled; 183 | @SerializedName("permissions") 184 | @Expose 185 | private Object permissions; 186 | @SerializedName("last_login_at") 187 | @Expose 188 | private Object lastLoginAt; 189 | @SerializedName("remember_token") 190 | @Expose 191 | private Object rememberToken; 192 | @SerializedName("activation_code") 193 | @Expose 194 | private String activationCode; 195 | @SerializedName("reset_code") 196 | @Expose 197 | private String resetCode; 198 | @SerializedName("last_activity_at") 199 | @Expose 200 | private Object lastActivityAt; 201 | @SerializedName("ip_address") 202 | @Expose 203 | private Object ipAddress; 204 | @SerializedName("profile_picture_id") 205 | @Expose 206 | private Object profilePictureId; 207 | @SerializedName("city_id") 208 | @Expose 209 | private long cityId; 210 | @SerializedName("phone") 211 | @Expose 212 | private String phone; 213 | @SerializedName("dob") 214 | @Expose 215 | private Object dob; 216 | @SerializedName("street_address") 217 | @Expose 218 | private Object streetAddress; 219 | @SerializedName("bank_name") 220 | @Expose 221 | private Object bankName; 222 | @SerializedName("bank_account_number") 223 | @Expose 224 | private Object bankAccountNumber; 225 | @SerializedName("bank_account_name") 226 | @Expose 227 | private Object bankAccountName; 228 | @SerializedName("bank_swift_code") 229 | @Expose 230 | private Object bankSwiftCode; 231 | @SerializedName("subscribe_email") 232 | @Expose 233 | private long subscribeEmail; 234 | 235 | public long getId() { 236 | return id; 237 | } 238 | 239 | public void setId(long id) { 240 | this.id = id; 241 | } 242 | 243 | public long getSortOrder() { 244 | return sortOrder; 245 | } 246 | 247 | public void setSortOrder(long sortOrder) { 248 | this.sortOrder = sortOrder; 249 | } 250 | 251 | public String getCreatedAt() { 252 | return createdAt; 253 | } 254 | 255 | public void setCreatedAt(String createdAt) { 256 | this.createdAt = createdAt; 257 | } 258 | 259 | public Object getCreatedById() { 260 | return createdById; 261 | } 262 | 263 | public void setCreatedById(Object createdById) { 264 | this.createdById = createdById; 265 | } 266 | 267 | public String getUpdatedAt() { 268 | return updatedAt; 269 | } 270 | 271 | public void setUpdatedAt(String updatedAt) { 272 | this.updatedAt = updatedAt; 273 | } 274 | 275 | public Object getUpdatedById() { 276 | return updatedById; 277 | } 278 | 279 | public void setUpdatedById(Object updatedById) { 280 | this.updatedById = updatedById; 281 | } 282 | 283 | public Object getDeletedAt() { 284 | return deletedAt; 285 | } 286 | 287 | public void setDeletedAt(Object deletedAt) { 288 | this.deletedAt = deletedAt; 289 | } 290 | 291 | public String getEmail() { 292 | return email; 293 | } 294 | 295 | public void setEmail(String email) { 296 | this.email = email; 297 | } 298 | 299 | public String getUsername() { 300 | return username; 301 | } 302 | 303 | public void setUsername(String username) { 304 | this.username = username; 305 | } 306 | 307 | public String getPassword() { 308 | return password; 309 | } 310 | 311 | public void setPassword(String password) { 312 | this.password = password; 313 | } 314 | 315 | public String getDisplayName() { 316 | return displayName; 317 | } 318 | 319 | public void setDisplayName(String displayName) { 320 | this.displayName = displayName; 321 | } 322 | 323 | public Object getFirstName() { 324 | return firstName; 325 | } 326 | 327 | public void setFirstName(Object firstName) { 328 | this.firstName = firstName; 329 | } 330 | 331 | public Object getLastName() { 332 | return lastName; 333 | } 334 | 335 | public void setLastName(Object lastName) { 336 | this.lastName = lastName; 337 | } 338 | 339 | public long getActivated() { 340 | return activated; 341 | } 342 | 343 | public void setActivated(long activated) { 344 | this.activated = activated; 345 | } 346 | 347 | public long getEnabled() { 348 | return enabled; 349 | } 350 | 351 | public void setEnabled(long enabled) { 352 | this.enabled = enabled; 353 | } 354 | 355 | public Object getPermissions() { 356 | return permissions; 357 | } 358 | 359 | public void setPermissions(Object permissions) { 360 | this.permissions = permissions; 361 | } 362 | 363 | public Object getLastLoginAt() { 364 | return lastLoginAt; 365 | } 366 | 367 | public void setLastLoginAt(Object lastLoginAt) { 368 | this.lastLoginAt = lastLoginAt; 369 | } 370 | 371 | public Object getRememberToken() { 372 | return rememberToken; 373 | } 374 | 375 | public void setRememberToken(Object rememberToken) { 376 | this.rememberToken = rememberToken; 377 | } 378 | 379 | public String getActivationCode() { 380 | return activationCode; 381 | } 382 | 383 | public void setActivationCode(String activationCode) { 384 | this.activationCode = activationCode; 385 | } 386 | 387 | public String getResetCode() { 388 | return resetCode; 389 | } 390 | 391 | public void setResetCode(String resetCode) { 392 | this.resetCode = resetCode; 393 | } 394 | 395 | public Object getLastActivityAt() { 396 | return lastActivityAt; 397 | } 398 | 399 | public void setLastActivityAt(Object lastActivityAt) { 400 | this.lastActivityAt = lastActivityAt; 401 | } 402 | 403 | public Object getIpAddress() { 404 | return ipAddress; 405 | } 406 | 407 | public void setIpAddress(Object ipAddress) { 408 | this.ipAddress = ipAddress; 409 | } 410 | 411 | public Object getProfilePictureId() { 412 | return profilePictureId; 413 | } 414 | 415 | public void setProfilePictureId(Object profilePictureId) { 416 | this.profilePictureId = profilePictureId; 417 | } 418 | 419 | public long getCityId() { 420 | return cityId; 421 | } 422 | 423 | public void setCityId(long cityId) { 424 | this.cityId = cityId; 425 | } 426 | 427 | public String getPhone() { 428 | return phone; 429 | } 430 | 431 | public void setPhone(String phone) { 432 | this.phone = phone; 433 | } 434 | 435 | public Object getDob() { 436 | return dob; 437 | } 438 | 439 | public void setDob(Object dob) { 440 | this.dob = dob; 441 | } 442 | 443 | public Object getStreetAddress() { 444 | return streetAddress; 445 | } 446 | 447 | public void setStreetAddress(Object streetAddress) { 448 | this.streetAddress = streetAddress; 449 | } 450 | 451 | public Object getBankName() { 452 | return bankName; 453 | } 454 | 455 | public void setBankName(Object bankName) { 456 | this.bankName = bankName; 457 | } 458 | 459 | public Object getBankAccountNumber() { 460 | return bankAccountNumber; 461 | } 462 | 463 | public void setBankAccountNumber(Object bankAccountNumber) { 464 | this.bankAccountNumber = bankAccountNumber; 465 | } 466 | 467 | public Object getBankAccountName() { 468 | return bankAccountName; 469 | } 470 | 471 | public void setBankAccountName(Object bankAccountName) { 472 | this.bankAccountName = bankAccountName; 473 | } 474 | 475 | public Object getBankSwiftCode() { 476 | return bankSwiftCode; 477 | } 478 | 479 | public void setBankSwiftCode(Object bankSwiftCode) { 480 | this.bankSwiftCode = bankSwiftCode; 481 | } 482 | 483 | public long getSubscribeEmail() { 484 | return subscribeEmail; 485 | } 486 | 487 | public void setSubscribeEmail(long subscribeEmail) { 488 | this.subscribeEmail = subscribeEmail; 489 | } 490 | } 491 | } 492 | } 493 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/service/api/NotificationsDeleteApi.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.service.api; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import com.chintansoni.android.masterproject.service.ApiService; 8 | import com.chintansoni.android.masterproject.service.BaseApi; 9 | import com.google.gson.JsonObject; 10 | import com.google.gson.annotations.Expose; 11 | import com.google.gson.annotations.SerializedName; 12 | 13 | import retrofit2.Call; 14 | import retrofit2.Callback; 15 | import retrofit2.Response; 16 | import retrofit2.Retrofit; 17 | import retrofit2.http.DELETE; 18 | import retrofit2.http.Path; 19 | import retrofit2.http.Query; 20 | 21 | public class NotificationsDeleteApi extends BaseApi { 22 | 23 | public static final String ACTION = "NotificationsDelete"; 24 | // Login Api parameters 25 | public static final String URL = "delete-notification/{id}"; 26 | public static final String ARG_TOKEN = "Token"; 27 | public static final String ARG_ID = "Id"; 28 | public static final String PARAMETER_ID = "id"; 29 | public static final String PARAMETER_TOKEN = "token"; 30 | public static boolean isRunning = false; 31 | 32 | public static void fire(Retrofit retrofit, Bundle bundle) { 33 | if (isRunning) { 34 | showProgressDialog(); 35 | } else { 36 | mRetrofit = retrofit; 37 | showProgressDialog(); 38 | isRunning = true; 39 | 40 | String token = bundle.getString(ARG_TOKEN); 41 | String id = bundle.getString(ARG_ID); 42 | 43 | Service service = retrofit.create(Service.class); 44 | Call call = service.notificationsDelete(id, token); 45 | call.enqueue(new Callback() { 46 | @Override 47 | public void onResponse(Call call, Response response) { 48 | isRunning = false; 49 | parseResponse(response, ApiResponse.class); 50 | hideProgressDialog(); 51 | } 52 | 53 | @Override 54 | public void onFailure(Call call, Throwable t) { 55 | isRunning = false; 56 | hideProgressDialog(); 57 | } 58 | }); 59 | } 60 | } 61 | 62 | public static Intent getServiceIntent(Context context, String token, String id) { 63 | Intent intent = new Intent(context, ApiService.class); 64 | intent.setAction(ACTION); 65 | Bundle bundle = new Bundle(); 66 | bundle.putString(ARG_TOKEN, token); 67 | bundle.putString(ARG_ID, id); 68 | intent.putExtras(bundle); 69 | return intent; 70 | } 71 | 72 | interface Service { 73 | @DELETE(URL) 74 | Call notificationsDelete(@Path(PARAMETER_ID) String id, @Query(PARAMETER_TOKEN) String token); 75 | } 76 | 77 | public class ApiResponse { 78 | @SerializedName("status") 79 | @Expose 80 | private int status; 81 | @SerializedName("status_code") 82 | @Expose 83 | private int statusCode; 84 | @SerializedName("message") 85 | @Expose 86 | private String message; 87 | @SerializedName("token") 88 | @Expose 89 | private String token; 90 | 91 | public int getStatus() { 92 | return status; 93 | } 94 | 95 | public void setStatus(int status) { 96 | this.status = status; 97 | } 98 | 99 | public int getStatusCode() { 100 | return statusCode; 101 | } 102 | 103 | public void setStatusCode(int statusCode) { 104 | this.statusCode = statusCode; 105 | } 106 | 107 | public String getMessage() { 108 | return message; 109 | } 110 | 111 | public void setMessage(String message) { 112 | this.message = message; 113 | } 114 | 115 | public String getToken() { 116 | return token; 117 | } 118 | 119 | public void setToken(String token) { 120 | this.token = token; 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/service/api/UploadImageApi.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.service.api; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | 8 | import com.chintansoni.android.masterproject.service.ApiService; 9 | import com.chintansoni.android.masterproject.service.BaseApi; 10 | import com.chintansoni.android.masterproject.util.File.FileUtils; 11 | import com.google.gson.JsonObject; 12 | import com.google.gson.annotations.Expose; 13 | import com.google.gson.annotations.SerializedName; 14 | 15 | import okhttp3.MediaType; 16 | import okhttp3.MultipartBody; 17 | import okhttp3.RequestBody; 18 | import retrofit2.Call; 19 | import retrofit2.Callback; 20 | import retrofit2.Response; 21 | import retrofit2.Retrofit; 22 | import retrofit2.http.Multipart; 23 | import retrofit2.http.POST; 24 | import retrofit2.http.Part; 25 | import retrofit2.http.Query; 26 | 27 | public class UploadImageApi extends BaseApi { 28 | 29 | public static final String ACTION = "UploadImage"; 30 | private static final String ARG_FILE = "File"; 31 | private static final String ARG_FOLDER = "Folder"; 32 | private static final String ARG_TOKEN = "Token"; 33 | 34 | private static final String URL = "upload"; 35 | private static final String FORM_DATA_UPLOAD = "upload"; 36 | private static final String FORM_DATA_FOLDER = "folder"; 37 | private static final String PARAMETER_TOKEN = "token"; 38 | 39 | private static boolean isRunning = false; 40 | 41 | public static void fire(Context context, Retrofit retrofit, Bundle bundle) { 42 | if (isRunning) { 43 | showProgressDialog(); 44 | } else { 45 | mRetrofit = retrofit; 46 | showProgressDialog(); 47 | isRunning = true; 48 | String file = bundle.getString(ARG_FILE); 49 | String folder = bundle.getString(ARG_FOLDER); 50 | String token = bundle.getString(ARG_TOKEN); 51 | 52 | // First working for file 53 | // create RequestBody instance from file 54 | Uri fileUri = Uri.parse(file); 55 | RequestBody requestFile = RequestBody.create( 56 | MediaType.parse(context.getContentResolver().getType(fileUri)), 57 | FileUtils.getFile(context, fileUri) 58 | ); 59 | // MultipartBody.Part is used to send also the actual file name 60 | MultipartBody.Part body = MultipartBody.Part.createFormData(FORM_DATA_UPLOAD, FileUtils.getFile(context, fileUri).getName(), requestFile); 61 | 62 | // Now working for passing text along with file. 63 | RequestBody description = RequestBody.create(MultipartBody.FORM, folder); 64 | 65 | Service service = retrofit.create(Service.class); 66 | Call call = service.uploadImage(body, description, token); 67 | call.enqueue(new Callback() { 68 | 69 | @Override 70 | public void onResponse(Call call, Response response) { 71 | isRunning = false; 72 | parseResponse(response, ApiResponse.class); 73 | hideProgressDialog(); 74 | } 75 | 76 | @Override 77 | public void onFailure(Call call, Throwable t) { 78 | isRunning = false; 79 | hideProgressDialog(); 80 | } 81 | }); 82 | } 83 | } 84 | 85 | public static Intent getServiceIntent(Context context, String file, String folder, String token) { 86 | Intent intent = new Intent(context, ApiService.class); 87 | intent.setAction(ACTION); 88 | Bundle bundle = new Bundle(); 89 | bundle.putString(ARG_FILE, file); 90 | bundle.putString(ARG_FOLDER, folder); 91 | bundle.putString(ARG_TOKEN, token); 92 | intent.putExtras(bundle); 93 | return intent; 94 | } 95 | 96 | interface Service { 97 | @Multipart 98 | @POST(URL) 99 | Call uploadImage(@Part MultipartBody.Part file, @Part(FORM_DATA_FOLDER) RequestBody description, @Query(PARAMETER_TOKEN) String token); 100 | } 101 | 102 | public class ApiResponse { 103 | @SerializedName("status") 104 | @Expose 105 | private int status; 106 | @SerializedName("status_code") 107 | @Expose 108 | private int statusCode; 109 | @SerializedName("message") 110 | @Expose 111 | private String message; 112 | @SerializedName("token") 113 | @Expose 114 | private String token; 115 | @SerializedName("data") 116 | @Expose 117 | private Data data; 118 | 119 | public int getStatus() { 120 | return status; 121 | } 122 | 123 | public void setStatus(int status) { 124 | this.status = status; 125 | } 126 | 127 | public int getStatusCode() { 128 | return statusCode; 129 | } 130 | 131 | public void setStatusCode(int statusCode) { 132 | this.statusCode = statusCode; 133 | } 134 | 135 | public String getMessage() { 136 | return message; 137 | } 138 | 139 | public void setMessage(String message) { 140 | this.message = message; 141 | } 142 | 143 | public String getToken() { 144 | return token; 145 | } 146 | 147 | public void setToken(String token) { 148 | this.token = token; 149 | } 150 | 151 | public Data getData() { 152 | return data; 153 | } 154 | 155 | public void setData(Data data) { 156 | this.data = data; 157 | } 158 | 159 | public class Data { 160 | 161 | @SerializedName("name") 162 | @Expose 163 | private String name; 164 | @SerializedName("folder_id") 165 | @Expose 166 | private int folderId; 167 | @SerializedName("disk_id") 168 | @Expose 169 | private int diskId; 170 | @SerializedName("size") 171 | @Expose 172 | private int size; 173 | @SerializedName("mime_type") 174 | @Expose 175 | private String mimeType; 176 | @SerializedName("extension") 177 | @Expose 178 | private String extension; 179 | @SerializedName("entry_type") 180 | @Expose 181 | private String entryType; 182 | @SerializedName("deleted_at") 183 | @Expose 184 | private Object deletedAt; 185 | @SerializedName("width") 186 | @Expose 187 | private int width; 188 | @SerializedName("height") 189 | @Expose 190 | private int height; 191 | @SerializedName("created_at") 192 | @Expose 193 | private String createdAt; 194 | @SerializedName("created_by_id") 195 | @Expose 196 | private int createdById; 197 | @SerializedName("sort_order") 198 | @Expose 199 | private int sortOrder; 200 | @SerializedName("id") 201 | @Expose 202 | private int id; 203 | @SerializedName("updated_at") 204 | @Expose 205 | private String updatedAt; 206 | @SerializedName("updated_by_id") 207 | @Expose 208 | private int updatedById; 209 | 210 | public String getName() { 211 | return name; 212 | } 213 | 214 | public void setName(String name) { 215 | this.name = name; 216 | } 217 | 218 | public int getFolderId() { 219 | return folderId; 220 | } 221 | 222 | public void setFolderId(int folderId) { 223 | this.folderId = folderId; 224 | } 225 | 226 | public int getDiskId() { 227 | return diskId; 228 | } 229 | 230 | public void setDiskId(int diskId) { 231 | this.diskId = diskId; 232 | } 233 | 234 | public int getSize() { 235 | return size; 236 | } 237 | 238 | public void setSize(int size) { 239 | this.size = size; 240 | } 241 | 242 | public String getMimeType() { 243 | return mimeType; 244 | } 245 | 246 | public void setMimeType(String mimeType) { 247 | this.mimeType = mimeType; 248 | } 249 | 250 | public String getExtension() { 251 | return extension; 252 | } 253 | 254 | public void setExtension(String extension) { 255 | this.extension = extension; 256 | } 257 | 258 | public String getEntryType() { 259 | return entryType; 260 | } 261 | 262 | public void setEntryType(String entryType) { 263 | this.entryType = entryType; 264 | } 265 | 266 | public Object getDeletedAt() { 267 | return deletedAt; 268 | } 269 | 270 | public void setDeletedAt(Object deletedAt) { 271 | this.deletedAt = deletedAt; 272 | } 273 | 274 | public int getWidth() { 275 | return width; 276 | } 277 | 278 | public void setWidth(int width) { 279 | this.width = width; 280 | } 281 | 282 | public int getHeight() { 283 | return height; 284 | } 285 | 286 | public void setHeight(int height) { 287 | this.height = height; 288 | } 289 | 290 | public String getCreatedAt() { 291 | return createdAt; 292 | } 293 | 294 | public void setCreatedAt(String createdAt) { 295 | this.createdAt = createdAt; 296 | } 297 | 298 | public int getCreatedById() { 299 | return createdById; 300 | } 301 | 302 | public void setCreatedById(int createdById) { 303 | this.createdById = createdById; 304 | } 305 | 306 | public int getSortOrder() { 307 | return sortOrder; 308 | } 309 | 310 | public void setSortOrder(int sortOrder) { 311 | this.sortOrder = sortOrder; 312 | } 313 | 314 | public int getId() { 315 | return id; 316 | } 317 | 318 | public void setId(int id) { 319 | this.id = id; 320 | } 321 | 322 | public String getUpdatedAt() { 323 | return updatedAt; 324 | } 325 | 326 | public void setUpdatedAt(String updatedAt) { 327 | this.updatedAt = updatedAt; 328 | } 329 | 330 | public int getUpdatedById() { 331 | return updatedById; 332 | } 333 | 334 | public void setUpdatedById(int updatedById) { 335 | this.updatedById = updatedById; 336 | } 337 | 338 | } 339 | } 340 | } 341 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/DialogUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.support.v7.app.AlertDialog; 6 | 7 | /** 8 | * Created by chint on 9/4/2016. 9 | */ 10 | public class DialogUtils { 11 | 12 | public static void alert(Context context, int title, int message, int buttonTitle, DialogInterface.OnClickListener onPositiveButtonClickListener) { 13 | AlertDialog.Builder builder = new AlertDialog.Builder(context); 14 | builder.setTitle(title); 15 | builder.setMessage(message); 16 | builder.setNeutralButton(buttonTitle, onPositiveButtonClickListener); 17 | AlertDialog alertDialog = builder.create(); 18 | alertDialog.show(); 19 | } 20 | 21 | public static void alert(Context context, String title, String message, int buttonTitle, DialogInterface.OnClickListener onPositiveButtonClickListener) { 22 | AlertDialog.Builder builder = new AlertDialog.Builder(context); 23 | builder.setTitle(title); 24 | builder.setMessage(message); 25 | builder.setNeutralButton(buttonTitle, onPositiveButtonClickListener); 26 | AlertDialog alertDialog = builder.create(); 27 | alertDialog.show(); 28 | } 29 | 30 | public static void confirm(Context context, int title, int message, int positiveButtonTitle, DialogInterface.OnClickListener onPositiveButtonClickListener, int negativeButtonTitle, DialogInterface.OnClickListener onNegativeButtonClickListener) { 31 | AlertDialog.Builder builder = new AlertDialog.Builder(context); 32 | builder.setTitle(title); 33 | builder.setMessage(message); 34 | builder.setPositiveButton(positiveButtonTitle, onPositiveButtonClickListener); 35 | builder.setNegativeButton(negativeButtonTitle, onNegativeButtonClickListener); 36 | AlertDialog alertDialog = builder.create(); 37 | alertDialog.show(); 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/DpPxUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.util.DisplayMetrics; 6 | 7 | /** 8 | * Created by darshan on 22/2/17. 9 | */ 10 | 11 | public class DpPxUtils { 12 | /** 13 | * This method converts dp unit to equivalent pixels, depending on device density. 14 | * 15 | * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels 16 | * @param context Context to get resources and device specific display metrics 17 | * @return A float value to represent px equivalent to dp depending on device density 18 | */ 19 | public static int convertDpToPixel(int dp, Context context) { 20 | Resources resources = context.getResources(); 21 | DisplayMetrics metrics = resources.getDisplayMetrics(); 22 | return dp * metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT; 23 | } 24 | 25 | /** 26 | * This method converts device specific pixels to density independent pixels. 27 | * 28 | * @param px A value in px (pixels) unit. Which we need to convert into db 29 | * @param context Context to get resources and device specific display metrics 30 | * @return A float value to represent dp equivalent to px value 31 | */ 32 | public static int convertPixelsToDp(int px, Context context) { 33 | Resources resources = context.getResources(); 34 | DisplayMetrics metrics = resources.getDisplayMetrics(); 35 | return px / metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/File/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util.File; 2 | 3 | import android.content.ContentResolver; 4 | import android.content.ContentUris; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.database.Cursor; 8 | import android.database.DatabaseUtils; 9 | import android.graphics.Bitmap; 10 | import android.net.Uri; 11 | import android.os.Build; 12 | import android.os.Environment; 13 | import android.provider.DocumentsContract; 14 | import android.provider.MediaStore; 15 | import android.util.Log; 16 | import android.webkit.MimeTypeMap; 17 | 18 | import java.io.File; 19 | import java.io.FileFilter; 20 | import java.text.DecimalFormat; 21 | import java.util.Comparator; 22 | 23 | public class FileUtils { 24 | public static final String MIME_TYPE_AUDIO = "audio/*"; 25 | public static final String MIME_TYPE_TEXT = "text/*"; 26 | public static final String MIME_TYPE_IMAGE = "image/*"; 27 | public static final String MIME_TYPE_VIDEO = "video/*"; 28 | public static final String MIME_TYPE_APP = "application/*"; 29 | public static final String HIDDEN_PREFIX = "."; 30 | /** 31 | * TAG for log messages. 32 | */ 33 | static final String TAG = "FileUtils"; 34 | private static final boolean DEBUG = false; // Set to true to enable logging 35 | /** 36 | * File and folder comparator. 37 | * 38 | * @author paulburke 39 | */ 40 | public static Comparator sComparator = new Comparator() { 41 | @Override 42 | public int compare(File f1, File f2) { 43 | // Sort alphabetically by lower case, which is much cleaner 44 | return f1.getName().toLowerCase().compareTo( 45 | f2.getName().toLowerCase()); 46 | } 47 | }; 48 | /** 49 | * File (not directories) filter. 50 | * 51 | * @author paulburke 52 | */ 53 | public static FileFilter sFileFilter = new FileFilter() { 54 | @Override 55 | public boolean accept(File file) { 56 | final String fileName = file.getName(); 57 | // Return files only (not directories) and skip hidden files 58 | return file.isFile() && !fileName.startsWith(HIDDEN_PREFIX); 59 | } 60 | }; 61 | /** 62 | * Folder (directories) filter. 63 | * 64 | * @author paulburke 65 | */ 66 | public static FileFilter sDirFilter = new FileFilter() { 67 | @Override 68 | public boolean accept(File file) { 69 | final String fileName = file.getName(); 70 | // Return directories only and skip hidden directories 71 | return file.isDirectory() && !fileName.startsWith(HIDDEN_PREFIX); 72 | } 73 | }; 74 | 75 | private FileUtils() { 76 | } //private constructor to enforce Singleton pattern 77 | 78 | /** 79 | * Gets the extension of a file name, like ".png" or ".jpg". 80 | * 81 | * @param uri 82 | * @return Extension including the dot("."); "" if there is no extension; 83 | * null if uri was null. 84 | */ 85 | public static String getExtension(String uri) { 86 | if (uri == null) { 87 | return null; 88 | } 89 | 90 | int dot = uri.lastIndexOf("."); 91 | if (dot >= 0) { 92 | return uri.substring(dot); 93 | } else { 94 | // No extension. 95 | return ""; 96 | } 97 | } 98 | 99 | /** 100 | * @return Whether the URI is a local one. 101 | */ 102 | public static boolean isLocal(String url) { 103 | return url != null && !url.startsWith("http://") && !url.startsWith("https://"); 104 | } 105 | 106 | /** 107 | * @return True if Uri is a MediaStore Uri. 108 | * @author paulburke 109 | */ 110 | public static boolean isMediaUri(Uri uri) { 111 | return "media".equalsIgnoreCase(uri.getAuthority()); 112 | } 113 | 114 | /** 115 | * Convert File into Uri. 116 | * 117 | * @param file 118 | * @return uri 119 | */ 120 | public static Uri getUri(File file) { 121 | if (file != null) { 122 | return Uri.fromFile(file); 123 | } 124 | return null; 125 | } 126 | 127 | /** 128 | * Returns the path only (without file name). 129 | * 130 | * @param file 131 | * @return 132 | */ 133 | public static File getPathWithoutFilename(File file) { 134 | if (file != null) { 135 | if (file.isDirectory()) { 136 | // no file to be split off. Return everything 137 | return file; 138 | } else { 139 | String filename = file.getName(); 140 | String filepath = file.getAbsolutePath(); 141 | 142 | // Construct path without file name. 143 | String pathwithoutname = filepath.substring(0, 144 | filepath.length() - filename.length()); 145 | if (pathwithoutname.endsWith("/")) { 146 | pathwithoutname = pathwithoutname.substring(0, pathwithoutname.length() - 1); 147 | } 148 | return new File(pathwithoutname); 149 | } 150 | } 151 | return null; 152 | } 153 | 154 | /** 155 | * @return The MIME type for the given file. 156 | */ 157 | public static String getMimeType(File file) { 158 | 159 | String extension = getExtension(file.getName()); 160 | 161 | if (extension.length() > 0) 162 | return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.substring(1)); 163 | 164 | return "application/octet-stream"; 165 | } 166 | 167 | /** 168 | * @return The MIME type for the give Uri. 169 | */ 170 | public static String getMimeType(Context context, Uri uri) { 171 | File file = new File(getPath(context, uri)); 172 | return getMimeType(file); 173 | } 174 | 175 | /** 176 | * @param uri The Uri to check. 177 | * @return Whether the Uri authority is {@link LocalStorageProvider}. 178 | * @author paulburke 179 | */ 180 | public static boolean isLocalStorageDocument(Uri uri) { 181 | return LocalStorageProvider.AUTHORITY.equals(uri.getAuthority()); 182 | } 183 | 184 | /** 185 | * @param uri The Uri to check. 186 | * @return Whether the Uri authority is ExternalStorageProvider. 187 | * @author paulburke 188 | */ 189 | public static boolean isExternalStorageDocument(Uri uri) { 190 | return "com.android.externalstorage.documents".equals(uri.getAuthority()); 191 | } 192 | 193 | /** 194 | * @param uri The Uri to check. 195 | * @return Whether the Uri authority is DownloadsProvider. 196 | * @author paulburke 197 | */ 198 | public static boolean isDownloadsDocument(Uri uri) { 199 | return "com.android.providers.downloads.documents".equals(uri.getAuthority()); 200 | } 201 | 202 | /** 203 | * @param uri The Uri to check. 204 | * @return Whether the Uri authority is MediaProvider. 205 | * @author paulburke 206 | */ 207 | public static boolean isMediaDocument(Uri uri) { 208 | return "com.android.providers.media.documents".equals(uri.getAuthority()); 209 | } 210 | 211 | /** 212 | * @param uri The Uri to check. 213 | * @return Whether the Uri authority is Google Photos. 214 | */ 215 | public static boolean isGooglePhotosUri(Uri uri) { 216 | return "com.google.android.apps.photos.content".equals(uri.getAuthority()); 217 | } 218 | 219 | /** 220 | * Get the value of the data column for this Uri. This is useful for 221 | * MediaStore Uris, and other file-based ContentProviders. 222 | * 223 | * @param context The context. 224 | * @param uri The Uri to query. 225 | * @param selection (Optional) Filter used in the query. 226 | * @param selectionArgs (Optional) Selection arguments used in the query. 227 | * @return The value of the _data column, which is typically a file path. 228 | * @author paulburke 229 | */ 230 | public static String getDataColumn(Context context, Uri uri, String selection, 231 | String[] selectionArgs) { 232 | 233 | Cursor cursor = null; 234 | final String column = "_data"; 235 | final String[] projection = { 236 | column 237 | }; 238 | 239 | try { 240 | cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, 241 | null); 242 | if (cursor != null && cursor.moveToFirst()) { 243 | if (DEBUG) 244 | DatabaseUtils.dumpCursor(cursor); 245 | 246 | final int column_index = cursor.getColumnIndexOrThrow(column); 247 | return cursor.getString(column_index); 248 | } 249 | } finally { 250 | if (cursor != null) 251 | cursor.close(); 252 | } 253 | return null; 254 | } 255 | 256 | /** 257 | * Get a file path from a Uri. This will get the the path for Storage Access 258 | * Framework Documents, as well as the _data field for the MediaStore and 259 | * other file-based ContentProviders.
260 | *
261 | * Callers should check whether the path is local before assuming it 262 | * represents a local file. 263 | * 264 | * @param context The context. 265 | * @param uri The Uri to query. 266 | * @author paulburke 267 | * @see #isLocal(String) 268 | * @see #getFile(Context, Uri) 269 | */ 270 | public static String getPath(final Context context, final Uri uri) { 271 | 272 | if (DEBUG) 273 | Log.d(TAG + " File -", 274 | "Authority: " + uri.getAuthority() + 275 | ", Fragment: " + uri.getFragment() + 276 | ", Port: " + uri.getPort() + 277 | ", Query: " + uri.getQuery() + 278 | ", Scheme: " + uri.getScheme() + 279 | ", Host: " + uri.getHost() + 280 | ", Segments: " + uri.getPathSegments().toString() 281 | ); 282 | 283 | final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; 284 | 285 | // DocumentProvider 286 | if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { 287 | // LocalStorageProvider 288 | if (isLocalStorageDocument(uri)) { 289 | // The path is the id 290 | return DocumentsContract.getDocumentId(uri); 291 | } 292 | // ExternalStorageProvider 293 | else if (isExternalStorageDocument(uri)) { 294 | final String docId = DocumentsContract.getDocumentId(uri); 295 | final String[] split = docId.split(":"); 296 | final String type = split[0]; 297 | 298 | if ("primary".equalsIgnoreCase(type)) { 299 | return Environment.getExternalStorageDirectory() + "/" + split[1]; 300 | } 301 | 302 | } 303 | // DownloadsProvider 304 | else if (isDownloadsDocument(uri)) { 305 | 306 | final String id = DocumentsContract.getDocumentId(uri); 307 | final Uri contentUri = ContentUris.withAppendedId( 308 | Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); 309 | 310 | return getDataColumn(context, contentUri, null, null); 311 | } 312 | // MediaProvider 313 | else if (isMediaDocument(uri)) { 314 | final String docId = DocumentsContract.getDocumentId(uri); 315 | final String[] split = docId.split(":"); 316 | final String type = split[0]; 317 | 318 | Uri contentUri = null; 319 | if ("image".equals(type)) { 320 | contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; 321 | } else if ("video".equals(type)) { 322 | contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; 323 | } else if ("audio".equals(type)) { 324 | contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; 325 | } 326 | 327 | final String selection = "_id=?"; 328 | final String[] selectionArgs = new String[]{ 329 | split[1] 330 | }; 331 | 332 | return getDataColumn(context, contentUri, selection, selectionArgs); 333 | } 334 | } 335 | // MediaStore (and general) 336 | else if ("content".equalsIgnoreCase(uri.getScheme())) { 337 | 338 | // Return the remote address 339 | if (isGooglePhotosUri(uri)) 340 | return uri.getLastPathSegment(); 341 | 342 | return getDataColumn(context, uri, null, null); 343 | } 344 | // File 345 | else if ("file".equalsIgnoreCase(uri.getScheme())) { 346 | return uri.getPath(); 347 | } 348 | 349 | return null; 350 | } 351 | 352 | /** 353 | * Convert Uri into File, if possible. 354 | * 355 | * @return file A local file that the Uri was pointing to, or null if the 356 | * Uri is unsupported or pointed to a remote resource. 357 | * @author paulburke 358 | * @see #getPath(Context, Uri) 359 | */ 360 | public static File getFile(Context context, Uri uri) { 361 | if (uri != null) { 362 | String path = getPath(context, uri); 363 | if (path != null && isLocal(path)) { 364 | return new File(path); 365 | } 366 | } 367 | return null; 368 | } 369 | 370 | /** 371 | * Get the file size in a human-readable string. 372 | * 373 | * @param size 374 | * @return 375 | * @author paulburke 376 | */ 377 | public static String getReadableFileSize(int size) { 378 | final int BYTES_IN_KILOBYTES = 1024; 379 | final DecimalFormat dec = new DecimalFormat("###.#"); 380 | final String KILOBYTES = " KB"; 381 | final String MEGABYTES = " MB"; 382 | final String GIGABYTES = " GB"; 383 | float fileSize = 0; 384 | String suffix = KILOBYTES; 385 | 386 | if (size > BYTES_IN_KILOBYTES) { 387 | fileSize = size / BYTES_IN_KILOBYTES; 388 | if (fileSize > BYTES_IN_KILOBYTES) { 389 | fileSize = fileSize / BYTES_IN_KILOBYTES; 390 | if (fileSize > BYTES_IN_KILOBYTES) { 391 | fileSize = fileSize / BYTES_IN_KILOBYTES; 392 | suffix = GIGABYTES; 393 | } else { 394 | suffix = MEGABYTES; 395 | } 396 | } 397 | } 398 | return String.valueOf(dec.format(fileSize) + suffix); 399 | } 400 | 401 | /** 402 | * Attempt to retrieve the thumbnail of given File from the MediaStore. This 403 | * should not be called on the UI thread. 404 | * 405 | * @param context 406 | * @param file 407 | * @return 408 | * @author paulburke 409 | */ 410 | public static Bitmap getThumbnail(Context context, File file) { 411 | return getThumbnail(context, getUri(file), getMimeType(file)); 412 | } 413 | 414 | /** 415 | * Attempt to retrieve the thumbnail of given Uri from the MediaStore. This 416 | * should not be called on the UI thread. 417 | * 418 | * @param context 419 | * @param uri 420 | * @return 421 | * @author paulburke 422 | */ 423 | public static Bitmap getThumbnail(Context context, Uri uri) { 424 | return getThumbnail(context, uri, getMimeType(context, uri)); 425 | } 426 | 427 | /** 428 | * Attempt to retrieve the thumbnail of given Uri from the MediaStore. This 429 | * should not be called on the UI thread. 430 | * 431 | * @param context 432 | * @param uri 433 | * @param mimeType 434 | * @return 435 | * @author paulburke 436 | */ 437 | public static Bitmap getThumbnail(Context context, Uri uri, String mimeType) { 438 | if (DEBUG) 439 | Log.d(TAG, "Attempting to get thumbnail"); 440 | 441 | if (!isMediaUri(uri)) { 442 | Log.e(TAG, "You can only retrieve thumbnails for images and videos."); 443 | return null; 444 | } 445 | 446 | Bitmap bm = null; 447 | if (uri != null) { 448 | final ContentResolver resolver = context.getContentResolver(); 449 | Cursor cursor = null; 450 | try { 451 | cursor = resolver.query(uri, null, null, null, null); 452 | if (cursor.moveToFirst()) { 453 | final int id = cursor.getInt(0); 454 | if (DEBUG) 455 | Log.d(TAG, "Got thumb ID: " + id); 456 | 457 | if (mimeType.contains("video")) { 458 | bm = MediaStore.Video.Thumbnails.getThumbnail( 459 | resolver, 460 | id, 461 | MediaStore.Video.Thumbnails.MINI_KIND, 462 | null); 463 | } else if (mimeType.contains(FileUtils.MIME_TYPE_IMAGE)) { 464 | bm = MediaStore.Images.Thumbnails.getThumbnail( 465 | resolver, 466 | id, 467 | MediaStore.Images.Thumbnails.MINI_KIND, 468 | null); 469 | } 470 | } 471 | } catch (Exception e) { 472 | if (DEBUG) 473 | Log.e(TAG, "getThumbnail", e); 474 | } finally { 475 | if (cursor != null) 476 | cursor.close(); 477 | } 478 | } 479 | return bm; 480 | } 481 | 482 | /** 483 | * Get the Intent for selecting content to be used in an Intent Chooser. 484 | * 485 | * @return The intent for opening a file with Intent.createChooser() 486 | * @author paulburke 487 | */ 488 | public static Intent createGetContentIntent() { 489 | // Implicitly allow the user to select a particular kind of data 490 | final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 491 | // The MIME data type filter 492 | intent.setType("*/*"); 493 | // Only return URIs that can be opened with ContentResolver 494 | intent.addCategory(Intent.CATEGORY_OPENABLE); 495 | return intent; 496 | } 497 | } -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/File/LocalStorageProvider.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util.File; 2 | 3 | import android.content.res.AssetFileDescriptor; 4 | import android.database.Cursor; 5 | import android.database.MatrixCursor; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.graphics.Point; 9 | import android.os.CancellationSignal; 10 | import android.os.Environment; 11 | import android.os.ParcelFileDescriptor; 12 | import android.provider.DocumentsContract; 13 | import android.provider.DocumentsProvider; 14 | import android.util.Log; 15 | import android.webkit.MimeTypeMap; 16 | 17 | 18 | import com.chintansoni.android.masterproject.R; 19 | 20 | import java.io.File; 21 | import java.io.FileNotFoundException; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | 25 | public class LocalStorageProvider extends DocumentsProvider { 26 | 27 | public static final String AUTHORITY = "com.sportsvenue.sooryen.fileprovider"; 28 | 29 | /** 30 | * Default root projection: everything but Root.COLUMN_MIME_TYPES 31 | */ 32 | private final static String[] DEFAULT_ROOT_PROJECTION = new String[]{ 33 | DocumentsContract.Root.COLUMN_ROOT_ID, 34 | DocumentsContract.Root.COLUMN_FLAGS, 35 | DocumentsContract.Root.COLUMN_TITLE, 36 | DocumentsContract.Root.COLUMN_DOCUMENT_ID, 37 | DocumentsContract.Root.COLUMN_ICON, 38 | DocumentsContract.Root.COLUMN_AVAILABLE_BYTES 39 | }; 40 | /** 41 | * Default document projection: everything but Document.COLUMN_ICON and 42 | * Document.COLUMN_SUMMARY 43 | */ 44 | private final static String[] DEFAULT_DOCUMENT_PROJECTION = new String[]{ 45 | DocumentsContract.Document.COLUMN_DOCUMENT_ID, 46 | DocumentsContract.Document.COLUMN_DISPLAY_NAME, 47 | DocumentsContract.Document.COLUMN_FLAGS, 48 | DocumentsContract.Document.COLUMN_MIME_TYPE, 49 | DocumentsContract.Document.COLUMN_SIZE, 50 | DocumentsContract.Document.COLUMN_LAST_MODIFIED 51 | }; 52 | 53 | @Override 54 | public Cursor queryRoots(final String[] projection) throws FileNotFoundException { 55 | // Create a cursor with either the requested fields, or the default 56 | // projection if "projection" is null. 57 | final MatrixCursor result = new MatrixCursor(projection != null ? projection 58 | : DEFAULT_ROOT_PROJECTION); 59 | // Add Home directory 60 | File homeDir = Environment.getExternalStorageDirectory(); 61 | final MatrixCursor.RowBuilder row = result.newRow(); 62 | // These columns are required 63 | row.add(DocumentsContract.Root.COLUMN_ROOT_ID, homeDir.getAbsolutePath()); 64 | row.add(DocumentsContract.Root.COLUMN_DOCUMENT_ID, homeDir.getAbsolutePath()); 65 | row.add(DocumentsContract.Root.COLUMN_TITLE, getContext().getString(R.string.internal_storage)); 66 | row.add(DocumentsContract.Root.COLUMN_FLAGS, DocumentsContract.Root.FLAG_LOCAL_ONLY | DocumentsContract.Root.FLAG_SUPPORTS_CREATE); 67 | row.add(DocumentsContract.Root.COLUMN_ICON, R.drawable.ic_provider); 68 | // These columns are optional 69 | row.add(DocumentsContract.Root.COLUMN_AVAILABLE_BYTES, homeDir.getFreeSpace()); 70 | // Root.COLUMN_MIME_TYPE is another optional column and useful if you 71 | // have multiple roots with different 72 | // types of mime types (roots that don't match the requested mime type 73 | // are automatically hidden) 74 | return result; 75 | } 76 | 77 | @Override 78 | public String createDocument(final String parentDocumentId, final String mimeType, 79 | final String displayName) throws FileNotFoundException { 80 | File newFile = new File(parentDocumentId, displayName); 81 | try { 82 | newFile.createNewFile(); 83 | return newFile.getAbsolutePath(); 84 | } catch (IOException e) { 85 | Log.e(LocalStorageProvider.class.getSimpleName(), "Error creating new file " + newFile); 86 | } 87 | return null; 88 | } 89 | 90 | @Override 91 | public AssetFileDescriptor openDocumentThumbnail(final String documentId, final Point sizeHint, 92 | final CancellationSignal signal) throws FileNotFoundException { 93 | // Assume documentId points to an image file. Build a thumbnail no 94 | // larger than twice the sizeHint 95 | BitmapFactory.Options options = new BitmapFactory.Options(); 96 | options.inJustDecodeBounds = true; 97 | BitmapFactory.decodeFile(documentId, options); 98 | final int targetHeight = 2 * sizeHint.y; 99 | final int targetWidth = 2 * sizeHint.x; 100 | final int height = options.outHeight; 101 | final int width = options.outWidth; 102 | options.inSampleSize = 1; 103 | if (height > targetHeight || width > targetWidth) { 104 | final int halfHeight = height / 2; 105 | final int halfWidth = width / 2; 106 | // Calculate the largest inSampleSize value that is a power of 2 and 107 | // keeps both 108 | // height and width larger than the requested height and width. 109 | while ((halfHeight / options.inSampleSize) > targetHeight 110 | || (halfWidth / options.inSampleSize) > targetWidth) { 111 | options.inSampleSize *= 2; 112 | } 113 | } 114 | options.inJustDecodeBounds = false; 115 | Bitmap bitmap = BitmapFactory.decodeFile(documentId, options); 116 | // Write out the thumbnail to a temporary file 117 | File tempFile = null; 118 | FileOutputStream out = null; 119 | try { 120 | tempFile = File.createTempFile("thumbnail", null, getContext().getCacheDir()); 121 | out = new FileOutputStream(tempFile); 122 | bitmap.compress(Bitmap.CompressFormat.PNG, 90, out); 123 | } catch (IOException e) { 124 | Log.e(LocalStorageProvider.class.getSimpleName(), "Error writing thumbnail", e); 125 | return null; 126 | } finally { 127 | if (out != null) 128 | try { 129 | out.close(); 130 | } catch (IOException e) { 131 | Log.e(LocalStorageProvider.class.getSimpleName(), "Error closing thumbnail", e); 132 | } 133 | } 134 | // It appears the Storage Framework UI caches these results quite 135 | // aggressively so there is little reason to 136 | // write your own caching layer beyond what you need to return a single 137 | // AssetFileDescriptor 138 | return new AssetFileDescriptor(ParcelFileDescriptor.open(tempFile, 139 | ParcelFileDescriptor.MODE_READ_ONLY), 0, 140 | AssetFileDescriptor.UNKNOWN_LENGTH); 141 | } 142 | 143 | @Override 144 | public Cursor queryChildDocuments(final String parentDocumentId, final String[] projection, 145 | final String sortOrder) throws FileNotFoundException { 146 | // Create a cursor with either the requested fields, or the default 147 | // projection if "projection" is null. 148 | final MatrixCursor result = new MatrixCursor(projection != null ? projection 149 | : DEFAULT_DOCUMENT_PROJECTION); 150 | final File parent = new File(parentDocumentId); 151 | for (File file : parent.listFiles()) { 152 | // Don't show hidden files/folders 153 | if (!file.getName().startsWith(".")) { 154 | // Adds the file's display name, MIME type, size, and so on. 155 | includeFile(result, file); 156 | } 157 | } 158 | return result; 159 | } 160 | 161 | @Override 162 | public Cursor queryDocument(final String documentId, final String[] projection) 163 | throws FileNotFoundException { 164 | // Create a cursor with either the requested fields, or the default 165 | // projection if "projection" is null. 166 | final MatrixCursor result = new MatrixCursor(projection != null ? projection 167 | : DEFAULT_DOCUMENT_PROJECTION); 168 | includeFile(result, new File(documentId)); 169 | return result; 170 | } 171 | 172 | private void includeFile(final MatrixCursor result, final File file) 173 | throws FileNotFoundException { 174 | final MatrixCursor.RowBuilder row = result.newRow(); 175 | // These columns are required 176 | row.add(DocumentsContract.Document.COLUMN_DOCUMENT_ID, file.getAbsolutePath()); 177 | row.add(DocumentsContract.Document.COLUMN_DISPLAY_NAME, file.getName()); 178 | String mimeType = getDocumentType(file.getAbsolutePath()); 179 | row.add(DocumentsContract.Document.COLUMN_MIME_TYPE, mimeType); 180 | int flags = file.canWrite() ? DocumentsContract.Document.FLAG_SUPPORTS_DELETE | DocumentsContract.Document.FLAG_SUPPORTS_WRITE 181 | : 0; 182 | // We only show thumbnails for image files - expect a call to 183 | // openDocumentThumbnail for each file that has 184 | // this flag set 185 | if (mimeType.startsWith("image/")) 186 | flags |= DocumentsContract.Document.FLAG_SUPPORTS_THUMBNAIL; 187 | row.add(DocumentsContract.Document.COLUMN_FLAGS, flags); 188 | // COLUMN_SIZE is required, but can be null 189 | row.add(DocumentsContract.Document.COLUMN_SIZE, file.length()); 190 | // These columns are optional 191 | row.add(DocumentsContract.Document.COLUMN_LAST_MODIFIED, file.lastModified()); 192 | // Document.COLUMN_ICON can be a resource id identifying a custom icon. 193 | // The system provides default icons 194 | // based on mime type 195 | // Document.COLUMN_SUMMARY is optional additional information about the 196 | // file 197 | } 198 | 199 | @Override 200 | public String getDocumentType(final String documentId) throws FileNotFoundException { 201 | File file = new File(documentId); 202 | if (file.isDirectory()) 203 | return DocumentsContract.Document.MIME_TYPE_DIR; 204 | // From FileProvider.getType(Uri) 205 | final int lastDot = file.getName().lastIndexOf('.'); 206 | if (lastDot >= 0) { 207 | final String extension = file.getName().substring(lastDot + 1); 208 | final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); 209 | if (mime != null) { 210 | return mime; 211 | } 212 | } 213 | return "application/octet-stream"; 214 | } 215 | 216 | @Override 217 | public void deleteDocument(final String documentId) throws FileNotFoundException { 218 | new File(documentId).delete(); 219 | } 220 | 221 | @Override 222 | public ParcelFileDescriptor openDocument(final String documentId, final String mode, 223 | final CancellationSignal signal) throws FileNotFoundException { 224 | File file = new File(documentId); 225 | final boolean isWrite = (mode.indexOf('w') != -1); 226 | if (isWrite) { 227 | return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE); 228 | } else { 229 | return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); 230 | } 231 | } 232 | 233 | @Override 234 | public boolean onCreate() { 235 | return true; 236 | } 237 | } -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/FormValidationUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.AppCompatEditText; 5 | import android.text.TextUtils; 6 | import android.util.Patterns; 7 | import android.widget.Toast; 8 | 9 | import com.chintansoni.android.masterproject.customview.RobotoCheckBox; 10 | import com.chintansoni.android.masterproject.customview.RobotoTextInputEditText; 11 | 12 | public class FormValidationUtils { 13 | 14 | public static void clear(RobotoTextInputEditText... robotoTextInputEditTexts) { 15 | for (RobotoTextInputEditText robotoTextInputEditText : robotoTextInputEditTexts) 16 | robotoTextInputEditText.setError(null); 17 | } 18 | 19 | public static boolean isEmpty(RobotoTextInputEditText robotoTextInputEditText, String message) { 20 | if (TextUtils.isEmpty(robotoTextInputEditText.getText().toString().trim())) { 21 | setFocusAndError(robotoTextInputEditText, message); 22 | return true; 23 | } else return false; 24 | } 25 | 26 | public static boolean isEmailValid(RobotoTextInputEditText robotoTextInputEditText, String message) { 27 | if (Patterns.EMAIL_ADDRESS.matcher(robotoTextInputEditText.getText()).matches()) { 28 | return true; 29 | } else { 30 | setFocusAndError(robotoTextInputEditText, message); 31 | return false; 32 | } 33 | } 34 | 35 | public static boolean isEmailValid(RobotoTextInputEditText robotoTextInputEditText, String domain, String message) { 36 | if (Patterns.EMAIL_ADDRESS.matcher(robotoTextInputEditText.getText() + domain).matches()) { 37 | return true; 38 | } else { 39 | setFocusAndError(robotoTextInputEditText, message); 40 | return false; 41 | } 42 | } 43 | 44 | public static boolean arePasswordsSame(RobotoTextInputEditText robotoTextInputEditTextSetPassword, RobotoTextInputEditText robotoTextInputEditTextConfirmPassword, String message) { 45 | if (robotoTextInputEditTextSetPassword.getText().toString().equals(robotoTextInputEditTextConfirmPassword.getText().toString())) { 46 | return true; 47 | } else { 48 | setFocusAndError(robotoTextInputEditTextSetPassword, message); 49 | setFocusAndError(robotoTextInputEditTextConfirmPassword, message); 50 | return false; 51 | } 52 | } 53 | 54 | public static boolean isMobileValid(RobotoTextInputEditText robotoTextInputEditText, String message) { 55 | if (Patterns.PHONE.matcher(robotoTextInputEditText.getText().toString()).matches()) { 56 | return true; 57 | } else { 58 | setFocusAndError(robotoTextInputEditText, message); 59 | return false; 60 | } 61 | } 62 | 63 | public static boolean isChecked(Context context, RobotoCheckBox robotoCheckBox, String message) { 64 | if (robotoCheckBox.isChecked()) 65 | return true; 66 | else { 67 | Toast.makeText(context, message, Toast.LENGTH_LONG).show(); 68 | return false; 69 | } 70 | } 71 | 72 | private static void setFocusAndError(AppCompatEditText appCompatEditText, String error) { 73 | appCompatEditText.requestFocus(); 74 | appCompatEditText.setError(error); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/LogUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.util.Log; 4 | 5 | import com.chintansoni.android.masterproject.BuildConfig; 6 | 7 | public class LogUtils { 8 | 9 | private static boolean isLoggable() { 10 | return BuildConfig.DEBUG; 11 | } 12 | 13 | private static String createTag(Class tag) { 14 | String tempTag = tag.getSimpleName(); 15 | return tempTag.length() > 23 ? tempTag.substring(0, 22) : tempTag; 16 | } 17 | 18 | public static void error(Class tag, String message) { 19 | if (isLoggable()) { 20 | Log.e(createTag(tag), message); 21 | } 22 | } 23 | 24 | public static void warning(Class tag, String message) { 25 | if (isLoggable()) { 26 | Log.w(createTag(tag), message); 27 | } 28 | } 29 | 30 | public static void information(Class tag, String message) { 31 | if (isLoggable()) { 32 | Log.i(createTag(tag), message); 33 | } 34 | } 35 | 36 | public static void debug(Class tag, String message) { 37 | if (isLoggable()) { 38 | Log.d(createTag(tag), message); 39 | } 40 | } 41 | 42 | public static void verbose(Class tag, String message) { 43 | if (isLoggable()) { 44 | Log.v(createTag(tag), message); 45 | } 46 | } 47 | 48 | public static void wtf(Class tag, String message) { 49 | if (isLoggable()) { 50 | Log.wtf(createTag(tag), message); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/NetworkUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | import android.widget.Toast; 7 | 8 | import com.chintansoni.android.masterproject.R; 9 | 10 | /** 11 | * Created by Chintan Soni - Senior Software Engineer (Android). 12 | */ 13 | 14 | public class NetworkUtils { 15 | public static boolean isInternetAvailable(Context context) { 16 | ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 17 | NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); 18 | boolean isInternetAvailable = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); 19 | if (!isInternetAvailable) 20 | Toast.makeText(context, R.string.no_internet_connection, Toast.LENGTH_SHORT).show(); 21 | return isInternetAvailable; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/ProgressDialogUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | 7 | import com.chintansoni.android.masterproject.R; 8 | 9 | public class ProgressDialogUtils { 10 | 11 | private static ProgressDialogUtils ourInstance = null; 12 | private ProgressDialog mProgressDialog; 13 | private boolean mDefaultIndeterminate = true; 14 | private boolean mDefaultCancelable = false; 15 | private DialogInterface.OnCancelListener mDefaultOnCancelListener = new DialogInterface.OnCancelListener() { 16 | @Override 17 | public void onCancel(DialogInterface dialog) { 18 | 19 | } 20 | }; 21 | 22 | private ProgressDialogUtils() { 23 | } 24 | 25 | public static ProgressDialogUtils getInstance() { 26 | if (ourInstance == null) 27 | ourInstance = new ProgressDialogUtils(); 28 | return ourInstance; 29 | } 30 | 31 | public void show(Context context) { 32 | show(context, getTitle(context), getMessage(context), mDefaultIndeterminate, mDefaultCancelable, mDefaultOnCancelListener); 33 | } 34 | 35 | public void show(Context context, String title) { 36 | show(context, title, getMessage(context)); 37 | } 38 | 39 | public void show(Context context, String title, String message) { 40 | show(context, title, message, mDefaultIndeterminate, mDefaultCancelable, mDefaultOnCancelListener); 41 | } 42 | 43 | public void show(Context context, String title, String message, boolean indeterminate, boolean cancelable, DialogInterface.OnCancelListener onCancelListener) { 44 | if (mProgressDialog != null && mProgressDialog.isShowing()) { 45 | mProgressDialog.setMessage(message); 46 | } else { 47 | mProgressDialog = ProgressDialog.show(context, title, message, indeterminate, cancelable, onCancelListener); 48 | } 49 | } 50 | 51 | public void hide() { 52 | if (mProgressDialog != null && mProgressDialog.isShowing()) { 53 | mProgressDialog.dismiss(); 54 | } 55 | } 56 | 57 | private String getTitle(Context context) { 58 | return context.getString(R.string.default_progress_dialog_title); 59 | } 60 | 61 | private String getMessage(Context context) { 62 | return context.getString(R.string.default_progress_dialog_message); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/SharedPreferencesUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | public class SharedPreferencesUtils { 7 | 8 | public static final String PREFERENCE_IS_USER_LOGGED_IN = "IsUserLoggedIn"; 9 | public static final String PREFERENCE_LOGIN_RESPONSE = "LoginResponse"; 10 | public static final String PREFERENCE_TOKEN = "UserToken"; 11 | public static final String PREFERENCE_CITIES = "CitiesResponse"; 12 | 13 | public static final String PREFERENCE_COURTTYPERESPONSE = "CourtTypeResponse"; 14 | public static final String PREFERENCE_TEAMLEVELPERESPONSE = "TeamLevelResponse"; 15 | public static final String PREFERENCE_FLOORTYPERESPONSE = "FloorTypeResponse"; 16 | public static final String PREFERENCE_CAPACITYRESPONSE = "CapacitiesResponse"; 17 | public static final String PREFERENCE_EMAIL = "UserEmail"; 18 | public static final String PREFERENCE_DISPLAY_NAME = "UserDisplayName"; 19 | private static final String PREFERENCE_NAME = "SportsVenuePreferences"; 20 | private static SharedPreferencesUtils mSharedPreferencesUtils; 21 | private static SharedPreferences mSharedPreferences; 22 | 23 | private SharedPreferencesUtils() { 24 | 25 | } 26 | 27 | public static SharedPreferencesUtils getInstance(Context context) { 28 | if (mSharedPreferencesUtils == null) { 29 | mSharedPreferencesUtils = new SharedPreferencesUtils(); 30 | } 31 | if (mSharedPreferences == null) { 32 | mSharedPreferences = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); 33 | } 34 | return mSharedPreferencesUtils; 35 | } 36 | 37 | public void setInt(String key, int value) { 38 | mSharedPreferences.edit().putInt(key, value).apply(); 39 | } 40 | 41 | public int getInt(String key) { 42 | return mSharedPreferences.getInt(key, 0); 43 | } 44 | 45 | public void setString(String key, String value) { 46 | mSharedPreferences.edit().putString(key, value).apply(); 47 | } 48 | 49 | public String getString(String key) { 50 | return mSharedPreferences.getString(key, ""); 51 | } 52 | 53 | public void setBoolean(String key, boolean value) { 54 | mSharedPreferences.edit().putBoolean(key, value).apply(); 55 | } 56 | 57 | public boolean getBoolean(String key) { 58 | return mSharedPreferences.getBoolean(key, false); 59 | } 60 | 61 | public void clearKey(String key) { 62 | mSharedPreferences.edit().remove(key).apply(); 63 | } 64 | 65 | public void clearPreferences() { 66 | mSharedPreferences.edit().clear().apply(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/SnackBarUtils.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.support.design.widget.Snackbar; 4 | import android.view.View; 5 | 6 | import com.chintansoni.android.masterproject.R; 7 | 8 | 9 | public class SnackBarUtils { 10 | 11 | public static void show(View view, int description) { 12 | show(view, description, Snackbar.LENGTH_SHORT); 13 | } 14 | 15 | public static void show(View view, int description, int duration) { 16 | show(view, description, duration, R.string.default_snackbar_action_title, new View.OnClickListener() { 17 | @Override 18 | public void onClick(View v) { 19 | } 20 | }); 21 | } 22 | 23 | public static void show(View view, int description, int duration, int actionTitle, View.OnClickListener onActionClickListener) { 24 | Snackbar.make(view, description, duration) 25 | .setAction(actionTitle, onActionClickListener) 26 | .show(); 27 | } 28 | 29 | public static void show(View view, String description) { 30 | show(view, description, Snackbar.LENGTH_SHORT); 31 | } 32 | 33 | public static void show(View view, String description, int duration) { 34 | show(view, description, duration, R.string.default_snackbar_action_title, new View.OnClickListener() { 35 | @Override 36 | public void onClick(View v) { 37 | } 38 | }); 39 | } 40 | 41 | public static void show(View view, String description, int duration, int actionTitle, View.OnClickListener onActionClickListener) { 42 | Snackbar.make(view, description, duration) 43 | .setAction(actionTitle, onActionClickListener) 44 | .show(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/chintansoni/android/masterproject/util/VerticalSpaceItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.chintansoni.android.masterproject.util; 2 | 3 | import android.graphics.Rect; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | 7 | public class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration { 8 | 9 | private final int verticalSpaceHeight; 10 | 11 | public VerticalSpaceItemDecoration(int verticalSpaceHeight) { 12 | this.verticalSpaceHeight = verticalSpaceHeight; 13 | } 14 | 15 | @Override 16 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, 17 | RecyclerView.State state) { 18 | outRect.bottom = verticalSpaceHeight; 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_image.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_provider.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/layer_list_cold_start.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 21 | 22 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/bottom_sheet_select_image_using.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 25 | 26 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 16 | 17 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 46 | 47 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_import.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_divider.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_frame.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_frame_sub.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/nav_header_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 23 | 24 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_home_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 13 | 17 | 21 | 22 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_splash.xml: -------------------------------------------------------------------------------- 1 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/base_values.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 4dp 6 | 8dp 7 | 16dp 8 | 24dp 9 | 32dp 10 | 11 | 12 | 12sp 13 | 14sp 14 | 16sp 15 | 18sp 16 | 22sp 17 | 18 | 19 | Loading 20 | Please wait… 21 | 22 | 23 | OK 24 | 25 | 26 | Okay 27 | 28 | 29 | Open navigation drawer 30 | Close navigation drawer 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | Roboto-Black.ttf 58 | Roboto-BlackItalic.ttf 59 | Roboto-Bold.ttf 60 | Roboto-BoldItalic.ttf 61 | Roboto-Italic.ttf 62 | Roboto-Light.ttf 63 | Roboto-LightItalic.ttf 64 | Roboto-Medium.ttf 65 | Roboto-MediumItalic.ttf 66 | Roboto-Regular.ttf 67 | Roboto-Thin.ttf 68 | Roboto-ThinItalic.ttf 69 | RobotoCondensed-Bold.ttf 70 | RobotoCondensed-BoldItalic.ttf 71 | RobotoCondensed-Italic.ttf 72 | RobotoCondensed-Light.ttf 73 | RobotoCondensed-LightItalic.ttf 74 | RobotoCondensed-Regular.ttf 75 | 76 | 77 | 78 | No Internet Available 79 | 80 | Internal storage 81 | 82 | This app requires permission to storage to store and retrieve pictures captured from camera. 83 | Looks like permission for storage has been permanently disabled. Go to Settings and turn it On. 84 | Choose 85 | Camera 86 | Gallery 87 | Oops !!! 88 | Settings 89 | Cancel 90 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 160dp 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Master Project 3 | Settings 4 | Login 5 | Home 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/xml/file_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.0' 9 | classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iChintanSoni/Android-Master-Project/c6a5a93ef8972b8f2ef390b88ab0bcf3b8dd0fd6/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 16 11:17:18 IST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------