diff --git a/Basics Nanodegree/Educational App/.gitignore b/Advanced NanoDegree/AndroidMe/.gitignore similarity index 100% rename from Basics Nanodegree/Educational App/.gitignore rename to Advanced NanoDegree/AndroidMe/.gitignore diff --git a/Advanced NanoDegree/AndroidMe/.idea/caches/build_file_checksums.ser b/Advanced NanoDegree/AndroidMe/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..699aadb Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/.idea/caches/build_file_checksums.ser differ diff --git a/Advanced NanoDegree/AndroidMe/.idea/caches/gradle_models.ser b/Advanced NanoDegree/AndroidMe/.idea/caches/gradle_models.ser new file mode 100644 index 0000000..955b5dd Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/.idea/caches/gradle_models.ser differ diff --git a/Advanced NanoDegree/AndroidMe/.idea/encodings.xml b/Advanced NanoDegree/AndroidMe/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Advanced NanoDegree/AndroidMe/.idea/gradle.xml b/Advanced NanoDegree/AndroidMe/.idea/gradle.xml new file mode 100644 index 0000000..2996d53 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/.idea/gradle.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/Advanced NanoDegree/AndroidMe/.idea/misc.xml b/Advanced NanoDegree/AndroidMe/.idea/misc.xml new file mode 100644 index 0000000..7bfef59 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/Basics Nanodegree/Educational App/.idea/modules.xml b/Advanced NanoDegree/AndroidMe/.idea/modules.xml similarity index 69% rename from Basics Nanodegree/Educational App/.idea/modules.xml rename to Advanced NanoDegree/AndroidMe/.idea/modules.xml index ad3304e..9a0d0eb 100644 --- a/Basics Nanodegree/Educational App/.idea/modules.xml +++ b/Advanced NanoDegree/AndroidMe/.idea/modules.xml @@ -2,7 +2,7 @@ - + diff --git a/Advanced NanoDegree/AndroidMe/.idea/render.experimental.xml b/Advanced NanoDegree/AndroidMe/.idea/render.experimental.xml new file mode 100644 index 0000000..8ec256a --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/.idea/render.experimental.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Basics Nanodegree/Educational App/.idea/runConfigurations.xml b/Advanced NanoDegree/AndroidMe/.idea/runConfigurations.xml similarity index 100% rename from Basics Nanodegree/Educational App/.idea/runConfigurations.xml rename to Advanced NanoDegree/AndroidMe/.idea/runConfigurations.xml diff --git a/Advanced NanoDegree/AndroidMe/.idea/vcs.xml b/Advanced NanoDegree/AndroidMe/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Basics Nanodegree/Educational App/app/.gitignore b/Advanced NanoDegree/AndroidMe/app/.gitignore similarity index 100% rename from Basics Nanodegree/Educational App/app/.gitignore rename to Advanced NanoDegree/AndroidMe/app/.gitignore diff --git a/Advanced NanoDegree/AndroidMe/app/build.gradle b/Advanced NanoDegree/AndroidMe/app/build.gradle new file mode 100644 index 0000000..ae74b90 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.example.android.android_me" + minSdkVersion 16 + 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' + } + } + compileOptions { + sourceCompatibility = '1.8' + targetCompatibility = '1.8' + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + implementation 'com.android.support:appcompat-v7:28.0.0' + testImplementation 'junit:junit:4.12' +} diff --git a/Advanced NanoDegree/AndroidMe/app/proguard-rules.pro b/Advanced NanoDegree/AndroidMe/app/proguard-rules.pro new file mode 100644 index 0000000..8ba0bac --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/cezannec/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# 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 *; +#} diff --git a/Advanced NanoDegree/AndroidMe/app/src/androidTest/java/com/example/android/android_me/ExampleInstrumentedTest.java b/Advanced NanoDegree/AndroidMe/app/src/androidTest/java/com/example/android/android_me/ExampleInstrumentedTest.java new file mode 100644 index 0000000..1f3f126 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/androidTest/java/com/example/android/android_me/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.android.android_me; + +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.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.example.android.android_me", appContext.getPackageName()); + } +} diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/AndroidManifest.xml b/Advanced NanoDegree/AndroidMe/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..d9f2699 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/data/AndroidImageAssets.java b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/data/AndroidImageAssets.java new file mode 100644 index 0000000..ea82261 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/data/AndroidImageAssets.java @@ -0,0 +1,100 @@ +/* +* Copyright (C) 2017 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.example.android.android_me.data; + +import com.example.android.android_me.R; + +import java.util.ArrayList; +import java.util.List; + +// Class for storing all the image drawable resources in ArrayLists +public class AndroidImageAssets { + + // Lists for all AndroidMe images + // Broken down into heads, bodies, legs, and all images + + private static final List heads = new ArrayList() {{ + add(R.drawable.head1); + add(R.drawable.head2); + add(R.drawable.head3); + add(R.drawable.head4); + add(R.drawable.head5); + add(R.drawable.head6); + add(R.drawable.head7); + add(R.drawable.head8); + add(R.drawable.head9); + add(R.drawable.head10); + add(R.drawable.head11); + add(R.drawable.head12); + }}; + + private static final List bodies = new ArrayList() {{ + add(R.drawable.body1); + add(R.drawable.body2); + add(R.drawable.body3); + add(R.drawable.body4); + add(R.drawable.body5); + add(R.drawable.body6); + add(R.drawable.body7); + add(R.drawable.body8); + add(R.drawable.body9); + add(R.drawable.body10); + add(R.drawable.body11); + add(R.drawable.body12); + }}; + + private static final List legs = new ArrayList() {{ + add(R.drawable.legs1); + add(R.drawable.legs2); + add(R.drawable.legs3); + add(R.drawable.legs4); + add(R.drawable.legs5); + add(R.drawable.legs6); + add(R.drawable.legs7); + add(R.drawable.legs8); + add(R.drawable.legs9); + add(R.drawable.legs10); + add(R.drawable.legs11); + add(R.drawable.legs12); + }}; + + private static final List all = new ArrayList() {{ + addAll(heads); + addAll(bodies); + addAll(legs); + }}; + + + // Getter methods that return lists of all head images, body images, and leg images + + public static List getHeads() { + return heads; + } + + public static List getBodies() { + return bodies; + } + + public static List getLegs() { + return legs; + } + + // Returns a list of all the images combined: heads, bodies, and legs in that order + public static List getAll() { + return all; + } +} diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/AndroidMeActivity.java b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/AndroidMeActivity.java new file mode 100644 index 0000000..b23d5d8 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/AndroidMeActivity.java @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2017 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.example.android.android_me.ui; + +import android.content.Intent; +import android.support.v4.app.FragmentManager; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +import com.example.android.android_me.R; +import com.example.android.android_me.data.AndroidImageAssets; + +// This activity will display a custom Android image composed of three body parts: head, body, and legs +public class AndroidMeActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_android_me); + + //Create Fragment only if no saved instance state + if(savedInstanceState == null){ + Intent intent = getIntent(); + Bundle information = intent.getExtras(); + + //Fragment manager make easy to add, replace and remove fragment in run time + FragmentManager fragmentManager = getSupportFragmentManager(); + + //Create and display Heads Body Fragment + BodyPartFragment headFragment = new BodyPartFragment(); + headFragment.setImageIds(AndroidImageAssets.getHeads()); + int headIndex = information.getInt("headIndex",0); + headFragment.setListIndex(headIndex); + fragmentManager.beginTransaction() + .add(R.id.head_container,headFragment) + .commit(); + + //Create and display Body Fragment + BodyPartFragment bodyFragment = new BodyPartFragment(); + bodyFragment.setImageIds(AndroidImageAssets.getBodies()); + int bodyIndex = information.getInt("bodyIndex",0); + bodyFragment.setListIndex(bodyIndex); + fragmentManager.beginTransaction() + .add(R.id.body_container,bodyFragment) + .commit(); + + //Create and display Legs Body Fragment + BodyPartFragment legsFragment = new BodyPartFragment(); + legsFragment.setImageIds(AndroidImageAssets.getLegs()); + int legIndex = information.getInt("legIndex",0); + legsFragment.setListIndex(legIndex); + fragmentManager.beginTransaction() + .add(R.id.legs_container,legsFragment) + .commit(); + } + } +} diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/BodyPartFragment.java b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/BodyPartFragment.java new file mode 100644 index 0000000..807dcf4 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/BodyPartFragment.java @@ -0,0 +1,75 @@ +package com.example.android.android_me.ui; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import com.example.android.android_me.R; + +import java.util.ArrayList; +import java.util.List; + +public class BodyPartFragment extends Fragment { + + private List mImageIds; + private int mListIndex; + + private static final String TAG = "BodyPartFragment"; + private static final String LAST_INDEX = "last_index"; + private static final String IMAGE_ID_LIST = "images_id"; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + //Load saved state + if(savedInstanceState != null){ + mListIndex = savedInstanceState.getInt(LAST_INDEX,0); + mImageIds = savedInstanceState.getIntegerArrayList(IMAGE_ID_LIST); + } + + //Inflate the Android me fragment layout + View rootView = inflater.inflate(R.layout.fragment_body_part, container, false); + + //init body part image view + ImageView imageView = rootView.findViewById(R.id.body_part_image_View); + imageView.setImageResource(mImageIds.get(mListIndex)); + if(mImageIds != null){ + imageView.setOnClickListener(v -> { + if(mListIndex < mImageIds.size() - 1){ + mListIndex++; + }else{ + mListIndex = 0; + } + imageView.setImageResource(mImageIds.get(mListIndex)); + }); + }else{ + Log.v(TAG,"This fragment has null list of image id's"); + } + + return rootView; + } + + public void setImageIds(List imageIds) { + this.mImageIds = imageIds; + } + + public void setListIndex(int index) { + this.mListIndex = index; + } + + /* + * Save the current state + */ + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt(LAST_INDEX,mListIndex); + outState.putIntegerArrayList(IMAGE_ID_LIST,(ArrayList) mImageIds); + } +} diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MainActivity.java b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MainActivity.java new file mode 100644 index 0000000..aa4a43d --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MainActivity.java @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.android_me.ui; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v4.app.FragmentManager; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.Button; +import android.widget.GridView; +import android.widget.Toast; + +import com.example.android.android_me.R; +import com.example.android.android_me.data.AndroidImageAssets; + +// This activity is responsible for displaying the master list of all images +// Implement the MasterListFragment callback, OnImageClickListener +public class MainActivity extends AppCompatActivity implements MasterListFragment.OnImageChangeListener{ + + // Variables to store the values for the list index of the selected images + // The default value will be index = 0 + private int headIndex; + private int bodyIndex; + private int legIndex; + + // Track whether to display a two-pane or single-pane UI + // A single-pane display refers to phone screens, and two-pane to larger tablet screens + private boolean mTwoPane; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + // Determine if you're creating a two-pane or single-pane display + if(findViewById(R.id.android_me_linear_layout) != null) { + // This LinearLayout will only initially exist in the two-pane tablet case + mTwoPane = true; + + // Change the GridView to space out the images more on tablet + GridView gridView = findViewById(R.id.images_grid_view); + gridView.setNumColumns(2); + + // Getting rid of the "Next" button that appears on phones for launching a separate activity + Button nextButton = findViewById(R.id.next_button); + nextButton.setVisibility(View.GONE); + + if(savedInstanceState == null) { + // In two-pane mode, add initial BodyPartFragments to the screen + FragmentManager fragmentManager = getSupportFragmentManager(); + + // Creating a new head fragment + BodyPartFragment headFragment = new BodyPartFragment(); + headFragment.setImageIds(AndroidImageAssets.getHeads()); + // Add the fragment to its container using a transaction + fragmentManager.beginTransaction() + .add(R.id.head_container, headFragment) + .commit(); + + // New body fragment + BodyPartFragment bodyFragment = new BodyPartFragment(); + bodyFragment.setImageIds(AndroidImageAssets.getBodies()); + fragmentManager.beginTransaction() + .add(R.id.body_container, bodyFragment) + .commit(); + + // New leg fragment + BodyPartFragment legFragment = new BodyPartFragment(); + legFragment.setImageIds(AndroidImageAssets.getLegs()); + fragmentManager.beginTransaction() + .add(R.id.legs_container, legFragment) + .commit(); + } + } else { + // We're in single-pane mode and displaying fragments on a phone in separate activities + mTwoPane = false; + } + } + + // Define the behavior for onImageSelected + public void onImageSelected(int position) { + // Create a Toast that displays the position that was clicked + Toast.makeText(this, "Position clicked = " + position, Toast.LENGTH_SHORT).show(); + + // bodyPartNumber will be = 0 for the head fragment, 1 for the body, and 2 for the leg fragment + // Dividing by 12 gives us these integer values because each list of images resources has a size of 12 + int bodyPartNumber = position /12; + + // Store the correct list index no matter where in the image list has been clicked + // This ensures that the index will always be a value between 0-11 + int listIndex = position - 12*bodyPartNumber; + + // Handle the two-pane case and replace existing fragments right when a new image is selected from the master list + if (mTwoPane) { + // Create two=pane interaction + + BodyPartFragment newFragment = new BodyPartFragment(); + + // Set the currently displayed item for the correct body part fragment + switch (bodyPartNumber) { + case 0: + // A head image has been clicked + // Give the correct image resources to the new fragment + newFragment.setImageIds(AndroidImageAssets.getHeads()); + newFragment.setListIndex(listIndex); + // Replace the old head fragment with a new one + getSupportFragmentManager().beginTransaction() + .replace(R.id.head_container, newFragment) + .commit(); + break; + case 1: + newFragment.setImageIds(AndroidImageAssets.getBodies()); + newFragment.setListIndex(listIndex); + getSupportFragmentManager().beginTransaction() + .replace(R.id.body_container, newFragment) + .commit(); + break; + case 2: + newFragment.setImageIds(AndroidImageAssets.getLegs()); + newFragment.setListIndex(listIndex); + getSupportFragmentManager().beginTransaction() + .replace(R.id.legs_container, newFragment) + .commit(); + break; + default: + break; + } + } else { + + // Handle the single-pane phone case by passing information in a Bundle attached to an Intent + + switch (bodyPartNumber) { + case 0: + headIndex = listIndex; + break; + case 1: + bodyIndex = listIndex; + break; + case 2: + legIndex = listIndex; + break; + default: + break; + } + + // Put this information in a Bundle and attach it to an Intent that will launch an AndroidMeActivity + Bundle b = new Bundle(); + b.putInt("headIndex", headIndex); + b.putInt("bodyIndex", bodyIndex); + b.putInt("legIndex", legIndex); + + // Attach the Bundle to an intent + final Intent intent = new Intent(this, AndroidMeActivity.class); + intent.putExtras(b); + + // The "Next" button launches a new AndroidMeActivity + Button nextButton = findViewById(R.id.next_button); + nextButton.setOnClickListener(view -> startActivity(intent)); + } + } +} \ No newline at end of file diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MasterListAdapter.java b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MasterListAdapter.java new file mode 100644 index 0000000..ed4ee41 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MasterListAdapter.java @@ -0,0 +1,84 @@ +/* +* Copyright (C) 2017 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.example.android.android_me.ui; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.GridView; +import android.widget.ImageView; + +import java.util.List; + + +// Custom adapter class that displays a list of Android-Me images in a GridView +public class MasterListAdapter extends BaseAdapter { + + // Keeps track of the context and list of images to display + private Context mContext; + private List mImageIds; + + /** + * Constructor method + * @param imageIds The list of images to display + */ + public MasterListAdapter(Context context, List imageIds) { + mContext = context; + mImageIds = imageIds; + } + + /** + * Returns the number of items the adapter will display + */ + @Override + public int getCount() { + return mImageIds.size(); + } + + @Override + public Object getItem(int i) { + return null; + } + + @Override + public long getItemId(int i) { + return 0; + } + + /** + * Creates a new ImageView for each item referenced by the adapter + */ + public View getView(final int position, View convertView, ViewGroup parent) { + ImageView imageView; + if (convertView == null) { + // If the view is not recycled, this creates a new ImageView to hold an image + imageView = new ImageView(mContext); + // Define the layout parameters + imageView.setAdjustViewBounds(true); + imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + imageView.setPadding(8, 8, 8, 8); + } else { + imageView = (ImageView) convertView; + } + + // Set the image resource and return the newly created ImageView + imageView.setImageResource(mImageIds.get(position)); + return imageView; + } + +} diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MasterListFragment.java b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MasterListFragment.java new file mode 100644 index 0000000..1c97061 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/java/com/example/android/android_me/ui/MasterListFragment.java @@ -0,0 +1,55 @@ +package com.example.android.android_me.ui; + +import android.content.Context; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.GridView; + +import com.example.android.android_me.R; +import com.example.android.android_me.data.AndroidImageAssets; + +public class MasterListFragment extends Fragment { + + private OnImageChangeListener mCallsBack; + + + @FunctionalInterface + public interface OnImageChangeListener{ + void onImageSelected(int position); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + //Inflate the Android me fragment layout + View rootView = inflater.inflate(R.layout.fragment_master_list, container, false); + + GridView imagesGridView = rootView.findViewById(R.id.images_grid_view); + + MasterListAdapter masterListAdapter = new MasterListAdapter(getContext(),AndroidImageAssets.getAll()); + + imagesGridView.setAdapter(masterListAdapter); + + imagesGridView.setOnItemClickListener((parent, view, position, id) -> { + mCallsBack.onImageSelected(position); + }); + + return rootView; + } + + @Override + public void onAttach(Context context) { + super.onAttach(context); + try{ + mCallsBack = (OnImageChangeListener)context; + }catch (ClassCastException e){ + throw new ClassCastException(context.toString() + " Must Implement OnImageChangeListener"); + } + } +} diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body1.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body1.png new file mode 100644 index 0000000..56fa532 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body1.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body10.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body10.png new file mode 100644 index 0000000..19a95e3 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body10.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body11.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body11.png new file mode 100644 index 0000000..abed886 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body11.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body12.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body12.png new file mode 100644 index 0000000..0c0cc4c Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body12.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body2.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body2.png new file mode 100644 index 0000000..14f3726 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body2.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body3.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body3.png new file mode 100644 index 0000000..c979673 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body3.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body4.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body4.png new file mode 100644 index 0000000..b3dff0d Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body4.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body5.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body5.png new file mode 100644 index 0000000..1de97b2 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body5.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body6.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body6.png new file mode 100644 index 0000000..0fc7eef Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body6.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body7.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body7.png new file mode 100644 index 0000000..7633a5b Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body7.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body8.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body8.png new file mode 100644 index 0000000..3e9ce91 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body8.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body9.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body9.png new file mode 100644 index 0000000..6e4cf5a Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/body9.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head1.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head1.png new file mode 100644 index 0000000..535ad0b Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head1.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head10.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head10.png new file mode 100644 index 0000000..79cfcaf Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head10.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head11.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head11.png new file mode 100644 index 0000000..3e2e9af Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head11.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head12.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head12.png new file mode 100644 index 0000000..5f1bc5d Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head12.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head2.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head2.png new file mode 100644 index 0000000..a33d742 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head2.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head3.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head3.png new file mode 100644 index 0000000..2bacfa1 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head3.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head4.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head4.png new file mode 100644 index 0000000..32c17c1 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head4.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head5.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head5.png new file mode 100644 index 0000000..37c49f2 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head5.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head6.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head6.png new file mode 100644 index 0000000..b636fc8 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head6.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head7.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head7.png new file mode 100644 index 0000000..821dabb Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head7.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head8.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head8.png new file mode 100644 index 0000000..d6cae19 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head8.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head9.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head9.png new file mode 100644 index 0000000..e1851b6 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/head9.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs1.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs1.png new file mode 100644 index 0000000..437a540 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs1.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs10.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs10.png new file mode 100644 index 0000000..1a07d43 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs10.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs11.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs11.png new file mode 100644 index 0000000..1a9df5f Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs11.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs12.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs12.png new file mode 100644 index 0000000..b18b1d4 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs12.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs2.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs2.png new file mode 100644 index 0000000..33ef08e Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs2.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs3.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs3.png new file mode 100644 index 0000000..bfd7ef1 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs3.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs4.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs4.png new file mode 100644 index 0000000..9e7860d Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs4.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs5.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs5.png new file mode 100644 index 0000000..fe4499f Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs5.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs6.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs6.png new file mode 100644 index 0000000..c260b2c Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs6.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs7.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs7.png new file mode 100644 index 0000000..aff789d Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs7.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs8.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs8.png new file mode 100644 index 0000000..b7ece18 Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs8.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs9.png b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs9.png new file mode 100644 index 0000000..3818c2f Binary files /dev/null and b/Advanced NanoDegree/AndroidMe/app/src/main/res/drawable/legs9.png differ diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/layout-sw600dp/activity_main.xml b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout-sw600dp/activity_main.xml new file mode 100644 index 0000000..0b7a033 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout-sw600dp/activity_main.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/activity_android_me.xml b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/activity_android_me.xml new file mode 100644 index 0000000..81fa88e --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/activity_android_me.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/activity_main.xml b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..6e76157 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/fragment_body_part.xml b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/fragment_body_part.xml new file mode 100644 index 0000000..2a3f514 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/fragment_body_part.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/fragment_master_list.xml b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/fragment_master_list.xml new file mode 100644 index 0000000..f531780 --- /dev/null +++ b/Advanced NanoDegree/AndroidMe/app/src/main/res/layout/fragment_master_list.xml @@ -0,0 +1,38 @@ + + + + + + +