Skip to content
Open
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,21 +30,20 @@ public static <T extends BaseFragment, S extends BaseMvpPresenter> 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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected int getContentResource() {
return R.layout.activity_home;
}


@Override
protected void init(@Nullable Bundle savedInstanceState) {

Expand Down
Original file line number Diff line number Diff line change
@@ -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<View> {

}

interface View extends BaseView {

}
}
Original file line number Diff line number Diff line change
@@ -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<PlaceDetailContract.Presenter,FragmentPlaceDetailBinding> 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);
}



}
Original file line number Diff line number Diff line change
@@ -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<PlaceDetailContract.View> implements PlaceDetailContract.Presenter {


public PlaceDetailPresenter(SharedPrefManager mSharedPreferences, BaseRepo mBaseRepo, Context mContext) {
super(mSharedPreferences, mBaseRepo, mContext);
}

@Override
public void init() {

}
}
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/dots_indicator_active.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" android:useLevel="true" android:dither="true">
<solid android:color="#870000"/>
<size android:width="12dp" android:height="12dp"/>
</shape>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/dots_indicator_inactive.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" android:useLevel="true" android:dither="true">
<solid android:color="@android:color/darker_gray"/>
<size android:width="8dp" android:height="8dp"/>
</shape>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_heart_outline_red.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="378.94"
android:viewportWidth="378.94" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#870000" android:pathData="M348.151,54.514c-19.883,-19.884 -46.315,-30.826 -74.435,-30.826c-28.124,0 -54.559,10.942 -74.449,30.826l-9.798,9.8l-9.798,-9.8c-19.884,-19.884 -46.325,-30.826 -74.443,-30.826c-28.117,0 -54.56,10.942 -74.442,30.826c-41.049,41.053 -41.049,107.848 0,148.885l147.09,147.091c2.405,2.414 5.399,3.892 8.527,4.461c1.049,0.207 2.104,0.303 3.161,0.303c4.161,0 8.329,-1.587 11.498,-4.764l147.09,-147.091C389.203,162.362 389.203,95.567 348.151,54.514zM325.155,180.404L189.47,316.091L53.782,180.404c-28.368,-28.364 -28.368,-74.514 0,-102.893c13.741,-13.739 32.017,-21.296 51.446,-21.296c19.431,0 37.702,7.557 51.438,21.296l21.305,21.312c6.107,6.098 16.897,6.098 23.003,0l21.297,-21.312c13.737,-13.739 32.009,-21.296 51.446,-21.296c19.431,0 37.701,7.557 51.438,21.296C353.526,105.89 353.526,152.039 325.155,180.404z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_navigation_red_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#870000"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_share_red_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#870000"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/icon_circle_outline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@android:color/white"/>
<stroke android:color="#870000" android:width="2dp"/>
</shape>
Binary file added app/src/main/res/drawable/taj_mahal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

</data>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_container"
Expand All @@ -17,20 +17,22 @@
android:id="@id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/bottom_navigation_view"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />


<android.support.design.widget.BottomNavigationView
android:id="@id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
android:foregroundGravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_navigation_menu" />



</RelativeLayout>
</android.support.constraint.ConstraintLayout>
</layout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_states_with_cities.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>

<data>

</data>
Expand Down
Loading