當前位置: 首頁>>代碼示例>>Java>>正文


Java RESTClient類代碼示例

本文整理匯總了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;
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:14,代碼來源:DroneshareAccountFragment.java

示例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);
	}
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:41,代碼來源:UploaderService.java

示例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);
		}
	}
 
開發者ID:3drobotics,項目名稱:droneapi-java,代碼行數:31,代碼來源:DirectoryUploader.java

示例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);
	}
 
開發者ID:3drobotics,項目名稱:droneapi-java,代碼行數:12,代碼來源:TestClient.java


注:本文中的com.geeksville.apiproxy.rest.RESTClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。