mirror of
https://github.com/moparisthebest/android-app
synced 2024-12-23 15:08:49 -05:00
Correction problème encodage. Possibilité de vider la BD locale.
This commit is contained in:
parent
d6f6aba6f4
commit
c6150513a2
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:id="@+id/menuShowAll" android:title="@string/menuShowAll"></item>
|
||||
|
||||
<item android:id="@+id/menuWipeDb" android:title="@string/menuWipeDb"></item>
|
||||
|
||||
</menu>
|
||||
|
@ -15,6 +15,7 @@
|
||||
<string name="btnMarkRead">Mark as Read</string>
|
||||
<string name="menuSettings">Settings</string>
|
||||
<string name="menuShowAll">Show All</string>
|
||||
<string name="menuWipeDb">Wipe Database</string>
|
||||
<string name="txtSyncDone">Synchronize done !</string>
|
||||
<string name="txtSyncFailed">Synchronize failed !</string>
|
||||
<string name="txtNetOffline">Check Internet Connectivity !</string>
|
||||
|
@ -69,6 +69,8 @@ public class ArticlesSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public void truncateTables(SQLiteDatabase db) {
|
||||
db.execSQL("DELETE FROM " + ARTICLE_TABLE + ";");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,6 +50,12 @@ public class ListArticles extends Activity {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menuShowAll:
|
||||
setupList(true);
|
||||
return super.onOptionsItemSelected(item);
|
||||
case R.id.menuWipeDb:
|
||||
ArticlesSQLiteOpenHelper helper = new ArticlesSQLiteOpenHelper(this);
|
||||
helper.truncateTables(database);
|
||||
setupList(false);
|
||||
super.onOptionsItemSelected(item);
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ package fr.gaulupeau.apps.Poche;
|
||||
import fr.gaulupeau.apps.InThePoche.R;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Authenticator;
|
||||
import java.net.HttpURLConnection;
|
||||
@ -30,6 +31,7 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.thetransactioncompany.jsonrpc2.JSONRPC2ParseException;
|
||||
@ -72,6 +74,8 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_CONTENT;
|
||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARCHIVE;
|
||||
import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Main activity class
|
||||
*/
|
||||
@ -295,6 +299,26 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
|
||||
// }
|
||||
|
||||
|
||||
public String cleanString(String s){
|
||||
|
||||
s = s.replace("é", "é");
|
||||
s = s.replace("è", "è");
|
||||
s = s.replace("ê", "ê");
|
||||
s = s.replace("ë", "ë");
|
||||
s = s.replace("Ã ", "à");
|
||||
s = s.replace("ä", "ä");
|
||||
s = s.replace("â", "â");
|
||||
s = s.replace("ù", "ù");
|
||||
s = s.replace("û", "û");
|
||||
s = s.replace("ü", "ü");
|
||||
s = s.replace("ô", "ô");
|
||||
s = s.replace("ö", "ö");
|
||||
s = s.replace("î", "î");
|
||||
s = s.replace("ï", "ï");
|
||||
s = s.replace("ç", "ç");
|
||||
s = s.replace("&", "&");
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
public void parseRSS(){
|
||||
@ -318,8 +342,13 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
Document doc;
|
||||
doc = db.parse(url.openStream());
|
||||
// doc = db.parse(
|
||||
// new InputSource(
|
||||
// new InputStreamReader(
|
||||
// url.openStream(),
|
||||
// "latin-1")));
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
|
||||
// This is the root node of each section you want to parse
|
||||
NodeList itemLst = doc.getElementsByTagName("item");
|
||||
|
||||
@ -359,8 +388,7 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_SYNC;
|
||||
// exist
|
||||
try
|
||||
{
|
||||
arrays.PodcastTitle[i] = title.item(0)
|
||||
.getChildNodes().item(0).getNodeValue();
|
||||
arrays.PodcastTitle[i] = cleanString(title.item(0).getChildNodes().item(0).getNodeValue());
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
@ -19,6 +19,7 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
@ -50,8 +51,9 @@ public class ReadArticle extends Activity {
|
||||
txtTitre.setText(ac.getString(2));
|
||||
txtContent = (TextView)findViewById(R.id.txtContent);
|
||||
txtContent.setText(ac.getString(3));
|
||||
|
||||
txtAuthor = (TextView)findViewById(R.id.txtAuthor);
|
||||
txtAuthor.setText(ac.getString(5));
|
||||
txtAuthor.setText(ac.getString(0));
|
||||
btnMarkRead = (Button)findViewById(R.id.btnMarkRead);
|
||||
btnMarkRead.setOnClickListener(new OnClickListener() {
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import fr.gaulupeau.apps.InThePoche.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
Loading…
Reference in New Issue
Block a user