|
@@ -0,0 +1,142 @@
|
|
|
|
+package com.example.recipeproj;
|
|
|
|
+
|
|
|
|
+import android.content.Context;
|
|
|
|
+import android.content.DialogInterface;
|
|
|
|
+import android.content.Intent;
|
|
|
|
+import android.graphics.Bitmap;
|
|
|
|
+import android.graphics.BitmapFactory;
|
|
|
|
+import android.graphics.drawable.ColorDrawable;
|
|
|
|
+import android.net.Uri;
|
|
|
|
+import android.os.Bundle;
|
|
|
|
+import android.provider.MediaStore;
|
|
|
|
+import android.util.Log;
|
|
|
|
+import android.view.View;
|
|
|
|
+import android.widget.EditText;
|
|
|
|
+import android.widget.ImageView;
|
|
|
|
+import android.widget.TextView;
|
|
|
|
+import android.widget.Toast;
|
|
|
|
+import android.view.LayoutInflater;
|
|
|
|
+import androidx.activity.result.ActivityResultLauncher;
|
|
|
|
+import androidx.activity.result.contract.ActivityResultContracts;
|
|
|
|
+import androidx.appcompat.app.ActionBar;
|
|
|
|
+import androidx.appcompat.app.AlertDialog;
|
|
|
|
+import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
+
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+
|
|
|
|
+import retrofit2.Call;
|
|
|
|
+import retrofit2.Callback;
|
|
|
|
+import retrofit2.Response;
|
|
|
|
+import retrofit2.Retrofit;
|
|
|
|
+import retrofit2.converter.gson.GsonConverterFactory;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+public class ViewRecipe extends AppCompatActivity {
|
|
|
|
+ Bundle arg;
|
|
|
|
+ Recipe recipe;
|
|
|
|
+ EditText fullN, nameN;
|
|
|
|
+ TextView fullText;
|
|
|
|
+ final Context context = this;
|
|
|
|
+ String itog;
|
|
|
|
+ int ves;
|
|
|
|
+ private TextView final_text;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
+ setContentView(R.layout.activity_view_recipe);
|
|
|
|
+ fullText = findViewById(R.id.txtLog);
|
|
|
|
+ arg = getIntent().getExtras();
|
|
|
|
+ recipe = arg.getParcelable(Recipe.class.getSimpleName());
|
|
|
|
+ fullN = findViewById(R.id.txtFull);
|
|
|
|
+ nameN = findViewById(R.id.txtName);
|
|
|
|
+ final_text = (TextView) findViewById(R.id.txtWes);
|
|
|
|
+ fullN.setText(recipe.getFullRecipe());
|
|
|
|
+ nameN.setText(recipe.getNameRecipe());
|
|
|
|
+ fullText.setText("fffffffffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "ffffffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "ffffffffffffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "fffffffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "fffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "ffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "fffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "ffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "fffffffffffffffffffffffffffffffffffffffffffff" +
|
|
|
|
+ "ffffffffffffffffffffffffffffffffffffffffffff");
|
|
|
|
+ }
|
|
|
|
+ public void calcWeight(View v)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ LayoutInflater li = LayoutInflater.from(context);
|
|
|
|
+ View promptsView = li.inflate(R.layout.prompt, null);
|
|
|
|
+
|
|
|
|
+ //Создаем AlertDialog
|
|
|
|
+ AlertDialog.Builder mDialogBuilder = new AlertDialog.Builder(context);
|
|
|
|
+
|
|
|
|
+ //Настраиваем prompt.xml для нашего AlertDialog:
|
|
|
|
+ mDialogBuilder.setView(promptsView);
|
|
|
|
+
|
|
|
|
+ //Настраиваем отображение поля для ввода текста в открытом диалоге:
|
|
|
|
+ final EditText userInput = (EditText) promptsView.findViewById(R.id.input_text);
|
|
|
|
+
|
|
|
|
+ //Настраиваем сообщение в диалоговом окне:
|
|
|
|
+ mDialogBuilder
|
|
|
|
+ .setCancelable(false)
|
|
|
|
+ .setPositiveButton("OK",
|
|
|
|
+ new DialogInterface.OnClickListener() {
|
|
|
|
+ public void onClick(DialogInterface dialog,int id) {
|
|
|
|
+
|
|
|
|
+ //Вводим текст и отображаем в строке ввода на основном экране:
|
|
|
|
+
|
|
|
|
+ //final_text.setText(userInput.getText());
|
|
|
|
+ itog = userInput.getText().toString();
|
|
|
|
+ ves = Integer.parseInt(itog);
|
|
|
|
+ switch(recipe.getNameRecipe())
|
|
|
|
+ {
|
|
|
|
+ case "тест":
|
|
|
|
+ ves = ves*10;
|
|
|
|
+ break;
|
|
|
|
+ case "рецепт":
|
|
|
|
+ ves = ves /10;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ final_text.setText("Кол-во еды в граммах: " + ves);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .setNegativeButton("Отмена",
|
|
|
|
+ new DialogInterface.OnClickListener() {
|
|
|
|
+ public void onClick(DialogInterface dialog,int id) {
|
|
|
|
+ dialog.cancel();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //Создаем AlertDialog:
|
|
|
|
+ AlertDialog alertDialog = mDialogBuilder.create();
|
|
|
|
+
|
|
|
|
+ //и отображаем его:
|
|
|
|
+ alertDialog.show();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /* AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
+ builder
|
|
|
|
+ .setTitle("Рассчитать вес")
|
|
|
|
+ .setMessage("Введите вес")
|
|
|
|
+ .setIcon(android.R.drawable.ic_dialog_alert)
|
|
|
|
+ .setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
+ final_text.setText(userInput.getText());
|
|
|
|
+ dialogInterface.dismiss();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ AlertDialog alert = builder.create();
|
|
|
|
+ alert.show();*/
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|