diff --git a/app/src/main/java/com/udacity/exploreindia/adapters/ImagePagerAdapter.java b/app/src/main/java/com/udacity/exploreindia/adapters/ImagePagerAdapter.java new file mode 100644 index 0000000..bff8811 --- /dev/null +++ b/app/src/main/java/com/udacity/exploreindia/adapters/ImagePagerAdapter.java @@ -0,0 +1,51 @@ +package com.udacity.exploreindia.adapters; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.v4.view.PagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import com.udacity.exploreindia.R; + +public class ImagePagerAdapter extends PagerAdapter { + + private Context mContext; + private int[] mImages = {R.drawable.taj_mahal, R.drawable.taj_mahal, R.drawable.taj_mahal}; + + public ImagePagerAdapter(Context context) { + mContext = context; + } + + @Override + public int getCount() { + return mImages.length; + } + + @Override + public boolean isViewFromObject(@NonNull View view, @NonNull Object object) { + return view == object; + } + + @NonNull + @Override + public Object instantiateItem(@NonNull ViewGroup container, int position) { + View view = LayoutInflater.from(mContext).inflate(R.layout.image_slider_layout, container, false); + ImageView imageView = view.findViewById(R.id.places_details_list_img_images); + imageView.setImageResource(mImages[position]); + + ViewPager viewPager = (ViewPager)container; + viewPager.addView(view, 0); + return view; + } + + @Override + public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { + ViewPager viewPager = (ViewPager) container; + View view = (View) object; + viewPager.removeView(view); + } +} diff --git a/app/src/main/java/com/udacity/exploreindia/base/PresenterFactory.java b/app/src/main/java/com/udacity/exploreindia/base/PresenterFactory.java index 311833b..ae3b212 100644 --- a/app/src/main/java/com/udacity/exploreindia/base/PresenterFactory.java +++ b/app/src/main/java/com/udacity/exploreindia/base/PresenterFactory.java @@ -11,6 +11,8 @@ import com.udacity.exploreindia.ui.home.fragments.main.MainPresenter; import com.udacity.exploreindia.ui.home.fragments.place.PlaceFragment; import com.udacity.exploreindia.ui.home.fragments.place.PlacePresenter; +import com.udacity.exploreindia.ui.home.fragments.placedetail.PlaceDetailFragment; +import com.udacity.exploreindia.ui.home.fragments.placedetail.PlaceDetailPresenter; import com.udacity.exploreindia.ui.home.fragments.profile.UserDetailFragment; import com.udacity.exploreindia.ui.home.fragments.profile.UserDetailPresenter; import com.udacity.exploreindia.ui.home.fragments.search.SearchFragment; @@ -28,21 +30,20 @@ public static S getPresente S presenter = null; if (claxx instanceof MainFragment) { presenter = (S) new MainPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx.getContext()); - return presenter; } else if (claxx instanceof PlaceFragment) { presenter = (S) new PlacePresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx.getContext()); - return presenter; } else if (claxx instanceof UserDetailFragment) { presenter = (S) new UserDetailPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx.getContext()); - return presenter; + }else if (claxx instanceof PlaceDetailFragment) { + presenter = (S) new PlaceDetailPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx.getContext()); } else if (claxx instanceof SearchFragment) { presenter = (S) new UserDetailPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx.getContext()); - return presenter; } else if (claxx instanceof LikedPlacesFragment) { presenter = (S) new LikedPlacesPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx.getContext()); } else { throw new IllegalStateException("Activity presenter not supported yet"); } + //Commented the throw exception line and returned presenter for demo purpose and can be changed later as required return presenter; //throw new IllegalStateException("Fragment presenter not supported yet"); diff --git a/app/src/main/java/com/udacity/exploreindia/ui/home/HomeActivity.java b/app/src/main/java/com/udacity/exploreindia/ui/home/HomeActivity.java index 4bb11f9..30c0585 100644 --- a/app/src/main/java/com/udacity/exploreindia/ui/home/HomeActivity.java +++ b/app/src/main/java/com/udacity/exploreindia/ui/home/HomeActivity.java @@ -41,6 +41,7 @@ protected int getContentResource() { return R.layout.activity_home; } + @Override protected void init(@Nullable Bundle savedInstanceState) { diff --git a/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailContract.java b/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailContract.java new file mode 100644 index 0000000..b9f82b2 --- /dev/null +++ b/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailContract.java @@ -0,0 +1,15 @@ +package com.udacity.exploreindia.ui.home.fragments.placedetail; + +import com.udacity.exploreindia.base.BaseMvpPresenter; +import com.udacity.exploreindia.base.BaseView; + +public interface PlaceDetailContract { + + interface Presenter extends BaseMvpPresenter { + + } + + interface View extends BaseView { + + } +} diff --git a/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailFragment.java b/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailFragment.java new file mode 100644 index 0000000..681c71f --- /dev/null +++ b/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailFragment.java @@ -0,0 +1,91 @@ +package com.udacity.exploreindia.ui.home.fragments.placedetail; + + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; +import android.support.v4.view.ViewPager; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.udacity.exploreindia.R; +import com.udacity.exploreindia.adapters.ImagePagerAdapter; +import com.udacity.exploreindia.base.BaseFragment; +import com.udacity.exploreindia.databinding.FragmentPlaceDetailBinding; + +/** + * A simple {@link Fragment} subclass. + */ +public class PlaceDetailFragment extends BaseFragment implements PlaceDetailContract.View { + + private ImageView[] mImageSlideDotIndicators; + private int imageSlideDotsCount; + public PlaceDetailFragment() { + // Required empty public constructor + } + + @Override + protected int getContentResource() { + return R.layout.fragment_place_detail; + } + + @Override + protected void init(View view, @Nullable Bundle savedInstanceState) { + + //Code for image slider + ImagePagerAdapter imagePagerAdapter = new ImagePagerAdapter(getActivity()); + ViewPager imageViewPager = view.findViewById(R.id.places_details_vp_images); + imageViewPager.setAdapter(imagePagerAdapter); + //No of slides + imageSlideDotsCount = imagePagerAdapter.getCount(); + mImageSlideDotIndicators = new ImageView[imageSlideDotsCount]; + //Container for dots indicator + LinearLayout imageSliderDotsContainer = view.findViewById(R.id.places_details_ll_image_dots_indicator); + //setting up the dots indicator + for(int i = 0; i< imageSlideDotsCount; i++){ + mImageSlideDotIndicators[i] = new ImageView(getActivity()); + mImageSlideDotIndicators[i].setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.dots_indicator_inactive)); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); + + params.setMargins(32, 0, 32, 0); + + imageSliderDotsContainer.addView(mImageSlideDotIndicators[i], params); + } + //setting the first dot as active + mImageSlideDotIndicators[0].setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.dots_indicator_active)); + + //setting page change listener to view pager + imageViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + //resetting the dots to inactive state + for(int i = 0; i< imageSlideDotsCount; i++){ + mImageSlideDotIndicators[i].setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.dots_indicator_inactive)); + } + //setting the active dot for the current page + mImageSlideDotIndicators[position].setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.dots_indicator_active)); + + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); + + //Place Description + TextView placeDescriptionTextView = view.findViewById(R.id.places_details_tv_place_description); + placeDescriptionTextView.setText(R.string.dummy_place_description); + } + + + +} diff --git a/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailPresenter.java b/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailPresenter.java new file mode 100644 index 0000000..b051d36 --- /dev/null +++ b/app/src/main/java/com/udacity/exploreindia/ui/home/fragments/placedetail/PlaceDetailPresenter.java @@ -0,0 +1,29 @@ +package com.udacity.exploreindia.ui.home.fragments.placedetail; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.v4.view.PagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import com.udacity.exploreindia.R; +import com.udacity.exploreindia.base.BasePresenter; +import com.udacity.exploreindia.data.BaseRepo; +import com.udacity.exploreindia.helper.SharedPrefManager; +import com.udacity.exploreindia.ui.home.fragments.place.PlaceContract; + +public class PlaceDetailPresenter extends BasePresenter implements PlaceDetailContract.Presenter { + + + public PlaceDetailPresenter(SharedPrefManager mSharedPreferences, BaseRepo mBaseRepo, Context mContext) { + super(mSharedPreferences, mBaseRepo, mContext); + } + + @Override + public void init() { + + } +} diff --git a/app/src/main/res/drawable/dots_indicator_active.xml b/app/src/main/res/drawable/dots_indicator_active.xml new file mode 100644 index 0000000..d2e07d2 --- /dev/null +++ b/app/src/main/res/drawable/dots_indicator_active.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/dots_indicator_inactive.xml b/app/src/main/res/drawable/dots_indicator_inactive.xml new file mode 100644 index 0000000..e730d11 --- /dev/null +++ b/app/src/main/res/drawable/dots_indicator_inactive.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_heart_outline_red.xml b/app/src/main/res/drawable/ic_heart_outline_red.xml new file mode 100644 index 0000000..d8a394f --- /dev/null +++ b/app/src/main/res/drawable/ic_heart_outline_red.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_navigation_red_24dp.xml b/app/src/main/res/drawable/ic_navigation_red_24dp.xml new file mode 100644 index 0000000..9ab23be --- /dev/null +++ b/app/src/main/res/drawable/ic_navigation_red_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_share_red_24dp.xml b/app/src/main/res/drawable/ic_share_red_24dp.xml new file mode 100644 index 0000000..7d5c489 --- /dev/null +++ b/app/src/main/res/drawable/ic_share_red_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/icon_circle_outline.xml b/app/src/main/res/drawable/icon_circle_outline.xml new file mode 100644 index 0000000..1eff7f7 --- /dev/null +++ b/app/src/main/res/drawable/icon_circle_outline.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/taj_mahal.png b/app/src/main/res/drawable/taj_mahal.png new file mode 100644 index 0000000..3ee5055 Binary files /dev/null and b/app/src/main/res/drawable/taj_mahal.png differ diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index bcbe0c3..8915a46 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -5,7 +5,7 @@ - + - - - + diff --git a/app/src/main/res/layout/activity_states_with_cities.xml b/app/src/main/res/layout/activity_states_with_cities.xml index e579a2e..7408196 100644 --- a/app/src/main/res/layout/activity_states_with_cities.xml +++ b/app/src/main/res/layout/activity_states_with_cities.xml @@ -1,5 +1,6 @@ + diff --git a/app/src/main/res/layout/fragment_place_detail.xml b/app/src/main/res/layout/fragment_place_detail.xml new file mode 100644 index 0000000..4fb84a1 --- /dev/null +++ b/app/src/main/res/layout/fragment_place_detail.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/image_slider_layout.xml b/app/src/main/res/layout/image_slider_layout.xml new file mode 100644 index 0000000..fcec9bf --- /dev/null +++ b/app/src/main/res/layout/image_slider_layout.xml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index f2c07b2..09dc3bf 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,5 +1,8 @@ + 256dp + 8dp + 16dp 8dp 16dp 18sp @@ -7,5 +10,4 @@ 14sp - \ No newline at end of file diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 13f2323..6d7e316 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -247,13 +247,16 @@ - - - - - - - + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4facaf8..11abb81 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -6,6 +6,15 @@ Read our privacy and policy + + Taj Mahal + The Taj Mahal was commissioned by Shah Jahan in 1631, to be built in the memory of his wife Mumtaz Mahal, a Persian princess who died giving birth to their 14th child, Gauhara Begum.[6] Construction of the Taj Mahal began in 1632.[7] The imperial court documenting Shah Jahan\'s grief after the death of Mumtaz Mahal illustrate the love story held as the inspiration for Taj Mahal.[8][9] The principal mausoleum was completed in 1643 and the surrounding buildings and garden were finished about five years later.[10]. + The Taj Mahal incorporates and expands on design traditions of Persian and earlier Mughal architecture. Specific inspiration came from successful Timurid and Mughal buildings including the Gur-e Amir (the tomb of Timur, progenitor of the Mughal dynasty, in Samarkand),[12] Humayun's Tomb, Itmad-Ud-Daulah's Tomb (sometimes called the Baby Taj), and Shah Jahan's own Jama Masjid in Delhi. While earlier Mughal buildings were primarily constructed of red sandstone, Shah Jahan promoted the use of white marble inlaid with semi-precious stones. Buildings under his patronage reached new levels of refinement. + Place details share button + Places details favourite button + Places details map location button + + Explore India Mobile No.