本文整理汇总了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);
}