From 31c053b9c35134f5392f4799ce35f8a8caed73d3 Mon Sep 17 00:00:00 2001 From: danijoo Date: Sat, 2 Jan 2016 22:02:18 +0100 Subject: [PATCH] added onclicklistener to notificationlist --- .../NotificationListAdapter.java | 24 ++++++++++++++++++- .../NotificationListFragment.java | 16 ++++++++++++- .../res/layout/notification_list_item.xml | 4 ++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/net/headlezz/notificationlogger/notificationlist/NotificationListAdapter.java b/app/src/main/java/net/headlezz/notificationlogger/notificationlist/NotificationListAdapter.java index a28e5d9..bc85492 100644 --- a/app/src/main/java/net/headlezz/notificationlogger/notificationlist/NotificationListAdapter.java +++ b/app/src/main/java/net/headlezz/notificationlogger/notificationlist/NotificationListAdapter.java @@ -20,7 +20,7 @@ import butterknife.Bind; import butterknife.ButterKnife; -public class NotificationListAdapter extends CursorRecyclerViewAdapter { +public class NotificationListAdapter extends CursorRecyclerViewAdapter implements View.OnClickListener { class NotificationViewHolder extends RecyclerView.ViewHolder { @@ -61,13 +61,25 @@ public class NotificationListAdapter extends CursorRecyclerViewAdapter { +public class NotificationListFragment extends Fragment implements LoaderManager.LoaderCallbacks, NotificationListAdapter.NotificationClickListener { final int LOADER_ID = 124; @@ -32,6 +33,9 @@ public class NotificationListFragment extends Fragment implements LoaderManager. private NotificationListAdapter mAdapter; + // TODO reload list if new notification arrives + // TODO notification list divider + @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -46,6 +50,7 @@ public class NotificationListFragment extends Fragment implements LoaderManager. public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mAdapter = new NotificationListAdapter(getContext(), null); + mAdapter.setNotificationClickListener(this); mNotificationList.setAdapter(mAdapter); getLoaderManager().initLoader(LOADER_ID, Bundle.EMPTY, this); } @@ -86,4 +91,13 @@ public class NotificationListFragment extends Fragment implements LoaderManager. mNotificationList.setVisibility(View.VISIBLE); } } + + @Override + public void onNotificationClick(long id) { + String qry = Logged_notificationTable.FIELD__ID + " = ? "; + String[] args = { String.valueOf(id) }; + Cursor cursor = getContext().getContentResolver().query(Logged_notificationTable.CONTENT_URI, null, qry, args, null); + LoggedNotification notification = Logged_notificationTable.getRow(cursor, true); + Timber.e(notification.title); + } } diff --git a/app/src/main/res/layout/notification_list_item.xml b/app/src/main/res/layout/notification_list_item.xml index 008ba41..e3a7233 100644 --- a/app/src/main/res/layout/notification_list_item.xml +++ b/app/src/main/res/layout/notification_list_item.xml @@ -1,11 +1,11 @@ + android:padding="8dp" + android:foreground="?attr/selectableItemBackground">