Крупное обновление
This commit is contained in:
parent
00007eb049
commit
c66a4cc828
@ -28,13 +28,21 @@ public class MainActivity extends AppCompatActivity {
|
||||
navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
|
||||
|
||||
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
|
||||
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_task1)
|
||||
R.id.navigation_home,
|
||||
R.id.navigation_dashboard,
|
||||
R.id.navigation_task1,
|
||||
R.id.navigation_task2,
|
||||
R.id.navigation_task3,
|
||||
R.id.navigation_task4)
|
||||
.build();
|
||||
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||
NavigationUI.setupWithNavController(binding.navView, navController);
|
||||
|
||||
navController.addOnDestinationChangedListener((controller, destination, arguments) -> {
|
||||
if (destination.getId() == R.id.navigation_task1) {
|
||||
if (destination.getId() == R.id.navigation_task1
|
||||
|| destination.getId() == R.id.navigation_task2
|
||||
|| destination.getId() == R.id.navigation_task3
|
||||
|| destination.getId() == R.id.navigation_task4) {
|
||||
binding.navView.setVisibility(View.GONE);
|
||||
} else {
|
||||
binding.navView.setVisibility(View.VISIBLE);
|
||||
|
299
app/src/main/java/com/kolobochki/memory/fragment_task2.java
Normal file
299
app/src/main/java/com/kolobochki/memory/fragment_task2.java
Normal file
@ -0,0 +1,299 @@
|
||||
package com.kolobochki.memory;
|
||||
|
||||
import static com.kolobochki.memory.R.*;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.kolobochki.memory.R;
|
||||
|
||||
public class fragment_task2 extends Fragment {
|
||||
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
private String previousTitle;
|
||||
private boolean isGameComplete = false;
|
||||
|
||||
private List<Integer> sequence = new ArrayList<>();
|
||||
private int currentStep = 0;
|
||||
private int round = 1;
|
||||
private int lives = 3;
|
||||
private boolean isShowingSequence = false;
|
||||
private boolean isWaitingForInput = false;
|
||||
|
||||
private Button redButton, greenButton, blueButton, yellowButton;
|
||||
private ImageView centerImage;
|
||||
private TextView roundText, livesText;
|
||||
private GridLayout buttonsGrid;
|
||||
|
||||
private final int[] colorImages = {
|
||||
R.drawable.simon_red,
|
||||
R.drawable.simon_green,
|
||||
R.drawable.simon_blue,
|
||||
R.drawable.simon_yellow,
|
||||
R.drawable.simon_off
|
||||
};
|
||||
|
||||
public fragment_task2() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static fragment_task2 newInstance(String param1, String param2) {
|
||||
fragment_task2 fragment = new fragment_task2();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
|
||||
OnBackPressedCallback backPressedCallback = new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (!isGameComplete) {
|
||||
showExitConfirmationDialog();
|
||||
} else {
|
||||
setEnabled(false);
|
||||
navigateHome();
|
||||
}
|
||||
}
|
||||
};
|
||||
requireActivity().getOnBackPressedDispatcher().addCallback(this, backPressedCallback);
|
||||
|
||||
if (getActivity() instanceof AppCompatActivity) {
|
||||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle("Упражнение 2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_task2, container, false);
|
||||
|
||||
redButton = view.findViewById(R.id.redButton);
|
||||
greenButton = view.findViewById(R.id.greenButton);
|
||||
blueButton = view.findViewById(R.id.blueButton);
|
||||
yellowButton = view.findViewById(R.id.yellowButton);
|
||||
centerImage = view.findViewById(R.id.centerImage);
|
||||
roundText = view.findViewById(R.id.roundText);
|
||||
livesText = view.findViewById(R.id.livesText);
|
||||
buttonsGrid = view.findViewById(R.id.buttonsGrid);
|
||||
|
||||
redButton.setOnClickListener(v -> onColorClicked(0));
|
||||
greenButton.setOnClickListener(v -> onColorClicked(1));
|
||||
blueButton.setOnClickListener(v -> onColorClicked(2));
|
||||
yellowButton.setOnClickListener(v -> onColorClicked(3));
|
||||
|
||||
startNewGame();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void startNewGame() {
|
||||
sequence.clear();
|
||||
round = 1;
|
||||
lives = 3;
|
||||
currentStep = 0;
|
||||
updateUI();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
generateNextSequence();
|
||||
}
|
||||
|
||||
showSequence();
|
||||
}
|
||||
|
||||
private void generateNextSequence() {
|
||||
Random random = new Random();
|
||||
sequence.add(random.nextInt(4));
|
||||
}
|
||||
|
||||
private void showSequence() {
|
||||
isShowingSequence = true;
|
||||
isWaitingForInput = false;
|
||||
buttonsGrid.setVisibility(View.INVISIBLE);
|
||||
|
||||
Handler handler = new Handler();
|
||||
for (int i = 0; i < sequence.size(); i++) {
|
||||
final int colorIndex = sequence.get(i);
|
||||
handler.postDelayed(() -> showColor(colorIndex), i * 1000L);
|
||||
handler.postDelayed(() -> resetCenterImage(), i * 1000L + 800L);
|
||||
}
|
||||
|
||||
handler.postDelayed(() -> {
|
||||
isShowingSequence = false;
|
||||
isWaitingForInput = true;
|
||||
currentStep = 0;
|
||||
buttonsGrid.setVisibility(View.VISIBLE);
|
||||
centerImage.setImageResource(R.drawable.simon_off);
|
||||
}, sequence.size() * 1000L);
|
||||
}
|
||||
|
||||
private void highlightButton(int colorIndex) {
|
||||
switch (colorIndex) {
|
||||
case 0:
|
||||
redButton.setBackgroundResource(R.drawable.simon_red);
|
||||
break;
|
||||
case 1:
|
||||
greenButton.setBackgroundResource(R.drawable.simon_green);
|
||||
break;
|
||||
case 2:
|
||||
blueButton.setBackgroundResource(R.drawable.simon_blue);
|
||||
break;
|
||||
case 3:
|
||||
yellowButton.setBackgroundResource(R.drawable.simon_yellow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showColor(int colorIndex) {
|
||||
centerImage.setImageResource(colorImages[colorIndex]);
|
||||
}
|
||||
|
||||
private void resetCenterImage() {
|
||||
centerImage.setImageResource(R.drawable.simon_off);
|
||||
}
|
||||
|
||||
private void resetButtons() {
|
||||
redButton.setBackgroundResource(R.drawable.simon_off);
|
||||
greenButton.setBackgroundResource(R.drawable.simon_off);
|
||||
blueButton.setBackgroundResource(R.drawable.simon_off);
|
||||
yellowButton.setBackgroundResource(R.drawable.simon_off);
|
||||
}
|
||||
|
||||
private void onColorClicked(int colorIndex) {
|
||||
if (!isWaitingForInput || isShowingSequence) return;
|
||||
|
||||
showColor(colorIndex);
|
||||
new Handler().postDelayed(this::resetCenterImage, 300);
|
||||
|
||||
if (colorIndex == sequence.get(currentStep)) {
|
||||
currentStep++;
|
||||
if (currentStep == sequence.size()) {
|
||||
round++;
|
||||
currentStep = 0;
|
||||
updateUI();
|
||||
generateNextSequence();
|
||||
|
||||
new Handler().postDelayed(() -> {
|
||||
if (!isGameComplete) {
|
||||
showSequence();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
} else {
|
||||
lives--;
|
||||
updateUI();
|
||||
if (lives <= 0) {
|
||||
gameOver();
|
||||
} else {
|
||||
new Handler().postDelayed(() -> {
|
||||
if (!isGameComplete) {
|
||||
currentStep = 0;
|
||||
showSequence();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
roundText.setText("Раунд: " + round);
|
||||
|
||||
StringBuilder hearts = new StringBuilder();
|
||||
for (int i = 0; i < lives; i++) {
|
||||
hearts.append("❤️");
|
||||
}
|
||||
livesText.setText(hearts.toString());
|
||||
}
|
||||
|
||||
private void gameOver() {
|
||||
isGameComplete = true;
|
||||
isWaitingForInput = false;
|
||||
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setTitle("Игра окончена")
|
||||
.setMessage("Вы прошли " + round + " раундов!")
|
||||
.setPositiveButton("Играть снова", (dialog, which) -> {
|
||||
isGameComplete = false;
|
||||
startNewGame();
|
||||
})
|
||||
.setNegativeButton("Выход", (dialog, which) -> navigateHome())
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void showExitConfirmationDialog() {
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setTitle("Закончить упражнение?")
|
||||
.setMessage("Вы точно хотите закончить упражнение?")
|
||||
.setPositiveButton("Да", (dialog, which) -> {
|
||||
NavController navController = Navigation.findNavController(requireView());
|
||||
navController.popBackStack();
|
||||
})
|
||||
.setNegativeButton("Нет", null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void navigateHome() {
|
||||
NavController navController = Navigation.findNavController(requireView());
|
||||
navController.popBackStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getActivity() != null && ((AppCompatActivity)getActivity()).getSupportActionBar() != null) {
|
||||
((AppCompatActivity)getActivity()).getSupportActionBar().hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (getActivity() != null && ((AppCompatActivity)getActivity()).getSupportActionBar() != null) {
|
||||
((AppCompatActivity)getActivity()).getSupportActionBar().show();
|
||||
}
|
||||
|
||||
if (getActivity() instanceof AppCompatActivity) {
|
||||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null && previousTitle != null) {
|
||||
actionBar.setTitle(previousTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
247
app/src/main/java/com/kolobochki/memory/fragment_task3.java
Normal file
247
app/src/main/java/com/kolobochki/memory/fragment_task3.java
Normal file
@ -0,0 +1,247 @@
|
||||
package com.kolobochki.memory;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class fragment_task3 extends Fragment {
|
||||
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
private String previousTitle;
|
||||
private boolean isGameComplete = false;
|
||||
|
||||
private GridLayout gridLayout;
|
||||
private TextView roundTextView;
|
||||
private TextView livesTextView;
|
||||
private List<Integer> sequence = new ArrayList<>();
|
||||
private List<Integer> userSequence = new ArrayList<>();
|
||||
private int currentRound = 1;
|
||||
private int lives = 3;
|
||||
private int rows = 3;
|
||||
private int cols = 3;
|
||||
private final int SHOW_TIME = 4500;
|
||||
|
||||
public fragment_task3() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static fragment_task3 newInstance(String param1, String param2) {
|
||||
fragment_task3 fragment = new fragment_task3();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
|
||||
OnBackPressedCallback backPressedCallback = new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (!isGameComplete) {
|
||||
showExitConfirmationDialog();
|
||||
} else {
|
||||
setEnabled(false);
|
||||
navigateHome();
|
||||
}
|
||||
}
|
||||
};
|
||||
requireActivity().getOnBackPressedDispatcher().addCallback(this, backPressedCallback);
|
||||
|
||||
if (getActivity() instanceof AppCompatActivity) {
|
||||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle("Упражнение 3");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_task3, container, false);
|
||||
|
||||
gridLayout = view.findViewById(R.id.gridLayout);
|
||||
roundTextView = view.findViewById(R.id.roundTextView);
|
||||
livesTextView = view.findViewById(R.id.livesTextView);
|
||||
|
||||
setupGame();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void setupGame() {
|
||||
sequence.clear();
|
||||
userSequence.clear();
|
||||
gridLayout.removeAllViews();
|
||||
|
||||
gridLayout.setRowCount(rows);
|
||||
gridLayout.setColumnCount(cols);
|
||||
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenWidth = displayMetrics.widthPixels;
|
||||
int cellSize = (int) (screenWidth * 0.8 / cols);
|
||||
|
||||
int totalCells = rows * cols;
|
||||
for (int i = 1; i <= totalCells; i++) {
|
||||
sequence.add(i);
|
||||
}
|
||||
|
||||
Collections.shuffle(sequence);
|
||||
|
||||
for (int i = 0; i < totalCells; i++) {
|
||||
Button button = new Button(getContext());
|
||||
button.setTag(sequence.get(i));
|
||||
button.setText(String.valueOf(sequence.get(i)));
|
||||
button.setTextSize(24);
|
||||
//button.setBackgroundResource(R.drawable.cell_background);
|
||||
|
||||
GridLayout.LayoutParams params = new GridLayout.LayoutParams();
|
||||
params.width = cellSize;
|
||||
params.height = cellSize;
|
||||
params.rowSpec = GridLayout.spec(i / cols, 1f);
|
||||
params.columnSpec = GridLayout.spec(i % cols, 1f);
|
||||
params.setMargins(4, 4, 4, 4);
|
||||
|
||||
button.setLayoutParams(params);
|
||||
gridLayout.addView(button);
|
||||
}
|
||||
|
||||
updateUI();
|
||||
|
||||
new Handler().postDelayed(this::hideNumbers, SHOW_TIME);
|
||||
}
|
||||
|
||||
private void hideNumbers() {
|
||||
for (int i = 0; i < gridLayout.getChildCount(); i++) {
|
||||
Button button = (Button) gridLayout.getChildAt(i);
|
||||
button.setText("");
|
||||
button.setOnClickListener(v -> {
|
||||
Button clickedButton = (Button) v;
|
||||
int number = (int) clickedButton.getTag();
|
||||
userSequence.add(number);
|
||||
clickedButton.setText(String.valueOf(number));
|
||||
|
||||
if (userSequence.size() == sequence.size()) {
|
||||
checkSequence();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSequence() {
|
||||
boolean isCorrect = true;
|
||||
for (int i = 0; i < sequence.size(); i++) {
|
||||
if (!sequence.get(i).equals(userSequence.get(i))) {
|
||||
isCorrect = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isCorrect) {
|
||||
currentRound++;
|
||||
Toast.makeText(getContext(), "Правильно! Раунд " + currentRound, Toast.LENGTH_SHORT).show();
|
||||
new Handler().postDelayed(this::setupGame, 1500);
|
||||
} else {
|
||||
lives--;
|
||||
if (lives <= 0) {
|
||||
gameOver();
|
||||
} else {
|
||||
Toast.makeText(getContext(), "Ошибка! Осталось жизней: " + lives, Toast.LENGTH_SHORT).show();
|
||||
new Handler().postDelayed(this::setupGame, 1500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void gameOver() {
|
||||
isGameComplete = true;
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setTitle("Игра окончена")
|
||||
.setMessage("Вы прошли " + (currentRound - 1) + " раундов")
|
||||
.setPositiveButton("OK", (dialog, which) -> navigateHome())
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
roundTextView.setText("Раунд: " + currentRound);
|
||||
|
||||
StringBuilder hearts = new StringBuilder();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
hearts.append(i < lives ? "❤️" : "");
|
||||
}
|
||||
livesTextView.setText(hearts.toString());
|
||||
}
|
||||
|
||||
private void showExitConfirmationDialog() {
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setTitle("Закончить упражнение?")
|
||||
.setMessage("Вы точно хотите закончить упражнение?")
|
||||
.setPositiveButton("Да", (dialog, which) -> {
|
||||
NavController navController = Navigation.findNavController(requireView());
|
||||
navController.popBackStack();
|
||||
})
|
||||
.setNegativeButton("Нет", null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getActivity() != null && ((AppCompatActivity)getActivity()).getSupportActionBar() != null) {
|
||||
((AppCompatActivity)getActivity()).getSupportActionBar().hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (getActivity() != null && ((AppCompatActivity)getActivity()).getSupportActionBar() != null) {
|
||||
((AppCompatActivity)getActivity()).getSupportActionBar().show();
|
||||
}
|
||||
|
||||
if (getActivity() instanceof AppCompatActivity) {
|
||||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null && previousTitle != null) {
|
||||
actionBar.setTitle(previousTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void navigateHome() {
|
||||
NavController navController = Navigation.findNavController(requireView());
|
||||
navController.popBackStack();
|
||||
}
|
||||
}
|
290
app/src/main/java/com/kolobochki/memory/fragment_task4.java
Normal file
290
app/src/main/java/com/kolobochki/memory/fragment_task4.java
Normal file
@ -0,0 +1,290 @@
|
||||
package com.kolobochki.memory;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class fragment_task4 extends Fragment {
|
||||
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
private String previousTitle;
|
||||
private boolean isGameComplete = false;
|
||||
|
||||
private ImageView[][] cards = new ImageView[2][2];
|
||||
private int[][] cardValues = new int[2][2];
|
||||
private int changedRow = -1, changedCol = -1;
|
||||
private int lives = 3;
|
||||
private int round = 1;
|
||||
private Handler handler = new Handler();
|
||||
private Random random = new Random();
|
||||
private TextView roundTextView;
|
||||
private TextView livesTextView;
|
||||
private GridLayout gridLayout;
|
||||
|
||||
public fragment_task4() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static fragment_task4 newInstance(String param1, String param2) {
|
||||
fragment_task4 fragment = new fragment_task4();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
|
||||
OnBackPressedCallback backPressedCallback = new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (!isGameComplete) {
|
||||
showExitConfirmationDialog();
|
||||
} else {
|
||||
setEnabled(false);
|
||||
navigateHome();
|
||||
}
|
||||
}
|
||||
};
|
||||
requireActivity().getOnBackPressedDispatcher().addCallback(this, backPressedCallback);
|
||||
|
||||
if (getActivity() instanceof AppCompatActivity) {
|
||||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle("Упражнение 4");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_task4, container, false);
|
||||
|
||||
gridLayout = view.findViewById(R.id.grid_layout);
|
||||
cards[0][0] = view.findViewById(R.id.card00);
|
||||
cards[0][1] = view.findViewById(R.id.card01);
|
||||
cards[1][0] = view.findViewById(R.id.card10);
|
||||
cards[1][1] = view.findViewById(R.id.card11);
|
||||
|
||||
roundTextView = view.findViewById(R.id.round_text);
|
||||
livesTextView = view.findViewById(R.id.lives_text);
|
||||
|
||||
gridLayout.setAlignmentMode(GridLayout.ALIGN_BOUNDS);
|
||||
gridLayout.setUseDefaultMargins(true);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
final int row = i;
|
||||
final int col = j;
|
||||
cards[i][j].setOnClickListener(v -> onCardClicked(row, col));
|
||||
}
|
||||
}
|
||||
|
||||
startNewRound();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void startNewRound() {
|
||||
if (!isAdded()) return;
|
||||
|
||||
roundTextView.setText("Раунд: " + round);
|
||||
updateLivesDisplay();
|
||||
|
||||
List<Integer> availableImages = new ArrayList<>();
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
availableImages.add(i);
|
||||
}
|
||||
Collections.shuffle(availableImages);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
int index = i * 2 + j;
|
||||
if (index < availableImages.size()) {
|
||||
cardValues[i][j] = availableImages.get(index);
|
||||
setCardImage(i, j, "tile" + cardValues[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handler.postDelayed(() -> {
|
||||
// Flip all cards to back
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
setCardImage(i, j, "tile_back");
|
||||
}
|
||||
}
|
||||
|
||||
handler.postDelayed(() -> {
|
||||
changedRow = random.nextInt(2);
|
||||
changedCol = random.nextInt(2);
|
||||
|
||||
int newImage;
|
||||
List<Integer> currentImages = new ArrayList<>();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
if (!currentImages.contains(cardValues[i][j])) {
|
||||
currentImages.add(cardValues[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
newImage = random.nextInt(6) + 1;
|
||||
} while (currentImages.contains(newImage));
|
||||
|
||||
cardValues[changedRow][changedCol] = newImage;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
setCardImage(i, j, "tile" + cardValues[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
setCardsClickable(true);
|
||||
|
||||
}, 750);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
|
||||
private void onCardClicked(int row, int col) {
|
||||
if (!isAdded()) return;
|
||||
|
||||
setCardsClickable(false);
|
||||
|
||||
if (row == changedRow && col == changedCol) {
|
||||
// Correct guess
|
||||
round++;
|
||||
handler.postDelayed(() -> {
|
||||
if (isAdded()) startNewRound();
|
||||
}, 1000);
|
||||
} else {
|
||||
lives--;
|
||||
updateLivesDisplay();
|
||||
|
||||
if (lives <= 0) {
|
||||
gameOver();
|
||||
} else {
|
||||
cards[changedRow][changedCol].setImageResource(
|
||||
getResourceId("tile" + cardValues[changedRow][changedCol] + "_highlight")
|
||||
);
|
||||
|
||||
handler.postDelayed(() -> {
|
||||
if (!isAdded()) return;
|
||||
setCardImage(changedRow, changedCol, "tile" + cardValues[changedRow][changedCol]);
|
||||
startNewRound();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setCardImage(int row, int col, String imageName) {
|
||||
cards[row][col].setImageResource(getResourceId(imageName));
|
||||
}
|
||||
|
||||
private int getResourceId(String name) {
|
||||
return getResources().getIdentifier(name, "drawable", requireContext().getPackageName());
|
||||
}
|
||||
|
||||
private void setCardsClickable(boolean clickable) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
cards[i][j].setClickable(clickable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLivesDisplay() {
|
||||
StringBuilder hearts = new StringBuilder();
|
||||
for (int i = 0; i < lives; i++) {
|
||||
hearts.append("❤️");
|
||||
}
|
||||
livesTextView.setText(hearts.toString());
|
||||
}
|
||||
|
||||
private void gameOver() {
|
||||
isGameComplete = true;
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setTitle("Игра окончена")
|
||||
.setMessage("Вы прошли " + (round - 1) + " раундов!")
|
||||
.setPositiveButton("OK", (dialog, which) -> navigateHome())
|
||||
.setCancelable(false)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void showExitConfirmationDialog() {
|
||||
new AlertDialog.Builder(requireContext())
|
||||
.setTitle("Закончить упражнение?")
|
||||
.setMessage("Вы точно хотите закончить упражнение?")
|
||||
.setPositiveButton("Да", (dialog, which) -> {
|
||||
NavController navController = Navigation.findNavController(requireView());
|
||||
navController.popBackStack();
|
||||
})
|
||||
.setNegativeButton("Нет", null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getActivity() != null && ((AppCompatActivity)getActivity()).getSupportActionBar() != null) {
|
||||
((AppCompatActivity)getActivity()).getSupportActionBar().hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (getActivity() != null && ((AppCompatActivity)getActivity()).getSupportActionBar() != null) {
|
||||
((AppCompatActivity)getActivity()).getSupportActionBar().show();
|
||||
}
|
||||
|
||||
if (getActivity() instanceof AppCompatActivity) {
|
||||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null && previousTitle != null) {
|
||||
actionBar.setTitle(previousTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void navigateHome() {
|
||||
if (getView() == null) return;
|
||||
|
||||
NavController navController = Navigation.findNavController(requireView());
|
||||
navController.popBackStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
}
|
@ -31,6 +31,18 @@ public class HomeFragment extends Fragment {
|
||||
Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_task1);
|
||||
});
|
||||
|
||||
binding.button2.setOnClickListener(view-> {
|
||||
Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_task2);
|
||||
});
|
||||
|
||||
binding.button3.setOnClickListener(view -> {
|
||||
Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_task3);
|
||||
});
|
||||
|
||||
binding.button4.setOnClickListener(view -> {
|
||||
Navigation.findNavController(view).navigate(R.id.action_navigation_home_to_navigation_task4);
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
BIN
app/src/main/res/drawable/simon_blue.png
Normal file
BIN
app/src/main/res/drawable/simon_blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 924 KiB |
BIN
app/src/main/res/drawable/simon_green.png
Normal file
BIN
app/src/main/res/drawable/simon_green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 976 KiB |
BIN
app/src/main/res/drawable/simon_off.png
Normal file
BIN
app/src/main/res/drawable/simon_off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 925 KiB |
BIN
app/src/main/res/drawable/simon_red.png
Normal file
BIN
app/src/main/res/drawable/simon_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 842 KiB |
BIN
app/src/main/res/drawable/simon_yellow.png
Normal file
BIN
app/src/main/res/drawable/simon_yellow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 806 KiB |
@ -20,12 +20,78 @@
|
||||
android:id="@+id/button"
|
||||
android:layout_width="321dp"
|
||||
android:layout_height="63dp"
|
||||
android:layout_marginStart="46dp"
|
||||
android:layout_marginTop="268dp"
|
||||
android:layout_marginStart="48dp"
|
||||
android:layout_marginTop="140dp"
|
||||
android:text="Начать упражнение"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="321dp"
|
||||
android:layout_height="63dp"
|
||||
android:layout_marginStart="48dp"
|
||||
android:layout_marginTop="260dp"
|
||||
android:text="Начать упражнение"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="321dp"
|
||||
android:layout_height="63dp"
|
||||
android:layout_marginStart="48dp"
|
||||
android:layout_marginTop="372dp"
|
||||
android:text="Начать упражнение"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button4"
|
||||
android:layout_width="321dp"
|
||||
android:layout_height="63dp"
|
||||
android:layout_marginStart="48dp"
|
||||
android:layout_marginTop="496dp"
|
||||
android:text="Начать упражнение"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="248dp"
|
||||
android:layout_height="29dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="224dp"
|
||||
android:text="Саймон говорит"
|
||||
android:textAlignment="center"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView3"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="248dp"
|
||||
android:layout_height="29dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="344dp"
|
||||
android:text="Числовая матрица"
|
||||
android:textAlignment="center"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView3"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_width="248dp"
|
||||
android:layout_height="29dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="464dp"
|
||||
android:text="Найти лишнее"
|
||||
android:textAlignment="center"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView3"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
@ -37,4 +103,17 @@
|
||||
android:translationY="-7dp"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView3"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="248dp"
|
||||
android:layout_height="29dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="108dp"
|
||||
android:text="Найти пары"
|
||||
android:textAlignment="center"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView3"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
118
app/src/main/res/layout/fragment_task2.xml
Normal file
118
app/src/main/res/layout/fragment_task2.xml
Normal file
@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:drawable/menuitem_background"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/roundText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="Раунд: 1"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/livesText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/roundText"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="❤️❤️❤️"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/centerImage"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/simon_off" />
|
||||
|
||||
<GridLayout
|
||||
android:id="@+id/buttonsGrid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:columnCount="2"
|
||||
android:rowCount="2">
|
||||
|
||||
<Button
|
||||
android:id="@+id/redButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_rowWeight="1"
|
||||
android:layout_columnWeight="1"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:backgroundTint="@null"
|
||||
android:drawableTint="@null"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:foregroundTint="@null"
|
||||
android:stateListAnimator="@null"
|
||||
app:iconTint="@null"
|
||||
tools:visibility="invisible"
|
||||
style="@style/SimonButton"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/greenButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_rowWeight="1"
|
||||
android:layout_columnWeight="1"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:backgroundTint="@null"
|
||||
android:drawableTint="@null"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:foregroundTint="@null"
|
||||
android:stateListAnimator="@null"
|
||||
app:iconTint="@null"
|
||||
tools:visibility="invisible"
|
||||
style="@style/SimonButton"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/yellowButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_rowWeight="1"
|
||||
android:layout_columnWeight="1"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:backgroundTint="@null"
|
||||
android:drawableTint="@null"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:foregroundTint="@null"
|
||||
android:stateListAnimator="@null"
|
||||
app:iconTint="@null"
|
||||
tools:visibility="invisible"
|
||||
style="@style/SimonButton"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/blueButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_rowWeight="1"
|
||||
android:layout_columnWeight="1"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:backgroundTint="@null"
|
||||
android:drawableTint="@null"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:foregroundTint="@null"
|
||||
android:stateListAnimator="@null"
|
||||
app:iconTint="@null"
|
||||
tools:visibility="invisible"
|
||||
style="@style/SimonButton"/>
|
||||
</GridLayout>
|
||||
|
||||
</RelativeLayout>
|
54
app/src/main/res/layout/fragment_task3.xml
Normal file
54
app/src/main/res/layout/fragment_task3.xml
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="16dp">
|
||||
|
||||
<!-- Информационная панель -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:layout_marginBottom="24dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/roundTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:text="Раунд: 1" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/livesTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:text="❤️❤️❤️"/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Контейнер для центрирования GridLayout -->
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
|
||||
<GridLayout
|
||||
android:id="@+id/gridLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:rowCount="3"
|
||||
android:columnCount="3"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
70
app/src/main/res/layout/fragment_task4.xml
Normal file
70
app/src/main/res/layout/fragment_task4.xml
Normal file
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/round_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:text="Раунд: 1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lives_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="❤️❤️❤️"
|
||||
android:textAlignment="textEnd"
|
||||
android:textSize="18sp"
|
||||
android:translationX="235dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<GridLayout
|
||||
android:id="@+id/grid_layout"
|
||||
android:layout_width="395dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:alignmentMode="alignBounds"
|
||||
android:columnCount="2"
|
||||
android:rowCount="2"
|
||||
android:useDefaultMargins="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/card00"
|
||||
android:layout_width="183dp"
|
||||
android:layout_height="196dp"
|
||||
android:layout_margin="8dp"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/card01"
|
||||
android:layout_width="183dp"
|
||||
android:layout_height="196dp"
|
||||
android:layout_margin="8dp"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/card10"
|
||||
android:layout_width="183dp"
|
||||
android:layout_height="196dp"
|
||||
android:layout_margin="8dp"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/card11"
|
||||
android:layout_width="183dp"
|
||||
android:layout_height="196dp"
|
||||
android:layout_margin="8dp"
|
||||
android:scaleType="fitCenter" />
|
||||
</GridLayout>
|
||||
</LinearLayout>
|
@ -16,6 +16,15 @@
|
||||
<action
|
||||
android:id="@+id/action_navigation_home_to_navigation_task1"
|
||||
app:destination="@id/navigation_task1" />
|
||||
<action
|
||||
android:id="@+id/action_navigation_home_to_navigation_task2"
|
||||
app:destination="@id/navigation_task2" />
|
||||
<action
|
||||
android:id="@+id/action_navigation_home_to_navigation_task3"
|
||||
app:destination="@id/navigation_task3" />
|
||||
<action
|
||||
android:id="@+id/action_navigation_home_to_navigation_task4"
|
||||
app:destination="@id/navigation_task4" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
@ -37,4 +46,31 @@
|
||||
android:id="@+id/action_navigation_notifications_to_navigation_home"
|
||||
app:destination="@id/navigation_home" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/navigation_task2"
|
||||
android:name="com.kolobochki.memory.fragment_task2"
|
||||
android:label="navigation_task2"
|
||||
tools:layout="@layout/fragment_task2">
|
||||
<action
|
||||
android:id="@+id/action_navigation_notifications_to_navigation_home"
|
||||
app:destination="@id/navigation_home" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/navigation_task3"
|
||||
android:name="com.kolobochki.memory.fragment_task3"
|
||||
android:label="navigation_task3"
|
||||
tools:layout="@layout/fragment_task3">
|
||||
<action
|
||||
android:id="@+id/action_navigation_notifications_to_navigation_home"
|
||||
app:destination="@id/navigation_home" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/navigation_task4"
|
||||
android:name="com.kolobochki.memory.fragment_task4"
|
||||
android:label="navigation_task4"
|
||||
tools:layout="@layout/fragment_task4">
|
||||
<action
|
||||
android:id="@+id/action_navigation_notifications_to_navigation_home"
|
||||
app:destination="@id/navigation_home" />
|
||||
</fragment>
|
||||
</navigation>
|
@ -13,4 +13,8 @@
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
<style name="SimonButton" parent="Widget.AppCompat.Button.Borderless">
|
||||
<item name="android:background">@drawable/simon_off</item>
|
||||
<item name="android:stateListAnimator">@null</item>
|
||||
</style>
|
||||
</resources>
|
@ -1,6 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">Memory</string>
|
||||
<string name="title_home">Карта</string>
|
||||
<string name="title_home">Упражнения</string>
|
||||
<string name="title_dashboard">Профиль</string>
|
||||
<string name="title_notifications">Notifications</string>
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
|
@ -13,4 +13,8 @@
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
<style name="SimonButton" parent="Widget.AppCompat.Button.Borderless">
|
||||
<item name="android:background">@drawable/simon_off</item>
|
||||
<item name="android:stateListAnimator">@null</item>
|
||||
</style>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user