From 13dd88c3438a0d4b7f727238cdb7800dbb27cfc8 Mon Sep 17 00:00:00 2001 From: DariaZubkova <56001699+DariaZubkova@users.noreply.github.com> Date: Fri, 10 Jul 2020 12:06:57 +0300 Subject: [PATCH] #57 edit window menu drinkable --- .../ubercoffee/MenuFilterActivity.java | 36 +++++++++++------- .../example/ubercoffee/MenuListActivity.java | 38 +++++++++---------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/com/example/ubercoffee/MenuFilterActivity.java b/app/src/main/java/com/example/ubercoffee/MenuFilterActivity.java index 70ef76c..b27ac52 100644 --- a/app/src/main/java/com/example/ubercoffee/MenuFilterActivity.java +++ b/app/src/main/java/com/example/ubercoffee/MenuFilterActivity.java @@ -20,6 +20,7 @@ public class MenuFilterActivity extends Activity { Button buttonSize3; Button buttonPrice; Button buttonAccept; + Button buttonResent; int sizeDrinkable = -1; @@ -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)); } }); @@ -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); } }); @@ -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(); } }); diff --git a/app/src/main/java/com/example/ubercoffee/MenuListActivity.java b/app/src/main/java/com/example/ubercoffee/MenuListActivity.java index df789a2..a2ec0cc 100644 --- a/app/src/main/java/com/example/ubercoffee/MenuListActivity.java +++ b/app/src/main/java/com/example/ubercoffee/MenuListActivity.java @@ -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; @@ -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 adapter; - // определяем массив типа String - final String[] catnames = new String[] { "Рыжик", "Барсик", "Мурзик", - "Мурка", "Васька", "Томасина", "Кристина", "Пушок", "Дымка", - "Кузя", "Китти", "Масяня", "Симба" }; - List list = new ArrayList<>(); + @RequiresApi(api = Build.VERSION_CODES.P) @Override protected void onCreate(Bundle savedInstanceState) { @@ -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); @@ -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 image_details = getListDataPopular(); final GridView gridView = (GridView) findViewById(R.id.gridList); gridView.setAdapter(new MenuAdapter(this, image_details)); @@ -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); } }); @@ -232,7 +231,10 @@ private List getListDataPopular() { size.add(0.2); size.add(0.4); size.add(0.5); - Drinkables Cappuccino = new Drinkables("Cappuccino", size, 120); + ArrayList 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); @@ -255,7 +257,7 @@ private List getListDataCoffee() { ArrayList 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); @@ -296,10 +298,4 @@ private List getListDataTea() { return list; } - - private void setUpList() { - for (String item:catnames) - list.add(item); - - } } \ No newline at end of file