use of br.ufrj.caronae.models.ChatAssets in project caronae-android by caronae.
the class ChatAct method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
ButterKnife.bind(this);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
App.getBus().register(this);
SharedPref.setChatActIsForeground(true);
final ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
}
rideId = getIntent().getExtras().getString(RIDE_ID_BUNDLE_KEY);
// ChatAssets chatAssets;
List<ChatAssets> l = ChatAssets.find(ChatAssets.class, "ride_id = ?", rideId);
if (l == null || l.isEmpty()) {
List<Ride> ride = Ride.find(Ride.class, "db_id = ?", rideId);
if (ride == null || ride.isEmpty()) {
getRideFromServer(this);
}
} else {
configureActivityWithChatAssets(l.get(0));
}
}
use of br.ufrj.caronae.models.ChatAssets in project caronae-android by caronae.
the class MyFirebaseMessagingService method createNotification.
private void createNotification(String msgType, String senderName, String message, String rideId) {
String title;
Intent resultIntent;
if (msgType.equals("chat")) {
title = "Nova mensagem";
List<ChatAssets> l = ChatAssets.find(ChatAssets.class, "ride_id = ?", rideId);
if (l != null && !l.isEmpty()) {
resultIntent = new Intent(this, ChatAct.class);
resultIntent.putExtra("rideId", rideId);
} else {
resultIntent = new Intent(this, MainAct.class);
}
} else {
title = "Aviso de carona";
resultIntent = new Intent(this, MainAct.class);
}
resultIntent.putExtra("msgType", msgType);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Context context = App.getInst();
Uri alarmSound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.beep);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_stat_name).setContentTitle(title).setContentIntent(resultPendingIntent).setSound(alarmSound).setAutoCancel(true).setContentText(message);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mBuilder.build());
}
Aggregations