Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Robin Koedood
2021-01-12 14:54:56 +01:00
8 changed files with 39 additions and 34 deletions

View File

@@ -53,7 +53,8 @@ public class CouponFragment extends Fragment {
this.backButton = view.findViewById(R.id.coupon_back_button); this.backButton = view.findViewById(R.id.coupon_back_button);
this.backButton.setOnClickListener(v -> { this.backButton.setOnClickListener(v -> {
StatisticFragment statisticFragment = new StatisticFragment(); StatisticFragment statisticFragment = new StatisticFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit();
}); });
this.couponRecyclerView.setLayoutManager(this.layoutManager); this.couponRecyclerView.setLayoutManager(this.layoutManager);

View File

@@ -91,7 +91,8 @@ public class HomeFragment extends Fragment implements LocationListener {
this.imageButton = view.findViewById(R.id.location_list_button); this.imageButton = view.findViewById(R.id.location_list_button);
this.imageButton.setOnClickListener(v -> { this.imageButton.setOnClickListener(v -> {
LocationFragment locationFragment = new LocationFragment(); LocationFragment locationFragment = new LocationFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
}); });
// set up the route stop button // set up the route stop button

View File

@@ -12,7 +12,6 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.a1.nextlocation.R; import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Data; import com.a1.nextlocation.data.Data;
@@ -74,7 +73,8 @@ public class LocationDetailFragment extends Fragment {
this.backButton = view.findViewById(R.id.detail_location_back_button); this.backButton = view.findViewById(R.id.detail_location_back_button);
this.backButton.setOnClickListener(v -> { this.backButton.setOnClickListener(v -> {
LocationFragment locationFragment = new LocationFragment(); LocationFragment locationFragment = new LocationFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
}); });
//Logs the location //Logs the location

View File

@@ -43,7 +43,8 @@ public class LocationFragment extends Fragment {
this.backButton = view.findViewById(R.id.location_back_button); this.backButton = view.findViewById(R.id.location_back_button);
this.backButton.setOnClickListener(v -> { this.backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment(); HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
}); });
//Loads the location list //Loads the location list
@@ -58,7 +59,8 @@ public class LocationFragment extends Fragment {
//Gives the clicked location to the adapter //Gives the clicked location to the adapter
locationBundle.putParcelable("location", this.locationList.get(clickedPosition)); locationBundle.putParcelable("location", this.locationList.get(clickedPosition));
locationDetailFragment.setArguments(locationBundle); locationDetailFragment.setArguments(locationBundle);
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationDetailFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationDetailFragment).addToBackStack(null).commit();
}); });
this.locationRecyclerView.setLayoutManager(this.layoutManager); this.locationRecyclerView.setLayoutManager(this.layoutManager);

View File

@@ -14,7 +14,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.a1.nextlocation.R; import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Location; import com.a1.nextlocation.data.Location;
@@ -79,7 +78,8 @@ public class RouteDetailFragment extends Fragment {
ImageButton backButton = view.findViewById(R.id.route_detail_back_button); ImageButton backButton = view.findViewById(R.id.route_detail_back_button);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
RouteFragment routeFragment = new RouteFragment(); RouteFragment routeFragment = new RouteFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit();
}); });
Button startButton = view.findViewById(R.id.start_route_button); Button startButton = view.findViewById(R.id.start_route_button);

View File

@@ -9,7 +9,6 @@ import android.widget.ImageButton;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@@ -49,13 +48,15 @@ public class RouteFragment extends Fragment {
Bundle routeBundle = new Bundle(); Bundle routeBundle = new Bundle();
routeBundle.putParcelable("route", this.routeList.get(clickedPosition)); routeBundle.putParcelable("route", this.routeList.get(clickedPosition));
routeDetailFragment.setArguments(routeBundle); routeDetailFragment.setArguments(routeBundle);
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeDetailFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeDetailFragment).addToBackStack(null).commit();
}); });
ImageButton backButton = view.findViewById(R.id.route_back_button); ImageButton backButton = view.findViewById(R.id.route_back_button);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment(); HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
}); });
routeRecyclerView.setLayoutManager(layoutManager); routeRecyclerView.setLayoutManager(layoutManager);

View File

@@ -5,7 +5,6 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -17,10 +16,8 @@ import android.widget.Spinner;
import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import com.a1.nextlocation.MainActivity;
import com.a1.nextlocation.R; import com.a1.nextlocation.R;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -66,7 +63,8 @@ public class SettingsFragment extends Fragment {
ImageView backButton = view.findViewById(R.id.settings_back_button); ImageView backButton = view.findViewById(R.id.settings_back_button);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment(); HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
}); });
SharedPreferences sharedPreferences = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE); SharedPreferences sharedPreferences = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE);
@@ -96,8 +94,7 @@ public class SettingsFragment extends Fragment {
//Changes the font settings depending on the state of the toggle //Changes the font settings depending on the state of the toggle
fontSwitch.setOnClickListener(view1 -> { fontSwitch.setOnClickListener(view1 -> {
if(fontSwitch.isChecked()) if (fontSwitch.isChecked()) {
{
requireActivity().setTheme(R.style.Theme_NextLocationBig); requireActivity().setTheme(R.style.Theme_NextLocationBig);
getActivity().recreate(); getActivity().recreate();
} }

View File

@@ -58,21 +58,24 @@ public class StatisticFragment extends Fragment {
ImageView backButton = view.findViewById(R.id.statistics_back_button); ImageView backButton = view.findViewById(R.id.statistics_back_button);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment(); HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
}); });
//Initialises the coupon button //Initialises the coupon button
ImageView couponButton = view.findViewById(R.id.coupon_button); ImageView couponButton = view.findViewById(R.id.coupon_button);
couponButton.setOnClickListener(v -> { couponButton.setOnClickListener(v -> {
CouponFragment couponFragment = new CouponFragment(); CouponFragment couponFragment = new CouponFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
}); });
//Makes the constraintlayout clickable and opens the same layout as the coupon button //Makes the constraintlayout clickable and opens the same layout as the coupon button
ConstraintLayout constraintLayout = view.findViewById(R.id.Box4); ConstraintLayout constraintLayout = view.findViewById(R.id.Box4);
constraintLayout.setOnClickListener(v -> { constraintLayout.setOnClickListener(v -> {
CouponFragment couponFragment = new CouponFragment(); CouponFragment couponFragment = new CouponFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
}); });
return view; return view;
} }