diff --git a/CountryApp/.gitignore b/CountryApp/.gitignore new file mode 100644 index 00000000..fd45b12f --- /dev/null +++ b/CountryApp/.gitignore @@ -0,0 +1,11 @@ +*.iml +.gradle +/local.properties +/.idea/caches/build_file_checksums.ser +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/CountryApp/.idea/.gitignore b/CountryApp/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/CountryApp/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/CountryApp/.idea/assetWizardSettings.xml b/CountryApp/.idea/assetWizardSettings.xml new file mode 100644 index 00000000..a0f256ea --- /dev/null +++ b/CountryApp/.idea/assetWizardSettings.xml @@ -0,0 +1,47 @@ + + + + + + \ No newline at end of file diff --git a/CountryApp/.idea/codeStyles/Project.xml b/CountryApp/.idea/codeStyles/Project.xml new file mode 100644 index 00000000..30aa626c --- /dev/null +++ b/CountryApp/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountryApp/.idea/compiler.xml b/CountryApp/.idea/compiler.xml new file mode 100644 index 00000000..61a9130c --- /dev/null +++ b/CountryApp/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CountryApp/.idea/gradle.xml b/CountryApp/.idea/gradle.xml new file mode 100644 index 00000000..526b4c25 --- /dev/null +++ b/CountryApp/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/CountryApp/.idea/jarRepositories.xml b/CountryApp/.idea/jarRepositories.xml new file mode 100644 index 00000000..4dd313aa --- /dev/null +++ b/CountryApp/.idea/jarRepositories.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountryApp/.idea/misc.xml b/CountryApp/.idea/misc.xml new file mode 100644 index 00000000..25ccd2a1 --- /dev/null +++ b/CountryApp/.idea/misc.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountryApp/app/.gitignore b/CountryApp/app/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/CountryApp/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/CountryApp/app/build.gradle b/CountryApp/app/build.gradle new file mode 100644 index 00000000..ea20145b --- /dev/null +++ b/CountryApp/app/build.gradle @@ -0,0 +1,47 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.codingwithmitch.mvvmrecyclerview" + minSdkVersion 21 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + + // Lifecycle components + def archLifecycleVersion = '1.1.1' + implementation "android.arch.lifecycle:extensions:$archLifecycleVersion" + annotationProcessor "android.arch.lifecycle:compiler:$archLifecycleVersion" + + // Glide + def glideVersion = '4.8.0' + implementation "com.github.bumptech.glide:glide:$glideVersion" + annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion" + + //RecyclerView + implementation 'com.android.support:recyclerview-v7:28.0.0' + + //Support Design for Coordinator layout + implementation 'com.android.support:design:28.0.0' + + //circle imageview + implementation 'de.hdodenhof:circleimageview:2.2.0' +} diff --git a/CountryApp/app/proguard-rules.pro b/CountryApp/app/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/CountryApp/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/CountryApp/app/src/androidTest/java/com/codingwithmitch/mvvmrecyclerview/ExampleInstrumentedTest.java b/CountryApp/app/src/androidTest/java/com/codingwithmitch/mvvmrecyclerview/ExampleInstrumentedTest.java new file mode 100644 index 00000000..d7f9b92c --- /dev/null +++ b/CountryApp/app/src/androidTest/java/com/codingwithmitch/mvvmrecyclerview/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.codingwithmitch.mvvmrecyclerview; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.codingwithmitch.mvvmrecyclerview", appContext.getPackageName()); + } +} diff --git a/CountryApp/app/src/main/AndroidManifest.xml b/CountryApp/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..748124e1 --- /dev/null +++ b/CountryApp/app/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/MainActivity.java b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/MainActivity.java new file mode 100644 index 00000000..70f5ca2b --- /dev/null +++ b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/MainActivity.java @@ -0,0 +1,76 @@ +package com.codingwithmitch.mvvmrecyclerview; + +import android.arch.lifecycle.Observer; +import android.arch.lifecycle.ViewModelProviders; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; + +import com.codingwithmitch.mvvmrecyclerview.adapters.CountryModelAdapter; +import com.codingwithmitch.mvvmrecyclerview.models.CountryModel; +import com.codingwithmitch.mvvmrecyclerview.viewmodels.MainActivityViewModel; + + +import java.util.List; + +public class MainActivity extends AppCompatActivity { + + private static final String TAG = "MainActivity"; + + private RecyclerView mRecyclerView; + private CountryModelAdapter mAdapter; + private MainActivityViewModel mMainActivityViewModel; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + mRecyclerView = findViewById(R.id.recycler_view); + + + mMainActivityViewModel = ViewModelProviders.of(this).get(MainActivityViewModel.class); + + mMainActivityViewModel.init(); + + + + +// mMainActivityViewModel.getCountry().observe(this, new Observer>() { +// @Override +// public void onChanged(@Nullable List nicePlaces) { +// mAdapter.notifyDataSetChanged(); +// } +// }); + + initRecyclerView(); + } + + private void initRecyclerView(){ + mAdapter = new CountryModelAdapter(this, mMainActivityViewModel.getCountry().getValue()); + RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(this); + mRecyclerView.setLayoutManager(linearLayoutManager); + mRecyclerView.setAdapter(mAdapter); + } +} + + + + + + + + + + + + + + + + + + + + diff --git a/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/adapters/CountryModelAdapter.java b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/adapters/CountryModelAdapter.java new file mode 100644 index 00000000..71f77ea7 --- /dev/null +++ b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/adapters/CountryModelAdapter.java @@ -0,0 +1,76 @@ +package com.codingwithmitch.mvvmrecyclerview.adapters; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; +import com.codingwithmitch.mvvmrecyclerview.R; +import com.codingwithmitch.mvvmrecyclerview.models.CountryModel; + +import java.util.ArrayList; +import java.util.List; + +import de.hdodenhof.circleimageview.CircleImageView; + +public class CountryModelAdapter extends RecyclerView.Adapter { + + private List countryModels = new ArrayList<>(); + private Context context; + + public CountryModelAdapter(Context context, List cCountry) { + countryModels = cCountry; + this.context = context; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { + View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_listitem, viewGroup, false); + ViewHolderClass vh = new ViewHolderClass(view); + return vh; + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) { + + // Set the name of the 'NicePlace' + ((ViewHolderClass)viewHolder).cName.setText(countryModels.get(i).getcName()); + ((ViewHolderClass)viewHolder).cPresident.setText(countryModels.get(i).getcPresident()); + ((ViewHolderClass)viewHolder).cPopulation.setText(countryModels.get(i).getcPopulartion()); + + // Set the image + RequestOptions defaultOptions = new RequestOptions() + .error(R.drawable.ic_launcher_background); + Glide.with(context) + .setDefaultRequestOptions(defaultOptions) + .load(countryModels.get(i).getcImageUrl()) + .into(((ViewHolderClass)viewHolder).mImage); + } + + @Override + public int getItemCount() { + return countryModels.size(); + } + + private class ViewHolderClass extends RecyclerView.ViewHolder{ + + private CircleImageView mImage; + private TextView cName; + private TextView cPresident; + private TextView cPopulation; + + public ViewHolderClass(@NonNull View itemView) { + super(itemView); + mImage = itemView.findViewById(R.id.image); + cName = itemView.findViewById(R.id.cNameTxt); + cPresident = itemView.findViewById(R.id.presidentNameTxt); + cPopulation = itemView.findViewById(R.id.populationTxt); + } + } +} diff --git a/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/models/CountryModel.java b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/models/CountryModel.java new file mode 100644 index 00000000..867dde31 --- /dev/null +++ b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/models/CountryModel.java @@ -0,0 +1,51 @@ +package com.codingwithmitch.mvvmrecyclerview.models; + +public class CountryModel { + + private String cName; + private String cImageUrl; + private String cPresident; + private String cPopulartion; + + public CountryModel(String cName, String cImageUrl, String cPresident, String cPopulartion) { + this.cName = cName; + this.cImageUrl = cImageUrl; + this.cPresident = cPresident; + this.cPopulartion = cPopulartion; + } + + public CountryModel() { + } + + public String getcName() { + return cName; + } + + public void setcName(String cName) { + this.cName = cName; + } + + public String getcImageUrl() { + return cImageUrl; + } + + public void setcImageUrl(String cImageUrl) { + this.cImageUrl = cImageUrl; + } + + public String getcPresident() { + return cPresident; + } + + public void setcPresident(String cPresident) { + this.cPresident = cPresident; + } + + public String getcPopulartion() { + return cPopulartion; + } + + public void setcPopulartion(String cPopulartion) { + this.cPopulartion = cPopulartion; + } +} diff --git a/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/repositories/CountryRepository.java b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/repositories/CountryRepository.java new file mode 100644 index 00000000..70f5b823 --- /dev/null +++ b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/repositories/CountryRepository.java @@ -0,0 +1,93 @@ +package com.codingwithmitch.mvvmrecyclerview.repositories; + +import android.arch.lifecycle.MutableLiveData; + +import com.codingwithmitch.mvvmrecyclerview.models.CountryModel; + +import java.util.ArrayList; +import java.util.List; + + +/** + * Singleton pattern + */ +public class CountryRepository { + + private static CountryRepository instance; + private ArrayList dataSet = new ArrayList<>(); + + + public static CountryRepository getInstance(){ + if(instance == null){ + instance = new CountryRepository(); + } + return instance; + } + + + /** + * Pretend to get data from a webservice or online source + */ + public MutableLiveData> getCountry1(){ + setCountry(); + MutableLiveData> data = new MutableLiveData<>(); + data.setValue(dataSet); + return data; + } + + + private void setCountry(){ + + dataSet.add( + new CountryModel("SRI LANKA", "https://live.staticflickr.com/2052/2294634746_838b570b51_c.jpg", + "G Rajapaksha", "2M") + ); + + dataSet.add( + new CountryModel("AUSTRALIA", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT4AAACfCAMAAABX0UX9AAABKVBMVEUBAIr/////AQH8AAD14N/yaWj//v8AAIjyq6sAAIX///0BAIwAAIEAAHUAAH+kpMLb2uPyAADyn58AAHqXCE8AAHT1AADuAADBwti5utK/wN2mpsjy1NP83NzzZGL5y8w1Noo1NJS4uNnlbW0lJo7Nztz5+f/lVVUwMInySEfkY2QvMJLyTk4nKIRWV6vv7vhWV42ur9eysMklI5pmZ6XLzOlJSKRMTI+cncZtcKdoabFpa57Cw9LLzNOYmLp9f7d/gK3i4PMXF5MZGYdDQ5dcXKamprcAAGkTEnlNTaqXb5Z+f70gIIWwstTyQT75xcLp09OFhafkUUxOTbA9P4qVmcqMjslycaHzWliwr7mMi7fp5/qEXo2KADlcX65hYo43N4MuL6Xn5+ilHZ+BAAARlElEQVR4nO1dC0PbRhLWolTb1cqKU9UEA2lDarv0KDhxoJBcC5hHSRO4a3p59Mhd2+P//4jb2Ye0kiVZsiRbJPpy0MDF0urbmdnZ2ZmR8f3XCCHbspGC3d10DQNTjCk1MsBpI/bhz5fC+BzZNmo7WS5gYPjChrP1CIZx55tlfgWT/e+7r71MV1gcYIyMMxTwh9DKQ8+g8ERZ+CtOn0ExJc7GKtz6zt/u+eTBzHYyjWFxWFoSBAbSx56bEegy6cNZLlACfQaW5D3g5JmcP64WqPbS50+0ok98rTAVzsRfCcrrbEnJu68+7s9oq9jTVQ7OnhqvrsGMQI/bpCliODt92OAT5E6Qtyxm074F9N2TyqIItDUpZDaQwgOmCmEB6WNrE3Y1m2cG5NmWlL56mz7jzjf3p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64wXlrfRBXSr69TDKvtw9t4TGgpJYbILLRbqBLYt73bghUToolbTCro62Q+A/FG3HgFopcO+O6tsUVv0UMKIbTWLa2afd9sd8dqBcab3180P8U3caD3cZgX8i0dlJcpZLbZDPjCNDcUXbo1XLtRwCr1V5hOGbN1dL5vSoEGDBg0aNGjQoEGDBg0aNGjQIIL/A7ivsN26o/gpAAAAAElFTkSuQmCC", + "S Morrison", "25.36M") + ); + + dataSet.add( + new CountryModel("INDIA", "https://upload.wikimedia.org/wikipedia/en/thumb/4/41/Flag_of_India.svg/1200px-Flag_of_India.svg.png", + "R N Kovind", "1.3B") + ); + + dataSet.add( + new CountryModel("AMERICA", "https://upload.wikimedia.org/wikipedia/en/thumb/a/a4/Flag_of_the_United_States.svg/1200px-Flag_of_the_United_States.svg.png", + "Joe Biden", "328.2M") + ); + + dataSet.add( + new CountryModel("CANADA", "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_%28Pantone%29.svg/1200px-Flag_of_Canada_%28Pantone%29.svg.png", + "J Trudeau", "37.2M") + ); + + dataSet.add( + new CountryModel("JAPAN", "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/Flag_of_Japan_%28bordered%29.svg/2560px-Flag_of_Japan_%28bordered%29.svg.png", + "Joe Biden", "328.2M") + ); + + dataSet.add( + new CountryModel("CHINA", "https://cdn.britannica.com/90/7490-004-BAD4AA72/Flag-China.jpg", + "Xi Jinping", "1.39B") + ); + + dataSet.add( + new CountryModel("NEW ZEALAND", "https://cdn.britannica.com/17/3017-004-DCC13F9D/Flag-New-Zealand.jpg", + "J Ardern", "328.2M") + ); + + } +} + + + + + + + + + + + diff --git a/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/viewmodels/MainActivityViewModel.java b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/viewmodels/MainActivityViewModel.java new file mode 100644 index 00000000..048f3665 --- /dev/null +++ b/CountryApp/app/src/main/java/com/codingwithmitch/mvvmrecyclerview/viewmodels/MainActivityViewModel.java @@ -0,0 +1,36 @@ +package com.codingwithmitch.mvvmrecyclerview.viewmodels; + +import android.arch.lifecycle.LiveData; +import android.arch.lifecycle.MutableLiveData; +import android.arch.lifecycle.ViewModel; + +import com.codingwithmitch.mvvmrecyclerview.models.CountryModel; +import com.codingwithmitch.mvvmrecyclerview.repositories.CountryRepository; + +import java.util.List; + +public class MainActivityViewModel extends ViewModel { + + /** + * mutable data mean can be change + * live data cant be directly change + */ + private MutableLiveData> mCountryMutableData; + private CountryRepository mRepo; +// private MutableLiveData mIsUpdating = new MutableLiveData<>(); + + public void init() { + if (mCountryMutableData != null) { + return; + } + mRepo = CountryRepository.getInstance(); + mCountryMutableData = mRepo.getCountry1(); //retrieve mutable live data from repository + } + + + public LiveData> getCountry() { + return mCountryMutableData; + } + + +} diff --git a/CountryApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/CountryApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..1f6bb290 --- /dev/null +++ b/CountryApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/CountryApp/app/src/main/res/drawable/ic_add_white_24dp.xml b/CountryApp/app/src/main/res/drawable/ic_add_white_24dp.xml new file mode 100644 index 00000000..e3979cd7 --- /dev/null +++ b/CountryApp/app/src/main/res/drawable/ic_add_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/CountryApp/app/src/main/res/drawable/ic_launcher_background.xml b/CountryApp/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..0d025f9b --- /dev/null +++ b/CountryApp/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CountryApp/app/src/main/res/layout/activity_main.xml b/CountryApp/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..7344682b --- /dev/null +++ b/CountryApp/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/CountryApp/app/src/main/res/layout/layout_listitem.xml b/CountryApp/app/src/main/res/layout/layout_listitem.xml new file mode 100644 index 00000000..a19a05dd --- /dev/null +++ b/CountryApp/app/src/main/res/layout/layout_listitem.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/CountryApp/app/src/main/res/menu/test.xml b/CountryApp/app/src/main/res/menu/test.xml new file mode 100644 index 00000000..fe187c0c --- /dev/null +++ b/CountryApp/app/src/main/res/menu/test.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/CountryApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/CountryApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..eca70cfe --- /dev/null +++ b/CountryApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/CountryApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/CountryApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..eca70cfe --- /dev/null +++ b/CountryApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/CountryApp/app/src/main/res/mipmap-hdpi/ic_launcher.png b/CountryApp/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..898f3ed5 Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/CountryApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/CountryApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 00000000..dffca360 Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/CountryApp/app/src/main/res/mipmap-mdpi/ic_launcher.png b/CountryApp/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..64ba76f7 Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/CountryApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/CountryApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 00000000..dae5e082 Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/CountryApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/CountryApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..e5ed4659 Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/CountryApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/CountryApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 00000000..14ed0af3 Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/CountryApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/CountryApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..b0907cac Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/CountryApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/CountryApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..d8ae0315 Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/CountryApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/CountryApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..2c18de9e Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/CountryApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/CountryApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..beed3cdd Binary files /dev/null and b/CountryApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/CountryApp/app/src/main/res/values/colors.xml b/CountryApp/app/src/main/res/values/colors.xml new file mode 100644 index 00000000..10c24823 --- /dev/null +++ b/CountryApp/app/src/main/res/values/colors.xml @@ -0,0 +1,8 @@ + + + + #FF6200EE + #FF6200EE + #D81B60 + + diff --git a/CountryApp/app/src/main/res/values/strings.xml b/CountryApp/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..ee3d8ac2 --- /dev/null +++ b/CountryApp/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + MVVMRecyclerView + diff --git a/CountryApp/app/src/main/res/values/styles.xml b/CountryApp/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..5885930d --- /dev/null +++ b/CountryApp/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/CountryApp/app/src/test/java/com/codingwithmitch/mvvmrecyclerview/ExampleUnitTest.java b/CountryApp/app/src/test/java/com/codingwithmitch/mvvmrecyclerview/ExampleUnitTest.java new file mode 100644 index 00000000..c28e2e43 --- /dev/null +++ b/CountryApp/app/src/test/java/com/codingwithmitch/mvvmrecyclerview/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.codingwithmitch.mvvmrecyclerview; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/CountryApp/build.gradle b/CountryApp/build.gradle new file mode 100644 index 00000000..8d3ef8e5 --- /dev/null +++ b/CountryApp/build.gradle @@ -0,0 +1,27 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' + + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/CountryApp/gradle.properties b/CountryApp/gradle.properties new file mode 100644 index 00000000..82618cec --- /dev/null +++ b/CountryApp/gradle.properties @@ -0,0 +1,15 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + + diff --git a/CountryApp/gradle/wrapper/gradle-wrapper.jar b/CountryApp/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..f6b961fd Binary files /dev/null and b/CountryApp/gradle/wrapper/gradle-wrapper.jar differ diff --git a/CountryApp/gradle/wrapper/gradle-wrapper.properties b/CountryApp/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..9a4163a4 --- /dev/null +++ b/CountryApp/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/CountryApp/gradlew b/CountryApp/gradlew new file mode 100644 index 00000000..cccdd3d5 --- /dev/null +++ b/CountryApp/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/CountryApp/gradlew.bat b/CountryApp/gradlew.bat new file mode 100644 index 00000000..f9553162 --- /dev/null +++ b/CountryApp/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/CountryApp/settings.gradle b/CountryApp/settings.gradle new file mode 100644 index 00000000..e7b4def4 --- /dev/null +++ b/CountryApp/settings.gradle @@ -0,0 +1 @@ +include ':app'