Correction bug #11 et #13

This commit is contained in:
GAULUPEAU Jonathan 2014-01-08 00:20:41 +01:00
parent c4636fbb25
commit 30634ae224
7 changed files with 24 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest package="fr.gaulupeau.apps.InThePoche" <manifest package="fr.gaulupeau.apps.InThePoche"
android:versionCode="7" android:versionCode="8"
android:versionName="@string/version" xmlns:android="http://schemas.android.com/apk/res/android"> android:versionName="@string/version" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8" <uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="8" /> android:targetSdkVersion="8" />

View File

@ -23,5 +23,5 @@
<string name="txtGlobalToken"><b><u>API global token :</u></b></string> <string name="txtGlobalToken"><b><u>API global token :</u></b></string>
<string name="txtAPIUsername"><b><u>Your username ID (user_id in Feed URL):</u></b></string> <string name="txtAPIUsername"><b><u>Your username ID (user_id in Feed URL):</u></b></string>
<string name="txtAPIToken"><b><u>Your token (token in Feed URL):</u></b></string> <string name="txtAPIToken"><b><u>Your token (token in Feed URL):</u></b></string>
<string name="version">1.5.3.1</string> <string name="version">1.5.3.2</string>
</resources> </resources>

View File

@ -15,6 +15,7 @@ public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper {
public static final String DB_NAME = "article_db.sqlite"; public static final String DB_NAME = "article_db.sqlite";
public static String MY_ID = "my_id"; public static String MY_ID = "my_id";
public static String ARTICLE_TABLE = "article"; public static String ARTICLE_TABLE = "article";
public static String ARTICLE_DATE = "update_date";
public static String ARTICLE_ID = "article_id"; public static String ARTICLE_ID = "article_id";
public static String ARTICLE_AUTHOR = "author"; public static String ARTICLE_AUTHOR = "author";
public static String ARTICLE_CONTENT = "content"; public static String ARTICLE_CONTENT = "content";
@ -57,6 +58,7 @@ public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper {
"create table " + ARTICLE_TABLE + " (" + "create table " + ARTICLE_TABLE + " (" +
MY_ID + " integer primary key autoincrement not null, " + MY_ID + " integer primary key autoincrement not null, " +
ARTICLE_AUTHOR + " text, " + ARTICLE_AUTHOR + " text, " +
ARTICLE_DATE + " datetime, " +
ARTICLE_CONTENT + " text, " + ARTICLE_CONTENT + " text, " +
ARTICLE_TITLE + " text, " + ARTICLE_TITLE + " text, " +
ARTICLE_URL + " text, " + ARTICLE_URL + " text, " +

View File

@ -94,7 +94,7 @@ public class ListArticles extends Activity {
Cursor ac = database.query( Cursor ac = database.query(
ARTICLE_TABLE, ARTICLE_TABLE,
getStrColumns, getStrColumns,
filter, null, null, null, null); filter, null, null, null, ARTICLE_DATE + " DESC");
ac.moveToFirst(); ac.moveToFirst();
if(!ac.isAfterLast()) { if(!ac.isAfterLast()) {
do { do {

View File

@ -19,6 +19,8 @@ import java.net.URL;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.util.Date;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
@ -45,6 +47,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.sqlite.SQLiteConstraintException; import android.database.sqlite.SQLiteConstraintException;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.net.Uri; import android.net.Uri;
@ -68,6 +71,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_TITLE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT; import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE; import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC; import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
@ -392,6 +396,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
arrays.PodcastURL = new String[itemLst.getLength()]; arrays.PodcastURL = new String[itemLst.getLength()];
arrays.PodcastContent = new String[itemLst.getLength()]; arrays.PodcastContent = new String[itemLst.getLength()];
arrays.PodcastMedia = new String[itemLst.getLength()]; arrays.PodcastMedia = new String[itemLst.getLength()];
arrays.PodcastDate = new String[itemLst.getLength()];
// Loop through the XML passing the data to the arrays // Loop through the XML passing the data to the arrays
for (int i = 0; i < itemLst.getLength(); i++) for (int i = 0; i < itemLst.getLength(); i++)
@ -407,6 +412,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
// and remove elements that you want / don't want // and remove elements that you want / don't want
NodeList title = ielem.getElementsByTagName("title"); NodeList title = ielem.getElementsByTagName("title");
NodeList link = ielem.getElementsByTagName("link"); NodeList link = ielem.getElementsByTagName("link");
NodeList date = ielem.getElementsByTagName("pubDate");
NodeList content = ielem NodeList content = ielem
.getElementsByTagName("description"); .getElementsByTagName("description");
//NodeList media = ielem //NodeList media = ielem
@ -429,7 +435,12 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
e.printStackTrace(); e.printStackTrace();
arrays.PodcastTitle[i] = "Echec"; arrays.PodcastTitle[i] = "Echec";
} }
try {
arrays.PodcastDate[i] = date.item(0).getChildNodes().item(0).getNodeValue();
} catch (NullPointerException e) {
e.printStackTrace();
arrays.PodcastDate[i] = null;
}
try try
{ {
arrays.PodcastURL[i] = link.item(0).getChildNodes() arrays.PodcastURL[i] = link.item(0).getChildNodes()
@ -454,12 +465,16 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
values.put(ARTICLE_CONTENT, Html.fromHtml(arrays.PodcastContent[i]).toString()); values.put(ARTICLE_CONTENT, Html.fromHtml(arrays.PodcastContent[i]).toString());
//values.put(ARTICLE_ID, Html.fromHtml(article.getString("id")).toString()); //values.put(ARTICLE_ID, Html.fromHtml(article.getString("id")).toString());
values.put(ARTICLE_URL, Html.fromHtml(arrays.PodcastURL[i]).toString()); values.put(ARTICLE_URL, Html.fromHtml(arrays.PodcastURL[i]).toString());
values.put(ARTICLE_DATE, arrays.PodcastDate[i]);
values.put(ARCHIVE, 0); values.put(ARCHIVE, 0);
values.put(ARTICLE_SYNC, 0); values.put(ARTICLE_SYNC, 0);
try { try {
database.insertOrThrow(ARTICLE_TABLE, null, values); database.insertOrThrow(ARTICLE_TABLE, null, values);
} catch (SQLiteConstraintException e) { } catch (SQLiteConstraintException e) {
continue; continue;
} catch (SQLiteException e) {
database.execSQL("ALTER TABLE " + ARTICLE_TABLE + " ADD COLUMN " + ARTICLE_DATE + " datetime;");
database.insertOrThrow(ARTICLE_TABLE, null, values);
} }
} }
} }

View File

@ -62,6 +62,7 @@ public class ReadArticle extends Activity {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(ARCHIVE, 1); values.put(ARCHIVE, 1);
database.update(ARTICLE_TABLE, values, MY_ID + "=" + id, null); database.update(ARTICLE_TABLE, values, MY_ID + "=" + id, null);
finish();
} }
}); });

View File

@ -5,4 +5,5 @@ public class arrays {
public static String[] PodcastURL; public static String[] PodcastURL;
public static String[] PodcastContent; public static String[] PodcastContent;
public static String[] PodcastMedia; public static String[] PodcastMedia;
public static String[] PodcastDate;
} }