-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MenuFinder/development
Sprint 1
- Loading branch information
Showing
64 changed files
with
1,695 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyCT3geBi-P4CbjxQv0BxhXVoBy2GIbJ8rY</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/cat/udl/menufinder/activities/DetailMenuActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package cat.udl.menufinder.activities; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.MenuItem; | ||
|
||
import cat.udl.menufinder.R; | ||
import cat.udl.menufinder.application.MasterActivity; | ||
import cat.udl.menufinder.fragments.DetailMenuFragment; | ||
import cat.udl.menufinder.models.Menu; | ||
|
||
import static cat.udl.menufinder.utils.Constants.KEY_MENU; | ||
|
||
public class DetailMenuActivity extends MasterActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_detail_menu); | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
Intent intent = getIntent(); | ||
Menu menu = (Menu) intent.getSerializableExtra(KEY_MENU); | ||
DetailMenuFragment fragment = (DetailMenuFragment) getFragmentManager().findFragmentById(R.id.detail_fragment); | ||
fragment.update(menu); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case android.R.id.home: | ||
onBackPressed(); | ||
break; | ||
} | ||
return false; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/cat/udl/menufinder/activities/DetailRestaurantActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cat.udl.menufinder.activities; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.MenuItem; | ||
|
||
import cat.udl.menufinder.R; | ||
import cat.udl.menufinder.application.MasterActivity; | ||
import cat.udl.menufinder.fragments.DetailRestaurantFragment; | ||
import cat.udl.menufinder.models.Restaurant; | ||
|
||
import static cat.udl.menufinder.utils.Constants.KEY_RESTAURANT; | ||
|
||
public class DetailRestaurantActivity extends MasterActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_detail_restaurant); | ||
Intent intent = getIntent(); | ||
Restaurant restaurant = (Restaurant) intent.getSerializableExtra(KEY_RESTAURANT); | ||
DetailRestaurantFragment fragment = (DetailRestaurantFragment) getFragmentManager().findFragmentById(R.id.detail_fragment); | ||
fragment.update(restaurant); | ||
} | ||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case android.R.id.home: | ||
onBackPressed(); | ||
break; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
app/src/main/java/cat/udl/menufinder/activities/ReviewActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package cat.udl.menufinder.activities; | ||
|
||
import android.content.DialogInterface; | ||
import android.os.Bundle; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.support.v7.app.AlertDialog; | ||
import android.support.v7.widget.DividerItemDecoration; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.text.TextUtils; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.EditText; | ||
import android.widget.TextView; | ||
|
||
import java.util.List; | ||
|
||
import cat.udl.menufinder.R; | ||
import cat.udl.menufinder.adapters.ReviewAdapter; | ||
import cat.udl.menufinder.application.MasterActivity; | ||
import cat.udl.menufinder.models.Item; | ||
import cat.udl.menufinder.models.Review; | ||
|
||
import static cat.udl.menufinder.utils.Constants.KEY_ITEM; | ||
|
||
public class ReviewActivity extends MasterActivity { | ||
|
||
ReviewAdapter adapter; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_review); | ||
Item item = (Item) getIntent().getSerializableExtra(KEY_ITEM); | ||
((TextView) findViewById(R.id.name)).setText(item.getName()); | ||
((TextView) findViewById(R.id.description)).setText(item.getDescription()); | ||
configList(item.getReviews()); | ||
configFAB(item); | ||
} | ||
|
||
private void configList(List<Review> reviews) { | ||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list); | ||
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration( | ||
ReviewActivity.this, DividerItemDecoration.VERTICAL); | ||
recyclerView.addItemDecoration(itemDecoration); | ||
adapter = new ReviewAdapter(ReviewActivity.this, reviews); | ||
recyclerView.setAdapter(adapter); | ||
recyclerView.setLayoutManager(new LinearLayoutManager(ReviewActivity.this)); | ||
} | ||
|
||
private void configFAB(final Item item) { | ||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.add_item_button); | ||
fab.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
showAddDialog(item); | ||
} | ||
}); | ||
} | ||
|
||
private void showAddDialog(Item item) { | ||
LayoutInflater inflater = getLayoutInflater(); | ||
final View dialogView = inflater.inflate(R.layout.view_review, null); | ||
final AlertDialog alertDialog = new AlertDialog.Builder(ReviewActivity.this) | ||
.setTitle(item.getName()) | ||
.setIcon(R.drawable.menu_finder_logo) | ||
.setView(dialogView) | ||
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialogInterface, int i) { | ||
} | ||
}) | ||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialogInterface, int i) { | ||
} | ||
}) | ||
.create(); | ||
|
||
alertDialog.show(); | ||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
boolean closeDialog = true; | ||
String review = ((EditText) dialogView.findViewById(R.id.review)).getText().toString(); | ||
if (TextUtils.isEmpty(review)) { | ||
closeDialog = false; | ||
} | ||
|
||
if (closeDialog) { | ||
alertDialog.dismiss(); | ||
saveToDB(new Review(review)); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private void saveToDB(Review review) { | ||
adapter.addReview(review); | ||
showToast(getString(R.string.review_added)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.