Skip to content

Commit

Permalink
Squashed Commits
Browse files Browse the repository at this point in the history
  • Loading branch information
jagzmz committed Sep 30, 2019
1 parent d21a642 commit d0bd182
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 14 deletions.
7 changes: 3 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Hotel Booking & Recommendations

## Workflow
<img src='./hotelapp.gif'>

## Problem Statement
1. Take a sample JSON for a list of Hotels
2. The hotel shall have most basic identifying fields
3. Create a few users who will perform the following activities.
4. Track the visitors on a hotel page
6. Users make a Draft Booking, where the user tries to book a hotel but don't complete the process
7. Users book a Hotel i.e. Create a completed booking

8. Display the activities happening around hotel page (Visits, Draft Bookings, Completed Booking)


9. Display recommendations of other hotels based on the activities done by the user.

10. Implement a basic UI with minimal functionality required.

## App Features
Expand Down
Binary file added app/release/app-release.apk
Binary file not shown.
1 change: 1 addition & 0 deletions app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
if (v.getId() == R.id.loginBtn) {
if (getUsername().equals("") || getUsername().length() < 5) {
if (getUsername().equals("")) {
setError(username, "Enter valid username with length greater than 5 char");
} else {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
Expand All @@ -33,6 +33,8 @@ public class HomeFrag extends Fragment {
private String mParam2;
private HotelAdapter hotelAdapter;
HotelResult hotelResult;
RecyclerView recyclerView;
int lastPos=0;

public HomeFrag() {
// Required empty public constructor
Expand Down Expand Up @@ -71,10 +73,25 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,


View view=inflater.inflate(R.layout.fragment_home, container, false);
recyclerView=view.findViewById(R.id.hotelList);


return view;
}

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);

}

@Override
public void onPause() {
super.onPause();
lastPos = ((LinearLayoutManager)recyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();

}

public String getHotels(){
SharedPreferences sp=getActivity().getSharedPreferences("hotel",Context.MODE_PRIVATE);
Gson gson=new Gson();
Expand All @@ -91,8 +108,6 @@ public String getHotels(){
@Override
public void onResume() {
super.onResume();
RecyclerView recyclerView=getActivity().findViewById(R.id.hotelList);

HotelAdapter hotelAdapter=new HotelAdapter(getContext());
Gson gson=new Gson();

Expand All @@ -101,7 +116,7 @@ public void onResume() {

BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(getActivity().getAssets().open("hotels.json")));
br = new BufferedReader(new InputStreamReader(getContext().getAssets().open("hotels.json")));
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -114,10 +129,11 @@ public void onResume() {
}

hotelAdapter.setHotels(hotelResult.getHotels());
Log.d("afafaf", "onCreateView: "+hotelResult.getHotels().get(0).getCompletedBookings());
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(hotelAdapter);

recyclerView.getLayoutManager().scrollToPosition(lastPos);

}

// TODO: Rename method, update argument and hook method into UI event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
Expand Down Expand Up @@ -40,6 +41,7 @@ public class Recommendation extends Fragment {
private String mParam2;
public static Set<String> tagSet = new HashSet<>();
RecommendationAdapter recommendationAdapter;
TextView placeholderEmpty;


private HotelResult hotelResult;
Expand Down Expand Up @@ -81,7 +83,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_recommendation, container, false);


placeholderEmpty=v.findViewById(R.id.emptyRecommendationPlaceHolder);
RecyclerView recyclerView = v.findViewById(R.id.hotelList);

this.recommendationAdapter = new RecommendationAdapter(getContext());
Expand All @@ -91,6 +93,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(recommendationAdapter);



return v;


Expand All @@ -100,6 +104,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
public void onResume() {
super.onResume();

if(recommendationAdapter.getItemCount()==0){
placeholderEmpty.setVisibility(View.VISIBLE);
}
else{
placeholderEmpty.setVisibility(View.INVISIBLE);
}

}

Expand Down
14 changes: 12 additions & 2 deletions app/src/main/res/layout/fragment_recommendation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@
android:tag="reco"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/hotelList"
/>
android:id="@+id/hotelList" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:id="@+id/emptyRecommendationPlaceHolder"
android:text="Book hotel for getting a recommendation"
android:layout_centerInParent="true"
android:gravity="center"
android:visibility="invisible"
android:textSize="23sp"/>

</RelativeLayout>
Binary file added hotelapp.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d0bd182

Please sign in to comment.