mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-21 20:19:23 +01:00
Use lambda everywhere (#23)
This commit is contained in:
parent
d11048d679
commit
2f54326206
6 changed files with 66 additions and 101 deletions
|
@ -57,19 +57,16 @@ public class CustomScannerActivity extends Activity implements DecoratedBarcodeV
|
|||
|
||||
//changeMaskColor(null);
|
||||
changeLaserVisibility(true);
|
||||
barcodeScannerView.decodeSingle(new BarcodeCallback() {
|
||||
@Override
|
||||
public void barcodeResult(BarcodeResult result) {
|
||||
Intent scanResult = new Intent();
|
||||
//Bundle scanResultBundle = new Bundle();
|
||||
scanResult.putExtra("Barcode Content", result.getText());
|
||||
scanResult.putExtra("Barcode Format name", result.getBarcodeFormat().name());
|
||||
scanResult.putExtra("returnCode", captureIntentBundle.getInt("returnCode"));
|
||||
scanResult.putExtra("resultCode", 1);
|
||||
CustomScannerActivity.this.setResult(RESULT_OK, scanResult);
|
||||
Log.d(TAG, "scanResult == " + scanResult);
|
||||
finish();
|
||||
}
|
||||
barcodeScannerView.decodeSingle(result -> {
|
||||
Intent scanResult = new Intent();
|
||||
//Bundle scanResultBundle = new Bundle();
|
||||
scanResult.putExtra("Barcode Content", result.getText());
|
||||
scanResult.putExtra("Barcode Format name", result.getBarcodeFormat().name());
|
||||
scanResult.putExtra("returnCode", captureIntentBundle.getInt("returnCode"));
|
||||
scanResult.putExtra("resultCode", 1);
|
||||
CustomScannerActivity.this.setResult(RESULT_OK, scanResult);
|
||||
Log.d(TAG, "scanResult == " + scanResult);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -270,14 +270,11 @@ class DBHelper extends SQLiteOpenHelper {
|
|||
|
||||
Log.d(TAG, "Before sort == " + drugs);
|
||||
|
||||
drugs.sort(new Comparator<Drug>() {
|
||||
@Override
|
||||
public int compare(Drug lhs, Drug rhs) {
|
||||
if (lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()) != 0)
|
||||
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
|
||||
else
|
||||
return (int) (lhs.getStock() - rhs.getStock());
|
||||
}
|
||||
drugs.sort((lhs, rhs) -> {
|
||||
if (lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()) != 0)
|
||||
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
|
||||
else
|
||||
return (int) (lhs.getStock() - rhs.getStock());
|
||||
});
|
||||
Log.d(TAG, "After sort " + drugs);
|
||||
|
||||
|
|
|
@ -47,16 +47,13 @@ public class DrugDetailActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
ImageButton fab = findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.d(TAG, "Click on save icon");
|
||||
fab.setOnClickListener(v -> {
|
||||
Log.d(TAG, "Click on save icon");
|
||||
|
||||
getDrugChanges();
|
||||
setResult(1);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right);
|
||||
}
|
||||
getDrugChanges();
|
||||
setResult(1);
|
||||
finish();
|
||||
overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right);
|
||||
});
|
||||
|
||||
// Show the Up button in the action bar.
|
||||
|
|
|
@ -375,21 +375,16 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
});
|
||||
ok.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
Log.i("EditText Value",editText.getEditableText().toString());
|
||||
MedicinesDAO medicinesDAO = medicines.getMedicinesDAO();
|
||||
Medicine aMedicine = medicinesDAO.getMedicineByCIP13(cip13);
|
||||
askToAddInDB(aMedicine);
|
||||
}
|
||||
ok.setOnClickListener(v -> {
|
||||
dialog.cancel();
|
||||
Log.i("EditText Value",editText.getEditableText().toString());
|
||||
MedicinesDAO medicinesDAO = medicines.getMedicinesDAO();
|
||||
Medicine aMedicine = medicinesDAO.getMedicineByCIP13(cip13);
|
||||
askToAddInDB(aMedicine);
|
||||
});
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
Log.i(TAG, "dismiss dialog");
|
||||
}
|
||||
cancel.setOnClickListener(v -> {
|
||||
dialog.cancel();
|
||||
Log.i(TAG, "dismiss dialog");
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
|
@ -423,27 +418,21 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
cpl.setEnabled(false);
|
||||
}
|
||||
icon.setImageResource(R.drawable.tickmark);
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
dlg.dismiss();
|
||||
finish();
|
||||
addDrugToList(Utils.medicine2prescription(aMedicine));
|
||||
}
|
||||
btn.setOnClickListener(v -> {
|
||||
// TODO Auto-generated method stub
|
||||
dlg.dismiss();
|
||||
finish();
|
||||
addDrugToList(Utils.medicine2prescription(aMedicine));
|
||||
});
|
||||
} else {
|
||||
msgString = getString(R.string.msgNotFound);
|
||||
msg.setText(msgString);
|
||||
cpl.setText("");
|
||||
icon.setImageResource(R.drawable.tickcross);
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
dlg.dismiss();
|
||||
finish();
|
||||
}
|
||||
btn.setOnClickListener(v -> {
|
||||
// TODO Auto-generated method stub
|
||||
dlg.dismiss();
|
||||
finish();
|
||||
});
|
||||
}
|
||||
dlg.show();
|
||||
|
@ -521,13 +510,10 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
Snackbar.make(recyclerView, prescription.getName(),
|
||||
Snackbar.LENGTH_LONG).setAction(R.string.Undo, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
prescriptionList.add(position, prescription);
|
||||
mAdapter.notifyItemInserted(position);
|
||||
}
|
||||
}).show();
|
||||
Snackbar.LENGTH_LONG).setAction(R.string.Undo, v -> {
|
||||
prescriptionList.add(position, prescription);
|
||||
mAdapter.notifyItemInserted(position);
|
||||
}).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -654,17 +640,14 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
holder.mView.setBackgroundResource(R.drawable.gradient_bg);
|
||||
holder.mIconView.setImageResource(R.drawable.ic_suspended_pill);
|
||||
|
||||
holder.mView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Prescription aPrescription = mValues.get(position);
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, DrugDetailActivity.class);
|
||||
intent.putExtra("prescription", aPrescription);
|
||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
||||
holder.mView.setOnClickListener(v -> {
|
||||
Prescription aPrescription = mValues.get(position);
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, DrugDetailActivity.class);
|
||||
intent.putExtra("prescription", aPrescription);
|
||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
int remainingStock = (int) Math.floor(mValues.get(position).getStock() / mValues.get(position).getTake());
|
||||
|
@ -680,16 +663,13 @@ public class DrugListActivity extends AppCompatActivity {
|
|||
holder.mIconView.setImageResource(R.drawable.ok_stock_vect);
|
||||
}
|
||||
|
||||
holder.mView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Prescription prescription = mValues.get(position);
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, DrugDetailActivity.class);
|
||||
intent.putExtra("prescription", prescription);
|
||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
||||
}
|
||||
holder.mView.setOnClickListener(v -> {
|
||||
Prescription prescription = mValues.get(position);
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, DrugDetailActivity.class);
|
||||
intent.putExtra("prescription", prescription);
|
||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
||||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,14 +49,11 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static void sortPrescriptionList(List<Prescription> prescriptionList) {
|
||||
prescriptionList.sort(new Comparator<>() {
|
||||
@Override
|
||||
public int compare(Prescription lhs, Prescription rhs) {
|
||||
if (lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()) != 0)
|
||||
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
|
||||
else
|
||||
return (int) (lhs.getStock() - rhs.getStock());
|
||||
}
|
||||
prescriptionList.sort((lhs, rhs) -> {
|
||||
if (lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock()) != 0)
|
||||
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
|
||||
else
|
||||
return (int) (lhs.getStock() - rhs.getStock());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -156,13 +156,10 @@ public class WelcomeActivity extends AppCompatActivity {
|
|||
}
|
||||
//icon.setImageResource(R.drawable.pilldroid_icon);
|
||||
btn.setText(R.string.Yes);
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
dlg.dismiss();
|
||||
finish();
|
||||
}
|
||||
btn.setOnClickListener(v -> {
|
||||
// TODO Auto-generated method stub
|
||||
dlg.dismiss();
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue