From 835ec518119d6cd1190d13c730b43893ec13da44 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 2 May 2012 08:35:53 +0400 Subject: [PATCH] disable transitioner in offline mode (broken) fix androidhttpclient leaks introduced with previous patch --- .classpath | 1 + src/org/fox/ttrss/ApiRequest.java | 10 ++++++++++ src/org/fox/ttrss/FeedsFragment.java | 9 ++++++++- src/org/fox/ttrss/OfflineActivity.java | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.classpath b/.classpath index b59b51ad..05a903b5 100644 --- a/.classpath +++ b/.classpath @@ -6,5 +6,6 @@ + diff --git a/src/org/fox/ttrss/ApiRequest.java b/src/org/fox/ttrss/ApiRequest.java index c514387c..837aaa0c 100644 --- a/src/org/fox/ttrss/ApiRequest.java +++ b/src/org/fox/ttrss/ApiRequest.java @@ -12,18 +12,24 @@ import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.protocol.ClientContext; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpParams; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.protocol.HttpContext; import android.content.Context; import android.content.SharedPreferences; +import android.net.http.AndroidHttpClient; import android.os.AsyncTask; import android.preference.PreferenceManager; import android.util.Log; @@ -189,6 +195,8 @@ public class ApiRequest extends AsyncTask, Integer, JsonE m_apiStatusCode = resultObj.get("status").getAsInt(); + client.close(); + switch (m_apiStatusCode) { case API_STATUS_OK: return result.getAsJsonObject().get("content"); @@ -209,6 +217,8 @@ public class ApiRequest extends AsyncTask, Integer, JsonE m_lastError = ApiError.API_UNKNOWN; } } + + client.close(); return null; case 401: diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index 459ba077..b8ac66be 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -18,14 +18,19 @@ import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.protocol.ClientContext; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpParams; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.protocol.HttpContext; import android.app.Activity; import android.content.Context; @@ -33,6 +38,7 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.net.http.AndroidHttpClient; import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; @@ -538,10 +544,11 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh fos.close(); is.close(); + client.close(); + } catch (Exception e) { e.printStackTrace(); } - } protected void onPostExecute(Integer result) { diff --git a/src/org/fox/ttrss/OfflineActivity.java b/src/org/fox/ttrss/OfflineActivity.java index a67f87a5..96e82bba 100644 --- a/src/org/fox/ttrss/OfflineActivity.java +++ b/src/org/fox/ttrss/OfflineActivity.java @@ -133,7 +133,7 @@ public class OfflineActivity extends FragmentActivity implements Log.d(TAG, "m_compatMode=" + m_compatMode); if (!m_compatMode) { - if (android.os.Build.VERSION.SDK_INT < 14 || android.os.Build.VERSION.SDK_INT == 15) { + if (android.os.Build.VERSION.SDK_INT < 14 /* || android.os.Build.VERSION.SDK_INT == 15 */) { if (!m_smallScreenMode) { LayoutTransition transitioner = new LayoutTransition(); ((ViewGroup) findViewById(R.id.main)).setLayoutTransition(transitioner);