1
0
mirror of https://github.com/ultrasonic/ultrasonic synced 2025-01-29 16:39:20 +01:00

Migrate PodcastsChannel entity to kotlin.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-02-21 22:38:13 +01:00
parent 82e265fda9
commit 257a014b18
5 changed files with 50 additions and 191 deletions

View File

@ -1,119 +0,0 @@
/*
This file is part of Subsonic.
Subsonic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Subsonic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2009 (C) Sindre Mehus
*/
package org.moire.ultrasonic.domain;
import java.io.Serializable;
/**
* @author Sindre Mehus
*/
public class PodcastsChannel implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -4160515427075433798L;
private String id;
private String title;
private String url;
private String description;
private String status;
public PodcastsChannel(String id, String title,String url, String description, String status)
{
this.id = id;
this.title = title;
this.url = url;
this.description = description;
this.status = status;
}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
return getTitle();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PodcastsChannel that = (PodcastsChannel) o;
if (id != null ? !id.equals(that.id) : that.id != null) return false;
if (title != null ? !title.equals(that.title) : that.title != null) return false;
if (url != null ? !url.equals(that.url) : that.url != null) return false;
if (description != null ? !description.equals(that.description) : that.description != null)
return false;
return status != null ? status.equals(that.status) : that.status == null;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + (url != null ? url.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (status != null ? status.hashCode() : 0);
return result;
}
}

View File

@ -1,83 +1,46 @@
package org.moire.ultrasonic.view;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import org.moire.ultrasonic.R;
import org.moire.ultrasonic.activity.SubsonicTabActivity;
import org.moire.ultrasonic.domain.Playlist;
import org.moire.ultrasonic.domain.PodcastsChannel;
import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @author Sindre Mehus
*/
public class PodcastsChannelsAdapter extends ArrayAdapter<PodcastsChannel>
{
public class PodcastsChannelsAdapter extends ArrayAdapter<PodcastsChannel> {
private final LayoutInflater layoutInflater;
//private final SubsonicTabActivity activity;
public PodcastsChannelsAdapter(Context context, List<PodcastsChannel> channels) {
super(context, R.layout.podcasts_channel_item, channels);
public PodcastsChannelsAdapter(Activity activity, List<PodcastsChannel> channels)
{
super(activity, R.layout.podcasts_channel_item, channels);
//this.activity = activity;
}
@Override
public void add(PodcastsChannel object) {
super.add(object);
layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
/* @Override
public View getView(int position, View convertView, ViewGroup parent)
{
PodcastsChannel entry = getItem(position);
PlaylistView view;
if (convertView != null && convertView instanceof PlaylistView)
{
PlaylistView currentView = (PlaylistView) convertView;
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
PodcastsChannel entry = getItem(position);
ViewHolder viewHolder = (ViewHolder) convertView.getTag();
view = currentView;
view.setViewHolder(viewHolder);
}
else
{
view = new PlaylistView(activity);
view.setLayout();
}
TextView view;
if (convertView != null && convertView instanceof PlaylistView) {
view = (TextView) convertView;
} else {
view = (TextView) layoutInflater
.inflate(R.layout.podcasts_channel_item, parent, false);
}
view.setPlaylist(entry);
return view;
}
*/
view.setText(entry.getTitle());
/* public static class PlaylistComparator implements Comparator<Playlist>, Serializable
{
private static final long serialVersionUID = -6201663557439120008L;
@Override
public int compare(Playlist playlist1, Playlist playlist2)
{
return playlist1.getName().compareToIgnoreCase(playlist2.getName());
}
public static List<Playlist> sort(List<Playlist> playlists)
{
Collections.sort(playlists, new PlaylistComparator());
return playlists;
}
} */
/* static class ViewHolder
{
TextView name;
} */
}
return view;
}
}

View File

@ -0,0 +1,15 @@
package org.moire.ultrasonic.domain
import java.io.Serializable
data class PodcastsChannel(
val id: String,
val title: String?,
val url: String?,
val description: String?,
val status: String?
) : Serializable {
companion object {
private const val serialVersionUID = -4160515427075433798L
}
}

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/podcast_channel_item"
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:padding="10dip"
a:visibility="visible" />
<TextView xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/podcast_channel_item"
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:padding="10dip"
a:visibility="visible" />

View File

@ -20,11 +20,11 @@ class APIPodcastConverterTest {
val converterEntity = entity.toDomainEntity()
with(converterEntity) {
id = entity.id
description = entity.description
status = entity.status
title = entity.title
url = entity.url
id `should equal` entity.id
description `should equal` entity.description
status `should equal` entity.status
title `should equal` entity.title
url `should equal` entity.url
}
}