本文整理匯總了Java中com.geeksville.apiproxy.rest.RESTClient類的典型用法代碼示例。如果您正苦於以下問題:Java RESTClient類的具體用法?Java RESTClient怎麽用?Java RESTClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RESTClient類屬於com.geeksville.apiproxy.rest包,在下文中一共展示了RESTClient類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doInBackground
import com.geeksville.apiproxy.rest.RESTClient; //導入依賴的package包/類
@Override
protected JSONObject doInBackground(String... params) {
final String username = params[0];
final String password = params[1];
JSONObject userData = null;
try {
userData = RESTClient.getUserData(username, password, dpPrefs.getDroneshareApiKey());
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}
return userData;
}
示例2: doUploads
import com.geeksville.apiproxy.rest.RESTClient; //導入依賴的package包/類
private void doUploads(List<Pair<Long, Uri>> dataToUpload) {
String login = dpPrefs.getDroneshareLogin();
String password = dpPrefs.getDronesharePassword();
if (!login.isEmpty() && !password.isEmpty()) {
final Notification notification = generateNotificationBuilder()
.setContentText("Uploading tlog data")
.build();
startForeground(ONGOING_UPLOAD_NOTIFICATION_ID, notification);
try {
int numUploaded = 0;
for (Pair<Long, Uri> datumInfo : dataToUpload) {
long uploadId = datumInfo.first;
Uri dataUri = datumInfo.second;
File uploadFile = new File(dataUri.getPath());
if (uploadFile.isFile()) {
Timber.i("Starting upload for " + uploadFile);
String url = RESTClient.doUpload(uploadFile, login, password, null, apiKey, DRONESHARE_PRIVACY);
if (url != null) {
numUploaded++;
}
onUploadSuccess(uploadFile, url, numUploaded);
}
else{
Timber.w("TLog data file is not available.");
}
droneShareDb.commitUploadedData(uploadId, System.currentTimeMillis());
}
} catch (IOException e) {
Timber.e(e, "Unable to complete tlog data upload");
onUploadFailure(e);
}
stopForeground(true);
}
}
示例3: run
import com.geeksville.apiproxy.rest.RESTClient; //導入依賴的package包/類
public void run() {
File[] files = srcDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".tlog");
}
});
File processing = null;
try {
for (File f : files) {
processing = f;
callback.onUploadStart(f);
String url = RESTClient.doUpload(f, userId, userPass,
vehicleId, apiKey, privacy);
destDir.mkdirs();
File newName = new File(destDir, f.getName());
f.renameTo(newName);
callback.onUploadSuccess(f, url);
}
} catch (IOException ex) {
// If the server returns any IO or HTTP exceptions, report _one_
// failure to the application
// but then stop scanning until asked to scan again.
callback.onUploadFailure(processing, ex);
}
}
示例4: runRESTTest
import com.geeksville.apiproxy.rest.RESTClient; //導入依賴的package包/類
/**
* Test simple REST uploads
*
* @throws Exception
*/
public static void runRESTTest() throws Exception {
// RESTClient.doUpload(testTlog, login, password, vehicleId, apiKey, "DEFAULT");
JSONObject userData = RESTClient.getUserData("test", "test", apiKey);
System.out.println("User data: " + userData);
}