mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-30 06:13:54 +01:00
Convert few model classes to kotlin (#3270)
This commit is contained in:
parent
d0f97398a5
commit
b0be4970ef
86 changed files with 661 additions and 1300 deletions
|
|
@ -1,16 +0,0 @@
|
|||
package fr.free.nrw.commons.notification;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class MarkReadResponse {
|
||||
@SuppressWarnings("unused") @Nullable
|
||||
private String result;
|
||||
|
||||
public String result() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class QueryMarkReadResponse {
|
||||
@SuppressWarnings("unused") @Nullable private MarkReadResponse echomarkread;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
package fr.free.nrw.commons.notification;
|
||||
|
||||
import org.wikipedia.util.DateUtil;
|
||||
|
||||
/**
|
||||
* Created by root on 18.12.2017.
|
||||
*/
|
||||
|
||||
public class Notification {
|
||||
public NotificationType notificationType;
|
||||
public String notificationText;
|
||||
public String date;
|
||||
public String link;
|
||||
public String iconUrl;
|
||||
public String notificationId;
|
||||
|
||||
public Notification(NotificationType notificationType,
|
||||
String notificationText,
|
||||
String date,
|
||||
String link,
|
||||
String iconUrl,
|
||||
String notificationId) {
|
||||
this.notificationType = notificationType;
|
||||
this.notificationText = notificationText;
|
||||
this.date = date;
|
||||
this.link = link;
|
||||
this.iconUrl = iconUrl;
|
||||
this.notificationId=notificationId;
|
||||
}
|
||||
|
||||
public static Notification from(org.wikipedia.notifications.Notification wikiNotification) {
|
||||
org.wikipedia.notifications.Notification.Contents contents = wikiNotification.getContents();
|
||||
String notificationLink = contents == null || contents.getLinks() == null
|
||||
|| contents.getLinks().getPrimary() == null ? "" : contents.getLinks().getPrimary().getUrl();
|
||||
return new Notification(NotificationType.UNKNOWN,
|
||||
contents == null ? "" : contents.getCompactHeader(),
|
||||
DateUtil.getMonthOnlyDateString(wikiNotification.getTimestamp()),
|
||||
notificationLink,
|
||||
"",
|
||||
String.valueOf(wikiNotification.id()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Notification" +
|
||||
"notificationType='" + notificationType + '\'' +
|
||||
", notificationText='" + notificationText + '\'' +
|
||||
", date='" + date + '\'' +
|
||||
", link='" + link + '\'' +
|
||||
", iconUrl='" + iconUrl + '\'' +
|
||||
", notificationId='" + notificationId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package fr.free.nrw.commons.notification
|
||||
|
||||
import org.wikipedia.util.DateUtil
|
||||
|
||||
/**
|
||||
* Created by root on 18.12.2017.
|
||||
*/
|
||||
data class Notification(var notificationType: NotificationType,
|
||||
var notificationText: String,
|
||||
var date: String,
|
||||
var link: String,
|
||||
var iconUrl: String,
|
||||
var notificationId: String) {
|
||||
override fun toString(): String {
|
||||
return "Notification" +
|
||||
"notificationType='" + notificationType + '\'' +
|
||||
", notificationText='" + notificationText + '\'' +
|
||||
", date='" + date + '\'' +
|
||||
", link='" + link + '\'' +
|
||||
", iconUrl='" + iconUrl + '\'' +
|
||||
", notificationId='" + notificationId + '\'' +
|
||||
'}'
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun from(wikiNotification: org.wikipedia.notifications.Notification): Notification {
|
||||
val contents = wikiNotification.contents
|
||||
val notificationLink = if (contents == null || contents.links == null || contents.links!!.primary == null) "" else contents.links!!.primary!!.url
|
||||
return Notification(NotificationType.UNKNOWN,
|
||||
contents?.compactHeader ?: "",
|
||||
DateUtil.getMonthOnlyDateString(wikiNotification.timestamp),
|
||||
notificationLink,
|
||||
"", wikiNotification.id().toString())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -225,14 +225,14 @@ public class NotificationActivity extends NavigationBaseActivity {
|
|||
notificationAdapterFactory = new NotificationAdapterFactory(new NotificationRenderer.NotificationClicked() {
|
||||
@Override
|
||||
public void notificationClicked(Notification notification) {
|
||||
Timber.d("Notification clicked %s", notification.link);
|
||||
handleUrl(notification.link);
|
||||
Timber.d("Notification clicked %s", notification.getLink());
|
||||
handleUrl(notification.getLink());
|
||||
removeNotification(notification);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markNotificationAsRead(Notification notification) {
|
||||
Timber.d("Notification to mark as read %s", notification.notificationId);
|
||||
Timber.d("Notification to mark as read %s", notification.getNotificationId());
|
||||
removeNotification(notification);
|
||||
}
|
||||
}, isarchivedvisible);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@ public class NotificationController {
|
|||
}
|
||||
|
||||
Observable<Boolean> markAsRead(Notification notification) {
|
||||
return notificationClient.markNotificationAsRead(notification.notificationId);
|
||||
return notificationClient.markNotificationAsRead(notification.getNotificationId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ public class NotificationRenderer extends Renderer<Notification> {
|
|||
@Override
|
||||
public void render() {
|
||||
Notification notification = getContent();
|
||||
setTitle(notification.notificationText);
|
||||
time.setText(notification.date);
|
||||
setTitle(notification.getNotificationText());
|
||||
time.setText(notification.getDate());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue