added findbyname in locationlistmanager
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.NextLocation"
|
||||
android:hardwareAccelerated="false">
|
||||
<activity android:name=".MainActivity">
|
||||
<activity android:name=".MainActivity"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
{
|
||||
"name":"Het Klooster Breda Schorsmolenstraat 13",
|
||||
"coordinates":"51.58765659148822, 4.764801414019652"
|
||||
"coordinates":"51.58775443759389,4.765568874365066"
|
||||
}
|
||||
],
|
||||
"totalDistance": 1073.0,
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.a1.nextlocation.R;
|
||||
import com.a1.nextlocation.data.Location;
|
||||
import com.a1.nextlocation.recyclerview.LocationListManager;
|
||||
|
||||
public class LocationDetailFragment extends Fragment {
|
||||
private static final String TAG = LocationDetailFragment.class.getCanonicalName();
|
||||
@@ -62,9 +63,11 @@ public class LocationDetailFragment extends Fragment {
|
||||
}
|
||||
|
||||
this.locationImage = view.findViewById(R.id.detail_location_image);
|
||||
Context context = this.locationImage.getContext();
|
||||
int id = context.getResources().getIdentifier(this.location.getImageUrl(), "drawable", context.getPackageName());
|
||||
this.locationImage.setImageResource(id);
|
||||
if (this.location.getImageUrl() != null) {
|
||||
|
||||
int id = requireContext().getResources().getIdentifier(this.location.getImageUrl(), "drawable", requireContext().getPackageName());
|
||||
this.locationImage.setImageResource(id);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -33,4 +33,13 @@ public enum LocationListManager {
|
||||
this.locationList = locationLoader.load();
|
||||
}
|
||||
|
||||
public Location findByName(String name) {
|
||||
Location res = null;
|
||||
for (Location location : this.locationList) {
|
||||
if (location.getName().equals(name)) res = location;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user