Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ dependencies {
//CardView
implementation deps.android.support.cardView


//PinView
implementation 'com.github.GoodieBag:Pinview:v1.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation deps.junit
androidTestImplementation deps.android.support.test.runner
androidTestImplementation deps.android.support.test.espressoCore
Expand Down
29 changes: 14 additions & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.udacity.exploreindia">
package="com.udacity.exploreindia">

<application
android:name=".ExploreApp"
Expand All @@ -10,30 +10,29 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name=".ui.splash.SplashActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

<activity
android:name=".ui.login.LoginActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"></activity>

android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity
android:name=".ui.home.HomeActivity"
android:windowSoftInputMode="adjustPan|adjustResize"></activity>

<activity android:name=".ui.City.CityActivity" />

<activity android:name=".ui.StatesWithCities.StatesWithCitiesActivity" />

<activity android:name=".ui.StatesWithPlaces.StatesWithPlacesActivity"></activity>
android:windowSoftInputMode="adjustPan|adjustResize">
</activity>
<activity android:name=".ui.City.CityActivity"/>
<activity android:name=".ui.StatesWithCities.StatesWithCitiesActivity"/>
<activity android:name=".ui.StatesWithPlaces.StatesWithPlacesActivity"/>
<activity android:name=".ui.selectedstate.SelectedStateActivity">
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.udacity.exploreindia.base;

import com.udacity.exploreindia.injection.InjectionUtils;
import com.udacity.exploreindia.ui.City.CityActivity;
import com.udacity.exploreindia.ui.City.CityPresenter;
import com.udacity.exploreindia.ui.home.HomeActivity;
import com.udacity.exploreindia.ui.home.HomePresenter;
import com.udacity.exploreindia.ui.home.fragments.likedplaces.LikedPlacesFragment;
Expand All @@ -16,6 +14,10 @@
import com.udacity.exploreindia.ui.home.fragments.search.SearchFragment;
import com.udacity.exploreindia.ui.login.LoginActivity;
import com.udacity.exploreindia.ui.login.LoginPresenter;
import com.udacity.exploreindia.ui.selectedstate.SelectedStateActivity;
import com.udacity.exploreindia.ui.selectedstate.SelectedStatePresenter;
import com.udacity.exploreindia.ui.selectedstate.fragment.SelectedPlacesFragment;
import com.udacity.exploreindia.ui.selectedstate.fragment.SelectedPlacesPresenter;
import com.udacity.exploreindia.ui.splash.SplashActivity;
import com.udacity.exploreindia.ui.splash.SplashPresenter;

Expand All @@ -40,6 +42,8 @@ public static <T extends BaseFragment, S extends BaseMvpPresenter> S getPresente
return presenter;
} else if (claxx instanceof LikedPlacesFragment) {
presenter = (S) new LikedPlacesPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx.getContext());
} else if (claxx instanceof SelectedPlacesFragment) {
presenter = (S) new SelectedPlacesPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx.getContext());
} else {
throw new IllegalStateException("Activity presenter not supported yet");
}
Expand All @@ -57,8 +61,8 @@ public static <T extends BaseActivity, S extends BaseMvpPresenter> S getPresente
presenter = (S) new LoginPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx);
} else if (claxx instanceof HomeActivity) {
presenter = (S) new HomePresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx);
} else if (claxx instanceof CityActivity) {
presenter = (S) new CityPresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx);
} else if (claxx instanceof SelectedStateActivity) {
presenter = (S) new SelectedStatePresenter(InjectionUtils.getSharedPreference(), InjectionUtils.providesDataRepo(), claxx);
} else {
throw new IllegalStateException("Activity presenter not supported yet");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.udacity.exploreindia.ui.selectedstate;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.Menu;

import com.udacity.exploreindia.R;
import com.udacity.exploreindia.base.BaseActivity;
import com.udacity.exploreindia.databinding.ActivitySelectedStateBinding;
import com.udacity.exploreindia.ui.home.HomeContract;
import com.udacity.exploreindia.ui.selectedstate.adapter.SelectedStateVPAdapter;
import com.udacity.exploreindia.ui.selectedstate.fragment.SelectedPlacesFragment;

public class SelectedStateActivity extends BaseActivity<HomeContract.Presenter, ActivitySelectedStateBinding> implements HomeContract.View {

private ViewPager mVpSelectedState;
private TabLayout mTabSelectedState;

@Override
protected int getContentResource() {
return R.layout.activity_selected_state;
}

@Override
protected void init(@Nullable Bundle savedInstanceState) {
mVpSelectedState = findViewById(R.id.vp_selected_state);
mTabSelectedState = findViewById(R.id.tb_selected_state);
//Set up the view pager
setupViewPager(mVpSelectedState);
//set up the tab layout with the tab layout
mTabSelectedState.setupWithViewPager(mVpSelectedState);
}

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

}

private void setupViewPager(ViewPager viewPager) {
SelectedStateVPAdapter adapter = new SelectedStateVPAdapter(getSupportFragmentManager());
adapter.addFragment(SelectedPlacesFragment.newInstance(), getString(R.string.tab_places_title));
//TODO
//Add the City fragment here
adapter.addFragment(SelectedPlacesFragment.newInstance(), getString(R.string.tab_city_title));
viewPager.setAdapter(adapter);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_menu, menu);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.udacity.exploreindia.ui.selectedstate;

import com.udacity.exploreindia.base.BaseMvpPresenter;
import com.udacity.exploreindia.base.BaseView;

public interface SelectedStateContract {

interface Presenter extends BaseMvpPresenter<View> {

}

interface View extends BaseView {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.udacity.exploreindia.ui.selectedstate;

import android.content.Context;

import com.udacity.exploreindia.base.BasePresenter;
import com.udacity.exploreindia.data.BaseRepo;
import com.udacity.exploreindia.helper.SharedPrefManager;

public class SelectedStatePresenter extends BasePresenter<SelectedStateContract.View> implements SelectedStateContract.Presenter {


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

@Override
public void init() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.udacity.exploreindia.ui.selectedstate.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
* Created by Bhavik Makwana on 11-05-2018.
*/
public class SelectedStateVPAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();

public SelectedStateVPAdapter(FragmentManager manager) {
super(manager);
}

@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}

@Override
public int getCount() {
return mFragmentList.size();
}

public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}

@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.udacity.exploreindia.ui.selectedstate.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.udacity.exploreindia.R;

/**
* Created by Divya on 30-04-2018.
*/

public class StatePlacesAdapter extends RecyclerView.Adapter<StatePlacesAdapter.ViewHolder> {
private Context context;

/*TODO
* 1. add the arrayList in the Constructor
* */
public StatePlacesAdapter(Context context) {
this.context = context;
}

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.places_item_layout, parent, false);
return new ViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

//TODO Remove this code when fetch the data from the server
if (position % 2 == 0)
holder.mIvPlaceImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.gateway_of_india));
else
holder.mIvPlaceImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.gateway_of_india_small));

holder.mTvPlaceName.setText("Diu Daman");
holder.mIvIsFavorite.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_action_favorite_fill));
}


@Override
public int getItemCount() {
//TODO Change this to -> arrayListObject.size()
return 10;
}

class ViewHolder extends RecyclerView.ViewHolder {
private ImageView mIvPlaceImage;
private TextView mTvPlaceName;
private ImageView mIvIsFavorite;

ViewHolder(View itemView) {
super(itemView);
mIvPlaceImage = itemView.findViewById(R.id.iv_state_place_image);
mTvPlaceName = itemView.findViewById(R.id.tv_state_place_name);
mIvIsFavorite = itemView.findViewById(R.id.iv_state_place_favourite);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.udacity.exploreindia.ui.selectedstate.fragment;

import com.udacity.exploreindia.base.BaseMvpPresenter;
import com.udacity.exploreindia.base.BaseView;

/**
* Created by kamalshree on 5/3/2018.
*/

public interface SelectedPlacesContract {

interface Presenter extends BaseMvpPresenter<View> {
}

interface View extends BaseView {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.udacity.exploreindia.ui.selectedstate.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.widget.LinearLayout;

import com.udacity.exploreindia.R;
import com.udacity.exploreindia.base.BaseFragment;
import com.udacity.exploreindia.databinding.FragmentSelectedPlacesBinding;
import com.udacity.exploreindia.ui.selectedstate.adapter.StatePlacesAdapter;


public class SelectedPlacesFragment extends BaseFragment<SelectedPlacesContract.Presenter, FragmentSelectedPlacesBinding> implements SelectedPlacesContract.View {

public SelectedPlacesFragment() {
// Required empty public constructor
}

public static SelectedPlacesFragment newInstance() {
SelectedPlacesFragment fragment = new SelectedPlacesFragment();
Bundle bundle = new Bundle();
fragment.setArguments(bundle);
return fragment;
}

@Override
protected int getContentResource() {
return R.layout.fragment_selected_places;
}

@Override
protected void init(View view, @Nullable Bundle savedInstanceState) {
//initializations
RecyclerView mRvSelectedPlaces = view.findViewById(R.id.rv_selected_state_places);
//set up the RecyclerView
mRvSelectedPlaces.setHasFixedSize(true);
mRvSelectedPlaces.setLayoutManager(new StaggeredGridLayoutManager(2, LinearLayout.VERTICAL));
mRvSelectedPlaces.setAdapter(new StatePlacesAdapter(getContext()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.udacity.exploreindia.ui.selectedstate.fragment;

import android.content.Context;

import com.udacity.exploreindia.base.BasePresenter;
import com.udacity.exploreindia.data.BaseRepo;
import com.udacity.exploreindia.helper.SharedPrefManager;

/**
* Created by kamalshree on 5/3/2018.
*/

public class SelectedPlacesPresenter extends BasePresenter<SelectedPlacesContract.View> implements SelectedPlacesContract.Presenter {

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

@Override
public void init() {

}
}
Loading