Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions app/src/main/java/com/udacity/exploreindia/PlaceDetailsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package com.udacity.exploreindia;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.LinearLayout;


/**
* Created by kamalshree on 4/29/2018.
*/

public class PlaceDetailsActivity extends AppCompatActivity {

ViewPager viewPagerImages, viewPagerText;
ViewPagerImageAdapter viewPagerImageAdapter;
ViewPagerTextAdapter viewPagerTextAdapter;
LinearLayout linearLayoutImages, linearLayoutText;
private int dotcountImages, dotcountText;
private ImageView[] dotsImages, dotsText;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_details);

/* Toolbar */
Toolbar mytoolbar = findViewById(R.id.app_bar);
setSupportActionBar(mytoolbar);
setTitle(" " + getResources().getString(R.string.app_tb_title).toString());
getSupportActionBar().setIcon(R.drawable.ic_menu);

/* Start of ViewPager implementation for the siding Images */
linearLayoutImages = findViewById(R.id.slidrDots);
viewPagerImages = findViewById(R.id.places_details_vp_images);
viewPagerImageAdapter = new ViewPagerImageAdapter(this);
viewPagerImages.setAdapter(viewPagerImageAdapter);


dotcountImages = viewPagerImageAdapter.getCount();
dotsImages = new ImageView[dotcountImages];


for (int i = 0; i < dotcountImages; i++) {
dotsImages[i] = new ImageView(this);
dotsImages[i].setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.nonactive_dot));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

params.setMargins(8, 0, 8, 0);
linearLayoutImages.addView(dotsImages[i], params);

}
dotsImages[0].setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.active_dot));
viewPagerImages.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

}

@Override
public void onPageSelected(int position) {

for (int i = 0; i < dotcountImages; i++) {
dotsImages[i].setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.nonactive_dot));
}

dotsImages[position].setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.active_dot));

}

@Override
public void onPageScrollStateChanged(int state) {
}
});
/* End sliding Image */

/* Start of ViewPager implementation for the siding Text */
linearLayoutText = findViewById(R.id.slidrDotsText);
viewPagerText = findViewById(R.id.places_details_vp_text);
viewPagerTextAdapter = new ViewPagerTextAdapter(this);
viewPagerText.setAdapter(viewPagerTextAdapter);

dotcountText = viewPagerTextAdapter.getCount();
dotsText = new ImageView[dotcountText];

for (int i = 0; i < dotcountText; i++) {
dotsText[i] = new ImageView(this);
dotsText[i].setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.nonactive_dot));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(8, 0, 8, 0);

linearLayoutText.addView(dotsText[i], params);

}
dotsText[0].setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.active_dot));
viewPagerText.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

}

@Override
public void onPageSelected(int position) {

for (int i = 0; i < dotcountText; i++) {
dotsText[i].setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.nonactive_dot));
}

dotsText[position].setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.active_dot));

}

@Override
public void onPageScrollStateChanged(int state) {
}
});
/* End sliding Text */

}

/* Start of Menu item Implementation */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
/* End of Menu item Implementation */
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.udacity.exploreindia;

import android.content.Context;
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;

/**
* Created by kamalshree on 4/29/2018.
*/

public class ViewPagerImageAdapter extends PagerAdapter {
private Context context;
private LayoutInflater layoutInflater;
private Integer[] images = {R.drawable.slider1, R.drawable.slider2, R.drawable.slider3};

public ViewPagerImageAdapter(Context context) {
this.context = context;
}

@Override
public int getCount() {
return images.length;
}

@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}

@Override
public Object instantiateItem(ViewGroup container, int position) {

layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=layoutInflater.inflate(R.layout.custom_image_layout,null);

ImageView imageView=(ImageView)view.findViewById(R.id.places_details_list_img_images);
imageView.setImageResource(images[position]);

ViewPager viewPager=(ViewPager)container;
viewPager.addView(view,0);
return view;
}

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
ViewPager viewPager=(ViewPager)container;
View view=(View) object;
viewPager.removeView(view);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.udacity.exploreindia;

import android.content.Context;
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 android.widget.TextView;

/**
* Created by kamalshree on 4/29/2018.
*/

public class ViewPagerTextAdapter extends PagerAdapter {
private Context context;
private LayoutInflater layoutInflater;
private String[] textdetails = {
"The Taj Mahal is an enormous mausoleum complex commissioned in 1632 by the Mughal emperor Shah Jahan to house the remains of his beloved wife. Constructed over a 20-year period on the southern bank of the Yamuna River in Agra, India, the famed complex is one of the most outstanding examples of Mughal architecture, which combined Indian, Persian and Islamic influences.",
"Shah Jahan was a member of the Mughal dynasty that ruled most of northern India from the early 16th to the mid 18th-century. After the death of his father, King Jahangir, in 1627, Shah Jahan emerged the victor of a bitter power struggle with his brothers, and crowned himself emperor at Agra in 1628. ",
"Construction began around 1632 and would continue for the next two decades. The chief architect was probably Ustad Ahmad Lahouri, an Indian of Persian descent who would later be credited with designing the Red Fort at Delhi. "};


public ViewPagerTextAdapter(Context context) {
this.context = context;
}

@Override
public int getCount() {
return textdetails.length;
}

@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}

@Override
public Object instantiateItem(ViewGroup container, int position) {

layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=layoutInflater.inflate(R.layout.custom_text_layout,null);

TextView textView=(TextView)view.findViewById(R.id.places_details_tv_place_description);
textView.setText(textdetails[position]);

ViewPager viewPager=(ViewPager)container;
viewPager.addView(view,0);
return view;
}

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
ViewPager viewPager=(ViewPager)container;
View view=(View) object;
viewPager.removeView(view);
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/active_dot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?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">

<size android:height="12dip" android:width="12dip"/>

<solid android:color="#bebebe"/>
</shape>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_favourite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="44.236"
android:viewportWidth="44.236" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#870000" android:pathData="M22.12,44.24C9.92,44.24 0,34.31 0,22.12S9.92,0 22.12,0s22.12,9.92 22.12,22.12S34.31,44.24 22.12,44.24zM22.12,1.5C10.75,1.5 1.5,10.75 1.5,22.12c0,11.37 9.25,20.62 20.62,20.62c11.37,0 20.62,-9.25 20.62,-20.62C42.74,10.75 33.49,1.5 22.12,1.5z"/>
<path android:fillColor="#870000" android:pathData="M22.12,31.92c-0.19,0 -0.38,-0.07 -0.53,-0.22l-6.53,-6.52c-0.08,-0.07 -2.4,-2.27 -2.4,-4.89c0,-3.21 1.9,-5.13 5.09,-5.13c1.82,0 3.52,1.44 4.38,2.3c0.86,-0.87 2.56,-2.3 4.38,-2.3c3.19,0 5.09,1.92 5.09,5.13c0,2.62 -2.32,4.81 -2.42,4.9l-6.52,6.5C22.5,31.85 22.31,31.92 22.12,31.92zM17.74,16.68c-1.64,0 -3.59,0.63 -3.59,3.63c0,1.96 1.92,3.79 1.94,3.81l6.02,6l6.01,-5.99c0.04,-0.03 1.96,-1.87 1.96,-3.83c0,-3 -1.95,-3.63 -3.59,-3.63c-1.52,0 -3.25,1.72 -3.79,2.38c-0.28,0.35 -0.88,0.35 -1.16,0C21,18.4 19.26,16.68 17.74,16.68z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_map.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="479.586"
android:viewportWidth="479.586" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#870000" android:pathData="M239.8,0C107.4,0 0,107.4 0,239.8s107.4,239.8 239.8,239.8s239.8,-107.4 239.8,-239.8S372.2,0 239.8,0zM239.8,447.1c-114.3,0 -207.3,-93 -207.3,-207.3S125.5,32.5 239.8,32.5s207.3,93 207.3,207.3S354.1,447.1 239.8,447.1z"/>
<path android:fillColor="#870000" android:pathData="M108.2,311.6l131.6,-62.8l131.6,62.9l-131.6,-237.7z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector android:height="24dp" android:viewportHeight="62.246"
android:viewportWidth="62.246" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M57.55,45.11H19.97c-2.6,0 -4.7,2.11 -4.7,4.7c0,2.59 2.1,4.7 4.7,4.7h37.58c2.59,0 4.7,-2.11 4.7,-4.7C62.25,47.21 60.14,45.11 57.55,45.11z"/>
<path android:fillColor="#FF000000" android:pathData="M57.55,26.4H19.97c-2.6,0 -4.7,2.1 -4.7,4.7c0,2.6 2.1,4.7 4.7,4.7h37.58c2.59,0 4.7,-2.1 4.7,-4.7S60.14,26.4 57.55,26.4z"/>
<path android:fillColor="#FF000000" android:pathData="M19.97,17.1h37.58c2.59,0 4.7,-2.1 4.7,-4.7s-2.1,-4.7 -4.7,-4.7H19.97c-2.6,0 -4.7,2.1 -4.7,4.7C15.27,14.99 17.37,17.1 19.97,17.1z"/>
<path android:fillColor="#FF000000" android:pathData="M4.77,12.44m-4.77,0a4.77,4.77 0,1 1,9.54 0a4.77,4.77 0,1 1,-9.54 0"/>
<path android:fillColor="#FF000000" android:pathData="M4.77,31.1m-4.77,0a4.77,4.77 0,1 1,9.54 0a4.77,4.77 0,1 1,-9.54 0"/>
<path android:fillColor="#FF000000" android:pathData="M4.77,49.81m-4.77,0a4.77,4.77 0,1 1,9.54 0a4.77,4.77 0,1 1,-9.54 0"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_share.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="60.0"
android:viewportWidth="60.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#870000" android:pathData="M30,0C13.46,0 0,13.46 0,30s13.46,30 30,30s30,-13.46 30,-30S46.54,0 30,0zM30,58C14.56,58 2,45.44 2,30S14.56,2 30,2s28,12.56 28,28S45.44,58 30,58z"/>
<path android:fillColor="#870000" android:pathData="M39,20c3.31,0 6,-2.69 6,-6s-2.69,-6 -6,-6c-3.13,0 -5.7,2.41 -5.97,5.47L18.96,23.79C18.09,23.29 17.08,23 16,23c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c1.08,0 2.09,-0.29 2.96,-0.79l14.06,10.31C33.29,47.59 35.87,50 39,50c3.31,0 6,-2.69 6,-6s-2.69,-6 -6,-6c-2.69,0 -4.97,1.78 -5.73,4.22l-12.72,-9.32C21.45,31.85 22,30.49 22,29s-0.55,-2.85 -1.45,-3.9l12.72,-9.32C34.03,18.22 36.31,20 39,20zM39,10c2.21,0 4,1.79 4,4s-1.79,4 -4,4s-4,-1.79 -4,-4S36.79,10 39,10zM12,29c0,-2.21 1.79,-4 4,-4s4,1.79 4,4s-1.79,4 -4,4S12,31.21 12,29zM39,40c2.21,0 4,1.79 4,4s-1.79,4 -4,4s-4,-1.79 -4,-4S36.79,40 39,40z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/nonactive_dot.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?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">

<size android:height="8dip" android:width="8dip"/>

<solid android:color="#000000"/>
</shape>
Binary file added app/src/main/res/drawable/slider1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/slider2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/slider3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading