|
@@ -1,39 +1,114 @@
|
|
|
package com.sharix.sportsmanfriend.view.fragments;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.os.Bundle;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ImageButton;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
+import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
+import androidx.fragment.app.FragmentManager;
|
|
|
+import androidx.fragment.app.FragmentTransaction;
|
|
|
|
|
|
+import com.sharix.sportsmanfriend.BaseDialogClass;
|
|
|
import com.sharix.sportsmanfriend.OnBackPressedListener;
|
|
|
import com.sharix.sportsmanfriend.R;
|
|
|
+import com.sharix.sportsmanfriend.dialogs.AgeLimitDialog;
|
|
|
+import com.sharix.sportsmanfriend.dialogs.ChoiceOfGenderDialog;
|
|
|
+import com.sharix.sportsmanfriend.dialogs.DurationDialog;
|
|
|
+import com.sharix.sportsmanfriend.dialogs.RecommendedLevelDialog;
|
|
|
|
|
|
-public class EventFiltersFragment extends Fragment implements OnBackPressedListener {
|
|
|
+public class EventFiltersFragment extends Fragment implements OnBackPressedListener, BaseDialogClass.DialogListener {
|
|
|
|
|
|
- private View view;
|
|
|
+ private View v;
|
|
|
+ private ConstraintLayout durationBlock, ageBlock, genderBlock, levelBlock;
|
|
|
+ private TextView durationBlockText, ageBlockText, genderBlockText, levelBlockText, btnClear;
|
|
|
private ImageButton btnBack;
|
|
|
|
|
|
@Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
Bundle savedInstanceState) {
|
|
|
- view = inflater.inflate(R.layout.fragment_event_filters, container, false);
|
|
|
+ v = inflater.inflate(R.layout.fragment_event_filters, container, false);
|
|
|
|
|
|
- btnBack = view.findViewById(R.id.btnBack);
|
|
|
+ btnBack = v.findViewById(R.id.btnBack);
|
|
|
+
|
|
|
+ durationBlock = v.findViewById(R.id.durationBlock);
|
|
|
+ durationBlockText = v.findViewById(R.id.durationBlockText);
|
|
|
+ ageBlock = v.findViewById(R.id.ageBlock);
|
|
|
+ ageBlockText = v.findViewById(R.id.ageBlockText);
|
|
|
+ genderBlock = v.findViewById(R.id.genderBlock);
|
|
|
+ genderBlockText = v.findViewById(R.id.genderBlockText);
|
|
|
+ levelBlock = v.findViewById(R.id.levelBlock);
|
|
|
+ levelBlockText = v.findViewById(R.id.levelBlockText);
|
|
|
+ btnClear = v.findViewById(R.id.btnClear);
|
|
|
|
|
|
addClickEventToAllViews();
|
|
|
|
|
|
- return view;
|
|
|
+ return v;
|
|
|
}
|
|
|
|
|
|
private void addClickEventToAllViews() {
|
|
|
btnBack.setOnClickListener(v -> onBackPressed());
|
|
|
+
|
|
|
+ durationBlock.setOnClickListener(v -> {
|
|
|
+ DurationDialog durationDialog = new DurationDialog();
|
|
|
+ durationDialog.setTargetFragment(EventFiltersFragment.this, 0);
|
|
|
+ durationDialog.show(requireActivity().getSupportFragmentManager(), "durationDialog");
|
|
|
+ });
|
|
|
+
|
|
|
+ ageBlock.setOnClickListener(v -> {
|
|
|
+ AgeLimitDialog ageLimitDialog = new AgeLimitDialog();
|
|
|
+ ageLimitDialog.setTargetFragment(EventFiltersFragment.this, 0);
|
|
|
+ ageLimitDialog.show(requireActivity().getSupportFragmentManager(), "ageLimitDialog");
|
|
|
+ });
|
|
|
+
|
|
|
+ genderBlock.setOnClickListener(v -> {
|
|
|
+ ChoiceOfGenderDialog choiceOfGenderDialog = new ChoiceOfGenderDialog();
|
|
|
+ choiceOfGenderDialog.setTargetFragment(EventFiltersFragment.this, 0);
|
|
|
+ choiceOfGenderDialog.show(requireActivity().getSupportFragmentManager(), "choiceOfGenderDialog");
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ levelBlock.setOnClickListener(v -> {
|
|
|
+ RecommendedLevelDialog recommendedLevelDialog = new RecommendedLevelDialog();
|
|
|
+ recommendedLevelDialog.setTargetFragment(EventFiltersFragment.this, 0);
|
|
|
+ recommendedLevelDialog.show(requireActivity().getSupportFragmentManager(), "recommendedLevelDialog");
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ btnClear.setOnClickListener(v -> {
|
|
|
+ FragmentManager fragmentManager = requireActivity().getSupportFragmentManager();
|
|
|
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
|
+ EventFiltersFragment myFragment = new EventFiltersFragment();
|
|
|
+ fragmentTransaction.replace(R.id.frameWindow, myFragment);
|
|
|
+ fragmentTransaction.commit();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onBackPressed() {
|
|
|
requireActivity().getSupportFragmentManager().popBackStack();
|
|
|
}
|
|
|
+
|
|
|
+ @SuppressLint({"DefaultLocale", "SetTextI18n"})
|
|
|
+ @Override
|
|
|
+ public void applyInfo(Bundle bundle) {
|
|
|
+ switch (bundle.getString("FromBlock")){
|
|
|
+ case "DurationBlock":
|
|
|
+ durationBlockText.setText(String.format("До %d часов %d минут", bundle.getInt("HourStart"), bundle.getInt("MinuteStart")));
|
|
|
+ break;
|
|
|
+ case "LevelBlock":
|
|
|
+ levelBlockText.setText(String.format("%s - %s", bundle.getFloat("LimitFrom"), bundle.getFloat("LimitTo")));
|
|
|
+ break;
|
|
|
+ case "GenderBlock":
|
|
|
+ genderBlockText.setText(bundle.getString("Name"));
|
|
|
+ break;
|
|
|
+ case "AgeLimitBlock":
|
|
|
+ ageBlockText.setText(String.format("%s - %s", bundle.getFloat("LimitFrom"), bundle.getFloat("LimitTo")));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|