Исправление ошибок загрузки постов

This commit is contained in:
Victor 2013-08-29 20:36:24 +03:00
parent f91ddb6a83
commit 2b61d5e990
2 changed files with 12 additions and 11 deletions

View File

@ -16,7 +16,7 @@ import android.widget.ProgressBar;
*/
public class ForumPostLoader extends AsyncTask<String, Void, List<ForumPost>> {
private static final String SEPARATOR = "|$|";
private static final String SEPARATOR = "\\|\\$\\|";
private Context context;
private FinishLoadingListener listener;
@ -39,12 +39,12 @@ public class ForumPostLoader extends AsyncTask<String, Void, List<ForumPost>> {
for (int i = 0; i < size; i++) {
ForumPost post = new ForumPost();
String titleAuthor = data[i];
String titleAuthor = data[i * 3];
int breakCharIndex = titleAuthor.indexOf('\n');
post.setForumTitle(titleAuthor.substring(0, breakCharIndex));
post.setAuthor(titleAuthor.substring(breakCharIndex + 1));
post.setDate(data[i + 1]);
post.setMessage(data[i + 2]);
post.setDate(data[i * 3 + 1]);
post.setMessage(data[i * 3 + 2]);
postItems.add(post);
}

View File

@ -1,6 +1,5 @@
package com.annimon.client.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
@ -14,16 +13,18 @@ public class InetUtils {
public static synchronized String getTextFromUri(String urlsite) {
StringBuilder text = new StringBuilder();
BufferedReader reader = null;
InputStreamReader reader = null;
try {
final URL url = new URL(urlsite);
reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = reader.readLine()) != null) {
text.append(line);
reader = new InputStreamReader(url.openStream());
final int bufferSize = 2048;
char[] buffer = new char[bufferSize];
int readSize;
while ( (readSize = reader.read(buffer, 0, bufferSize)) != -1 ) {
text.append(buffer, 0, readSize);
}
} catch (IOException ex) {
ex.printStackTrace();
ExceptionHandler.log(ex);
} finally {
if (reader != null) {
try {