mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Remove GooglePlay references
Add some tests to avoid nullPointerException
This commit is contained in:
parent
c4df2a7b00
commit
9c7945406f
2 changed files with 15 additions and 48 deletions
|
@ -29,9 +29,9 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.appindexing.Action;
|
||||
import com.google.android.gms.appindexing.AppIndex;
|
||||
import com.google.android.gms.common.api.GoogleApiClient;
|
||||
//import com.google.android.gms.appindexing.Action;
|
||||
//import com.google.android.gms.appindexing.AppIndex;
|
||||
//import com.google.android.gms.common.api.GoogleApiClient;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
@ -65,54 +65,20 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
final static Boolean DBDEMO = true;
|
||||
final static Random random = new Random();
|
||||
|
||||
/**
|
||||
* ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
* See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
*/
|
||||
private GoogleApiClient client;
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
Log.d(TAG, "Remove old notification");
|
||||
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
nm.cancelAll();
|
||||
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
client.connect();
|
||||
Action viewAction = Action.newAction(
|
||||
Action.TYPE_VIEW, // TODO: choose an action type.
|
||||
"MedicamentList Page", // TODO: Define a title for the content shown.
|
||||
// TODO: If you have web page content that matches this app activity's content,
|
||||
// make sure this auto-generated web page URL is correct.
|
||||
// Otherwise, set the URL to null.
|
||||
Uri.parse("http://host/path"),
|
||||
// TODO: Make sure this auto-generated app URL is correct.
|
||||
Uri.parse("android-app://net.foucry.pilldroid/http/host/path")
|
||||
);
|
||||
AppIndex.AppIndexApi.start(client, viewAction);
|
||||
if (nm != null) {
|
||||
nm.cancelAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
Action viewAction = Action.newAction(
|
||||
Action.TYPE_VIEW, // TODO: choose an action type.
|
||||
"MedicamentList Page", // TODO: Define a title for the content shown.
|
||||
// TODO: If you have web page content that matches this app activity's content,
|
||||
// make sure this auto-generated web page URL is correct.
|
||||
// Otherwise, set the URL to null.
|
||||
Uri.parse("http://host/path"),
|
||||
// TODO: Make sure this auto-generated app URL is correct.
|
||||
Uri.parse("android-app://net.foucry.pilldroid/http/host/path")
|
||||
);
|
||||
AppIndex.AppIndexApi.end(client, viewAction);
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
private static final String TAG = MedicamentListActivity.class.getName();
|
||||
|
@ -219,9 +185,6 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
// activity should be in two-pane mode.
|
||||
mTwoPane = true;
|
||||
}
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
|
||||
}
|
||||
|
||||
|
||||
|
@ -375,7 +338,9 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
|
||||
long futureInMillis = SystemClock.elapsedRealtime() + 30000;
|
||||
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, futureInMillis, pendingIntent);
|
||||
if (alarmManager != null) {
|
||||
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, futureInMillis, pendingIntent);
|
||||
}
|
||||
}
|
||||
|
||||
private Notification getNotification(String content) {
|
||||
|
|
|
@ -8,8 +8,6 @@ import android.content.Intent;
|
|||
import android.os.Vibrator;
|
||||
import android.util.Log;
|
||||
|
||||
import static android.support.v7.widget.StaggeredGridLayoutManager.TAG;
|
||||
|
||||
/**
|
||||
* Created by jfoucry on 6/23/16.
|
||||
*/
|
||||
|
@ -26,9 +24,13 @@ public class NotificationPublisher extends BroadcastReceiver {
|
|||
|
||||
Notification notification = intent.getParcelableExtra(NOTIFICATION);
|
||||
int id = intent.getIntExtra(NOTIFICATION_ID,0);
|
||||
notificationManager.notify(id, notification);
|
||||
if (notificationManager != null) {
|
||||
notificationManager.notify(id, notification);
|
||||
}
|
||||
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vibrator.vibrate(400);
|
||||
if (vibrator != null) {
|
||||
vibrator.vibrate(400);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue