Proyectos de Subversion Android Microlearning - Inconcert

Rev

Rev 6 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6 Rev 7
Línea 13... Línea 13...
13
import android.view.View;
13
import android.view.View;
14
import android.view.ViewGroup;
14
import android.view.ViewGroup;
15
import android.widget.TextView;
15
import android.widget.TextView;
16
import android.widget.Toast;
16
import android.widget.Toast;
Línea -... Línea 17...
-
 
17
 
17
 
18
import com.cesams.twogetskills.inconcert.Constants;
18
import com.cesams.twogetskills.inconcert.R;
19
import com.cesams.twogetskills.inconcert.R;
19
import com.cesams.twogetskills.inconcert.adapter.CardViewAdapter;
20
import com.cesams.twogetskills.inconcert.adapter.CardViewAdapter;
20
import com.cesams.twogetskills.inconcert.dao.NotificationCenterDao;
21
import com.cesams.twogetskills.inconcert.dao.NotificationCenterDao;
Línea -... Línea 22...
-
 
22
import com.cesams.twogetskills.inconcert.skeleton.ITwoGetSkills;
-
 
23
 
21
import com.cesams.twogetskills.inconcert.skeleton.ITwoGetSkills;
24
import java.text.ParseException;
-
 
25
import java.text.SimpleDateFormat;
-
 
26
import java.util.ArrayList;
22
 
27
import java.util.Calendar;
23
import java.util.ArrayList;
28
import java.util.Date;
24
import java.util.HashMap;
29
import java.util.HashMap;
Línea 25... Línea 30...
25
import java.util.List;
30
import java.util.List;
Línea 35... Línea 40...
35
   RecyclerView notificaciones;
40
   RecyclerView notificaciones;
36
   CardViewAdapter notificacionadapter;
41
   CardViewAdapter notificacionadapter;
37
   private ITwoGetSkills iTwoGetSkills;
42
   private ITwoGetSkills iTwoGetSkills;
38
   TextView notienenuevas;
43
   TextView notienenuevas;
Línea 39... Línea 44...
39
 
44
 
Línea 40... Línea 45...
40
    ArrayList<HashMap<String, String>> notificacionList;
45
    ArrayList<HashMap<String, String>> notificacionListToday;
41
 
46
 
42
 
47
 
Línea 60... Línea 65...
60
                             Bundle savedInstanceState) {
65
                             Bundle savedInstanceState) {
61
        View view =inflater.inflate(R.layout.fragment_notification_center, container, false);
66
        View view =inflater.inflate(R.layout.fragment_notification_center, container, false);
Línea 62... Línea 67...
62
 
67
 
Línea -... Línea 68...
-
 
68
        iTwoGetSkills = (ITwoGetSkills) getActivity();
63
        iTwoGetSkills = (ITwoGetSkills) getActivity();
69
 
64
 
70
 
65
        notificaciones = view.findViewById(R.id.notificacioneslista);
71
        notificaciones = view.findViewById(R.id.notificacioneslista);
66
        notificacionList= new ArrayList<>();
72
        notificacionListToday= new ArrayList<>();
Línea 67... Línea 73...
67
        notienenuevas= view.findViewById(R.id.textView18);
73
        notienenuevas= view.findViewById(R.id.textView18);
Línea 68... Línea 74...
68
        notienenuevas.setVisibility(View.VISIBLE);
74
        notienenuevas.setVisibility(View.VISIBLE);
69
 
75
 
Línea 70... Línea 76...
70
        notificacionadapter = new CardViewAdapter(getContext(),notificacionList);
76
        notificacionadapter = new CardViewAdapter(getContext(),notificacionListToday);
71
 
77
 
Línea 72... Línea 78...
72
        LinearLayoutManager layoutnotifi = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL, true);
78
        LinearLayoutManager layoutnotifi = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL, false);
Línea 84... Línea 90...
84
 
90
 
85
        return view;
91
        return view;
Línea 86... Línea 92...
86
    }
92
    }
-
 
93
 
Línea 87... Línea 94...
87
 
94
    private void loaddata(){
88
    private void loaddata(){
95
        iTwoGetSkills.setTitleActionBar("Centro de notificaciones");
Línea 89... Línea 96...
89
 
96
 
Línea 90... Línea 97...
90
        notificacionList.clear();
97
        notificacionListToday.clear();
Línea 91... Línea 98...
91
        NotificationCenterDao notificacionDao;
98
        NotificationCenterDao notificacionDao;
92
 
99
 
Línea 93... Línea -...
93
        notificacionDao =iTwoGetSkills.getDatabase().getNotificationCenterDao();
-
 
94
 
100
        notificacionDao =iTwoGetSkills.getDatabase().getNotificationCenterDao();
Línea -... Línea 101...
-
 
101
 
-
 
102
        //Log.e("Notificaciones","estas:"+notificacionDao.selectAllNotification().toString());
-
 
103
 
-
 
104
        List<com.cesams.twogetskills.inconcert.entity.NotificationCenter> grupo;
-
 
105
        grupo=notificacionDao.selectAllNotificationOrderDay();
-
 
106
 
-
 
107
        boolean hoy = false,ayer=false,other=false;
-
 
108
 
-
 
109
        for (com.cesams.twogetskills.inconcert.entity.NotificationCenter notificaciongrupos: grupo){
95
        //Log.e("Notificaciones","estas:"+notificacionDao.selectAllNotification().toString());
110
 
96
 
111
            String diaactual= notificaciongrupos.getDate();
-
 
112
 
-
 
113
            List<com.cesams.twogetskills.inconcert.entity.NotificationCenter> lista;
97
        List<com.cesams.twogetskills.inconcert.entity.NotificationCenter> lista;
114
            lista=notificacionDao.selectAllNotificationInDay(diaactual);
-
 
115
 
-
 
116
            HashMap<String, String> m_li,dias;
-
 
117
 
-
 
118
            for(com.cesams.twogetskills.inconcert.entity.NotificationCenter notificacion: lista)
-
 
119
            {
-
 
120
                m_li = new HashMap<>(); dias = new HashMap<>();
-
 
121
 
-
 
122
                m_li.put("titulo",notificacion.getTitle());
-
 
123
                m_li.put("date",notificacion.getDate());
-
 
124
                m_li.put("descripcion",notificacion.getDescription());
-
 
125
                m_li.put("color",notificacion.getViewed());
-
 
126
                m_li.put("url",notificacion.getUrl());
-
 
127
                dias.put("titulo","");
-
 
128
                dias.put("date",notificacion.getDate());
-
 
129
                dias.put("descripcion","");
-
 
130
                dias.put("color","");
-
 
131
                dias.put("url","");
-
 
132
 
-
 
133
                Calendar calendar = Calendar.getInstance();
-
 
134
                Date date = calendar.getTime();
-
 
135
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATE_SERVICE);
-
 
136
                String  dateOn = simpleDateFormat.format(date);
-
 
137
 
-
 
138
 
-
 
139
                final Calendar cal = Calendar.getInstance();
-
 
140
                cal.add(Calendar.DATE, -1);
-
 
141
                Date date2 = cal.getTime();
-
 
142
                SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(Constants.FORMAT_DATE_SERVICE);
-
 
143
                String  dateOn2 = simpleDateFormat2.format(date2);
-
 
144
 
-
 
145
                if(Objects.equals(notificacion.getDate(), dateOn))
-
 
146
                {
-
 
147
                    if(!hoy){
-
 
148
 
-
 
149
                        dias.put("day","today");
-
 
150
                        notificacionListToday.add(dias);
-
 
151
                        hoy=true;
-
 
152
                    }
-
 
153
                    m_li.put("day","");
98
        lista=notificacionDao.selectAllNotification();
154
                    notificacionListToday.add(m_li);
-
 
155
 
-
 
156
                }
-
 
157
                else if (Objects.equals(notificacion.getDate(), dateOn2))
-
 
158
                {
-
 
159
                    if(!ayer){
-
 
160
                        dias.put("day","yesterday");
Línea 99... Línea -...
99
 
-
 
100
       // Toast.makeText(getContext(), "Hay registradas "+lista.size()+" notificaciones", Toast.LENGTH_SHORT).show();
-
 
101
        HashMap<String, String> m_li;
-
 
102
 
-
 
103
        for(com.cesams.twogetskills.inconcert.entity.NotificationCenter notificacion: lista)
-
 
104
        {
-
 
105
            Log.e("Esto",""+notificacion.getTitle());
-
 
106
            m_li = new HashMap<>();
161
                        notificacionListToday.add(dias);
107
 
-
 
108
            m_li.put("titulo",notificacion.getTitle());
-
 
109
            m_li.put("date",notificacion.getDate());
-
 
110
            m_li.put("descripcion",notificacion.getDescription());
-
 
111
           // Log.e("Viewer: ",notificacion.getViewed());
-
 
112
            m_li.put("color",notificacion.getViewed());
-
 
113
            m_li.put("url",notificacion.getUrl());
-
 
114
 
-
 
115
            notificacionList.add(m_li);
-
 
116
            notienenuevas.setVisibility(View.GONE);
-
 
117
 
-
 
Línea -... Línea 162...
-
 
162
                        ayer=true;
-
 
163
                    }
-
 
164
                    m_li.put("day","");
-
 
165
                    notificacionListToday.add(m_li);
-
 
166
 
-
 
167
                }
-
 
168
                else if(!Objects.equals(notificacion.getDate(), dateOn) || !Objects.equals(notificacion.getDate(), dateOn2)) {
-
 
169
 
-
 
170
                    if(!other){
-
 
171
 
-
 
172
                        dias.put("day","other");
-
 
173
                        notificacionListToday.add(dias);
-
 
174
                        other=true;
-
 
175
                    }
-
 
176
                    m_li.put("day","");
-
 
177
                    notificacionListToday.add(m_li);
-
 
178
 
-
 
179
                }
-
 
180
 
-
 
181
 
118
            //Agregar notificacion a la lista de vista
182
                notienenuevas.setVisibility(View.GONE);
-
 
183
 
-
 
184
                //Agregar notificacion a la lista de vistas
-
 
185
                com.cesams.twogetskills.inconcert.entity.NotificationCenter notificacionupdate = new com.cesams.twogetskills.inconcert.entity.NotificationCenter();
-
 
186
                notificacionupdate.setId(notificacion.getId());
-
 
187
                notificacionupdate.setDescription(notificacion.getDescription());
Línea 119... Línea 188...
119
            com.cesams.twogetskills.inconcert.entity.NotificationCenter notificacionupdate = new com.cesams.twogetskills.inconcert.entity.NotificationCenter();
188
                notificacionupdate.setDate(notificacion.getDate());
-
 
189
                notificacionupdate.setTitle(notificacion.getTitle());
-
 
190
                notificacionupdate.setUrl(notificacion.getUrl());
-
 
191
                notificacionupdate.setViewed("white");
120
            notificacionupdate.setId(notificacion.getId());
192
                notificacionDao.update(notificacionupdate);
Línea 121... Línea 193...
121
            notificacionupdate.setDescription(notificacion.getDescription());
193
 
122
            notificacionupdate.setDate(notificacion.getDate());
194
                notificacionadapter.notifyItemChanged(notificacionListToday.size()-1);
123
            notificacionupdate.setTitle(notificacion.getTitle());
195
 
Línea 167... Línea 239...
167
    public void onItemClick(int position, View v) {
239
    public void onItemClick(int position, View v) {
168
        Log.e("Aqui", "pise en el fragment"+position);
240
        Log.e("Aqui", "pise en el fragment"+position);
169
        //        notificacionList.get(position).put("color","white");
241
        //        notificacionList.get(position).put("color","white");
170
       // loaddata();
242
       // loaddata();
Línea -... Línea 243...
-
 
243
 
171
 
244
 
172
        if(!notificacionList.get(position).get("url").isEmpty())
245
        if(!notificacionListToday.get(position).get("url").isEmpty())
173
        {
246
        {
174
            Log.e("Tiene url", "vamos alla");
247
            Log.e("Tiene url", "vamos alla");
175
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(notificacionList.get(position).get("url")));
248
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(notificacionListToday.get(position).get("url")));
176
            try{
249
            try{
177
                startActivity(browserIntent);
250
                startActivity(browserIntent);
178
            }catch (Exception e)
251
            }catch (Exception e)
179
            {
252
            {