| 9 |
gabriel |
1 |
package com.cesams.twogetskills.fragment;
|
|
|
2 |
|
| 25 |
gabriel |
3 |
import android.graphics.Color;
|
| 9 |
gabriel |
4 |
import android.os.Bundle;
|
|
|
5 |
|
| 25 |
gabriel |
6 |
import androidx.cardview.widget.CardView;
|
| 9 |
gabriel |
7 |
import androidx.fragment.app.Fragment;
|
| 11 |
gabriel |
8 |
import androidx.recyclerview.widget.GridLayoutManager;
|
|
|
9 |
import androidx.recyclerview.widget.RecyclerView;
|
| 9 |
gabriel |
10 |
|
| 25 |
gabriel |
11 |
import android.text.format.DateFormat;
|
| 11 |
gabriel |
12 |
import android.util.Log;
|
| 9 |
gabriel |
13 |
import android.view.LayoutInflater;
|
|
|
14 |
import android.view.View;
|
|
|
15 |
import android.view.ViewGroup;
|
| 11 |
gabriel |
16 |
import android.widget.TextView;
|
| 9 |
gabriel |
17 |
|
| 25 |
gabriel |
18 |
import com.cesams.twogetskills.Constants;
|
| 9 |
gabriel |
19 |
import com.cesams.twogetskills.R;
|
| 11 |
gabriel |
20 |
import com.cesams.twogetskills.adapter.CardViewAdapter;
|
|
|
21 |
import com.cesams.twogetskills.dao.NotificationCenterDao;
|
|
|
22 |
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
|
| 9 |
gabriel |
23 |
|
| 25 |
gabriel |
24 |
import java.text.SimpleDateFormat;
|
| 11 |
gabriel |
25 |
import java.util.ArrayList;
|
| 25 |
gabriel |
26 |
import java.util.Calendar;
|
|
|
27 |
import java.util.Date;
|
| 11 |
gabriel |
28 |
import java.util.HashMap;
|
|
|
29 |
import java.util.List;
|
|
|
30 |
|
| 9 |
gabriel |
31 |
/**
|
|
|
32 |
* A simple {@link Fragment} subclass.
|
|
|
33 |
* Use the {@link NotificationCenter#newInstance} factory method to
|
|
|
34 |
* create an instance of this fragment.
|
|
|
35 |
*/
|
| 25 |
gabriel |
36 |
public class NotificationCenter extends Fragment implements CardViewAdapter.ClickListener {
|
| 9 |
gabriel |
37 |
|
| 11 |
gabriel |
38 |
RecyclerView notificaciones;
|
|
|
39 |
CardViewAdapter notificacionadapter;
|
|
|
40 |
private ITwoGetSkills iTwoGetSkills;
|
|
|
41 |
TextView notienenuevas;
|
| 9 |
gabriel |
42 |
|
| 11 |
gabriel |
43 |
ArrayList<HashMap<String, String>> notificacionList;
|
| 9 |
gabriel |
44 |
|
| 11 |
gabriel |
45 |
|
| 9 |
gabriel |
46 |
public NotificationCenter() {
|
|
|
47 |
// Required empty public constructor
|
|
|
48 |
}
|
|
|
49 |
|
| 11 |
gabriel |
50 |
public static NotificationCenter newInstance() {
|
| 9 |
gabriel |
51 |
NotificationCenter fragment = new NotificationCenter();
|
|
|
52 |
return fragment;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
@Override
|
|
|
56 |
public void onCreate(Bundle savedInstanceState) {
|
|
|
57 |
super.onCreate(savedInstanceState);
|
| 11 |
gabriel |
58 |
|
| 9 |
gabriel |
59 |
}
|
|
|
60 |
|
|
|
61 |
@Override
|
|
|
62 |
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
63 |
Bundle savedInstanceState) {
|
| 11 |
gabriel |
64 |
View view =inflater.inflate(R.layout.fragment_notification_center, container, false);
|
|
|
65 |
|
|
|
66 |
iTwoGetSkills = (ITwoGetSkills) getActivity();
|
|
|
67 |
|
|
|
68 |
notificaciones = view.findViewById(R.id.notificacioneslista);
|
|
|
69 |
|
|
|
70 |
notificacionList= new ArrayList<>();
|
|
|
71 |
notienenuevas= view.findViewById(R.id.textView18);
|
|
|
72 |
notienenuevas.setVisibility(View.VISIBLE);
|
|
|
73 |
|
|
|
74 |
notificacionadapter = new CardViewAdapter(getContext(),notificacionList);
|
|
|
75 |
|
|
|
76 |
GridLayoutManager layoutnotifi = new GridLayoutManager(getContext(),1,GridLayoutManager.VERTICAL, false);
|
|
|
77 |
notificaciones.setLayoutManager(layoutnotifi);
|
|
|
78 |
notificaciones.setAdapter(notificacionadapter);
|
|
|
79 |
|
| 25 |
gabriel |
80 |
notificacionadapter.setClickListener(this);
|
| 11 |
gabriel |
81 |
NotificationCenterDao notificacionDao;
|
|
|
82 |
|
|
|
83 |
notificacionDao =iTwoGetSkills.getDatabase().getNotificationCenterDao();
|
|
|
84 |
|
| 25 |
gabriel |
85 |
//Log.e("Notificaciones","estas:"+notificacionDao.selectAllNotification().toString());
|
| 11 |
gabriel |
86 |
|
|
|
87 |
List<com.cesams.twogetskills.entity.NotificationCenter> lista;
|
|
|
88 |
lista=notificacionDao.selectAllNotification();
|
|
|
89 |
|
|
|
90 |
HashMap<String, String> m_li;
|
|
|
91 |
|
|
|
92 |
for(com.cesams.twogetskills.entity.NotificationCenter notificacion: lista)
|
|
|
93 |
{
|
| 25 |
gabriel |
94 |
//Log.e("Esto",""+notificacion.getTitle());
|
| 11 |
gabriel |
95 |
m_li = new HashMap<>();
|
|
|
96 |
|
|
|
97 |
m_li.put("titulo",notificacion.getTitle());
|
|
|
98 |
m_li.put("date",notificacion.getDate());
|
|
|
99 |
m_li.put("descripcion",notificacion.getDescription());
|
|
|
100 |
|
|
|
101 |
notificacionList.add(m_li);
|
|
|
102 |
notienenuevas.setVisibility(View.GONE);
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
notificacionadapter.notifyDataSetChanged();
|
|
|
106 |
|
| 25 |
gabriel |
107 |
|
| 11 |
gabriel |
108 |
}
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
return view;
|
| 9 |
gabriel |
112 |
}
|
| 11 |
gabriel |
113 |
|
|
|
114 |
|
| 25 |
gabriel |
115 |
@Override
|
|
|
116 |
public void onItemClick(int position, View v) {
|
|
|
117 |
Log.e("Aqui", "pise en el fragment"+position);
|
|
|
118 |
notificacionList.get(position).put("color","white");
|
|
|
119 |
notificacionadapter.notifyDataSetChanged();
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
}
|
| 9 |
gabriel |
123 |
}
|