Added comments

This commit is contained in:
RemoMeijer
2021-01-06 19:18:23 +01:00
parent 0d94d17b2f
commit ae2aab7275
6 changed files with 49 additions and 55 deletions

View File

@@ -1,7 +1,6 @@
package com.a1.nextlocation.fragments;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
@@ -21,14 +20,13 @@ import com.a1.nextlocation.data.Location;
public class LocationDetailFragment extends Fragment {
private static final String TAG = LocationDetailFragment.class.getCanonicalName();
private ImageButton imageButton;
private ImageButton backButton;
private Location location;
private TextView titelText;
private TextView detailText;
private ImageView locationImage;
public LocationDetailFragment() {
}
public LocationDetailFragment(Location location) {
@@ -51,12 +49,14 @@ public class LocationDetailFragment extends Fragment {
this.detailText = view.findViewById(R.id.detail_location_text);
this.detailText.setText(location.getDescription());
this.imageButton = view.findViewById(R.id.detail_location_back_button);
this.imageButton.setOnClickListener(v -> {
//Initialises the back button
this.backButton = view.findViewById(R.id.detail_location_back_button);
this.backButton.setOnClickListener(v -> {
LocationFragment locationFragment = new LocationFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
});
//Logs the location
if (location != null) {
Log.d(TAG, "onCreateView: the location has a name of: " + location.getName());
}
@@ -68,8 +68,4 @@ public class LocationDetailFragment extends Fragment {
return view;
}
public void setLocation(Location location) {
this.location = location;
}
}