improving article list: adding host label

This commit is contained in:
Kevin Meyer 2014-11-13 19:36:43 +01:00
parent d63d47c1f8
commit 440354e578
3 changed files with 44 additions and 15 deletions

View File

@ -1,18 +1,37 @@
package fr.gaulupeau.apps.Poche;
import android.util.Log;
import java.net.URL;
public class Article {
public String url;
public String id;
public String title;
public String content;
public String archive;
private URL m_url = null;
public Article(String url, String id, String title, String content, String archive) {
super();
this.url = url;
this.id = id;
this.title = title;
this.content = content;
this.archive = archive;
}
super();
this.url = url;
this.id = id;
this.title = title;
this.content = content;
this.archive = archive;
try {
this.m_url = new URL(url);
} catch (Exception e) {
e.printStackTrace();
}
}
public String getHostOfUrl() {
if (this.m_url != null) {
return m_url.getHost();
}
return "";
}
}

View File

@ -42,8 +42,10 @@ public class ReadingListAdapter extends BaseAdapter {
convertView = inflater.inflate(R.layout.article_list, parent, false);
}
TextView tvTitle = (TextView) convertView.findViewById(R.id.listitem_titre);
//Log.e("title", entry.title);
TextView tvHost = (TextView) convertView.findViewById(R.id.listitem_textview_url);
tvTitle.setText(entry.title);
tvHost.setText(entry.getHostOfUrl());
return convertView;
}

View File

@ -1,14 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:padding="10sp"
android:orientation="vertical" android:padding="8sp"
android:layout_width="fill_parent" android:layout_height="fill_parent" >
<TextView
android:id="@+id/listitem_titre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:typeface="serif" />
<TextView
android:id="@+id/listitem_titre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="@android:color/black"
android:paddingBottom="4sp"/>
<TextView
android:id="@+id/listitem_textview_url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:singleLine="true" />
</LinearLayout>