<file_sep>package com.example.travelchoice;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

public class InformationActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_information);

        Intent intent = getIntent();
        String cityName = intent.getStringExtra("city");

        City city = CardViewActivity.getCity(cityName);

        TextView nameTV = (TextView) findViewById(R.id.nameTV);
        nameTV.setText(city.getName());

        ImageView imageView = (ImageView) findViewById(R.id.imageT);
        int resID = getResources().getIdentifier(city.getName().toLowerCase(), "drawable", "com.example.travelchoice");
        imageView.setImageResource(resID);

        Toolbar toolbar = findViewById(R.id.toolBar);
        setSupportActionBar(toolbar);
    }

}

<file_sep>package com.example.travelchoice;

import java.io.Serializable;
import java.util.ArrayList;

public class City implements Serializable {
    private boolean beach, mountain, island;
    private String name;
    private int big, country_side, clubbing, puntuaction, monuments;

    public boolean isBeach() {
        return beach;
    }

    public void setBeach(boolean beach) {
        this.beach = beach;
    }

    public boolean isMountain() {
        return mountain;
    }

    public void setMountain(boolean mountain) {
        this.mountain = mountain;
    }

    public boolean isIsland() {
        return island;
    }

    public void setIsland(boolean island) {
        this.island = island;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getBig() {
        return big;
    }

    public void setBig(int big) {
        this.big = big;
    }

    public int getCountry_side() {
        return country_side;
    }

    public void setCountry_side(int country_side) {
        this.country_side = country_side;
    }

    public int getClubbing() {
        return clubbing;
    }

    public void setClubbing(int clubbing) {
        this.clubbing = clubbing;
    }

    public int getPuntuaction() {
        return puntuaction;
    }

    public void setPuntuaction(int puntuaction) {
        this.puntuaction = puntuaction;
    }

    public int getMonuments() {
        return monuments;
    }

    public void setMonuments(int monuments) {
        this.monuments = monuments;
    }

    public static ArrayList<City> getList_cities() {
        return list_cities;
    }

    public static void setList_cities(ArrayList<City> list_cities) {
        City.list_cities = list_cities;
    }

    static ArrayList<City> list_cities = new ArrayList<>();

    public City(String name, boolean beach, boolean mountain, boolean island, int big, int country_side, int clubbing, int monuments){
        this.name = name;
        this.beach = beach;
        this.mountain = mountain;
        this.island = island;
        this.big = big;
        this.country_side = country_side;
        this.clubbing = clubbing;
        this.monuments = monuments;
        list_cities.add(this);
    }

    public String name(){
        return name;
    }

}
<file_sep>package com.example.travelchoice;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Collectors;

public class MainActivity extends AppCompatActivity {

    TextView textView, beachTV, mountainTV;
    CheckBox beachCB, mountainCB, islandCB;
    boolean a1, a2, a3, a4;
    Button nextB, backB;
    SeekBar clubbingSB, bigSB, countrySideSB, monumentsSB;
    int index = 0;
    LinearLayout beachL, mountainL, islandL, clubbingL, bigL, countrySideL, monumentsL;
    ArrayList<LinearLayout> listQuestions;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = (TextView) findViewById(R.id.text);

        nextB = (Button) findViewById(R.id.nextB);
        backB = (Button) findViewById(R.id.backB);


        beachTV = (TextView) findViewById(R.id.beachTV);
        mountainTV = (TextView) findViewById(R.id.mountainTV);

        beachCB = (CheckBox) findViewById(R.id.beachCB);
        mountainCB = (CheckBox) findViewById(R.id.mountainCB);
        islandCB = (CheckBox) findViewById(R.id.islandCB);
        clubbingSB = (SeekBar) findViewById(R.id.clubbingSB);
        bigSB = (SeekBar) findViewById(R.id.bigSB);
        countrySideSB = (SeekBar) findViewById(R.id.countrySideSB);
        monumentsSB = (SeekBar) findViewById(R.id.monumentsSB);

        beachL = (LinearLayout) findViewById(R.id.beachL);
        mountainL = (LinearLayout) findViewById(R.id.mountainL);
        islandL = (LinearLayout) findViewById(R.id.islandL);
        clubbingL = (LinearLayout) findViewById(R.id.clubbingL);
        bigL = (LinearLayout) findViewById(R.id.bigL);
        countrySideL = (LinearLayout) findViewById(R.id.countrySideL);
        monumentsL = (LinearLayout) findViewById(R.id.monumentsL);

        textView.setVisibility(View.GONE);

        mountainL.setVisibility(View.GONE);
        islandL.setVisibility(View.GONE);
        clubbingL.setVisibility(View.GONE);
        bigL.setVisibility(View.GONE);
        countrySideL.setVisibility(View.GONE);
        monumentsL.setVisibility(View.GONE);

        listQuestions = new ArrayList();
        listQuestions.add(beachL);
        listQuestions.add(mountainL);
        listQuestions.add(islandL);
        listQuestions.add(clubbingL);
        listQuestions.add(bigL);
        listQuestions.add(countrySideL);
        listQuestions.add(monumentsL);


        Create_cities create_cities = new Create_cities(this);



        nextB.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v){
                buttonN();
            }
        });

        backB.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v){
                buttonB();
            }
        });

    }


    private void animationF(LinearLayout firstL, LinearLayout secondL){
        firstL.animate()
                .alpha(-1f)
                .translationY(200f)
                .setDuration(800)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        firstL.setVisibility(View.GONE);
                        firstL.animate()
                                .alpha(1f)
                                .translationYBy(-200f)
                                .setDuration(1)
                                .setListener(null);
                    }
                });

        secondL.setAlpha(0f);
        secondL.setVisibility(View.VISIBLE);

        secondL.animate()
                .translationYBy(-200f)
                .setDuration(1)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        secondL.animate()
                                .alpha(1f)
                                .translationYBy(200f)
                                .setDuration(800)
                                .setListener(null);
                    }
                });

    }

    private void animationB(LinearLayout firstL, LinearLayout secondL){
        firstL.animate()
                .alpha(-1f)
                .translationY(-200f)
                .setDuration(800)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        firstL.setVisibility(View.GONE);
                        firstL.animate()
                                .alpha(1f)
                                .translationYBy(200f)
                                .setDuration(1)
                                .setListener(null);
                    }
                });

        secondL.setAlpha(0f);
        secondL.setVisibility(View.VISIBLE);

        secondL.animate()
                .translationYBy(200f)
                .setDuration(1)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        secondL.animate()
                                .alpha(1f)
                                .translationYBy(-200f)
                                .setDuration(800)
                                .setListener(null);
                    }
                });

    }

    private void buttonN(){
        if(index + 1 < listQuestions.size()){
            animationF(listQuestions.get(index), listQuestions.get(index + 1));

            index++;
        }
        else {
            a1 = beachCB.isChecked();
            a2 = mountainCB.isChecked();
            a3 = islandCB.isChecked();

            City.list_cities.forEach(s -> s.setPuntuaction(0));

            /**
            ArrayList<City> al1 = City.list_cities.stream()
                    .filter(s -> s.beach == a1)
                    .filter(s -> a2 == s.mountain)
                    .filter(s -> a3 == s.island)
                    .collect(Collectors.toCollection(ArrayList::new));
**/

            ArrayList<City> filteredCities = City.list_cities.stream()
                    .filter(s -> (!a1)||s.isBeach())
                    .filter(s -> (!a2)||s.isMountain())
                    .filter(s -> (!a3)||s.isIsland())
                    .collect(Collectors.toCollection(ArrayList::new));

            filteredCities.forEach(s -> s.setPuntuaction(Math.abs(s.getClubbing() - clubbingSB.getProgress())
                    + Math.abs(s.getBig() - bigSB.getProgress())
                    + Math.abs(s.getCountry_side() - countrySideSB.getProgress())
                    + Math.abs(s.getMonuments() - monumentsSB.getProgress())));
            Collections.sort(filteredCities, new CityComparator());

            if (filteredCities.size() > 0) {
                textView.setText(filteredCities.get(0).name());
            } else {
                textView.setText("rffff");
            }

            Bundle b = new Bundle();
            b.putSerializable("extra", filteredCities);

            Intent intent = new Intent(this, CardViewActivity.class);
            intent.putExtras(b);
            startActivity(intent);
        }
    }

    private void buttonB(){
        if(index  > 0){
            animationB(listQuestions.get(index), listQuestions.get(index - 1));

            index--;
        }
    }

}


<file_sep>package com.example.travelchoice;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

public class CardViewActivity extends AppCompatActivity implements Serializable {

    RecyclerView recyclerView;
    MyAdapter myAdapter;
    ArrayList<City> finalCities = new ArrayList<>();
    static HashMap<String, City> hashMap = new HashMap<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card_view);

        Bundle b = getIntent().getExtras();
        finalCities = (ArrayList<City>) b.getSerializable("extra");

        for (City each : finalCities){
            hashMap.put(each.getName(), each);
        }

        recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        myAdapter = new MyAdapter(this, getMyList());
        recyclerView.setAdapter(myAdapter);

    }

    private ArrayList<Model> getMyList() {

        ArrayList<Model> models = new ArrayList<>();

        Model m;

        for(City city : finalCities){
            m = new Model();
            m.setTitle(city.getName());
            m.setDescription("This is the description..");
            int resID = getResources().getIdentifier(city.getName().toLowerCase(), "drawable", "com.example.travelchoice");
            m.setImage(resID);
            models.add(m);
        }

        return models;
    }

    static City getCity(String city){
        return hashMap.get(city);
    }
}
<file_sep>package com.example.travelchoice;

import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.util.Pair;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class MyHolder extends RecyclerView.ViewHolder {

    ImageView imageViewRV;
    TextView titleRV, descriptionRV;
    Context context;

    public MyHolder(@NonNull View itemView, Context context) {
        super(itemView);

        this.context = context;
        imageViewRV = itemView.findViewById(R.id.imageCV);
        titleRV = itemView.findViewById(R.id.textCV);
        descriptionRV = itemView.findViewById(R.id.descriptionCV);

        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, InformationActivity.class);

                Pair[] pairs = new Pair[2];

                pairs[0] = new Pair<View, String>(imageViewRV, "image");
                pairs[1] = new Pair<View, String>(titleRV, "name");

                intent.putExtra("city", titleRV.getText());

                ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation((Activity) context, pairs);
                context.startActivity(intent, activityOptions.toBundle());
            }
        });
    }
}
<file_sep>include ':app'
rootProject.name='TravelChoice'
