-
Notifications
You must be signed in to change notification settings - Fork 66
/
DownloadOuisAsyncTask.java
55 lines (47 loc) · 1.56 KB
/
DownloadOuisAsyncTask.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.aaronjwood.portauthority.async;
import com.aaronjwood.portauthority.activity.MainActivity;
import com.aaronjwood.portauthority.db.Database;
import com.aaronjwood.portauthority.parser.Parser;
import com.aaronjwood.portauthority.response.MainAsyncResponse;
import java.lang.ref.WeakReference;
public class DownloadOuisAsyncTask extends DownloadAsyncTask {
// The official source on gitlab.com doesn't provide a content length header which ruins our ability to report progress!
private static final String SERVICE = "https://raw.githubusercontent.com/wireshark/wireshark/master/manuf";
/**
* Creates a new asynchronous task to handle downloading OUI data.
*
* @param database
* @param parser
* @param activity
*/
public DownloadOuisAsyncTask(Database database, Parser parser, MainAsyncResponse activity) {
db = database;
delegate = new WeakReference<>(activity);
this.parser = parser;
}
/**
* Downloads new OUI data.
*
* @param params
* @return
*/
@Override
protected Void doInBackground(Void... params) {
db.clearOuis();
doInBackground(SERVICE, parser);
return null;
}
/**
* Updates the UI with the MAC address from the newly fetched data.
*
* @param result
*/
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
MainAsyncResponse activity = delegate.get();
if (activity != null) {
((MainActivity) activity).setupMac();
}
}
}