Lint fixes

This commit is contained in:
Christian Basler 2016-10-20 05:49:07 +02:00
parent 2b1fb436a9
commit b3dd53a5df
20 changed files with 192 additions and 262 deletions

View File

@ -37,7 +37,7 @@ public abstract class AbstractItemListFragment<T> extends ListFragment implement
* A dummy implementation of the {@link ListSelectionListener} interface that does * A dummy implementation of the {@link ListSelectionListener} interface that does
* nothing. Used only when this fragment is not attached to an activity. * nothing. Used only when this fragment is not attached to an activity.
*/ */
private static ListSelectionListener<Object> dummyCallbacks = plaintext -> { private static final ListSelectionListener<Object> dummyCallbacks = plaintext -> {
}; };
/** /**
* The fragment's current callback object, which is notified of list item * The fragment's current callback object, which is notified of list item

View File

@ -144,11 +144,6 @@ public class AddressListFragment extends AbstractItemListFragment<BitmessageAddr
return view; return view;
} }
@Override
public void startActivityForResult(Intent intent, int requestCode) {
super.startActivityForResult(intent, requestCode);
}
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null && data.hasExtra("SCAN_RESULT")) { if (data != null && data.hasExtra("SCAN_RESULT")) {

View File

@ -20,7 +20,6 @@ import android.app.Activity;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Switch; import android.widget.Switch;
@ -61,17 +60,12 @@ public class CreateAddressActivity extends AppCompatActivity {
} }
final Button cancel = (Button) findViewById(R.id.cancel); final Button cancel = (Button) findViewById(R.id.cancel);
cancel.setOnClickListener(new View.OnClickListener() { cancel.setOnClickListener(v -> {
@Override
public void onClick(View v) {
setResult(Activity.RESULT_CANCELED); setResult(Activity.RESULT_CANCELED);
finish(); finish();
}
}); });
final Button ok = (Button) findViewById(R.id.do_import); final Button ok = (Button) findViewById(R.id.do_import);
ok.setOnClickListener(new View.OnClickListener() { ok.setOnClickListener(v -> {
@Override
public void onClick(View v) {
String addressText = String.valueOf(address.getText()).trim(); String addressText = String.valueOf(address.getText()).trim();
try { try {
BitmessageAddress bmAddress = new BitmessageAddress(addressText); BitmessageAddress bmAddress = new BitmessageAddress(addressText);
@ -89,7 +83,6 @@ public class CreateAddressActivity extends AppCompatActivity {
} catch (RuntimeException e) { } catch (RuntimeException e) {
address.setError(getString(R.string.error_illegal_address)); address.setError(getString(R.string.error_illegal_address));
} }
}
}); });
} }

View File

@ -12,7 +12,7 @@ import com.mikepenz.materialize.MaterializeBuilder;
/** /**
* @author Christian Basler * @author Christian Basler
*/ */
public class DetailActivity extends AppCompatActivity { public abstract class DetailActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {

View File

@ -31,10 +31,10 @@ public class Identicon extends Drawable {
private static final int CENTER_COLUMN = 5; private static final int CENTER_COLUMN = 5;
private final Paint paint; private final Paint paint;
private int color; private final int color;
private int background; private final int background;
private boolean[][] fields; private final boolean[][] fields;
private boolean chan; private final boolean chan;
private final TextPaint textPaint; private final TextPaint textPaint;
public Identicon(BitmessageAddress input) { public Identicon(BitmessageAddress input) {

View File

@ -28,7 +28,6 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.github.angads25.filepicker.controller.DialogSelectionListener;
import com.github.angads25.filepicker.model.DialogConfigs; import com.github.angads25.filepicker.model.DialogConfigs;
import com.github.angads25.filepicker.model.DialogProperties; import com.github.angads25.filepicker.model.DialogProperties;
import com.github.angads25.filepicker.view.FilePickerDialog; import com.github.angads25.filepicker.view.FilePickerDialog;
@ -61,9 +60,7 @@ public class InputWifFragment extends Fragment {
View view = inflater.inflate(R.layout.fragment_import_input, container, false); View view = inflater.inflate(R.layout.fragment_import_input, container, false);
wifData = (TextView) view.findViewById(R.id.wif_input); wifData = (TextView) view.findViewById(R.id.wif_input);
view.findViewById(R.id.next).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.next).setOnClickListener(v -> {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(WIF_DATA, wifData.getText().toString()); bundle.putString(WIF_DATA, wifData.getText().toString());
@ -73,7 +70,6 @@ public class InputWifFragment extends Fragment {
getFragmentManager().beginTransaction() getFragmentManager().beginTransaction()
.replace(R.id.content, fragment) .replace(R.id.content, fragment)
.commit(); .commit();
}
}); });
return view; return view;
} }
@ -93,9 +89,7 @@ public class InputWifFragment extends Fragment {
properties.extensions = null; properties.extensions = null;
FilePickerDialog dialog = new FilePickerDialog(getActivity(), properties); FilePickerDialog dialog = new FilePickerDialog(getActivity(), properties);
dialog.setTitle(getString(R.string.select_file_title)); dialog.setTitle(getString(R.string.select_file_title));
dialog.setDialogSelectionListener(new DialogSelectionListener() { dialog.setDialogSelectionListener(files -> {
@Override
public void onSelectedFilePaths(String[] files) {
if (files.length > 0) { if (files.length > 0) {
try (InputStream in = new FileInputStream(files[0])) { try (InputStream in = new FileInputStream(files[0])) {
ByteArrayOutputStream data = new ByteArrayOutputStream(); ByteArrayOutputStream data = new ByteArrayOutputStream();
@ -114,7 +108,6 @@ public class InputWifFragment extends Fragment {
).show(); ).show();
} }
} }
}
}); });
dialog.show(); dialog.show();
return true; return true;

View File

@ -130,15 +130,12 @@ public class MessageListFragment extends Fragment implements ListHolder {
// Show the dummy content as text in a TextView. // Show the dummy content as text in a TextView.
FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id
.fab_compose_message); .fab_compose_message);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(view -> {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity().getApplicationContext(), Intent intent = new Intent(getActivity().getApplicationContext(),
ComposeMessageActivity.class); ComposeMessageActivity.class);
intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, Singleton.getIdentity intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, Singleton.getIdentity
(getActivity())); (getActivity()));
startActivity(intent); startActivity(intent);
}
}); });
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss // touch guard manager (this class is required to suppress scrolling while swipe-dismiss
@ -173,7 +170,7 @@ public class MessageListFragment extends Fragment implements ListHolder {
} }
@Override @Override
public void onItemViewClicked(View v, boolean pinned) { public void onItemViewClicked(View v) {
int position = recyclerView.getChildAdapterPosition(v); int position = recyclerView.getChildAdapterPosition(v);
adapter.setSelectedPosition(position); adapter.setSelectedPosition(position);
if (position != RecyclerView.NO_POSITION) { if (position != RecyclerView.NO_POSITION) {

View File

@ -46,9 +46,7 @@ public class SettingsFragment
addPreferencesFromResource(R.xml.preferences); addPreferencesFromResource(R.xml.preferences);
Preference about = findPreference("about"); Preference about = findPreference("about");
about.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { about.setOnPreferenceClickListener(preference -> {
@Override
public boolean onPreferenceClick(Preference preference) {
new LibsBuilder() new LibsBuilder()
.withActivityTitle(getActivity().getString(R.string.about)) .withActivityTitle(getActivity().getString(R.string.about))
.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR) .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
@ -57,16 +55,12 @@ public class SettingsFragment
.withAboutDescription(getString(R.string.about_app)) .withAboutDescription(getString(R.string.about_app))
.start(getActivity()); .start(getActivity());
return true; return true;
}
}); });
Preference status = findPreference("status"); Preference status = findPreference("status");
status.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { status.setOnPreferenceClickListener(preference -> {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(getActivity(), StatusActivity.class)); startActivity(new Intent(getActivity(), StatusActivity.class));
return true; return true;
}
}); });
} }

View File

@ -21,7 +21,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
@ -69,20 +68,17 @@ public class AddressSelectorAdapter
static class ViewHolder extends RecyclerView.ViewHolder { static class ViewHolder extends RecyclerView.ViewHolder {
public Selectable<BitmessageAddress> data; public Selectable<BitmessageAddress> data;
public CheckBox checkbox; public final CheckBox checkbox;
public TextView address; public final TextView address;
private ViewHolder(View v) { private ViewHolder(View v) {
super(v); super(v);
checkbox = (CheckBox) v.findViewById(R.id.checkbox); checkbox = (CheckBox) v.findViewById(R.id.checkbox);
address = (TextView) v.findViewById(R.id.address); address = (TextView) v.findViewById(R.id.address);
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { checkbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (data != null) { if (data != null) {
data.selected = isChecked; data.selected = isChecked;
} }
}
}); });
} }
} }

View File

@ -59,8 +59,8 @@ public class SwipeableMessageAdapter
private List<Plaintext> data = Collections.emptyList(); private List<Plaintext> data = Collections.emptyList();
private EventListener eventListener; private EventListener eventListener;
private View.OnClickListener itemViewOnClickListener; private final View.OnClickListener itemViewOnClickListener;
private View.OnClickListener swipeableViewContainerOnClickListener; private final View.OnClickListener swipeableViewContainerOnClickListener;
private Label label; private Label label;
private int selectedPosition; private int selectedPosition;
@ -75,12 +75,12 @@ public class SwipeableMessageAdapter
void onItemArchived(Plaintext item); void onItemArchived(Plaintext item);
void onItemViewClicked(View v, boolean pinned); void onItemViewClicked(View v);
} }
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
static class ViewHolder extends AbstractSwipeableItemViewHolder { static class ViewHolder extends AbstractSwipeableItemViewHolder {
public FrameLayout container; public final FrameLayout container;
public final ImageView avatar; public final ImageView avatar;
public final TextView sender; public final TextView sender;
public final TextView subject; public final TextView subject;
@ -102,18 +102,8 @@ public class SwipeableMessageAdapter
} }
public SwipeableMessageAdapter() { public SwipeableMessageAdapter() {
itemViewOnClickListener = new View.OnClickListener() { itemViewOnClickListener = this::onItemViewClick;
@Override swipeableViewContainerOnClickListener = this::onSwipeableViewContainerClick;
public void onClick(View v) {
onItemViewClick(v);
}
};
swipeableViewContainerOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
onSwipeableViewContainerClick(v);
}
};
// SwipeableItemAdapter requires stable ID, and also // SwipeableItemAdapter requires stable ID, and also
// have to implement the getItemId() method appropriately. // have to implement the getItemId() method appropriately.
@ -127,14 +117,14 @@ public class SwipeableMessageAdapter
private void onItemViewClick(View v) { private void onItemViewClick(View v) {
if (eventListener != null) { if (eventListener != null) {
eventListener.onItemViewClicked(v, true); // pinned eventListener.onItemViewClicked(v);
} }
} }
private void onSwipeableViewContainerClick(View v) { private void onSwipeableViewContainerClick(View v) {
if (eventListener != null) { if (eventListener != null) {
eventListener.onItemViewClicked( eventListener.onItemViewClicked(
RecyclerViewAdapterUtils.getParentViewHolderItemView(v), false); // not pinned RecyclerViewAdapterUtils.getParentViewHolderItemView(v));
} }
} }

View File

@ -19,7 +19,6 @@ package ch.dissem.apps.abit.dialog;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
@ -61,9 +60,7 @@ public class AddIdentityDialogFragment extends AppCompatDialogFragment {
getDialog().setTitle(R.string.add_identity); getDialog().setTitle(R.string.add_identity);
View view = inflater.inflate(R.layout.dialog_add_identity, container, false); View view = inflater.inflate(R.layout.dialog_add_identity, container, false);
final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup); final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup);
view.findViewById(R.id.ok).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.ok).setOnClickListener(v -> {
@Override
public void onClick(View v) {
final Context ctx = getActivity().getBaseContext(); final Context ctx = getActivity().getBaseContext();
switch (radioGroup.getCheckedRadioButtonId()) { switch (radioGroup.getCheckedRadioButtonId()) {
case R.id.create_identity: case R.id.create_identity:
@ -102,15 +99,8 @@ public class AddIdentityDialogFragment extends AppCompatDialogFragment {
return; return;
} }
dismiss(); dismiss();
}
});
view.findViewById(R.id.dismiss)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
}); });
view.findViewById(R.id.dismiss).setOnClickListener(v -> dismiss());
return view; return view;
} }
@ -123,9 +113,7 @@ public class AddIdentityDialogFragment extends AppCompatDialogFragment {
new AlertDialog.Builder(activity) new AlertDialog.Builder(activity)
.setTitle(R.string.add_chan) .setTitle(R.string.add_chan)
.setView(dialogView) .setView(dialogView)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.ok, (dialogInterface, i) -> {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
TextView passphrase = (TextView) dialogView.findViewById(R.id.passphrase); TextView passphrase = (TextView) dialogView.findViewById(R.id.passphrase);
Toast.makeText(ctx, R.string.toast_long_running_operation, Toast.makeText(ctx, R.string.toast_long_running_operation,
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
@ -150,7 +138,6 @@ public class AddIdentityDialogFragment extends AppCompatDialogFragment {
} }
} }
}.execute(passphrase.getText().toString()); }.execute(passphrase.getText().toString());
}
}) })
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.show(); .show();

View File

@ -29,6 +29,7 @@ import ch.dissem.bitmessage.BitmessageContext;
public class WifiReceiver extends BroadcastReceiver { public class WifiReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context ctx, Intent intent) { public void onReceive(Context ctx, Intent intent) {
if ("android.net.conn.CONNECTIVITY_CHANGE".equals(intent.getAction())) {
if (Preferences.isWifiOnly(ctx)) { if (Preferences.isWifiOnly(ctx)) {
BitmessageContext bmc = Singleton.getBitmessageContext(ctx); BitmessageContext bmc = Singleton.getBitmessageContext(ctx);
@ -37,13 +38,14 @@ public class WifiReceiver extends BroadcastReceiver {
} }
} }
} }
}
public static boolean isConnectedToMeteredNetwork(Context ctx) { public static boolean isConnectedToMeteredNetwork(Context ctx) {
NetworkInfo netInfo = getNetworkInfo(ctx); NetworkInfo netInfo = getNetworkInfo(ctx);
if (netInfo == null || !netInfo.isConnectedOrConnecting()) { if (netInfo == null || !netInfo.isConnectedOrConnecting()) {
return false; return false;
} }
switch (netInfo.getType()){ switch (netInfo.getType()) {
case ConnectivityManager.TYPE_ETHERNET: case ConnectivityManager.TYPE_ETHERNET:
case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_WIFI:
return false; return false;

View File

@ -31,7 +31,7 @@ import ch.dissem.apps.abit.R;
public class ErrorNotification extends AbstractNotification { public class ErrorNotification extends AbstractNotification {
public static final int ERROR_NOTIFICATION_ID = 4; public static final int ERROR_NOTIFICATION_ID = 4;
private NotificationCompat.Builder builder; private final NotificationCompat.Builder builder;
public ErrorNotification(Context ctx) { public ErrorNotification(Context ctx) {
super(ctx); super(ctx);

View File

@ -17,14 +17,12 @@
package ch.dissem.apps.abit.pow; package ch.dissem.apps.abit.pow;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import ch.dissem.apps.abit.service.Singleton; import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.apps.abit.synchronization.SyncAdapter; import ch.dissem.apps.abit.synchronization.SyncAdapter;
@ -52,21 +50,16 @@ public class ServerPowEngine implements ProofOfWorkEngine, InternalContext
public ServerPowEngine(Context ctx) { public ServerPowEngine(Context ctx) {
this.ctx = ctx; this.ctx = ctx;
pool = Executors.newCachedThreadPool(new ThreadFactory() { pool = Executors.newCachedThreadPool(r -> {
@Override
public Thread newThread(@NonNull Runnable r) {
Thread thread = Executors.defaultThreadFactory().newThread(r); Thread thread = Executors.defaultThreadFactory().newThread(r);
thread.setPriority(Thread.MIN_PRIORITY); thread.setPriority(Thread.MIN_PRIORITY);
return thread; return thread;
}
}); });
} }
@Override @Override
public void calculateNonce(final byte[] initialHash, final byte[] target, Callback callback) { public void calculateNonce(final byte[] initialHash, final byte[] target, Callback callback) {
pool.execute(new Runnable() { pool.execute(() -> {
@Override
public void run() {
BitmessageAddress identity = Singleton.getIdentity(ctx); BitmessageAddress identity = Singleton.getIdentity(ctx);
if (identity == null) throw new RuntimeException("No Identity for calculating POW"); if (identity == null) throw new RuntimeException("No Identity for calculating POW");
@ -86,7 +79,6 @@ public class ServerPowEngine implements ProofOfWorkEngine, InternalContext
} catch (Exception e) { } catch (Exception e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
} }
}
}); });
} }

View File

@ -169,15 +169,11 @@ public class AndroidAddressRepository implements AddressRepository {
@Override @Override
public void save(BitmessageAddress address) { public void save(BitmessageAddress address) {
try {
if (exists(address)) { if (exists(address)) {
update(address); update(address);
} else { } else {
insert(address); insert(address);
} }
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
} }
private boolean exists(BitmessageAddress address) { private boolean exists(BitmessageAddress address) {
@ -191,7 +187,7 @@ public class AndroidAddressRepository implements AddressRepository {
} }
} }
private void update(BitmessageAddress address) throws IOException { private void update(BitmessageAddress address) {
try { try {
SQLiteDatabase db = sql.getWritableDatabase(); SQLiteDatabase db = sql.getWritableDatabase();
// Create a new map of values, where column names are the keys // Create a new map of values, where column names are the keys
@ -224,7 +220,7 @@ public class AndroidAddressRepository implements AddressRepository {
} }
} }
private void insert(BitmessageAddress address) throws IOException { private void insert(BitmessageAddress address) {
try { try {
SQLiteDatabase db = sql.getWritableDatabase(); SQLiteDatabase db = sql.getWritableDatabase();
// Create a new map of values, where column names are the keys // Create a new map of values, where column names are the keys

View File

@ -275,14 +275,12 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} catch (SQLiteConstraintException e) { } catch (SQLiteConstraintException e) {
LOG.trace(e.getMessage(), e); LOG.trace(e.getMessage(), e);
} catch (IOException e) {
LOG.error(e.getMessage(), e);
} finally { } finally {
db.endTransaction(); db.endTransaction();
} }
} }
private void insert(SQLiteDatabase db, Plaintext message) throws IOException { private void insert(SQLiteDatabase db, Plaintext message) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(COLUMN_IV, message.getInventoryVector() == null ? null : message values.put(COLUMN_IV, message.getInventoryVector() == null ? null : message
.getInventoryVector().getHash()); .getInventoryVector().getHash());
@ -302,7 +300,7 @@ public class AndroidMessageRepository extends AbstractMessageRepository {
message.setId(id); message.setId(id);
} }
private void update(SQLiteDatabase db, Plaintext message) throws IOException { private void update(SQLiteDatabase db, Plaintext message) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(COLUMN_IV, message.getInventoryVector() == null ? null : message values.put(COLUMN_IV, message.getInventoryVector() == null ? null : message
.getInventoryVector().getHash()); .getInventoryVector().getHash());

View File

@ -27,10 +27,10 @@ import ch.dissem.apps.abit.util.Assets;
*/ */
public class SqlHelper extends SQLiteOpenHelper { public class SqlHelper extends SQLiteOpenHelper {
// If you change the database schema, you must increment the database version. // If you change the database schema, you must increment the database version.
public static final int DATABASE_VERSION = 5; private static final int DATABASE_VERSION = 5;
public static final String DATABASE_NAME = "jabit.db"; private static final String DATABASE_NAME = "jabit.db";
protected final Context ctx; private final Context ctx;
public SqlHelper(Context ctx) { public SqlHelper(Context ctx) {
super(ctx, DATABASE_NAME, null, DATABASE_VERSION); super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
@ -65,7 +65,7 @@ public class SqlHelper extends SQLiteOpenHelper {
} }
} }
protected void executeMigration(SQLiteDatabase db, String name) { private void executeMigration(SQLiteDatabase db, String name) {
for (String statement : Assets.readSqlStatements(ctx, "db/migration/" + name + ".sql")) { for (String statement : Assets.readSqlStatements(ctx, "db/migration/" + name + ".sql")) {
db.execSQL(statement); db.execSQL(statement);
} }

View File

@ -37,9 +37,9 @@ import static ch.dissem.apps.abit.notification.ProofOfWorkNotification.ONGOING_N
*/ */
public class ProofOfWorkService extends Service { public class ProofOfWorkService extends Service {
// Object to use as a thread-safe lock // Object to use as a thread-safe lock
private static ProofOfWorkEngine engine = new MultiThreadedPOWEngine(); private static final ProofOfWorkEngine engine = new MultiThreadedPOWEngine();
private static boolean calculating;
private static final Queue<PowItem> queue = new LinkedList<>(); private static final Queue<PowItem> queue = new LinkedList<>();
private static boolean calculating;
private ProofOfWorkNotification notification; private ProofOfWorkNotification notification;
@Override @Override

View File

@ -38,14 +38,14 @@ public class ServicePowEngine implements ProofOfWorkEngine {
private final Context ctx; private final Context ctx;
private static final Object lock = new Object(); private static final Object lock = new Object();
private Queue<PowItem> queue = new LinkedList<>(); private final Queue<PowItem> queue = new LinkedList<>();
private PowBinder service; private PowBinder service;
public ServicePowEngine(Context ctx) { public ServicePowEngine(Context ctx) {
this.ctx = ctx; this.ctx = ctx;
} }
private ServiceConnection connection = new ServiceConnection() { private final ServiceConnection connection = new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
synchronized (lock) { synchronized (lock) {

View File

@ -20,9 +20,6 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;