Browse Source

Fixed null pointer exception, fixed threading bug on ICS, upgraded leak canary version

master
Anthony Restaino 9 years ago
parent
commit
984aa133ec
  1. 4
      app/build.gradle
  2. 7
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  3. 15
      app/src/main/java/acr/browser/lightning/async/ImageDownloadTask.java
  4. 2
      app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java
  5. 2
      app/src/main/java/acr/browser/lightning/object/SearchAdapter.java
  6. 6
      app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java

4
app/build.gradle

@ -101,7 +101,7 @@ dependencies { @@ -101,7 +101,7 @@ dependencies {
compile project(':libnetcipher')
// memory leak analysis
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
provided 'javax.annotation:jsr250-api:1.0'
}

7
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -1752,6 +1752,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1752,6 +1752,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
}
mCustomViewCallback = null;
setRequestedOrientation(mOriginalOrientation);
setTabHeight();
}
private class VideoCompletionListener implements MediaPlayer.OnCompletionListener,
@ -1795,8 +1796,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1795,8 +1796,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
Window window = getWindow();
View decor = window.getDecorView();
if (enabled) {
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (immersive) {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
@ -1804,7 +1803,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1804,7 +1803,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
} else {
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);

15
app/src/main/java/acr/browser/lightning/async/ImageDownloadTask.java

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
package acr.browser.lightning.async;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -141,9 +142,19 @@ public class ImageDownloadTask extends AsyncTask<Void, Void, Bitmap> { @@ -141,9 +142,19 @@ public class ImageDownloadTask extends AsyncTask<Void, Void, Bitmap> {
super.onPostExecute(bitmap);
AsyncExecutor.getInstance().notifyThreadFinish();
final Bitmap fav = Utils.padFavicon(bitmap);
ImageView view = mFaviconImage.get();
final ImageView view = mFaviconImage.get();
if (view != null && view.getTag().equals(mWeb.getUrl().hashCode())) {
view.setImageBitmap(fav);
Context context = view.getContext();
if (context instanceof Activity) {
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
view.setImageBitmap(fav);
}
});
} else {
view.setImageBitmap(fav);
}
}
mWeb.setBitmap(fav);
}

2
app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java

@ -100,7 +100,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, @@ -100,7 +100,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
public void onSubscribe(@NonNull Subscriber<BookmarkViewAdapter> subscriber) {
Context context = getContext();
if (context != null) {
mBookmarkAdapter = new BookmarkViewAdapter(getContext(), mBookmarks);
mBookmarkAdapter = new BookmarkViewAdapter(context, mBookmarks);
setBookmarkDataSet(mBookmarkManager.getBookmarksFromFolder(null, true), false);
subscriber.onNext(mBookmarkAdapter);
}

2
app/src/main/java/acr/browser/lightning/object/SearchAdapter.java

@ -417,7 +417,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { @@ -417,7 +417,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
connection.disconnect();
cacheFile.setLastModified(System.currentTimeMillis());
} catch (Exception e) {
e.printStackTrace();
Log.w(TAG, "Problem getting search suggestions", e);
} finally {
Utils.close(in);
Utils.close(fos);

6
app/src/main/java/acr/browser/lightning/view/LightningChromeClient.java

@ -64,8 +64,8 @@ class LightningChromeClient extends WebChromeClient { @@ -64,8 +64,8 @@ class LightningChromeClient extends WebChromeClient {
*
* @param icon the icon to cache
*/
private static void cacheFavicon(final String url, @Nullable final Bitmap icon, @NonNull final Context context) {
if (icon == null) return;
private static void cacheFavicon(@Nullable final String url, @Nullable final Bitmap icon, @NonNull final Context context) {
if (icon == null || url == null) return;
final Uri uri = Uri.parse(url);
if (uri.getHost() == null) {
return;
@ -82,7 +82,7 @@ class LightningChromeClient extends WebChromeClient { @@ -82,7 +82,7 @@ class LightningChromeClient extends WebChromeClient {
mLightningView.getTitleInfo().setTitle(mActivity.getString(R.string.untitled));
}
mUIController.tabChanged(mLightningView);
if (view != null) {
if (view != null && view.getUrl() != null) {
mUIController.updateHistory(title, view.getUrl());
}
}

Loading…
Cancel
Save