Skip to content

Commit

Permalink
#57 edit window menu drinkable
Browse files Browse the repository at this point in the history
  • Loading branch information
DariaZubkova authored Jul 10, 2020
1 parent 7991991 commit 13dd88c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
36 changes: 23 additions & 13 deletions app/src/main/java/com/example/ubercoffee/MenuFilterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class MenuFilterActivity extends Activity {
Button buttonSize3;
Button buttonPrice;
Button buttonAccept;
Button buttonResent;

int sizeDrinkable = -1;

Expand All @@ -33,16 +34,21 @@ protected void onCreate(Bundle savedInstanceState) {
buttonSize2 = findViewById(R.id.s2);
buttonSize3 = findViewById(R.id.s3);
buttonAccept = findViewById(R.id.buttonAccept);
buttonResent = findViewById(R.id.buttonResent);
//buttonPrice = findViewById(R.id.coffee);


buttonSize1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sizeDrinkable = 1;
Context context = v.getContext();
buttonSize2.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
buttonSize3.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
buttonSize1.setBackground(context.getResources().getDrawable(R.drawable.rounded_new_button));
buttonSize1.setAlpha(1f);
buttonSize2.setAlpha(0.7f);
buttonSize3.setAlpha(0.7f);
//buttonSize2.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
//buttonSize3.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
//buttonSize1.setBackground(context.getResources().getDrawable(R.drawable.rounded_new_button));
}
});

Expand All @@ -51,9 +57,9 @@ public void onClick(View v) {
public void onClick(View v) {
sizeDrinkable = 2;
Context context = v.getContext();
buttonSize1.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
buttonSize3.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
buttonSize2.setBackground(context.getResources().getDrawable(R.drawable.rounded_new_button));
buttonSize2.setAlpha(1f);
buttonSize1.setAlpha(0.7f);
buttonSize3.setAlpha(0.7f);
}
});

Expand All @@ -62,20 +68,24 @@ public void onClick(View v) {
public void onClick(View v) {
sizeDrinkable = 3;
Context context = v.getContext();
buttonSize2.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
buttonSize1.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
buttonSize3.setBackground(context.getResources().getDrawable(R.drawable.rounded_new_button));
buttonSize3.setAlpha(1f);
buttonSize1.setAlpha(0.7f);
buttonSize2.setAlpha(0.7f);
//buttonSize2.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
//buttonSize1.setBackground(context.getResources().getDrawable(R.drawable.rounded_button));
//buttonSize3.setBackground(context.getResources().getDrawable(R.drawable.rounded_new_button));
}
});

buttonAccept.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Context context = v.getContext();
Intent i = new Intent(MenuFilterActivity.this, MenuListActivity.class);
i.putExtra("sizeFilter", sizeDrinkable);
//Context context = v.getContext();
//Intent intent = new Intent(MenuFilterActivity.this, MenuListActivity.class);
//intent.putExtra("sizeDrink", sizeDrinkable);
//sizeDrinkable = -1;
startActivity(i);
//startActivity(intent);
finish();
}
});

Expand Down
38 changes: 17 additions & 21 deletions app/src/main/java/com/example/ubercoffee/MenuListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
Expand Down Expand Up @@ -35,19 +36,16 @@ public class MenuListActivity extends AppCompatActivity {
double price = 75;
double time = 10;
double distance = 0.5;
int sizeDrinkable = -1;


GridView listView;
ArrayAdapter<String> adapter;

// определяем массив типа String
final String[] catnames = new String[] { "Рыжик", "Барсик", "Мурзик",
"Мурка", "Васька", "Томасина", "Кристина", "Пушок", "Дымка",
"Кузя", "Китти", "Масяня", "Симба" };

List<String> list = new ArrayList<>();



@RequiresApi(api = Build.VERSION_CODES.P)
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -60,7 +58,7 @@ protected void onCreate(Bundle savedInstanceState) {
buttonFilters = findViewById(R.id.filters);


Typeface typeface = ResourcesCompat.getFont(this, R.font.roboto_bold);
//Typeface typeface = ResourcesCompat.getFont(this, R.font.roboto_bold);
//TypefaceSpan type = new TypefaceSpan(typeface);

TextView tvAdress= (TextView) findViewById(R.id.adress);
Expand All @@ -71,33 +69,33 @@ protected void onCreate(Bundle savedInstanceState) {
tvAdress.setText(textAdress);

TextView tvB1= (TextView) findViewById(R.id.b1);
//передаем строкой адрес
//передаем строкой цену
SpannableString textB1= new SpannableString("from " + price + "₽");
//textB1.setSpan( type, 0, textB1.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE );
tvB1.setText(textB1);

TextView tvB3= (TextView) findViewById(R.id.b3);
//передаем строкой адрес
//передаем строкой количество минут
SpannableString textB3= new SpannableString("> " + time + " minutes");
//textB3.setSpan( type, 0, textB3.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE );
tvB3.setText(textB3);

TextView tvB4= (TextView) findViewById(R.id.b4);
//передаем строкой адрес
//передаем строкой расстояние
SpannableString textB4= new SpannableString(distance + " km");
//textB4.setSpan( type, 0, textB4.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE );
tvB4.setText(textB4);


TextView tvButton= (TextView) findViewById(R.id.textButton);
//передаем строкой адрес
//передаем строкой в какой менюшке
final SpannableString textButton= new SpannableString("Popular");
//textButton.setSpan( type, 0, textButton.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE );
tvButton.setText(textButton);




//заполнение сетки данными (в нашем случае сначала популярными)
List<Drinkables> image_details = getListDataPopular();
final GridView gridView = (GridView) findViewById(R.id.gridList);
gridView.setAdapter(new MenuAdapter(this, image_details));
Expand All @@ -119,8 +117,9 @@ public void onItemClick(AdapterView<?> a, View v, int position, long id) {
buttonFilters.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), MenuFilterActivity.class);
startActivity(i);
Intent intent = new Intent(getApplicationContext(), MenuFilterActivity.class);
//intent.putExtra("sizeDrink", sizeDrinkable);
startActivity(intent);
}
});

Expand Down Expand Up @@ -232,7 +231,10 @@ private List<Drinkables> getListDataPopular() {
size.add(0.2);
size.add(0.4);
size.add(0.5);
Drinkables Cappuccino = new Drinkables("Cappuccino", size, 120);
ArrayList<Double> size2 = new ArrayList<>();
size2.add(0.2);
size2.add(0.4);
Drinkables Cappuccino = new Drinkables("Cappuccino", size2, 120);
Drinkables Latte = new Drinkables("Latte", size, 140);
Drinkables Macchiato = new Drinkables("Macchiato", size, 230);
Drinkables Expresso = new Drinkables("Espresso", size, 180);
Expand All @@ -255,7 +257,7 @@ private List<Drinkables> getListDataCoffee() {
ArrayList<Double> size = new ArrayList<>();
size.add(0.2);
size.add(0.4);
size.add(0.5);
//size.add(0.5);
Drinkables Glace = new Drinkables("Glace", size, 120);
Drinkables Raf = new Drinkables("Raf", size, 140);
Drinkables Frappe = new Drinkables("Frappe", size, 230);
Expand Down Expand Up @@ -296,10 +298,4 @@ private List<Drinkables> getListDataTea() {
return list;
}


private void setUpList() {
for (String item:catnames)
list.add(item);

}
}

0 comments on commit 13dd88c

Please sign in to comment.