本文整理汇总了Java中com.vk.sdk.api.VKParameters类的典型用法代码示例。如果您正苦于以下问题:Java VKParameters类的具体用法?Java VKParameters怎么用?Java VKParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VKParameters类属于com.vk.sdk.api包,在下文中一共展示了VKParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlaylistClicked
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
@Override
public void onPlaylistClicked(VkApiAlbum playlist, int position) {
if(binding.loadingIndicator.getVisibility() == View.VISIBLE){
return; // Don't accept click events when loading
}
binding.loadingIndicator.setVisibility(View.VISIBLE);
VKApi.audio().add(VKParameters.from("audio_id", audioToAdd.id, "owner_id", audioToAdd.owner_id, VKApiConst.ALBUM_ID, playlist.getId())).executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
if(listener != null){
listener.onAudioAddedToPlaylist(audioToAdd, playlist);
}
dismissAllowingStateLoss();
}
});
}
示例2: setVkParameters
import com.vk.sdk.api.VKParameters; //导入依赖的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;
}
示例3: removeAudio
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
private void removeAudio(VKApiAudio audio, int position) {
VKApi.audio().delete(VKParameters.from("audio_id", audio.id, "owner_id", audio.owner_id)).executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
try {
int responseCode = response.json.getInt("response");
if (responseCode == 1) {
audioArray.remove(position);
adapter.notifyItemRemoved(position);
Snackbar.make(binding.getRoot(), R.string.track_removed, Snackbar.LENGTH_SHORT).show();
}
} catch (JSONException e) {
onError(null);
}
}
@Override
public void onError(VKError error) {
Snackbar.make(binding.getRoot(), R.string.error_deleting_track, Snackbar.LENGTH_LONG).show();
}
});
}
示例4: onPlaylistItemLongClicked
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
private void onPlaylistItemLongClicked(VkApiAlbum playlist) {
new AlertDialog.Builder(this)
.setMessage("Are you sure you want to delete " + playlist.getTitle() + "?")
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
VKApi.audio().deleteAlbum(VKParameters.from(VKApiConst.ALBUM_ID, playlist.getId())).executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
drawer.removeItem(playlist.getId());
loadPlaylists();
Snackbar.make(binding.slidinglayout, R.string.deleted_playlist, Snackbar.LENGTH_SHORT).show();
}
});
})
.show();
}
示例5: setPhoto
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
public void setPhoto(final ImageView imageView, final Button button){
VKParameters params = new VKParameters();
params.put(VKApiConst.FIELDS, "photo_max_orig");
VKRequest request = new VKRequest("users.get",params);
request.executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
super.onComplete(response);
JSONArray resp = null;
try {
resp = response.json.getJSONArray("response");
JSONObject user = resp.getJSONObject(0);
String photo_max_orig_url = user.getString("photo_max_orig");
imageView.setVisibility(View.VISIBLE);
button.setVisibility(View.GONE);
Glide.with(context).load(photo_max_orig_url).into(imageView);
} catch (JSONException e) {
Log.d("VkSdkHelper", String.valueOf(e));
}
}
@Override
public void onError(VKError error) {
super.onError(error);
}
});
}
示例6: getSaveRequest
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
@Override
protected VKRequest getSaveRequest(JSONObject response) {
VKRequest saveRequest;
try {
saveRequest = VKApi.docs().save(new VKParameters(VKJsonHelper.toMap(response)));
} catch (JSONException e) {
return null;
}
if (mGroupId != 0)
saveRequest.addExtraParameters(VKUtil.paramsFrom(VKApiConst.GROUP_ID, mGroupId));
return saveRequest;
}
示例7: getSaveRequest
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
@Override
protected VKRequest getSaveRequest(JSONObject response) {
VKRequest saveRequest;
try {
saveRequest = VKApi.photos().save(new VKParameters(VKJsonHelper.toMap(response)));
} catch (JSONException e) {
return null;
}
if (mAlbumId != 0)
saveRequest.addExtraParameters(VKUtil.paramsFrom(VKApiConst.ALBUM_ID, mAlbumId));
if (mGroupId != 0)
saveRequest.addExtraParameters(VKUtil.paramsFrom(VKApiConst.GROUP_ID, mGroupId));
return saveRequest;
}
示例8: get
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
/**
* https://vk.com/dev/users.get
*
* @param params use parameters from description with VKApiConst class
* @return Request for load
*/
public VKRequest get(VKParameters params) {
return prepareRequest("get", params, new VKParser() {
@Override
public Object createModel(JSONObject object) {
return new VKList<>(object, VKApiUserFull.class);
}
});
}
示例9: get
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
public VKRequest get(VKParameters params) {
if (params.containsKey(VKApiConst.EXTENDED) && ((Integer) params.get(VKApiConst.EXTENDED)) == 1) {
return prepareRequest("get", params, VKApiCommunityArray.class);
} else {
return prepareRequest("get", params);
}
}
示例10: onResume
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
binding.loadingIndicator.setVisibility(View.VISIBLE);
VKApi.audio().getAlbums(VKParameters.from(VKApiConst.OWNER_ID, user.getId())).executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
VkApiAlbumArrayResponse albumsResponse = gson.fromJson(response.responseString, VkApiAlbumArrayResponse.class);
playlists.clear();
playlists.addAll(albumsResponse.getResponse().getItems());
for (VkApiAlbum album : playlists) {
String fixedTitle;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
fixedTitle = Html.fromHtml(album.getTitle(), Html.FROM_HTML_MODE_LEGACY).toString();
} else {
fixedTitle = Html.fromHtml(album.getTitle()).toString();
}
album.setTitle(fixedTitle);
}
adapter.notifyDataSetChanged();
binding.loadingIndicator.setVisibility(View.GONE);
}
@Override
public void onError(VKError error) {
binding.loadingIndicator.setVisibility(View.VISIBLE);
Snackbar.make(binding.rcvPlaylists, "Error loading playlists", Snackbar.LENGTH_LONG).show();
}
});
}
示例11: addAlbum
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
public VKRequest addAlbum(VKParameters params) {
return prepareRequest("addAlbum", params);
}
示例12: add
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
public VKRequest add(VKParameters params) {
return prepareRequest("add", params);
}
示例13: get
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
public VKRequest get(VKParameters params) {
return prepareRequest("get", params, VkVideoArray.class);
}
示例14: edit
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
public VKRequest edit(VKParameters params) {
return prepareRequest("edit", params);
}
示例15: getAlbumsByVideo
import com.vk.sdk.api.VKParameters; //导入依赖的package包/类
public VKRequest getAlbumsByVideo(VKParameters params) {
return prepareRequest("getAlbumsByVideo", params);
}