I have Create BDay app in notification class show to all people list but i want to display current date only.
In this code i have to compare to current date and my database date i want to display only current date people.
I want to display current date people in RecyclerView.
I have add static data in database.
I have disaply in another arralist but could not disaply
I'm new in android programming
My static Database
dd MMMM
2 October
14 November
24 October
My Code
private List<People> notificationList = new ArrayList<>();
private List<People> peopleListSelected = new ArrayList<>();
private RecyclerView recyclerView;
private NotificationAdapter notificationAdapter;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notificatoin);
BuildData();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
calender();
Calendar calendar = Calendar.getInstance();
for (People people : notificationList) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM");
String today = sdf.format(calendar.getTime());
String startDate = people.getDate() + "-" + people.getMonth();
if (today.equals(startDate)) {
Date date = sdf.parse(startDate);
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 18);
calendar.set(Calendar.MINUTE, 35);
calendar.set(Calendar.SECOND, 0);
peopleListSelected.add(people);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
Intent intent1 = new Intent(Notification.this, MyReceiver.class);
PendingIntent pendingIntent = PendingIntent.getService(Notification.this, 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) Notification.this.getSystemService(Notification.this.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
notificationAdapter = new NotificationAdapter(getApplicationContext(), peopleListSelected);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new
DefaultItemAnimator()
);
recyclerView.setAdapter(notificationAdapter);
Button backwindow = (Button) findViewById(R.id.backwindow);
backwindow.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
onBackPressed();
}
}
);
}
public void calender() {
}
public void clickMe(View view) {
Intent intent = new Intent(this, NotificationOpen.class);
this.startActivity(intent);
}
public void onBackPressed() {
super.onBackPressed();
}
private List<People> BuildData() {
DataBaseHelper db = new DataBaseHelper(getApplicationContext());
try {
db.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
if (db.open()) {
notificationList = db.getPeopleDate();
}
return notificationList;
}
}