本文整理汇总了Java中com.vk.sdk.api.model.VKAttachments类的典型用法代码示例。如果您正苦于以下问题:Java VKAttachments类的具体用法?Java VKAttachments怎么用?Java VKAttachments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VKAttachments类属于com.vk.sdk.api.model包,在下文中一共展示了VKAttachments类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setVkParameters
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
/**
* Serialize VKParameters map into http query parameters list
*
* @param params parameters map
*/
void setVkParameters(VKParameters params) {
ArrayList<Pair<String, String>> pairs = new ArrayList<>(params.size());
for (Map.Entry<String, Object> entry : params.entrySet()) {
Object value = entry.getValue();
if (value instanceof VKAttachments) {
pairs.add(new Pair<>(entry.getKey(), ((VKAttachments) value).toAttachmentsString()));
} else if (value instanceof Collection) {
Collection<?> values = (Collection<?>) value;
//VK style
pairs.add(new Pair<>(entry.getKey(), TextUtils.join(",", values)));
} else {
pairs.add(new Pair<>(entry.getKey(), value == null ? null : String.valueOf(value)));
}
}
this.parameters = pairs;
}
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:22,代码来源:VKHttpClient.java
示例2: onClick
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
@Override
public void onClick(View view) {
setIsLoading(true);
if (mAttachmentImages != null && VKSdk.getAccessToken() != null) {
final Long userId = Long.parseLong(VKSdk.getAccessToken().userId);
VKUploadWallPhotoRequest photoRequest = new VKUploadWallPhotoRequest(mAttachmentImages, userId, 0);
photoRequest.executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
VKPhotoArray photos = (VKPhotoArray) response.parsedModel;
VKAttachments attachments = new VKAttachments(photos);
makePostWithAttachments(attachments);
}
@Override
public void onError(VKError error) {
setIsLoading(false);
if (mListener != null) {
mListener.onVkShareError(error);
}
}
});
} else {
makePostWithAttachments(null);
}
}
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:27,代码来源:VKShareDialogDelegate.java
示例3: makePost
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
private void makePost(VKAttachments attachments, String message) {
VKRequest post = VKApi.wall().post(VKParameters.from(VKApiConst.OWNER_ID, "-" + TARGET_GROUP, VKApiConst.ATTACHMENTS, attachments, VKApiConst.MESSAGE, message));
post.setModelClass(VKWallPostResult.class);
post.executeWithListener(new VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
if (isAdded()) {
VKWallPostResult result = (VKWallPostResult) response.parsedModel;
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("https://vk.com/wall-%d_%s", TARGET_GROUP, result.post_id)));
startActivity(i);
}
}
@Override
public void onError(VKError error) {
showError(error.apiError != null ? error.apiError : error);
}
});
}
开发者ID:VKCOM,项目名称:vk-android-sdk,代码行数:20,代码来源:TestActivity.java
示例4: getFileDescription
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
protected String getFileDescription(File uploadFile, int i) {
String fileName;
if (mType != null && mType.equals(VKAttachments.TYPE_DOC)) {
fileName = "file";
} else {
fileName = String.format(Locale.US, "file%d", i + 1);
}
String extension = MimeTypeMap.getFileExtensionFromUrl(uploadFile.getAbsolutePath());
return String.format("\r\n--%s\r\n", mBoundary) +
String.format("Content-Disposition: form-data; name=\"%s\"; filename=\"%s.%s\"\r\n", fileName, fileName, extension) +
String.format("Content-Type: %s\r\n\r\n", getMimeType(uploadFile.getAbsolutePath()));
}
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:13,代码来源:VKMultipartEntity.java
示例5: joinParams
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
/**
* Join parameters map into string, usually query string
*
* @param queryParams Map to join
* @param isUri Indicates that value parameters must be uri-encoded
* @return Result query string, like k=v&k1=v1
*/
public static String joinParams(Map<String, ?> queryParams, boolean isUri) {
ArrayList<String> params = new ArrayList<String>(queryParams.size());
for (Map.Entry<String, ?> entry : queryParams.entrySet()) {
Object value = entry.getValue();
if (value instanceof VKAttachments) {
value = ((VKAttachments)value).toAttachmentsString();
}
params.add(String.format("%s=%s", entry.getKey(),
isUri ? Uri.encode(String.valueOf(value)) : String.valueOf(value)));
}
return join(params, "&");
}
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:20,代码来源:VKStringJoiner.java
示例6: joinParams
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
/**
* Join parameters map into string, usually query string
*
* @param queryParams Map to join
* @param isUri Indicates that value parameters must be uri-encoded
* @return Result query string, like k=v&k1=v1
*/
public static String joinParams(Map<String, Object> queryParams, boolean isUri) {
ArrayList<String> params = new ArrayList<String>(queryParams.size());
for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
Object value = entry.getValue();
if (value instanceof VKAttachments) {
value = ((VKAttachments)value).toAttachmentsString();
}
params.add(String.format("%s=%s", entry.getKey(),
isUri ? Uri.encode(String.valueOf(value)) : String.valueOf(value)));
}
return join(params, "&");
}
开发者ID:DementorAl,项目名称:VkAdmin,代码行数:20,代码来源:VKStringJoiner.java
示例7: setAttachments
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
public void setAttachments(VKAttachments attachments) {
setStretchAllColumns(false);
row.removeAllViews();
setVisibility(GONE);
if (attachments == null) {
return;
}
ArrayList<VKApiPhoto> photos = new ArrayList<>();
for (VKAttachments.VKApiAttachment a : attachments) {
if (a instanceof VKApiPhoto) {
photos.add((VKApiPhoto) a);
if (photos.size() >= 2) {
break;
}
}
}
if (photos.isEmpty()) {
return;
}
setVisibility(VISIBLE);
for (VKApiPhoto p : photos) {
DownloadableImageView imageView = new DownloadableImageView(getContext());
boolean downloadBigPhoto = false;
if (photos.size() == 1) {
// Download big picture iff there is only one picture to show (otherwise they're packed
// tight) and big photo does actually exist
downloadBigPhoto = p.photo_1280 != null && !p.photo_1280.isEmpty();
}
imageView.setDownloadableImageUri(downloadBigPhoto ? p.photo_1280 : p.photo_604);
TableRow.LayoutParams params = new TableRow.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
params.leftMargin = 4;
params.rightMargin = 4;
imageView.setLayoutParams(params);
row.addView(imageView);
}
if (!photos.isEmpty()) {
setStretchAllColumns(true);
}
}
开发者ID:yeputons,项目名称:ofeed,代码行数:43,代码来源:PhotoAttachmentsView.java
示例8: requestWithVkRequest
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
/**
* Prepares new "normal" request from VKRequest
*
* @param vkRequest Request, created for some method
* @return Prepared request for creating VKHttpOperation
*/
public static HttpUriRequest requestWithVkRequest(VKRequest vkRequest) {
HttpUriRequest request = null;
VKParameters preparedParameters = vkRequest.getPreparedParameters();
StringBuilder urlStringBuilder = new StringBuilder(
String.format(Locale.US, "http%s://api.vk.com/method/%s",
vkRequest.secure ? "s" : "", vkRequest.methodName));
switch (vkRequest.httpMethod) {
case GET:
if (preparedParameters.size() > 0) {
urlStringBuilder.append("?").append(VKStringJoiner.joinUriParams(preparedParameters));
}
request = new HttpGet(urlStringBuilder.toString());
break;
case POST:
HttpPost post = new HttpPost(urlStringBuilder.toString());
ArrayList<NameValuePair> pairs = new ArrayList<NameValuePair>(preparedParameters.size());
for (Map.Entry<String, Object> entry : preparedParameters.entrySet()) {
Object value = entry.getValue();
if (value instanceof VKAttachments) {
pairs.add(new BasicNameValuePair(entry.getKey(), ((VKAttachments)value).toAttachmentsString()));
}
else if (value instanceof Collection) {
Collection<?> values = (Collection<?>) value;
for (Object v : values) {
// This will add a parameter for each value in the Collection/List
pairs.add(new BasicNameValuePair(String.format("%s[]", entry.getKey()), v == null ? null : String.valueOf(v)));
}
} else {
pairs.add(new BasicNameValuePair(entry.getKey(), value == null ? null : String.valueOf(value)));
}
}
try {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(pairs, "UTF-8");
post.setEntity(entity);
} catch (UnsupportedEncodingException e) {
return null;
}
request = post;
break;
}
Map<String, String> defaultHeaders = getDefaultHeaders();
for (String key : defaultHeaders.keySet()) {
request.addHeader(key, defaultHeaders.get(key));
}
return request;
}
开发者ID:DementorAl,项目名称:VkAdmin,代码行数:55,代码来源:VKHttpClient.java
示例9: docUploadRequest
import com.vk.sdk.api.model.VKAttachments; //导入依赖的package包/类
/**
* Prepares new request with multipart boundary for uploading document
*
* @param uploadUrl String url received with some of *.getUploadServer method
* @param file File to upload
* @return prepared HTTP request, ready for upload
*/
public static VKHTTPRequest docUploadRequest(@NonNull String uploadUrl, File file) {
VKHTTPRequest request = new VKHTTPRequest(uploadUrl);
request.entity = new VKMultipartEntity(new File[]{file}, VKAttachments.TYPE_DOC);
return request;
}
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:13,代码来源:VKHttpClient.java
注:本文中的com.vk.sdk.api.model.VKAttachments类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论