hack flavor image support for schemaless urls UIL refuses to load
implement asking for feed update for API >= 9 on refresh
This commit is contained in:
parent
74615af614
commit
8e8bbf70aa
@ -1,10 +1,5 @@
|
|||||||
package org.fox.ttrss;
|
package org.fox.ttrss;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
@ -22,7 +17,6 @@ import org.fox.ttrss.util.TypefaceCache;
|
|||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -30,13 +24,9 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources.Theme;
|
import android.content.res.Resources.Theme;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.http.HttpResponseCache;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@ -52,8 +42,6 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.webkit.WebSettings;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.AbsListView.OnScrollListener;
|
import android.widget.AbsListView.OnScrollListener;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@ -312,7 +300,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
m_swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
m_swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
refresh(false);
|
refresh(false, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -416,8 +404,12 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "serial" })
|
|
||||||
public void refresh(boolean append) {
|
public void refresh(boolean append) {
|
||||||
|
refresh(append, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "serial" })
|
||||||
|
public void refresh(boolean append, boolean userInitiated) {
|
||||||
if (m_activity != null && m_feed != null) {
|
if (m_activity != null && m_feed != null) {
|
||||||
m_refreshInProgress = true;
|
m_refreshInProgress = true;
|
||||||
|
|
||||||
@ -523,6 +515,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
final int fskip = skip;
|
final int fskip = skip;
|
||||||
|
|
||||||
|
final boolean allowForceUpdate = m_activity.getApiLevel() >= 9 &&
|
||||||
|
!m_feed.is_cat && m_feed.id > 0 && !append && userInitiated &&
|
||||||
|
skip == 0;
|
||||||
|
|
||||||
|
Log.d(TAG, "allowForceUpdate=" + allowForceUpdate + " userInitiated=" + userInitiated);
|
||||||
|
|
||||||
|
|
||||||
req.setOffset(skip);
|
req.setOffset(skip);
|
||||||
|
|
||||||
HashMap<String,String> map = new HashMap<String,String>() {
|
HashMap<String,String> map = new HashMap<String,String>() {
|
||||||
@ -540,12 +539,17 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
put("order_by", m_prefs.getBoolean("oldest_first", false) ? "date_reverse" : "");
|
put("order_by", m_prefs.getBoolean("oldest_first", false) ? "date_reverse" : "");
|
||||||
|
|
||||||
if (isCat) put("is_cat", "true");
|
if (isCat) put("is_cat", "true");
|
||||||
|
|
||||||
|
if (allowForceUpdate) {
|
||||||
|
put("force_update", "true");
|
||||||
|
}
|
||||||
|
|
||||||
if (m_searchQuery != null && m_searchQuery.length() != 0) {
|
if (m_searchQuery != null && m_searchQuery.length() != 0) {
|
||||||
put("search", m_searchQuery);
|
put("search", m_searchQuery);
|
||||||
put("search_mode", "");
|
put("search_mode", "");
|
||||||
put("match_on", "both");
|
put("match_on", "both");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -824,56 +828,53 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
Element img = doc.select("img").first();
|
Element img = doc.select("img").first();
|
||||||
|
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
URL imgUri;
|
String imgSrc = img.attr("src");
|
||||||
try {
|
|
||||||
imgUri = new URL(img.attr("src"));
|
// retarded schema-less urls
|
||||||
|
if (imgSrc.indexOf("//") == 0)
|
||||||
flavorImage.setTag(imgUri);
|
imgSrc = "http:" + imgSrc;
|
||||||
|
|
||||||
DisplayImageOptions options = new DisplayImageOptions.Builder().
|
flavorImage.setTag(imgSrc);
|
||||||
cacheInMemory(true).
|
|
||||||
cacheOnDisk(true).
|
DisplayImageOptions options = new DisplayImageOptions.Builder().
|
||||||
build();
|
cacheInMemory(true).
|
||||||
|
cacheOnDisk(true).
|
||||||
ImageLoader.getInstance().displayImage(imgUri.toString(), flavorImage, options, new ImageLoadingListener() {
|
build();
|
||||||
|
|
||||||
|
ImageLoader.getInstance().displayImage(imgSrc, flavorImage, options, new ImageLoadingListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadingCancelled(String arg0,
|
public void onLoadingCancelled(String arg0,
|
||||||
View arg1) {
|
View arg1) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadingComplete(String arg0,
|
|
||||||
View arg1, Bitmap arg2) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
flavorImage.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadingFailed(String arg0,
|
|
||||||
View arg1, FailReason arg2) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadingStarted(String arg0,
|
|
||||||
View arg1) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
}
|
||||||
|
|
||||||
//new DownloadFlavorImagesTask().execute(flavorImage);
|
|
||||||
|
|
||||||
} catch (MalformedURLException e) {
|
@Override
|
||||||
// TODO Auto-generated catch block
|
public void onLoadingComplete(String arg0,
|
||||||
e.printStackTrace();
|
View arg1, Bitmap arg2) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
flavorImage.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadingFailed(String arg0,
|
||||||
|
View arg1, FailReason arg2) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadingStarted(String arg0,
|
||||||
|
View arg1) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
//new DownloadFlavorImagesTask().execute(flavorImage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
case R.id.update_headlines:
|
case R.id.update_headlines:
|
||||||
if (hf != null) {
|
if (hf != null) {
|
||||||
//m_pullToRefreshAttacher.setRefreshing(true);
|
//m_pullToRefreshAttacher.setRefreshing(true);
|
||||||
hf.refresh(false);
|
hf.refresh(false, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user