Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

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