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">