use of com.manan.dev.ec2018app.Models.NotificationModel in project EC2018App by Manan-YMCA.
the class MyNotificationsActivity method attachDatabaseListener.
private void attachDatabaseListener() {
if (mChildEventListener == null) {
mChildEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
NotificationModel nm = dataSnapshot.getValue(NotificationModel.class);
updateList(nm);
progress.dismiss();
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
try {
NotificationModel nm = dataSnapshot.getValue(NotificationModel.class);
updateList(nm);
progress.dismiss();
} catch (Exception e) {
e.printStackTrace();
progress.dismiss();
}
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
NotificationModel nm = dataSnapshot.getValue(NotificationModel.class);
allNotificationsArrayList.remove(nm);
progress.dismiss();
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
progress.dismiss();
}
};
mDatabaseReference.addChildEventListener(mChildEventListener);
}
}
use of com.manan.dev.ec2018app.Models.NotificationModel in project EC2018App by Manan-YMCA.
the class MyNotificationsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
NotificationModel nm = notificationModelArrayList.get(position);
holder.notificationHeadingTextView.setText(nm.getTextHeading());
holder.notificationDescriptionTextView.setText(nm.getText());
holder.logoImageView.setTag(1);
holder.notifyCardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// }
if (holder.logoImageView.getTag().equals(1)) {
holder.logoImageView.setImageResource(R.drawable.logo_black);
holder.logoImageView.setTag(2);
} else {
holder.logoImageView.setImageResource(R.drawable.logo_300);
holder.logoImageView.setTag(1);
}
}
});
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(nm.getTime());
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM, yy", Locale.ENGLISH);
String formattedDate = sdf.format(cal.getTime());
SimpleDateFormat sdf1 = new SimpleDateFormat("kk:mm", Locale.US);
String formattedTime = sdf1.format(cal.getTime());
holder.notificationTimeTextView.setText(formattedTime);
holder.notificationDateTextView.setText(formattedDate);
}
Aggregations