mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-14 01:21:35 +01:00
Remove unused method;
This commit is contained in:
parent
d7b193471e
commit
d6a30a54f0
1 changed files with 33 additions and 51 deletions
|
@ -1,22 +1,11 @@
|
||||||
package net.foucry.pilldroid;
|
package net.foucry.pilldroid;
|
||||||
|
|
||||||
import android.app.AlarmManager;
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.job.JobInfo;
|
|
||||||
import android.app.job.JobScheduler;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.icu.util.Calendar;
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.core.app.NotificationCompat;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -47,14 +36,9 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.google.zxing.client.android.Intents;
|
|
||||||
import com.google.zxing.integration.android.IntentIntegrator;
|
|
||||||
import com.google.zxing.integration.android.IntentResult;
|
|
||||||
|
|
||||||
import static net.foucry.pilldroid.NotificationPublisher.NOTIFICATION_ID;
|
|
||||||
import static net.foucry.pilldroid.UtilDate.date2String;
|
import static net.foucry.pilldroid.UtilDate.date2String;
|
||||||
import static net.foucry.pilldroid.Utils.intRandomExclusive;
|
import static net.foucry.pilldroid.Utils.intRandomExclusive;
|
||||||
|
import net.foucry.pilldroid.PillDroidJobService;
|
||||||
/**
|
/**
|
||||||
* An activity representing a list of Medicaments. This activity
|
* An activity representing a list of Medicaments. This activity
|
||||||
* has different presentations for handset and tablet-size devices. On
|
* has different presentations for handset and tablet-size devices. On
|
||||||
|
@ -64,7 +48,6 @@ import static net.foucry.pilldroid.Utils.intRandomExclusive;
|
||||||
* item details side-by-side using two vertical panes.
|
* item details side-by-side using two vertical panes.
|
||||||
*/
|
*/
|
||||||
public class MedicamentListActivity extends AppCompatActivity {
|
public class MedicamentListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
|
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
|
||||||
* device.
|
* device.
|
||||||
|
@ -101,12 +84,17 @@ public class MedicamentListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private SimpleItemRecyclerViewAdapter mAdapter;
|
private SimpleItemRecyclerViewAdapter mAdapter;
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return medicaments.size();
|
||||||
|
}
|
||||||
|
|
||||||
public Medicament getItem(int position) {
|
public Medicament getItem(int position) {
|
||||||
return medicaments.get(position);
|
return medicaments.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void constructMedsList()
|
public void constructMedsList()
|
||||||
{
|
{
|
||||||
|
Medicament currentMedicament;
|
||||||
dbHelper = new DBHelper(getApplicationContext());
|
dbHelper = new DBHelper(getApplicationContext());
|
||||||
|
|
||||||
if (!(medicaments == null)) {
|
if (!(medicaments == null)) {
|
||||||
|
@ -116,6 +104,19 @@ public class MedicamentListActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
medicaments = dbHelper.getAllDrugs();
|
medicaments = dbHelper.getAllDrugs();
|
||||||
|
|
||||||
|
Collections.sort(medicaments, new Comparator<Medicament>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Medicament lhs, Medicament rhs) {
|
||||||
|
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (int position = 0 ; position < this.getCount() ; position++ ) {
|
||||||
|
currentMedicament = this.getItem(position);
|
||||||
|
currentMedicament.newStock(currentMedicament.getStock());
|
||||||
|
dbHelper.updateDrug(currentMedicament);
|
||||||
|
}
|
||||||
|
|
||||||
View mRecyclerView = findViewById(R.id.medicament_list);
|
View mRecyclerView = findViewById(R.id.medicament_list);
|
||||||
assert mRecyclerView != null;
|
assert mRecyclerView != null;
|
||||||
setupRecyclerView((RecyclerView) mRecyclerView);
|
setupRecyclerView((RecyclerView) mRecyclerView);
|
||||||
|
@ -218,11 +219,8 @@ public class MedicamentListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
scheduleJob();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onResume() {
|
();
|
||||||
super.onResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** scanNow
|
/** scanNow
|
||||||
|
@ -236,9 +234,6 @@ public class MedicamentListActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
|
||||||
Log.d(TAG, "REQUEST_CODE = " + requestCode + " RESULT_CODE = " + resultCode);
|
|
||||||
|
|
||||||
if (requestCode != CUSTOMIZED_REQUEST_CODE && requestCode != IntentIntegrator.REQUEST_CODE) {
|
if (requestCode != CUSTOMIZED_REQUEST_CODE && requestCode != IntentIntegrator.REQUEST_CODE) {
|
||||||
// This is important, otherwise the result will not be passed to the fragment
|
// This is important, otherwise the result will not be passed to the fragment
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -372,27 +367,13 @@ public class MedicamentListActivity extends AppCompatActivity {
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scheduleJob() {
|
private String getAppName() {
|
||||||
Calendar calendar = Calendar.getInstance();
|
PackageManager packageManager = getApplicationContext().getPackageManager();
|
||||||
Date now = calendar.getTime();
|
ApplicationInfo applicationInfo = null;
|
||||||
|
try {
|
||||||
ComponentName componentName = new ComponentName(this, PillDroidJobService.class);
|
applicationInfo = packageManager.getApplicationInfo(this.getPackageName(), 0);
|
||||||
JobInfo info = new JobInfo.Builder(24560, componentName)
|
} catch (final PackageManager.NameNotFoundException ignored) {}
|
||||||
.setPersisted(true)
|
return (String)((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");
|
||||||
.setPeriodic(15 *60 *1000)
|
|
||||||
.build();
|
|
||||||
JobScheduler scheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
|
|
||||||
int resultCode = scheduler.schedule(info);
|
|
||||||
if (resultCode == JobScheduler.RESULT_SUCCESS) {
|
|
||||||
Log.d(TAG, ("Job scheduled " + UtilDate.convertDate(now.getTime()+15 * 60*1000)));
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Job scheduling failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void cancelJob(View v) {
|
|
||||||
JobScheduler scheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
|
|
||||||
scheduler.cancel(24560);
|
|
||||||
Log.d(TAG, "Job cancelled");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -413,7 +394,7 @@ public class MedicamentListActivity extends AppCompatActivity {
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
dbHelper.addDrug(scannedMedoc);
|
dbHelper.addDrug(scannedMedoc);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getApplicationContext(), "already in the database", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "aleready in the database", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +456,8 @@ public class MedicamentListActivity extends AppCompatActivity {
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
Intent intent = new Intent(context, MedicamentDetailActivity.class);
|
Intent intent = new Intent(context, MedicamentDetailActivity.class);
|
||||||
intent.putExtra("medicament", medicamentCourant);
|
intent.putExtra("medicament", medicamentCourant);
|
||||||
startActivityForResult(intent, CUSTOMIZED_REQUEST_CODE);
|
int requestCode =1;
|
||||||
|
startActivityForResult(intent, requestCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -527,4 +509,4 @@ editText.addTextChangeListener( new TextWatcher() {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
*/
|
Loading…
Reference in a new issue