mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-13 00:51:35 +01:00
Use more modern method (#40)
This commit is contained in:
parent
e7d8436a5e
commit
6ee7781767
1 changed files with 20 additions and 19 deletions
|
@ -27,24 +27,24 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.room.Room;
|
import androidx.room.Room;
|
||||||
|
|
||||||
|
import com.google.android.material.appbar.MaterialToolbar;
|
||||||
|
import com.google.android.material.button.MaterialButton;
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.google.android.material.imageview.ShapeableImageView;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.google.android.material.textview.MaterialTextView;
|
||||||
import com.google.zxing.client.android.BuildConfig;
|
import com.google.zxing.client.android.BuildConfig;
|
||||||
import com.google.zxing.client.android.Intents;
|
import com.google.zxing.client.android.Intents;
|
||||||
import com.journeyapps.barcodescanner.ScanOptions;
|
import com.journeyapps.barcodescanner.ScanOptions;
|
||||||
|
@ -177,7 +177,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
// Set view content
|
// Set view content
|
||||||
setContentView(R.layout.drug_list_activity);
|
setContentView(R.layout.drug_list_activity);
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
MaterialToolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
|
||||||
if (toolbar != null) {
|
if (toolbar != null) {
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
@ -346,11 +346,11 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
dialog.setCanceledOnTouchOutside(true);
|
dialog.setCanceledOnTouchOutside(true);
|
||||||
dialog.setContentView(R.layout.input_dialog);
|
dialog.setContentView(R.layout.input_dialog);
|
||||||
|
|
||||||
Button ok = dialog.findViewById(R.id.agreed);
|
MaterialButton ok = dialog.findViewById(R.id.agreed);
|
||||||
Button cancel = dialog.findViewById(R.id.notagreed);
|
MaterialButton cancel = dialog.findViewById(R.id.notagreed);
|
||||||
ok.setEnabled(false);
|
ok.setEnabled(false);
|
||||||
ok.setBackground(ContextCompat.getDrawable(this, R.drawable.rounded_btn_disabled));
|
ok.setBackground(getDrawable(R.drawable.rounded_btn_disabled));
|
||||||
//TextView title = dialog.findViewById(R.id.title);
|
//MaterialTextView title = dialog.findViewById(R.id.title);
|
||||||
final EditText editText= dialog.findViewById(R.id.editcip13);
|
final EditText editText= dialog.findViewById(R.id.editcip13);
|
||||||
String cip13 = String.valueOf(editText.getText());
|
String cip13 = String.valueOf(editText.getText());
|
||||||
|
|
||||||
|
@ -404,12 +404,12 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
dlg.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
dlg.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
||||||
dlg.setContentView(R.layout.custom_dialog_layout_one_button);
|
dlg.setContentView(R.layout.custom_dialog_layout_one_button);
|
||||||
dlg.setCancelable(false);
|
dlg.setCancelable(false);
|
||||||
TextView msg = dlg.findViewById(R.id.msg);
|
MaterialTextView msg = dlg.findViewById(R.id.msg);
|
||||||
String msgString;
|
String msgString;
|
||||||
TextView cpl = dlg.findViewById(R.id.cpl);
|
MaterialTextView cpl = dlg.findViewById(R.id.cpl);
|
||||||
String cplString;
|
String cplString;
|
||||||
ImageView icon = dlg.findViewById(R.id.image);
|
ShapeableImageView icon = dlg.findViewById(R.id.image);
|
||||||
Button btn = dlg.findViewById(R.id.txtClose);
|
MaterialButton btn = dlg.findViewById(R.id.txtClose);
|
||||||
dlg.show();
|
dlg.show();
|
||||||
|
|
||||||
if (aMedicine != null) {
|
if (aMedicine != null) {
|
||||||
|
@ -444,7 +444,7 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
* Tell user that the barre code cannot be interpreted
|
* Tell user that the barre code cannot be interpreted
|
||||||
*/
|
*/
|
||||||
private void scanNotOK() {
|
private void scanNotOK() {
|
||||||
AlertDialog.Builder dlg = new AlertDialog.Builder(this);
|
MaterialAlertDialogBuilder dlg = new MaterialAlertDialogBuilder(this);
|
||||||
dlg.setTitle(getString(R.string.app_name));
|
dlg.setTitle(getString(R.string.app_name));
|
||||||
|
|
||||||
dlg.setMessage(R.string.notInterpreted);
|
dlg.setMessage(R.string.notInterpreted);
|
||||||
|
@ -515,7 +515,8 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
Snackbar.LENGTH_LONG).setAction(R.string.Undo, v -> {
|
Snackbar.LENGTH_LONG).setAction(R.string.Undo, v -> {
|
||||||
prescriptionList.add(position, prescription);
|
prescriptionList.add(position, prescription);
|
||||||
mAdapter.notifyItemInserted(position);
|
mAdapter.notifyItemInserted(position);
|
||||||
}).show();
|
}).setActionTextColor(getResources().getColor(R.color.bg_screen1))
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -683,9 +684,9 @@ public class DrugListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
class ViewHolder extends RecyclerView.ViewHolder {
|
class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
final View mView;
|
final View mView;
|
||||||
final TextView mContentView;
|
final MaterialTextView mContentView;
|
||||||
final TextView mEndOfStock;
|
final MaterialTextView mEndOfStock;
|
||||||
final ImageView mIconView;
|
final ShapeableImageView mIconView;
|
||||||
public Prescription mItem;
|
public Prescription mItem;
|
||||||
|
|
||||||
ViewHolder(View view) {
|
ViewHolder(View view) {
|
||||||
|
|
Loading…
Reference in a new issue