@@ -0,0 +1,114 @@
package org.calmarj.sportboxrssreader.db;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;

public class RSSContentProvider extends ContentProvider {
public static final int ITEMS = 1;
public static final int ITEMS_ID = 2;
private static final String AUTHORITY = "org.calmarj.sportboxrssreader.db";
private static final String ITEMS_TABLE = "items";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + ITEMS_TABLE);
private static final UriMatcher mURImatcher = new UriMatcher(UriMatcher.NO_MATCH);

static {
mURImatcher.addURI(AUTHORITY, ITEMS_TABLE, ITEMS);
mURImatcher.addURI(AUTHORITY, ITEMS_TABLE + "/#",
ITEMS_ID);
}

private DatabaseHelper mDatabaseHelper;

public RSSContentProvider() {
}

@Override
public boolean onCreate() {
boolean result = true;
mDatabaseHelper = new DatabaseHelper(getContext());
SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();

if (db == null) {
result = false;
}

if (db != null) {
if (db.isReadOnly()) {
db.close();
db = null;
result = false;
}
}

return result;
}

@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
// Implement this to handle requests to delete one or more rows.
throw new UnsupportedOperationException("Not yet implemented");
}

@Override
public String getType(Uri uri) {
// TODO: Implement this to handle requests for the MIME type of the data
// at the given URI.
throw new UnsupportedOperationException("Not yet implemented");
}

@Override
public Uri insert(Uri uri, ContentValues values) {
int uriType = mURImatcher.match(uri);

SQLiteDatabase sqlDB = mDatabaseHelper.getWritableDatabase();

long id = 0;
switch (uriType) {
case ITEMS:
id = sqlDB.insert(DatabaseHelper.TABLE_ITEM,
null, values);
break;
default:
throw new IllegalArgumentException("Unknown URI: " + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return Uri.parse(ITEMS_TABLE + "/" + id);
}

@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(DatabaseHelper.TABLE_ITEM);

int uriType = mURImatcher.match(uri);

switch (uriType) {
case ITEMS_ID:
queryBuilder.appendWhere(DatabaseHelper.KEY_ITEM_ID + "="
+ uri.getLastPathSegment());
break;
case ITEMS:
break;
default:
throw new IllegalArgumentException("Unknown URI");
}

Cursor cursor = queryBuilder.query(mDatabaseHelper.getReadableDatabase(),
projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}

@Override
public int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
// TODO: Implement this to handle requests to update one or more rows.
throw new UnsupportedOperationException("Not yet implemented");
}
}
@@ -1,4 +1,4 @@
package org.calmarj.sportboxrssreader.retrofit;
package org.calmarj.sportboxrssreader.model;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
@@ -1,13 +1,10 @@
package org.calmarj.sportboxrssreader.retrofit;
package org.calmarj.sportboxrssreader.model;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

/**
* Created by calmarj on 02.11.15.
*/
@Root(name = "item", strict = false)
public class Item {
public class Item implements Comparable<Item> {
@Element
private String title;
@Element
@@ -19,23 +16,51 @@ public class Item {
@Element(required = false)
private String pubDate;

public Item() {
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getLink() {
return link;
}

public void setLink(String link) {
this.link = link;
}

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

public String getPubDate() {
return pubDate;
}

public void setPubDate(String pubDate) {
this.pubDate = pubDate;
}

@Override
public int compareTo(Item another) {
return pubDate.compareTo(another.getPubDate());
}
}
@@ -1,4 +1,4 @@
package org.calmarj.sportboxrssreader.retrofit;
package org.calmarj.sportboxrssreader.model;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
@@ -1,4 +1,4 @@
package org.calmarj.sportboxrssreader;
package org.calmarj.sportboxrssreader.retrofit;

import retrofit.RestAdapter;
import retrofit.converter.SimpleXMLConverter;
@@ -1,6 +1,6 @@
package org.calmarj.sportboxrssreader;
package org.calmarj.sportboxrssreader.retrofit;

import org.calmarj.sportboxrssreader.retrofit.RSS;
import org.calmarj.sportboxrssreader.model.RSS;

import retrofit.http.GET;
import rx.Observable;
@@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.calmarj.sportboxrssreader.DetailActivity">
tools:context="org.calmarj.sportboxrssreader.activity.DetailActivity">


</RelativeLayout>
@@ -1,16 +1,13 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />

</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
@@ -10,8 +10,26 @@
card_view:cardCornerRadius="4dp"
card_view:elevation="2dp">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/info_text"
android:id="@+id/info_text_title"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:textSize="20sp"
android:textStyle="bold" />

<TextView
android:id="@+id/info_text_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="fill"
android:textSize="15sp" />
</LinearLayout>
</android.support.v7.widget.CardView>
@@ -1,7 +1,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.calmarj.sportboxrssreader.DetailActivity">
tools:context="org.calmarj.sportboxrssreader.activity.DetailActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"