Fix Codacy Issues + remove unused patch

This commit is contained in:
Adam Jones 2017-03-21 20:31:10 +00:00
parent 2e5fdf44ed
commit ea43e1a796
8 changed files with 18 additions and 46 deletions

View file

@ -85,8 +85,7 @@ public class CommonsApplication extends Application {
schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
params.setParameter(CoreProtocolPNames.USER_AGENT, "Commons/" + APPLICATION_VERSION + " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE);
DefaultHttpClient httpclient = new DefaultHttpClient(cm, params);
return httpclient;
return new DefaultHttpClient(cm, params);
}
public static MWApi createMWApi() {
@ -95,8 +94,8 @@ public class CommonsApplication extends Application {
@Override
public void onCreate() {
ACRA.init(this);
super.onCreate();
ACRA.init(this);
// Fire progress callbacks for every 3% of uploaded content
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
api = createMWApi();
@ -130,15 +129,10 @@ public class CommonsApplication extends Application {
imageCache = new LruCache<String, Bitmap>(cacheSize) {
@Override
protected int sizeOf(String key, Bitmap bitmap) {
// bitmap.getByteCount() not available on older androids
int bitmapSize;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
bitmapSize = bitmap.getRowBytes() * bitmap.getHeight();
} else {
bitmapSize = bitmap.getByteCount();
}
// The cache size will be measured in kilobytes rather than
// number of items.
bitmapSize = bitmap.getByteCount();
// The cache size will be measured in kilobytes rather than number of items.
return bitmapSize / 1024;
}
};

View file

@ -29,8 +29,8 @@ public abstract class HandlerService<T> extends Service {
@Override
public void onDestroy() {
super.onDestroy();
threadLooper.quit();
super.onDestroy();
}
public class HandlerServiceLocalBinder extends Binder {

View file

@ -225,17 +225,15 @@ public class MediaDataExtractor {
NodeList childNodes = node.getChildNodes();
for (int j = 0, childNodesLength = childNodes.getLength(); j < childNodesLength; j++) {
Node childNode = childNodes.item(j);
if (childNode.getNodeName().equals("name")) {
if (comparator.match(childNode)) {
// yay! Now fetch the value node.
for (int k = j + 1; k < childNodesLength; k++) {
Node siblingNode = childNodes.item(k);
if (siblingNode.getNodeName().equals("value")) {
return siblingNode;
}
if (childNode.getNodeName().equals("name") && comparator.match(childNode)) {
// yay! Now fetch the value node.
for (int k = j + 1; k < childNodesLength; k++) {
Node siblingNode = childNodes.item(k);
if (siblingNode.getNodeName().equals("value")) {
return siblingNode;
}
throw new IOException("No value node found for matched template parameter.");
}
throw new IOException("No value node found for matched template parameter.");
}
}
}

View file

@ -12,6 +12,7 @@ public class ContributionsSyncService extends Service {
@Override
public void onCreate() {
super.onCreate();
synchronized (sSyncAdapterLock) {
if (sSyncAdapter == null) {
sSyncAdapter = new ContributionsSyncAdapter(getApplicationContext(), true);

View file

@ -12,6 +12,7 @@ public class ModificationsSyncService extends Service {
@Override
public void onCreate() {
super.onCreate();
synchronized (sSyncAdapterLock) {
if (sSyncAdapter == null) {
sSyncAdapter = new ModificationsSyncAdapter(getApplicationContext(), true);

View file

@ -109,10 +109,8 @@ public class MultipleShareActivity
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == 1) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
multipleUploadBegins();
}
if (requestCode == 1 && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
multipleUploadBegins();
}
}