BeeHoneyt  1.1
BTS SNIR LaSalle Avignon 2021
Référence de la classe com.example.bee_honeyt.Historique.AsyncTaskHTTP

Classe permettant de lancer la tâche de chargement du contenu de l'historique en arrière plan. Plus de détails...

Graphe de collaboration de com.example.bee_honeyt.Historique.AsyncTaskHTTP:
Collaboration graph

Fonctions membres publiques

 AsyncTaskHTTP ()
 

Fonctions membres protégées

String doInBackground (String... strings)
 
void onPostExecute (String contenu)
 

Description détaillée

Classe permettant de lancer la tâche de chargement du contenu de l'historique en arrière plan.

Définition à la ligne 89 du fichier Historique.java.

Documentation des constructeurs et destructeur

◆ AsyncTaskHTTP()

com.example.bee_honeyt.Historique.AsyncTaskHTTP.AsyncTaskHTTP ( )

Définition à la ligne 91 du fichier Historique.java.

92  {
93  Log.d(TAG, "<AsyncTaskHTTP> new AsyncTaskHTTP()");
94  }

Références com.example.bee_honeyt.Historique.TAG.

Documentation des fonctions membres

◆ doInBackground()

String com.example.bee_honeyt.Historique.AsyncTaskHTTP.doInBackground ( String...  strings)
protected

Définition à la ligne 97 du fichier Historique.java.

98  {
99  URL url = null;
100  HttpsURLConnection connexionHTTPS = null;
101  InputStream in = null;
102  String contenu = null;
103 
104  Log.d(TAG, "<AsyncTaskHTTP> doInBackground() url : " + strings[0] + " - key : " + strings[1]);
105  try
106  {
107  url = new URL(strings[0]);
108  connexionHTTPS = (HttpsURLConnection) url.openConnection();
109  connexionHTTPS.setRequestProperty("Accept", "application/json");
110  connexionHTTPS.setRequestProperty("Authorization", "key " + strings[1]);
111  int codeReponse = connexionHTTPS.getResponseCode();
112  if (codeReponse != HttpURLConnection.HTTP_OK)
113  {
114  Log.d(TAG,"<AsyncTaskHTTP> Erreur code réponse = " + codeReponse);
115  return contenu;
116  }
117 
118  in = new BufferedInputStream(connexionHTTPS.getInputStream());
119  BufferedReader r = new BufferedReader(new InputStreamReader(in));
120  StringBuilder sb = new StringBuilder();
121  String ligne = null;
122  while(true)
123  {
124  try
125  {
126  if (!((ligne = r.readLine()) != null))
127  break;
128  }
129  catch (IOException e)
130  {
131  e.printStackTrace();
132  }
133  sb.append(ligne);
134  sb.append("\r\n");
135  }
136  contenu = sb.toString();
137  Log.d(TAG,"<AsyncTaskHTTP> données récupérées : " + contenu.length() + " octet(s)");
138  }
139  catch (MalformedURLException e)
140  {
141  Log.d(TAG,"MalformedURLException");
142  e.printStackTrace();
143  }
144  catch (IOException e)
145  {
146  Log.d(TAG,"IOException");
147  e.printStackTrace();
148  }
149  finally
150  {
151  if (connexionHTTPS != null)
152  connexionHTTPS.disconnect();
153  }
154 
155  return contenu;
156  }

Références com.example.bee_honeyt.Historique.TAG.

◆ onPostExecute()

void com.example.bee_honeyt.Historique.AsyncTaskHTTP.onPostExecute ( String  contenu)
protected

Définition à la ligne 159 du fichier Historique.java.

160  {
161  Log.d(TAG,"<AsyncTaskHTTP> onPostExecute()");
162  if(contenu == null)
163  {
164  chargement = false; // pas de chargement
165  if(callback != null)
166  {
167  callback.onError();
168  }
169  return;
170  }
171 
172  StringReader sin = new StringReader(contenu);
173  if(sin != null)
174  {
175  chargement = true;
176 
177  if(chargement)
178  {
179  if(callback != null)
180  {
181  callback.onLoad(contenu);
182  }
183  }
184  }
185  }

Références com.example.bee_honeyt.Historique.callback, com.example.bee_honeyt.Historique.chargement, com.example.bee_honeyt.HistoriqueEventListener.onError(), com.example.bee_honeyt.HistoriqueEventListener.onLoad(), et com.example.bee_honeyt.Historique.TAG.


La documentation de cette classe a été générée à partir du fichier suivant :
com.example.bee_honeyt.Historique.callback
HistoriqueEventListener callback
Pour les fonctions de rappel sur évènement (onLoad, onError, ...)
Definition: Historique.java:34
com.example.bee_honeyt.HistoriqueEventListener.onLoad
void onLoad(String contenu)
com.example.bee_honeyt.Historique.TAG
static final String TAG
TAG pour les logs.
Definition: Historique.java:30
com.example.bee_honeyt.HistoriqueEventListener.onError
void onError()
com.example.bee_honeyt.Historique.chargement
boolean chargement
Indique si le contenu a été chargé
Definition: Historique.java:32