Search in sources :

Example 6 with ChatAssets

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));
    }
}
Also used : ChatAssets(br.ufrj.caronae.models.ChatAssets) ActionBar(android.support.v7.app.ActionBar) Ride(br.ufrj.caronae.models.Ride)

Example 7 with ChatAssets

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());
}
Also used : Context(android.content.Context) ChatAssets(br.ufrj.caronae.models.ChatAssets) NotificationManager(android.app.NotificationManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Uri(android.net.Uri) MainAct(br.ufrj.caronae.acts.MainAct) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) ChatAct(br.ufrj.caronae.acts.ChatAct)

Aggregations

ChatAssets (br.ufrj.caronae.models.ChatAssets)7 Intent (android.content.Intent)4 Ride (br.ufrj.caronae.models.Ride)3 ProgressDialog (android.app.ProgressDialog)2 Context (android.content.Context)2 ActionBar (android.support.v7.app.ActionBar)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 RoundedTransformation (br.ufrj.caronae.RoundedTransformation)2 ChatAct (br.ufrj.caronae.acts.ChatAct)2 RideForJson (br.ufrj.caronae.models.modelsforjson.RideForJson)2 Gson (com.google.gson.Gson)2 List (java.util.List)2 Call (retrofit2.Call)2 Callback (retrofit2.Callback)2 Response (retrofit2.Response)2 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1