Fixed static analysis warnings
* Using strings when characters could be used * Unused imports * String concatenation in a loop
This commit is contained in:
parent
8a6ad81027
commit
2da5c4194c
@ -3,7 +3,6 @@ package acr.browser.lightning.utils;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
|
||||
|
@ -1220,13 +1220,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
|
||||
void saveOpenTabs() {
|
||||
if (mPreferences.getRestoreLostTabsEnabled()) {
|
||||
String s = "";
|
||||
StringBuilder s = new StringBuilder(mWebViewList.size() * 50);
|
||||
for (int n = 0, size = mWebViewList.size(); n < size; n++) {
|
||||
if (!mWebViewList.get(n).getUrl().isEmpty()) {
|
||||
s = s + mWebViewList.get(n).getUrl() + "|$|SEPARATOR|$|";
|
||||
s.append(mWebViewList.get(n).getUrl()).append("|$|SEPARATOR|$|");
|
||||
}
|
||||
}
|
||||
mPreferences.setMemoryUrl(s);
|
||||
mPreferences.setMemoryUrl(s.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ import acr.browser.lightning.utils.Utils;
|
||||
|
||||
public class SearchAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
private final List<HistoryItem> mHistory = new ArrayList<>();
|
||||
private final List<HistoryItem> mBookmarks = new ArrayList<>();
|
||||
private final List<HistoryItem> mSuggestions = new ArrayList<>();
|
||||
private final List<HistoryItem> mFilteredList = new ArrayList<>();
|
||||
private final List<HistoryItem> mAllBookmarks = new ArrayList<>();
|
||||
private final List<HistoryItem> mHistory = new ArrayList<>(5);
|
||||
private final List<HistoryItem> mBookmarks = new ArrayList<>(5);
|
||||
private final List<HistoryItem> mSuggestions = new ArrayList<>(5);
|
||||
private final List<HistoryItem> mFilteredList = new ArrayList<>(5);
|
||||
private final List<HistoryItem> mAllBookmarks = new ArrayList<>(5);
|
||||
private final Object mLock = new Object();
|
||||
private HistoryDatabase mDatabaseHandler;
|
||||
private final Context mContext;
|
||||
|
@ -204,24 +204,24 @@ public class Converter {
|
||||
int lastEncIndex;
|
||||
if (startChar == '\'')
|
||||
// if we have charset='something'
|
||||
lastEncIndex = str.indexOf("'", ++encIndex + clength);
|
||||
lastEncIndex = str.indexOf('\'', ++encIndex + clength);
|
||||
else if (startChar == '\"')
|
||||
// if we have charset="something"
|
||||
lastEncIndex = str.indexOf("\"", ++encIndex + clength);
|
||||
lastEncIndex = str.indexOf('\"', ++encIndex + clength);
|
||||
else {
|
||||
// if we have "text/html; charset=utf-8"
|
||||
int first = str.indexOf("\"", encIndex + clength);
|
||||
int first = str.indexOf('\"', encIndex + clength);
|
||||
if (first < 0)
|
||||
first = Integer.MAX_VALUE;
|
||||
|
||||
// or "text/html; charset=utf-8 "
|
||||
int sec = str.indexOf(" ", encIndex + clength);
|
||||
int sec = str.indexOf(' ', encIndex + clength);
|
||||
if (sec < 0)
|
||||
sec = Integer.MAX_VALUE;
|
||||
lastEncIndex = Math.min(first, sec);
|
||||
|
||||
// or "text/html; charset=utf-8 '
|
||||
int third = str.indexOf("'", encIndex + clength);
|
||||
int third = str.indexOf('\'', encIndex + clength);
|
||||
if (third > 0)
|
||||
lastEncIndex = Math.min(lastEncIndex, third);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import java.net.URL;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
@ -39,6 +40,8 @@ import java.util.zip.InflaterInputStream;
|
||||
*/
|
||||
public class HtmlFetcher {
|
||||
|
||||
private static final Pattern SPACE = Pattern.compile(" ");
|
||||
|
||||
static {
|
||||
SHelper.enableCookieMgmt();
|
||||
SHelper.enableUserAgentOverwrite();
|
||||
@ -50,8 +53,8 @@ public class HtmlFetcher {
|
||||
String line;
|
||||
Set<String> existing = new LinkedHashSet<>();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
int index1 = line.indexOf("\"");
|
||||
int index2 = line.indexOf("\"", index1 + 1);
|
||||
int index1 = line.indexOf('\"');
|
||||
int index2 = line.indexOf('\"', index1 + 1);
|
||||
String url = line.substring(index1 + 1, index2);
|
||||
String domainStr = SHelper.extractDomain(url, true);
|
||||
String counterStr = "";
|
||||
@ -381,7 +384,7 @@ public class HtmlFetcher {
|
||||
newUrl = hConn.getHeaderField("Location");
|
||||
// Note that the max recursion level is 5.
|
||||
if (responseCode / 100 == 3 && newUrl != null && num_redirects < 5) {
|
||||
newUrl = newUrl.replaceAll(" ", "+");
|
||||
newUrl = SPACE.matcher(newUrl).replaceAll("+");
|
||||
// some services use (none-standard) utf8 in their location header
|
||||
if (urlAsString.startsWith("http://bit.ly")
|
||||
|| urlAsString.startsWith("http://is.gd"))
|
||||
|
@ -230,7 +230,7 @@ public class JResult implements Serializable {
|
||||
}
|
||||
|
||||
public void addLink(String url, String text, Integer pos) {
|
||||
Map link = new HashMap();
|
||||
Map<String, String> link = new HashMap<>();
|
||||
link.put("url", url);
|
||||
link.put("text", text);
|
||||
link.put("offset", String.valueOf(pos));
|
||||
|
@ -193,7 +193,7 @@ public class SHelper {
|
||||
url = url.substring("m.".length());
|
||||
}
|
||||
|
||||
int slashIndex = url.indexOf("/");
|
||||
int slashIndex = url.indexOf('/');
|
||||
if (slashIndex > 0)
|
||||
url = url.substring(0, slashIndex);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user