mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	* fix issue with item with endtime shown as existing * Removed destroyed and endtime, Added comments and also fixed the broken tests * minor fix * Added comments * fix no such column location_exists error * minor improvement Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									d00127947c
								
							
						
					
					
						commit
						944225c3a3
					
				
					 10 changed files with 53 additions and 28 deletions
				
			
		|  | @ -201,7 +201,7 @@ public class NearbyController { | |||
|                         nearbyBaseMarker.icon(IconFactory.getInstance(context) | ||||
|                                 .fromBitmap(iconGreen)); | ||||
|                     } | ||||
|                 } else if (!place.destroyed.trim().isEmpty()) { // Means place is destroyed | ||||
|                 } else if (!place.exists) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed | ||||
|                     if (iconGrey != null) { | ||||
|                         nearbyBaseMarker.icon(IconFactory.getInstance(context) | ||||
|                                 .fromBitmap(iconGrey)); | ||||
|  |  | |||
|  | @ -25,13 +25,15 @@ public class Place implements Parcelable { | |||
|     public final LatLng location; | ||||
|     private final String category; | ||||
|     public final String pic; | ||||
|     public final String destroyed; | ||||
|     // exists boolean will tell whether the place exists or not, | ||||
|     // For a place to be existing both destroyed and endTime property should be null but it is also not necessary for a non-existing place to have both properties either one property is enough (in such case that not given property will be considered as null). | ||||
|     public final Boolean exists; | ||||
| 
 | ||||
|     public String distance; | ||||
|     public final Sitelinks siteLinks; | ||||
| 
 | ||||
| 
 | ||||
|     public Place(String language,String name, Label label, String longDescription, LatLng location, String category, Sitelinks siteLinks, String pic, String destroyed) { | ||||
|     public Place(String language,String name, Label label, String longDescription, LatLng location, String category, Sitelinks siteLinks, String pic, Boolean exists) { | ||||
|         this.language = language; | ||||
|         this.name = name; | ||||
|         this.label = label; | ||||
|  | @ -40,7 +42,7 @@ public class Place implements Parcelable { | |||
|         this.category = category; | ||||
|         this.siteLinks = siteLinks; | ||||
|         this.pic = (pic == null) ? "":pic; | ||||
|         this.destroyed = (destroyed == null) ? "":destroyed; | ||||
|         this.exists = exists; | ||||
|     } | ||||
|     public Place(Parcel in) { | ||||
|         this.language = in.readString(); | ||||
|  | @ -52,8 +54,8 @@ public class Place implements Parcelable { | |||
|         this.siteLinks = in.readParcelable(Sitelinks.class.getClassLoader()); | ||||
|         String picString = in.readString(); | ||||
|         this.pic = (picString == null) ? "":picString; | ||||
|         String destroyedString = in.readString(); | ||||
|         this.destroyed = (destroyedString == null) ? "":destroyedString; | ||||
|         String existString = in.readString(); | ||||
|         this.exists = Boolean.parseBoolean(existString); | ||||
|     } | ||||
|     public static Place from(NearbyResultItem item) { | ||||
|         String itemClass = item.getClassName().getValue(); | ||||
|  | @ -74,7 +76,8 @@ public class Place implements Parcelable { | |||
|                         .setWikidataLink(item.getItem().getValue()) | ||||
|                         .build(), | ||||
|                 item.getPic().getValue(), | ||||
|                 item.getDestroyed().getValue()); | ||||
|                 // Checking if the place exists or not | ||||
|                 (item.getDestroyed().getValue() == "") && (item.getEndTime().getValue() == "")); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -194,7 +197,7 @@ public class Place implements Parcelable { | |||
|                 ", distance='" + distance + '\'' + | ||||
|                 ", siteLinks='" + siteLinks.toString() + '\'' + | ||||
|                 ", pic='" + pic + '\'' + | ||||
|                 ", destroyed='" + destroyed + '\'' + | ||||
|                 ", exists='" + exists.toString() + '\'' + | ||||
|                 '}'; | ||||
|     } | ||||
| 
 | ||||
|  | @ -213,7 +216,7 @@ public class Place implements Parcelable { | |||
|         dest.writeString(category); | ||||
|         dest.writeParcelable(siteLinks, 0); | ||||
|         dest.writeString(pic); | ||||
|         dest.writeString(destroyed); | ||||
|         dest.writeString(exists.toString()); | ||||
|     } | ||||
| 
 | ||||
|     public static final Creator<Place> CREATOR = new Creator<Place>() { | ||||
|  |  | |||
|  | @ -1254,12 +1254,12 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
| 
 | ||||
|             if (displayExists && displayNeedsPhoto) { | ||||
|                 // Exists and needs photo | ||||
|                 if (place.destroyed.trim().isEmpty() && place.pic.trim().isEmpty()) { | ||||
|                 if (place.exists && place.pic.trim().isEmpty()) { | ||||
|                     updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation); | ||||
|                 } | ||||
|             } else if (displayExists && !displayNeedsPhoto) { | ||||
|                 // Exists and all included needs and doesn't needs photo | ||||
|                 if (place.destroyed.trim().isEmpty()) { | ||||
|                 if (place.exists) { | ||||
|                     updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation); | ||||
|                 } | ||||
|             } else if (!displayExists && displayNeedsPhoto) { | ||||
|  | @ -1317,7 +1317,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|             return (isBookmarked ? | ||||
|                 R.drawable.ic_custom_map_marker_green_bookmarked : | ||||
|                 R.drawable.ic_custom_map_marker_green); | ||||
|         } else if (!place.destroyed.trim().isEmpty()) { // Means place is destroyed | ||||
|         } else if (!place.exists) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed | ||||
|             return (isBookmarked ? | ||||
|                 R.drawable.ic_custom_map_marker_grey_bookmarked : | ||||
|                 R.drawable.ic_custom_map_marker_grey); | ||||
|  |  | |||
|  | @ -11,7 +11,8 @@ class NearbyResultItem(private val item: ResultTuple?, | |||
|                        @field:SerializedName("classLabel") private val classLabel: ResultTuple?, | ||||
|                        @field:SerializedName("commonsCategory") private val commonsCategory: ResultTuple?, | ||||
|                        @field:SerializedName("pic") private val pic: ResultTuple?, | ||||
|                        @field:SerializedName("destroyed") private val destroyed: ResultTuple?) { | ||||
|                        @field:SerializedName("destroyed") private val destroyed: ResultTuple?, | ||||
|                        @field:SerializedName("endTime") private val endTime: ResultTuple?) { | ||||
| 
 | ||||
|     fun getItem(): ResultTuple { | ||||
|         return item ?: ResultTuple() | ||||
|  | @ -57,4 +58,8 @@ class NearbyResultItem(private val item: ResultTuple?, | |||
|         return destroyed ?: ResultTuple() | ||||
|     } | ||||
| 
 | ||||
|     fun getEndTime(): ResultTuple { | ||||
|         return endTime ?: ResultTuple() | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Pratham Pahariya
						Pratham Pahariya