Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

Rev 28 | Rev 39 | 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
 
30 efrain 16
    public InternalReceiver()
17
    {
18
        Log.e("BUG Token", "InternalReceiver - Constructor");
19
    }
20
 
1 gabriel 21
    @Override
22
    public void onReceive(Context context, Intent intent) {
27 gabriel 23
        Log.e(TAG, "Recibiendo Internal");
24
 
1 gabriel 25
        try {
27 gabriel 26
            Log.e(TAG,""+intent.getAction());
27
 
1 gabriel 28
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_NOTIFICATION)) {
29
 
30
                String title = intent.getExtras().getString("title");
31
                String body = intent.getExtras().getString("body");
32
 
33
 
34
                int new_capsules = 0;
35
                if(intent.getExtras().containsKey("new_capsules")) {
36
                    new_capsules = intent.getExtras().getInt("new_capsules");
37
                }
38
 
11 gabriel 39
                Log.e(TAG, "Recibiendo una nueva NOTIFICACION");
1 gabriel 40
                Log.d(TAG, "Title : " + title);
41
                Log.d(TAG, "Body : " + body);
42
                Log.d(TAG, "New Capsules : " + new_capsules);
43
 
11 gabriel 44
 
1 gabriel 45
                if(context instanceof ITwoGetSkills) {
46
                    ((ITwoGetSkills) context).showFcmNotification(title, body, new_capsules);
11 gabriel 47
 
1 gabriel 48
                }
49
            }
50
 
51
 
28 gabriel 52
 
53
          if (intent.getAction().equals(Constants.BROADCAST_TYPE_TOKEN)) {
54
 
1 gabriel 55
                String token = intent.getStringExtra("token");
56
 
57
 
58
                if(context instanceof ITwoGetSkills) {
59
                    ((ITwoGetSkills) context).createSyncRecordNewToken(token);
60
                }
61
            }
62
 
63
 
64
 
30 efrain 65
 
1 gabriel 66
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_COMMAND)) {
67
 
68
 
69
                String command = intent.getStringExtra("command");
70
                Log.d(TAG, "Recibiendo un nuevo COMAND");
71
                Log.d(TAG, "Command : " + command);
72
 
73
                if(context instanceof ITwoGetSkills) {
74
                    ((ITwoGetSkills) context).executeFcmCommand(command);
75
                }
76
            }
77
 
78
            /*
79
              if (intent.getAction().equals(Constants.BROADCAST_TYPE_REFRESH_CONTENT)) {
80
 
81
                Log.d(TAG, "Hay que refrescar el contenido");
82
 
83
                if(context instanceof ITwoGetSkills) {
84
                    ((ITwoGetSkills) context).requestCheckChanges();
85
                }
86
            }
87
            */
88
 
89
            /*
90
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_SYNC_TO_SERVER)) {
91
                Log.d(TAG, "Sync Data");
92
                if(context instanceof ITwoGetSkills) {
93
                    ((ITwoGetSkills) context).syncToServer();
94
                }
95
            }
96
            */
97
 
98
            if (intent.getAction().equals(Constants.BROADCAST_TYPE_SYNC_TO_SERVER_OR_CHECK_CHANGES)) {
99
                Log.d(TAG, "Sync Data");
100
                if(context instanceof ITwoGetSkills) {
101
                    ((ITwoGetSkills) context).syncToServerOrCheckChanges();
102
                }
103
            }
104
 
105
 
3 gabriel 106
 
1 gabriel 107
        } catch (NullPointerException e) {
108
            e.printStackTrace();
109
        }
110
    }
111
 
112
 
113
}