Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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

Rev 54 Rev 56
Línea 24... Línea 24...
24
import com.cesams.twogetskills.R;
24
import com.cesams.twogetskills.R;
25
import com.cesams.twogetskills.adapter.CardViewAdapter;
25
import com.cesams.twogetskills.adapter.CardViewAdapter;
26
import com.cesams.twogetskills.dao.NotificationCenterDao;
26
import com.cesams.twogetskills.dao.NotificationCenterDao;
27
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
27
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
Línea -... Línea 28...
-
 
28
 
28
 
29
import java.text.ParseException;
29
import java.text.SimpleDateFormat;
30
import java.text.SimpleDateFormat;
30
import java.util.ArrayList;
31
import java.util.ArrayList;
31
import java.util.Calendar;
32
import java.util.Calendar;
32
import java.util.Collections;
33
import java.util.Collections;
33
import java.util.Date;
34
import java.util.Date;
34
import java.util.HashMap;
35
import java.util.HashMap;
-
 
36
import java.util.List;
Línea 35... Línea 37...
35
import java.util.List;
37
import java.util.Objects;
36
 
38
 
37
/**
39
/**
38
 * A simple {@link Fragment} subclass.
40
 * A simple {@link Fragment} subclass.
Línea 44... Línea 46...
44
   RecyclerView notificaciones;
46
   RecyclerView notificaciones;
45
   CardViewAdapter notificacionadapter;
47
   CardViewAdapter notificacionadapter;
46
   private ITwoGetSkills iTwoGetSkills;
48
   private ITwoGetSkills iTwoGetSkills;
47
   TextView notienenuevas;
49
   TextView notienenuevas;
Línea 48... Línea 50...
48
 
50
 
Línea 49... Línea 51...
49
    ArrayList<HashMap<String, String>> notificacionList;
51
    ArrayList<HashMap<String, String>> notificacionListToday;
50
 
52
 
51
 
53
 
Línea 70... Línea 72...
70
        View view =inflater.inflate(R.layout.fragment_notification_center, container, false);
72
        View view =inflater.inflate(R.layout.fragment_notification_center, container, false);
Línea 71... Línea 73...
71
 
73
 
Línea 72... Línea 74...
72
        iTwoGetSkills = (ITwoGetSkills) getActivity();
74
        iTwoGetSkills = (ITwoGetSkills) getActivity();
73
 
-
 
74
        notificaciones = view.findViewById(R.id.notificacioneslista);
75
 
75
 
76
        notificaciones = view.findViewById(R.id.notificacioneslista);
76
        notificacionList= new ArrayList<>();
77
        notificacionListToday= new ArrayList<>();
Línea 77... Línea 78...
77
        notienenuevas= view.findViewById(R.id.textView18);
78
        notienenuevas= view.findViewById(R.id.textView18);
Línea 78... Línea 79...
78
        notienenuevas.setVisibility(View.VISIBLE);
79
        notienenuevas.setVisibility(View.VISIBLE);
79
 
80
 
Línea 80... Línea 81...
80
        notificacionadapter = new CardViewAdapter(getContext(),notificacionList);
81
        notificacionadapter = new CardViewAdapter(getContext(),notificacionListToday);
81
 
82
 
Línea 82... Línea 83...
82
        LinearLayoutManager layoutnotifi = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL, true);
83
        LinearLayoutManager layoutnotifi = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL, false);
Línea 92... Línea 93...
92
 
93
 
93
        return view;
94
        return view;
Línea 94... Línea 95...
94
    }
95
    }
-
 
96
 
Línea 95... Línea 97...
95
 
97
    private void loaddata(){
96
    private void loaddata(){
98
        iTwoGetSkills.setTitleActionBar("Centro de notificaciones");
Línea 97... Línea 99...
97
 
99
 
Línea 98... Línea 100...
98
        notificacionList.clear();
100
        notificacionListToday.clear();
Línea 99... Línea 101...
99
        NotificationCenterDao notificacionDao;
101
        NotificationCenterDao notificacionDao;
100
 
102
 
Línea 101... Línea -...
101
        notificacionDao =iTwoGetSkills.getDatabase().getNotificationCenterDao();
-
 
102
 
103
        notificacionDao =iTwoGetSkills.getDatabase().getNotificationCenterDao();
Línea 103... Línea 104...
103
        //Log.e("Notificaciones","estas:"+notificacionDao.selectAllNotification().toString());
104
 
104
 
105
        //Log.e("Notificaciones","estas:"+notificacionDao.selectAllNotification().toString());
105
        List<com.cesams.twogetskills.entity.NotificationCenter> lista;
106
 
106
        lista=notificacionDao.selectAllNotification();
-
 
Línea -... Línea 107...
-
 
107
        List<com.cesams.twogetskills.entity.NotificationCenter> grupo;
-
 
108
        grupo=notificacionDao.selectAllNotificationOrderDay();
-
 
109
 
-
 
110
        boolean hoy = false,ayer=false,other=false;
-
 
111
 
-
 
112
        for (com.cesams.twogetskills.entity.NotificationCenter notificaciongrupos: grupo){
-
 
113
 
-
 
114
            String diaactual= notificaciongrupos.getDate();
-
 
115
 
107
 
116
            List<com.cesams.twogetskills.entity.NotificationCenter> lista;
108
        Toast.makeText(getContext(), "Hay registradas "+lista.size()+" notificaciones", Toast.LENGTH_SHORT).show();
117
            lista=notificacionDao.selectAllNotificationInDay(diaactual);
109
        HashMap<String, String> m_li;
118
 
110
 
119
            HashMap<String, String> m_li,dias;
111
        for(com.cesams.twogetskills.entity.NotificationCenter notificacion: lista)
120
 
-
 
121
            for(com.cesams.twogetskills.entity.NotificationCenter notificacion: lista)
112
        {
122
            {
-
 
123
                m_li = new HashMap<>(); dias = new HashMap<>();
-
 
124
 
-
 
125
                m_li.put("titulo",notificacion.getTitle());
113
            Log.e("Esto",""+notificacion.getTitle());
126
                m_li.put("date",notificacion.getDate());
-
 
127
                m_li.put("descripcion",notificacion.getDescription());
114
            m_li = new HashMap<>();
128
                m_li.put("color",notificacion.getViewed());
-
 
129
                m_li.put("url",notificacion.getUrl());
115
 
130
                dias.put("titulo","");
-
 
131
                dias.put("date",notificacion.getDate());
116
            m_li.put("titulo",notificacion.getTitle());
132
                dias.put("descripcion","");
117
            m_li.put("date",notificacion.getDate());
133
                dias.put("color","");
-
 
134
                dias.put("url","");
-
 
135
 
118
            m_li.put("descripcion",notificacion.getDescription());
136
                Calendar calendar = Calendar.getInstance();
119
           // Log.e("Viewer: ",notificacion.getViewed());
137
                Date date = calendar.getTime();
-
 
138
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.FORMAT_DATE_SERVICE);
120
            m_li.put("color",notificacion.getViewed());
139
                String  dateOn = simpleDateFormat.format(date);
-
 
140
 
-
 
141
 
-
 
142
                final Calendar cal = Calendar.getInstance();
-
 
143
                cal.add(Calendar.DATE, -1);
121
            m_li.put("url",notificacion.getUrl());
144
                Date date2 = cal.getTime();
-
 
145
                SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(Constants.FORMAT_DATE_SERVICE);
-
 
146
                String  dateOn2 = simpleDateFormat2.format(date2);
-
 
147
 
122
 
148
                if(Objects.equals(notificacion.getDate(), dateOn))
-
 
149
                {
-
 
150
                    if(!hoy){
123
            notificacionList.add(m_li);
151
 
-
 
152
                        dias.put("day","today");
-
 
153
                        notificacionListToday.add(dias);
-
 
154
                        hoy=true;
124
            notienenuevas.setVisibility(View.GONE);
155
                    }
-
 
156
                    m_li.put("day","");
-
 
157
                    notificacionListToday.add(m_li);
-
 
158
 
125
 
159
                }
-
 
160
                else if (Objects.equals(notificacion.getDate(), dateOn2))
-
 
161
                {
-
 
162
                    if(!ayer){
Línea -... Línea 163...
-
 
163
                        dias.put("day","yesterday");
-
 
164
                        notificacionListToday.add(dias);
-
 
165
                        ayer=true;
-
 
166
                    }
-
 
167
                    m_li.put("day","");
-
 
168
                    notificacionListToday.add(m_li);
-
 
169
 
-
 
170
                }
-
 
171
                else if(!Objects.equals(notificacion.getDate(), dateOn) || !Objects.equals(notificacion.getDate(), dateOn2)) {
-
 
172
 
-
 
173
                    if(!other){
-
 
174
 
-
 
175
                        dias.put("day","other");
-
 
176
                        notificacionListToday.add(dias);
-
 
177
                        other=true;
-
 
178
                    }
-
 
179
                    m_li.put("day","");
-
 
180
                    notificacionListToday.add(m_li);
-
 
181
 
-
 
182
                }
-
 
183
 
-
 
184
 
126
            //Agregar notificacion a la lista de vista
185
                notienenuevas.setVisibility(View.GONE);
-
 
186
 
-
 
187
                //Agregar notificacion a la lista de vistas
-
 
188
                com.cesams.twogetskills.entity.NotificationCenter notificacionupdate = new com.cesams.twogetskills.entity.NotificationCenter();
-
 
189
                notificacionupdate.setId(notificacion.getId());
-
 
190
                notificacionupdate.setDescription(notificacion.getDescription());
Línea 127... Línea 191...
127
            com.cesams.twogetskills.entity.NotificationCenter notificacionupdate = new com.cesams.twogetskills.entity.NotificationCenter();
191
                notificacionupdate.setDate(notificacion.getDate());
128
            notificacionupdate.setId(notificacion.getId());
192
                notificacionupdate.setTitle(notificacion.getTitle());
Línea 175... Línea 239...
175
    public void onItemClick(int position, View v) {
239
    public void onItemClick(int position, View v) {
176
        Log.e("Aqui", "pise en el fragment"+position);
240
        Log.e("Aqui", "pise en el fragment"+position);
177
        //        notificacionList.get(position).put("color","white");
241
        //        notificacionList.get(position).put("color","white");
178
       // loaddata();
242
       // loaddata();
Línea 179... Línea 243...
179
 
243
 
180
        if(!notificacionList.get(position).get("url").isEmpty())
244
        if(!notificacionListToday.get(position).get("url").isEmpty())
181
        {
245
        {
182
            Log.e("Tiene url", "vamos alla");
246
            Log.e("Tiene url", "vamos alla");
183
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(notificacionList.get(position).get("url")));
247
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(notificacionListToday.get(position).get("url")));
184
            try{
248
            try{
185
                startActivity(browserIntent);
249
                startActivity(browserIntent);
186
            }catch (Exception e)
250
            }catch (Exception e)
187
            {
251
            {
Línea 191... Línea 255...
191
        else
255
        else
192
        {
256
        {
193
            Log.e("No hay url", "no hago nada");
257
            Log.e("No hay url", "no hago nada");
194
        }
258
        }
195
    }
259
    }
196
}
-
 
197
260
}
-
 
261