当前位置: 首页>>代码示例>>Java>>正文


Java VKError类代码示例

本文整理汇总了Java中com.vk.sdk.api.VKError的典型用法代码示例。如果您正苦于以下问题:Java VKError类的具体用法?Java VKError怎么用?Java VKError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VKError类属于com.vk.sdk.api包,在下文中一共展示了VKError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import com.vk.sdk.api.VKError; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    mTwitterAuthClient.onActivityResult(requestCode, resultCode, data);
    if (!VKSdk.onActivityResult(requestCode, resultCode, data, new VKCallback<VKAccessToken>() {
        @Override
        public void onResult(VKAccessToken token) {
            initUIAfterLogin();
        }

        @Override
        public void onError(VKError error) {
        }
    })) {
        super.onActivityResult(requestCode, resultCode, data);
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:KKorvin,项目名称:uPods-android,代码行数:19,代码来源:FragmentProfile.java

示例2: onClick

import com.vk.sdk.api.VKError; //导入依赖的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: onActivityResult

import com.vk.sdk.api.VKError; //导入依赖的package包/类
@Override
public void onActivityResult( int requestCode, int resultCode, Intent data ) {
	if( !VKSdk.onActivityResult( requestCode, resultCode, data, new VKCallback<VKAccessToken>() {
		@Override
		public void onResult( VKAccessToken res ) {
			AIR.log( "AuthFunction::onActivityResult | VK_AUTH_SUCCESS" );
			AIR.dispatchEvent( AIRVKEvent.VK_AUTH_SUCCESS, VKAccessTokenUtils.toJSON( res ) );
		}

		@Override
		public void onError( VKError error ) {
			AIR.log( "AuthFunction::onActivityResult | VK_AUTH_ERROR: " + error.errorMessage + " reason: " + error.errorReason );
			AIR.dispatchEvent( AIRVKEvent.VK_AUTH_ERROR, (error.errorMessage == null) ? "Error - user denied access." : error.errorMessage );
		}
	} ) ) {
		AIR.log( "AuthFunction::onActivityResult | no callback" );
	}
	AndroidActivityWrapper.GetAndroidActivityWrapper().removeActivityResultListener( this );
}
 
开发者ID:marpies,项目名称:vk-ane,代码行数:20,代码来源:AuthFunction.java

示例4: removeAudio

import com.vk.sdk.api.VKError; //导入依赖的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();
        }
    });
}
 
开发者ID:Mavamaarten,项目名称:vk_music_android,代码行数:23,代码来源:AudioListFragment.java

示例5: onActivityResult

import com.vk.sdk.api.VKError; //导入依赖的package包/类
@Override
protected void onActivityResult(final int requestCode, int resultCode, Intent data) {
    if (!VKSdk.onActivityResult(requestCode, resultCode, data, new VKCallback<VKAccessToken>() {
        @Override
        public void onResult(final VKAccessToken accessToken) {
            createUserComponentAndLaunchMainActivity();
        }

        @Override
        public void onError(VKError error) {
            new AlertDialog.Builder(LoginActivity.this)
                    .setMessage("Login failed: " + error.errorReason)
                    .setPositiveButton(android.R.string.ok, null)
                    .show();
        }
    })) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:Mavamaarten,项目名称:vk_music_android,代码行数:20,代码来源:LoginActivity.java

示例6: onActivityResult

import com.vk.sdk.api.VKError; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (!VKSdk.onActivityResult(requestCode, resultCode, data, new VKCallback<VKAccessToken>() {
        @Override
        public void onResult(VKAccessToken res) {
            Log.i(LOG_TAG, "VKAccessToken: " + res);
            // User passed Authorization
            loadUser("onActivityResult");
        }
        @Override
        public void onError(VKError error) {
            // User didn't pass Authorization
            Log.e(LOG_TAG, "onActivityResult.onError: " + error);
        }
    })) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:DmitriyG1,项目名称:vk-music-player-android,代码行数:19,代码来源:LoginActivity.java

示例7: checkAndSetToken

import com.vk.sdk.api.VKError; //导入依赖的package包/类
/**
 * Check new access token and sets it as working token
 *
 * @param tokenParams params of token
 * @param renew       flag indicates token renewal
 * @return true if access token was set, or error was provided
 */
private static CheckTokenResult checkAndSetToken(Map<String, String> tokenParams, boolean renew) {

    VKAccessToken token = VKAccessToken.tokenFromParameters(tokenParams);
    if (token == null || token.accessToken == null) {
        if (tokenParams.containsKey(VKAccessToken.SUCCESS)) {
            return CheckTokenResult.Success;
        }

        VKError error = new VKError(tokenParams);
        if (error.errorMessage != null || error.errorReason != null) {
            setAccessTokenError(error);
            return CheckTokenResult.Error;
        }
    } else {
        setAccessToken(token, renew);
        return CheckTokenResult.Success;
    }
    return CheckTokenResult.None;
}
 
开发者ID:DementorAl,项目名称:VkAdmin,代码行数:27,代码来源:VKSdk.java

示例8: checkAndSetToken

import com.vk.sdk.api.VKError; //导入依赖的package包/类
/**
* Check new access token and sets it as working token
* @param tokenParams params of token
* @param renew flag indicates token renewal
   * @return true if access token was set, or error was provided
*/
  private static boolean checkAndSetToken(Map<String, String> tokenParams, boolean renew) {
      VKAccessToken token = VKAccessToken.tokenFromParameters(tokenParams);
      if (token == null || token.accessToken == null) {
          VKError error = new VKError(tokenParams);
          if (error.errorMessage != null || error.errorReason != null) {
              setAccessTokenError(error);
              return true;
          }

      } else {
          setAccessToken(token, renew);
          return true;
      }
      return false;
  }
 
开发者ID:LizaAlert-HotLine,项目名称:AndroidMobileWorkplace,代码行数:22,代码来源:VKSdk.java

示例9: performTokenCheck

import com.vk.sdk.api.VKError; //导入依赖的package包/类
private boolean performTokenCheck(VKAccessToken token, boolean isUserToken) {
    if (token != null) {
        if (token.isExpired()) {
            mListener.onTokenExpired(token);
        }
        else if (token.accessToken != null) {
            if (isUserToken) mListener.onAcceptUserToken(token);
            return true;
        }
        else {
            VKError error = new VKError(VKError.VK_API_CANCELED);
            error.errorMessage = "User token is invalid";
                mListener.onAccessDenied(error);
        }
    }
    return false;
}
 
开发者ID:LizaAlert-HotLine,项目名称:AndroidMobileWorkplace,代码行数:18,代码来源:VKSdk.java

示例10: makePost

import com.vk.sdk.api.VKError; //导入依赖的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

示例11: onActivityResult

import com.vk.sdk.api.VKError; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    VKCallback<VKAccessToken> callback = new VKCallback<VKAccessToken>() {
        @Override
        public void onResult(VKAccessToken res) {
            // User passed Authorization
            startTestActivity();
        }

        @Override
        public void onError(VKError error) {
            // User didn't pass Authorization
        }
    };

    if (!VKSdk.onActivityResult(requestCode, resultCode, data, callback)) {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:VKCOM,项目名称:vk-android-sdk,代码行数:20,代码来源:LoginActivity.java

示例12: setPhoto

import com.vk.sdk.api.VKError; //导入依赖的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);
        }
    });
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:30,代码来源:VkSdkHelper.java

示例13: onActivityResult

import com.vk.sdk.api.VKError; //导入依赖的package包/类
public static boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data, @NonNull VKCallback<VKAccessToken> vkCallback) {
    if (requestCode == VKServiceActivity.VKServiceType.Authorization.getOuterCode()) {
        if (resultCode == VKSdk.RESULT_OK) {
            vkCallback.onResult(VKAccessToken.currentToken());
        } else if (resultCode == VKSdk.RESULT_ERROR) {
            vkCallback.onError((VKError) VKObject.getRegisteredObject(data == null ? 0 : data.getLongExtra(VKSdk.EXTRA_ERROR_ID, 0)));
        }
        return true;
    } else {
        return false;
    }
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:13,代码来源:VKSdk.java

示例14: wakeUpSession

import com.vk.sdk.api.VKError; //导入依赖的package包/类
/**
 * Checks if an access token exist and performs a try to use it again
 *
 * @param context            An application context for store an access token
 * @param loginStateCallback if callback specified, {@link VKCallback#onResult(Object)} method will be called after login state changed
 * @return true, if an access token exists and not expired
 */
public static boolean wakeUpSession(@NonNull final Context context, final VKCallback<LoginState> loginStateCallback) {
    final Context appContext = context.getApplicationContext();
    VKUIHelper.setApplicationContext(appContext);

    VKAccessToken token = VKAccessToken.currentToken();

    if (token != null && token.accessToken != null && !token.isExpired()) {
        forceLoginState(LoginState.Pending, loginStateCallback);
        trackVisitor(new VKRequest.VKRequestListener() {
            @Override
            public void onComplete(VKResponse response) {
                updateLoginState(context, loginStateCallback);
            }

            @Override
            public void onError(VKError error) {
                //Possible double call of access token invalid
                if (error != null && error.apiError != null && error.apiError.errorCode == 5) {
                    onAccessTokenIsInvalid(appContext);
                }
                updateLoginState(context, loginStateCallback);
            }
        });
        return true;
    }
    updateLoginState(context, loginStateCallback);
    return false;
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:36,代码来源:VKSdk.java

示例15: onError

import com.vk.sdk.api.VKError; //导入依赖的package包/类
@Override
public void onError(VKError error) {
    synchronized (this.syncObj) {
        try {
            listener.onError(error);
        } catch (Exception e) {
            // nothing
        }
        isFinish = true;
        syncObj.notifyAll();
    }
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:13,代码来源:VKSyncRequestUtil.java


注:本文中的com.vk.sdk.api.VKError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。