Use NotificationChannel and prevent crash in API 26 (#1835)

This commit is contained in:
Yusuke Matsubara 2018-08-19 19:19:00 +09:00 committed by neslihanturan
parent 7a43c59c80
commit 6842420aeb
4 changed files with 44 additions and 16 deletions

View file

@ -14,6 +14,7 @@ import java.util.Locale;
import javax.inject.Inject;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.auth.SessionManager;
@ -44,14 +45,17 @@ public class DeleteTask extends AsyncTask<Void, Integer, Boolean> {
}
@Override
protected void onPreExecute(){
protected void onPreExecute() {
ApplicationlessInjection
.getInstance(context.getApplicationContext())
.getCommonsApplicationComponent()
.inject(this);
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationBuilder = new NotificationCompat.Builder(context);
notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationBuilder = new NotificationCompat.Builder(
context,
CommonsApplication.NOTIFICATION_CHANNEL_ID_ALL);
Toast toast = new Toast(context);
toast.setGravity(Gravity.CENTER,0,0);
toast = Toast.makeText(context,"Trying to nominate "+media.getDisplayTitle()+ " for deletion",Toast.LENGTH_SHORT);