Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

Rev 11 | Rev 28 | 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
 
46
 
27 gabriel 47
/*
1 gabriel 48
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_TOKEN)) {
49
 
50
                String token = intent.getStringExtra("token");
51
 
52
 
53
                if(context instanceof ITwoGetSkills) {
54
                    ((ITwoGetSkills) context).createSyncRecordNewToken(token);
55
                }
56
            }
27 gabriel 57
*/
1 gabriel 58
 
59
 
60
 
61
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_COMMAND)) {
62
 
63
 
64
                String command = intent.getStringExtra("command");
65
                Log.d(TAG, "Recibiendo un nuevo COMAND");
66
                Log.d(TAG, "Command : " + command);
67
 
68
                if(context instanceof ITwoGetSkills) {
69
                    ((ITwoGetSkills) context).executeFcmCommand(command);
70
                }
71
            }
72
 
73
            /*
74
              if (intent.getAction().equals(Constants.BROADCAST_TYPE_REFRESH_CONTENT)) {
75
 
76
                Log.d(TAG, "Hay que refrescar el contenido");
77
 
78
                if(context instanceof ITwoGetSkills) {
79
                    ((ITwoGetSkills) context).requestCheckChanges();
80
                }
81
            }
82
            */
83
 
84
            /*
85
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_SYNC_TO_SERVER)) {
86
                Log.d(TAG, "Sync Data");
87
                if(context instanceof ITwoGetSkills) {
88
                    ((ITwoGetSkills) context).syncToServer();
89
                }
90
            }
91
            */
92
 
93
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_SYNC_TO_SERVER_OR_CHECK_CHANGES)) {
94
                Log.d(TAG, "Sync Data");
95
                if(context instanceof ITwoGetSkills) {
96
                    ((ITwoGetSkills) context).syncToServerOrCheckChanges();
97
                }
98
            }
99
 
100
 
3 gabriel 101
 
1 gabriel 102
        } catch (NullPointerException e) {
103
            e.printStackTrace();
104
        }
105
    }
106
 
107
 
108
}