Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

Rev 25 | Rev 39 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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);
34 gabriel 81
 
82
        loaddata();
83
 
84
 
85
        return view;
86
    }
87
 
88
    private void loaddata(){
89
 
90
        notificacionList.clear();
11 gabriel 91
        NotificationCenterDao notificacionDao;
92
 
93
        notificacionDao =iTwoGetSkills.getDatabase().getNotificationCenterDao();
94
 
25 gabriel 95
        //Log.e("Notificaciones","estas:"+notificacionDao.selectAllNotification().toString());
11 gabriel 96
 
97
        List<com.cesams.twogetskills.entity.NotificationCenter> lista;
98
        lista=notificacionDao.selectAllNotification();
99
 
100
        HashMap<String, String> m_li;
101
 
102
        for(com.cesams.twogetskills.entity.NotificationCenter notificacion: lista)
103
        {
25 gabriel 104
            //Log.e("Esto",""+notificacion.getTitle());
11 gabriel 105
            m_li = new HashMap<>();
106
 
107
            m_li.put("titulo",notificacion.getTitle());
108
            m_li.put("date",notificacion.getDate());
109
            m_li.put("descripcion",notificacion.getDescription());
110
 
111
            notificacionList.add(m_li);
112
            notienenuevas.setVisibility(View.GONE);
113
 
114
 
115
            notificacionadapter.notifyDataSetChanged();
116
 
25 gabriel 117
 
11 gabriel 118
        }
34 gabriel 119
    }
11 gabriel 120
 
34 gabriel 121
    @Override
122
    public void onResume() {
123
        super.onResume();
124
        loaddata();
9 gabriel 125
    }
11 gabriel 126
 
25 gabriel 127
    @Override
128
    public void onItemClick(int position, View v) {
129
        Log.e("Aqui", "pise en el fragment"+position);
34 gabriel 130
        //        notificacionList.get(position).put("color","white");
131
        loaddata();
25 gabriel 132
 
133
    }
9 gabriel 134
}