Last active
November 1, 2015 00:26
-
-
Save hrafnkellbaldurs/334770b0dac3751f4b8e to your computer and use it in GitHub Desktop.
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
package com.example.notandi.hanastel.activities; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.view.Menu; | |
import android.view.View; | |
import android.widget.AdapterView; | |
import android.widget.ListView; | |
import com.example.notandi.hanastel.adapters.AllFilteredDrinksAdapter; | |
import com.example.notandi.hanastel.product.CocktailRecipe; | |
import com.example.notandi.hanastel.product.CocktailRecipeAddon; | |
import com.example.notandi.hanastel.product.Ingredient; | |
import com.example.notandi.hanastel.R; | |
import com.example.notandi.hanastel.adapters.AllDrinksAdapter; | |
import java.util.ArrayList; | |
/** | |
* Created by Notandi on 22-Oct-15. | |
*/ | |
public class AllDrinksActivity extends MainActivity { | |
private ListView listView; | |
AllDrinksAdapter adapter; | |
AllFilteredDrinksAdapter filteredAdapter; | |
boolean isSearch; | |
@Override | |
protected void onCreate(Bundle savedInstanceState){ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_all_drinks); | |
Intent i = getIntent(); | |
isSearch = i.getBooleanExtra("isSearch", false); | |
listView = (ListView) findViewById(R.id.drinks); | |
adapter = new AllDrinksAdapter(this, recipes); | |
filteredAdapter = new AllFilteredDrinksAdapter(this, filteredRecipes); | |
if(isSearch){ | |
listView.setAdapter(filteredAdapter); | |
} | |
else{ | |
listView.setAdapter(adapter); | |
} | |
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |
@Override | |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |
Object o = parent.getItemAtPosition(position); | |
onDrinkDetailClick(view,o); | |
//selectedIngredientsAdapter.notifyDataSetChanged(); | |
//searchBox.setText(""); | |
} | |
}); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
return false; | |
} | |
public void onDrinkDetailClick(View view, Object o) { | |
Intent intent = new Intent(this, DrinkDetailActivity.class); | |
if(isSearch){ | |
CocktailRecipeAddon cra = (CocktailRecipeAddon) o; | |
intent.putExtra("clickedCocktailSearch", cra); | |
intent.putExtra("isSearchDetail", true); | |
} | |
else{ | |
CocktailRecipe cr = (CocktailRecipe) o; | |
intent.putExtra("clickedCocktail", cr); | |
intent.putExtra("isSearchDetail", false); | |
} | |
intent.putExtra("isRandom", false); | |
startActivity(intent); | |
} | |
} |
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
package com.example.notandi.hanastel.product; | |
import java.io.Serializable; | |
import java.util.ArrayList; | |
/** | |
* Created by Hrafnkell on 31/10/2015. | |
*/ | |
public class CocktailRecipeAddon extends CocktailRecipe implements Serializable { | |
private ArrayList<IngredientAddon> ingredientAddons; | |
public CocktailRecipeAddon(){} | |
public CocktailRecipeAddon(int cocktailId, String name, String imgPath, ArrayList<Ingredient> ingredients, ArrayList<IngredientAddon> ingredientAddons) { | |
super(cocktailId, name, imgPath, ingredients); | |
this.ingredientAddons = ingredientAddons; | |
} | |
public CocktailRecipeAddon(int cocktailId, String name, String imgPath, ArrayList<Ingredient> ingredients, String description, ArrayList<IngredientAddon> ingredientAddons) { | |
super(cocktailId, name, imgPath, ingredients, description); | |
this.ingredientAddons = ingredientAddons; | |
} | |
public ArrayList<IngredientAddon> getIngredientAddons() { | |
return ingredientAddons; | |
} | |
public void setIngredientAddons(ArrayList<IngredientAddon> ingredientAddons) { | |
this.ingredientAddons = ingredientAddons; | |
} | |
} |
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
package com.example.notandi.hanastel.activities; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.text.method.ScrollingMovementMethod; | |
import android.view.Menu; | |
import android.widget.ImageView; | |
import android.widget.LinearLayout; | |
import android.widget.ListView; | |
import android.widget.ScrollView; | |
import android.widget.TextView; | |
import com.example.notandi.hanastel.product.CocktailRecipe; | |
import com.example.notandi.hanastel.R; | |
import com.example.notandi.hanastel.adapters.DrinkDetailIngredientsAdapter; | |
import com.example.notandi.hanastel.product.CocktailRecipeAddon; | |
/** | |
* Created by SigurdurMarAtlason on 30/10/15. | |
*/ | |
public class DrinkDetailActivity extends AllDrinksActivity { | |
CocktailRecipe cr; | |
CocktailRecipeAddon cra; | |
Boolean isRandom = false; | |
TextView drinkName; | |
ImageView drinkImage; | |
ListView drinkIngredients; | |
TextView drinkDescription; | |
DrinkDetailIngredientsAdapter adapter; | |
@Override | |
protected void onCreate(Bundle savedInstanceState){ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_drink_detail); | |
Intent intent = getIntent(); | |
drinkName = (TextView) findViewById(R.id.drink_detail_name); | |
drinkIngredients = (ListView) findViewById(R.id.drink_detail_ingredients_list); | |
drinkDescription = (TextView) findViewById(R.id.drink_detail_description); | |
drinkImage = (ImageView) findViewById(R.id.drink_detail_image); | |
Intent i = getIntent(); | |
if(intent.getBooleanExtra("isSearchDetail", false)){ | |
cra = (CocktailRecipeAddon) i.getSerializableExtra("clickedCocktailSearch"); | |
adapter = new DrinkDetailIngredientsAdapter(this, cra.getIngredientsList()); | |
drinkName.setText(cra.getName()); | |
drinkDescription.setText(cra.getDescription()); | |
drinkImage.setImageResource(cra.getImgResourceId(getApplicationContext())); | |
} | |
else{ | |
cr = (CocktailRecipe)i.getSerializableExtra("clickedCocktail"); | |
adapter = new DrinkDetailIngredientsAdapter(this, cr.getIngredientsList()); | |
drinkDescription.setText(cr.getDescription()); | |
drinkImage.setImageResource(cr.getImgResourceId(getApplicationContext())); | |
drinkName.setText(cra.getName()); | |
} | |
isRandom = (Boolean)i.getSerializableExtra("isRandom"); | |
if (!isRandom) { | |
drinkIngredients.setAdapter(adapter); | |
} | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
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
package com.example.notandi.hanastel.product; | |
import android.widget.Button; | |
import java.io.Serializable; | |
/** | |
* Created by Notandi on 23-Oct-15. | |
*/ | |
@SuppressWarnings("serial") | |
public class Ingredient implements Serializable { | |
int _id; | |
String name; | |
String quantity; | |
public Ingredient(){ | |
} | |
public Ingredient(int _id, String name, String quantity){ | |
this._id = _id; | |
this.name = name; | |
this.quantity = quantity; | |
} | |
public String getName() { return name; } | |
public void setName(String name) { | |
this.name = name; | |
} | |
public void setId(int _id) { | |
this._id = _id; | |
} | |
public int getId() { | |
return _id; | |
} | |
public String getQuantity() { | |
return quantity; | |
} | |
public void setQuantity(String quantity) { | |
this.quantity = quantity; | |
} | |
} |
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
package com.example.notandi.hanastel.product; | |
import com.example.notandi.hanastel.domain.IngredientRaw; | |
import java.io.Serializable; | |
/** | |
* Created by Hrafnkell on 31/10/2015. | |
*/ | |
public class IngredientAddon extends IngredientRaw implements Serializable { | |
private boolean isAvailable; | |
public IngredientAddon(){} | |
public IngredientAddon(int _id, String name, String quantity, boolean isAvailable) { | |
super(_id, name); | |
this.isAvailable = isAvailable; | |
} | |
public boolean isAvailable() { | |
return isAvailable; | |
} | |
public void setIsAvailable(boolean isAvailable) { | |
this.isAvailable = isAvailable; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment