Tried to add pictures in location detail
This commit is contained in:
@@ -15,21 +15,14 @@ public class Route implements Parcelable {
|
||||
|
||||
@NonNull
|
||||
private String name;
|
||||
|
||||
|
||||
private String description;
|
||||
private List<Location> locations;
|
||||
|
||||
|
||||
private float totalDistance;
|
||||
|
||||
|
||||
private int totalTime;
|
||||
|
||||
public Route(@NotNull String name) {
|
||||
|
||||
this.name = name;
|
||||
this.locations = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
protected Route(Parcel in) {
|
||||
@@ -103,4 +96,12 @@ public class Route implements Parcelable {
|
||||
parcel.writeFloat(totalDistance);
|
||||
parcel.writeInt(totalTime);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.a1.nextlocation.fragments;
|
||||
|
||||
import android.media.Image;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -9,12 +10,16 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.a1.nextlocation.R;
|
||||
import com.a1.nextlocation.data.Location;
|
||||
|
||||
public class LocationDetailFragment extends Fragment {
|
||||
|
||||
private ImageButton imageButton;
|
||||
private ImageView locationImage;
|
||||
private Location location;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -30,7 +35,19 @@ public class LocationDetailFragment extends Fragment {
|
||||
LocationFragment locationFragment = new LocationFragment();
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
|
||||
});
|
||||
System.out.println( getActivity().getPackageName() + "\n" + "drawable/" + location.getImageUrl());
|
||||
|
||||
this.locationImage = view.findViewById(R.id.detail_location_image);
|
||||
this.locationImage.setImageDrawable(getResources().getDrawable(getResources().getIdentifier("drawable/" + location.getImageUrl(), "drawable", getActivity().getPackageName())));
|
||||
|
||||
|
||||
// flag.setImageDrawable(getResources().getDrawable(getResources().getIdentifier("drawable/" + country_variable, "drawable", getPackageName()));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.a1.nextlocation.fragments;
|
||||
|
||||
import android.media.Image;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -52,6 +53,7 @@ public class LocationFragment extends Fragment {
|
||||
|
||||
this.locationAdapter = new LocationAdapter(this.getContext(), this.locationList, clickedPosition -> {
|
||||
LocationDetailFragment locationDetailFragment = new LocationDetailFragment();
|
||||
locationDetailFragment.setLocation(this.locationList.get(clickedPosition));
|
||||
Bundle locationBundle = new Bundle();
|
||||
locationBundle.putParcelable("location", this.locationList.get(clickedPosition));
|
||||
locationDetailFragment.setArguments(locationBundle);
|
||||
|
||||
Reference in New Issue
Block a user