Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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

Rev Autor Línea Nro. Línea
1 gabriel 1
package com.cesams.twogetskills.receiver;
2
 
3
import android.content.BroadcastReceiver;
4
import android.content.Context;
5
import android.content.Intent;
6
import android.util.Log;
7
 
8
import com.cesams.twogetskills.Constants;
11 gabriel 9
import com.cesams.twogetskills.dao.NotificationCenterDao;
10
import com.cesams.twogetskills.entity.NotificationCenter;
1 gabriel 11
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
12
 
13
public class InternalReceiver extends BroadcastReceiver {
14
    private final static String TAG = "C2GS - InternalReceiver";
15
 
16
    @Override
17
    public void onReceive(Context context, Intent intent) {
27 gabriel 18
        Log.e(TAG, "Recibiendo Internal");
19
 
1 gabriel 20
        try {
27 gabriel 21
            Log.e(TAG,""+intent.getAction());
22
 
1 gabriel 23
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_NOTIFICATION)) {
24
 
25
                String title = intent.getExtras().getString("title");
26
                String body = intent.getExtras().getString("body");
27
 
28
 
29
                int new_capsules = 0;
30
                if(intent.getExtras().containsKey("new_capsules")) {
31
                    new_capsules = intent.getExtras().getInt("new_capsules");
32
                }
33
 
11 gabriel 34
                Log.e(TAG, "Recibiendo una nueva NOTIFICACION");
1 gabriel 35
                Log.d(TAG, "Title : " + title);
36
                Log.d(TAG, "Body : " + body);
37
                Log.d(TAG, "New Capsules : " + new_capsules);
38
 
11 gabriel 39
 
1 gabriel 40
                if(context instanceof ITwoGetSkills) {
41
                    ((ITwoGetSkills) context).showFcmNotification(title, body, new_capsules);
11 gabriel 42
 
1 gabriel 43
                }
44
            }
45
 
27 gabriel 46
/*
1 gabriel 47
 
28 gabriel 48
        //Deshabilitado en falla de registro de token del 06/2022:
49
 
50
        El servicio envia el intent antes que el reciever sea registrado
51
 
52
          if (intent.getAction().equals(Constants.BROADCAST_TYPE_TOKEN)) {
53
 
1 gabriel 54
                String token = intent.getStringExtra("token");
55
 
56
 
57
                if(context instanceof ITwoGetSkills) {
58
                    ((ITwoGetSkills) context).createSyncRecordNewToken(token);
59
                }
60
            }
27 gabriel 61
*/
1 gabriel 62
 
63
 
64
 
65
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_COMMAND)) {
66
 
67
 
68
                String command = intent.getStringExtra("command");
69
                Log.d(TAG, "Recibiendo un nuevo COMAND");
70
                Log.d(TAG, "Command : " + command);
71
 
72
                if(context instanceof ITwoGetSkills) {
73
                    ((ITwoGetSkills) context).executeFcmCommand(command);
74
                }
75
            }
76
 
77
            /*
78
              if (intent.getAction().equals(Constants.BROADCAST_TYPE_REFRESH_CONTENT)) {
79
 
80
                Log.d(TAG, "Hay que refrescar el contenido");
81
 
82
                if(context instanceof ITwoGetSkills) {
83
                    ((ITwoGetSkills) context).requestCheckChanges();
84
                }
85
            }
86
            */
87
 
88
            /*
89
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_SYNC_TO_SERVER)) {
90
                Log.d(TAG, "Sync Data");
91
                if(context instanceof ITwoGetSkills) {
92
                    ((ITwoGetSkills) context).syncToServer();
93
                }
94
            }
95
            */
96
 
97
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_SYNC_TO_SERVER_OR_CHECK_CHANGES)) {
98
                Log.d(TAG, "Sync Data");
99
                if(context instanceof ITwoGetSkills) {
100
                    ((ITwoGetSkills) context).syncToServerOrCheckChanges();
101
                }
102
            }
103
 
104
 
3 gabriel 105
 
1 gabriel 106
        } catch (NullPointerException e) {
107
            e.printStackTrace();
108
        }
109
    }
110
 
111
 
112
}