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


Java VKSdk类代码示例

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


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

示例1: shareVK

import com.vk.sdk.VKSdk; //导入依赖的package包/类
private void shareVK() {
    if (VKSdk.isLoggedIn() || VKSdk.wakeUpSession()) {
        new VKShareDialog()
                .setText(getString(R.string.like_text))
                .setAttachmentLink(getString(R.string.like_url_title), getString(R.string.like_url))
                .setShareDialogListener(new VKShareDialog.VKShareDialogListener() {
                    @Override
                    public void onVkShareComplete(int i) {
                        showThankYouToast();

                        ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
                                .send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("VK").setLabel("OK").build());
                    }

                    @Override
                    public void onVkShareCancel() {
                        ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER)
                                .send(new HitBuilders.EventBuilder().setCategory("Sharing").setAction("VK").setLabel("Cancel").build());
                    }
                })
                .show(getFragmentManager(), "SHARE");

    } else
        VKSdk.authorize(NavigationActivity.vkScope, true, false);
}
 
开发者ID:dmllr,项目名称:IdealMedia,代码行数:26,代码来源:NavigationDrawerFragment.java

示例2: onActivityResult

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

示例3: logout

import com.vk.sdk.VKSdk; //导入依赖的package包/类
public void logout() {
    if (AccessToken.getCurrentAccessToken() != null) {
        LoginManager.getInstance().logOut();
        Logger.printInfo(LOG_TAG, "Loged out from facebook");
    }
    if (Twitter.getSessionManager().getActiveSession() != null) {
        Twitter.getSessionManager().clearActiveSession();
        Twitter.logOut();
        Logger.printInfo(LOG_TAG, "Loged out from twitter");
    }
    if (VKSdk.isLoggedIn()) {
        VKSdk.logout();
        Logger.printInfo(LOG_TAG, "Loged out from vk");
    }
    Prefs.remove(SyncMaster.GLOBAL_TOKEN);
    userProfile = new UserProfile();
}
 
开发者ID:KKorvin,项目名称:uPods-android,代码行数:18,代码来源:LoginMaster.java

示例4: initUserProfile

import com.vk.sdk.VKSdk; //导入依赖的package包/类
public void initUserProfile(final IOperationFinishWithDataCallback profileFetched, boolean isForceUpdate) {
    if (userProfile != null && !isForceUpdate) {
        profileFetched.operationFinished(userProfile);
    } else if (!isLogedIn()) {
        userProfile = new UserProfile();
        profileFetched.operationFinished(userProfile);
    } else {
        if (AccessToken.getCurrentAccessToken() != null) {
            fetchFacebookUserData(profileFetched);
        } else if (Twitter.getSessionManager().getActiveSession() != null) {
            fetchTwitterUserData(profileFetched);
        } else if (VKSdk.isLoggedIn()) {
            fetchVkUserData(profileFetched);
        }
    }
}
 
开发者ID:KKorvin,项目名称:uPods-android,代码行数:17,代码来源:LoginMaster.java

示例5: onResume

import com.vk.sdk.VKSdk; //导入依赖的package包/类
@Override
protected void onResume() {
    if(internetConnection.isNetworkConnected(getApplicationContext())){
    if (VKSdk.isLoggedIn()) {
        new VkSdkHelper(getApplicationContext()).setPhoto(vkimage, vkLoginButton);
    }
    else {
        vkimage.setVisibility(View.GONE);
        vkLoginButton.setVisibility(View.VISIBLE);
    }
    if (AccessToken.getCurrentAccessToken() != null) {
        new FacebookSdkHelper(getApplicationContext()).setPhoto(facebookImage,facebookLoginButton);
    }
    else {
        facebookImage.setVisibility(View.GONE);
        facebookLoginButton.setVisibility(View.VISIBLE);
    }}
    super.onResume();
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:20,代码来源:MainActivity.java

示例6: postExecution

import com.vk.sdk.VKSdk; //导入依赖的package包/类
@Override
protected boolean postExecution() {
    if (!super.postExecution())
        return false;

    if (mParser != null) {
        try {
            JSONObject response = getResponseJson();
            parsedModel = mParser.createModel(response);
            return true;
        } catch (Exception e) {
            if (VKSdk.DEBUG) {
                e.printStackTrace();
            }
        }
    }
    return false;
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:19,代码来源:VKModelOperation.java

示例7: fill

import com.vk.sdk.VKSdk; //导入依赖的package包/类
/**
 * Fills list according with data in {@code from}.
 * @param from an array of items in the list. You can use null.
 * @param creator interface implementation to parse objects.
 */
public void fill(JSONArray from, Parser<? extends T> creator) {
    if(from != null) {
        for(int i = 0; i < from.length(); i++) {
            try {
                T object = creator.parseObject(from.getJSONObject(i));
                if(object != null) {
                    items.add(object);
                }
            } catch (Exception e) {
                if (VKSdk.DEBUG)
                    e.printStackTrace();
            }
        }
    }
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:21,代码来源:VKList.java

示例8: getTmpFile

import com.vk.sdk.VKSdk; //导入依赖的package包/类
public File getTmpFile() {
    Context ctx = VKUIHelper.getApplicationContext();
    File outputDir = null;
    if (ctx != null) {
        outputDir = ctx.getExternalCacheDir();
        if (outputDir == null || !outputDir.canWrite())
            outputDir = ctx.getCacheDir();
    }
    File tmpFile = null;
    try {
        tmpFile = File.createTempFile("tmpImg", String.format(".%s", mParameters.fileExtension()), outputDir);
        FileOutputStream fos = new FileOutputStream(tmpFile);
        if (mParameters.mImageType == VKImageParameters.VKImageType.Png)
            mImageData.compress(Bitmap.CompressFormat.PNG, 100, fos);
        else
            mImageData.compress(Bitmap.CompressFormat.JPEG, (int) (mParameters.mJpegQuality * 100), fos);
        fos.close();
    } catch (IOException ignored) {
        if (VKSdk.DEBUG)
            ignored.printStackTrace();
    }
    return tmpFile;
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:24,代码来源:VKUploadImage.java

示例9: onClick

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

示例10: md5

import com.vk.sdk.VKSdk; //导入依赖的package包/类
/**
 * Returns md5 hash of string
 *
 * @param s string to hash
 * @return md5 hash
 */
public static String md5(final String s) {
    try {
        // Create MD5 Hash
        MessageDigest digest = MessageDigest.getInstance("MD5");
        digest.update(s.getBytes());
        byte messageDigest[] = digest.digest();

        // Create Hex String
        StringBuilder hexString = new StringBuilder();
        for (byte aMessageDigest : messageDigest) {
            String h = Integer.toHexString(0xFF & aMessageDigest);
            while (h.length() < 2)
                h = "0" + h;
            hexString.append(h);
        }
        return hexString.toString();

    } catch (NoSuchAlgorithmException e) {
        if (VKSdk.DEBUG)
            e.printStackTrace();
    }
    return "";
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:30,代码来源:VKUtil.java

示例11: mapFrom

import com.vk.sdk.VKSdk; //导入依赖的package包/类
/**
 * Builds map from list of strings
 *
 * @param args key-value pairs for build a map. Must be a multiple of 2
 * @return Result map. If args not multiple of 2, last argument will be ignored
 */
public static Map<String, Object> mapFrom(Object... args) {
    if (args.length % 2 != 0) {
        if (VKSdk.DEBUG)
            Log.w("VKUtil", "Params must be paired. Last one is ignored");
    }
    LinkedHashMap<String, Object> result = new LinkedHashMap<>(args.length / 2);
    for (int i = 0; i + 1 < args.length; i += 2) {
        if (args[i] == null || args[i + 1] == null || !(args[i] instanceof String)) {
            if (VKSdk.DEBUG)
                Log.e("VK SDK", "Error while using mapFrom", new InvalidParameterSpecException("Key and value must be specified. Key must be string"));
            continue;
        }
        result.put((String) args[i], args[i + 1]);
    }
    return result;
}
 
开发者ID:DESTROYED,项目名称:The_busy_calendar,代码行数:23,代码来源:VKUtil.java

示例12: onActivityResult

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

示例13: onActivityResult

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

示例14: onItemClick

import com.vk.sdk.VKSdk; //导入依赖的package包/类
@Override
public void onItemClick(int position) {
    ISocialType type = socialList.get(position);
    analytic.reportEvent(Analytic.Interaction.CLICK_SIGN_IN_SOCIAL, type.getIdentifier());
    if (type == SocialManager.SocialType.google) {
        if (client == null) {
            analytic.reportEvent(Analytic.Interaction.GOOGLE_SOCIAL_IS_NOT_ENABLED);
            Toast.makeText(App.Companion.getAppContext(), R.string.google_services_late, Toast.LENGTH_SHORT).show();
        } else {
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(client);
            activity.startActivityForResult(signInIntent, AppConstants.REQUEST_CODE_GOOGLE_SIGN_IN);
        }
    } else if (type == SocialManager.SocialType.facebook) {
        List<String> permissions = new ArrayList<>();
        permissions.add("email");
        LoginManager.getInstance().logInWithReadPermissions(activity, permissions);
    } else if (type == SocialManager.SocialType.vk) {
        String[] scopes = {VKScope.EMAIL};
        VKSdk.login(activity, scopes);
    } else {
        api.loginWithSocial(activity, type);
    }
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:24,代码来源:SocialAuthAdapter.java

示例15: onClick

import com.vk.sdk.VKSdk; //导入依赖的package包/类
@Override
public void onClick(DialogInterface dialog, int which) {
    switch (which){
        case Dialog.BUTTON_POSITIVE:
            VKSdk.logout();

            if (!VKSdk.isLoggedIn()) {
                // останавливаем проигрывание музыки
                Intent musicServiceIntent = new Intent(getActivity(), MusicService.class);
                musicServiceIntent.setAction(MusicService.ACTION_STOP);
                getActivity().startService(musicServiceIntent);

                // очищаем кэш
                PlayListManager.getInstance().clearAll();
                CacheData.getInstance().clearAll();
                // сброс настроек
                UserPreferences.getInstance().reset();

                // переходим в окно логина
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                startActivity(intent);
            }
            break;
    }
}
 
开发者ID:DmitriyG1,项目名称:vk-music-player-android,代码行数:26,代码来源:SettingsFragment.java


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