_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q169100
Facebook.authorize
validation
public void authorize(Activity activity, final DialogListener listener) { authorize(activity, new String[] {}, DEFAULT_AUTH_ACTIVITY_CODE, listener); }
java
{ "resource": "" }
q169101
Facebook.authorize
validation
public void authorize(Activity activity, String[] permissions, int activityCode, final DialogListener listener) { boolean singleSignOnStarted = false; mAuthDialogListener = listener; // Prefer single sign-on, where available. if (activityCode >= 0) { singleSignOnStarted = startSingleSignOn(activity, mAppId, permissions, activityCode); } // Otherwise fall back to traditional dialog. if (!singleSignOnStarted) { startDialogAuth(activity, permissions); } }
java
{ "resource": "" }
q169102
Facebook.validateActivityIntent
validation
private boolean validateActivityIntent(Context context, Intent intent) { ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, 0); if (resolveInfo == null) { return false; } return validateAppSignatureForPackage( context, resolveInfo.activityInfo.packageName); }
java
{ "resource": "" }
q169103
Facebook.logout
validation
public String logout(Context context) throws MalformedURLException, IOException { Util.clearCookies(context); Bundle b = new Bundle(); b.putString("method", "auth.expireSession"); String response = request(b); setAccessToken(null); setAccessExpires(0); return response; }
java
{ "resource": "" }
q169104
Facebook.dialog
validation
public void dialog(Context context, String action, Bundle parameters, final DialogListener listener) { String endpoint = DIALOG_BASE_URL + action; parameters.putString("display", "touch"); parameters.putString("redirect_uri", REDIRECT_URI); if (action.equals(LOGIN)) { parameters.putString("type", "user_agent"); parameters.putString("client_id", mAppId); } else { parameters.putString("app_id", mAppId); } if (isSessionValid()) { parameters.putString(TOKEN, getAccessToken()); } String url = endpoint + "?" + Util.encodeUrl(parameters); if (context.checkCallingOrSelfPermission(Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) { Util.showAlert(context, "Error", "Application requires permission to access the Internet"); } else { new FbDialog(context, url, listener).show(); } }
java
{ "resource": "" }
q169105
DefaultDateTypeAdapter.serialize
validation
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) { synchronized (localFormat) { String dateFormatAsString = enUsFormat.format(src); return new JsonPrimitive(dateFormatAsString); } }
java
{ "resource": "" }
q169106
FacebookUtils.link
validation
@Deprecated public static void link (Activity context, SocializeAuthListener listener) { proxy.link(context, listener); }
java
{ "resource": "" }
q169107
FacebookUtils.link
validation
@Deprecated public static void link (Activity context, SocializeAuthListener listener, String...permissions) { proxy.link(context, listener, permissions); }
java
{ "resource": "" }
q169108
FacebookUtils.link
validation
@Deprecated public static void link (Activity context, String token, boolean verifyPermissions, SocializeAuthListener listener){ proxy.link(context, token, verifyPermissions, listener); }
java
{ "resource": "" }
q169109
FacebookUtils.postEntity
validation
public static void postEntity(final Activity context, final Entity entity, final String text, final SocialNetworkShareListener listener){ if(proxy.isLinkedForWrite(context)) { proxy.postEntity(context, entity, text, listener); } else { proxy.linkForWrite(context, new SocializeAuthListener() { @Override public void onError(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.FACEBOOK, error); } } @Override public void onCancel() { if(listener != null) { listener.onCancel(); } } @Override public void onAuthSuccess(SocializeSession session) { proxy.postEntity(context, entity, text, listener); } @Override public void onAuthFail(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.FACEBOOK, error); } } }); } }
java
{ "resource": "" }
q169110
FacebookUtils.extendAccessToken
validation
@Deprecated public static void extendAccessToken(Activity context, SocializeAuthListener listener) { proxy.extendAccessToken(context, listener); }
java
{ "resource": "" }
q169111
FacebookUtils.getCurrentPermissions
validation
public static void getCurrentPermissions(Activity context, String token, OnPermissionResult callback) { proxy.getCurrentPermissions(context, token, callback); }
java
{ "resource": "" }
q169112
FacebookUtils.getHashKeys
validation
public static String[] getHashKeys(Activity context) throws NoSuchAlgorithmException { PackageInfo packageInfo = null; String[] keys = null; try { packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES); if(packageInfo != null && packageInfo.signatures != null && packageInfo.signatures.length > 0) { keys = new String[packageInfo.signatures.length]; for (int i = 0; i < packageInfo.signatures.length; i++) { Signature signature = packageInfo.signatures[i]; MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(signature.toByteArray()); String hash = new String(Base64.encode(md.digest(), 0)); keys[i] = hash; } } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return keys; }
java
{ "resource": "" }
q169113
EntityUtils.saveEntity
validation
public static void saveEntity (Activity context, Entity e, EntityAddListener listener) { proxy.saveEntity(context, e, listener); }
java
{ "resource": "" }
q169114
EntityUtils.getEntity
validation
public static void getEntity (Activity context, String key, EntityGetListener listener) { proxy.getEntity(context, key, listener); }
java
{ "resource": "" }
q169115
EntityUtils.getEntity
validation
public static void getEntity (Activity context, long id, EntityGetListener listener) { proxy.getEntity(context, id, listener); }
java
{ "resource": "" }
q169116
EntityUtils.getEntities
validation
public static void getEntities (Activity context, int start, int end, EntityListListener listener) { proxy.getEntities(context, start, end, SortOrder.CREATION_DATE, listener); }
java
{ "resource": "" }
q169117
EntityUtils.getEntities
validation
public static void getEntities (Activity context, EntityListListener listener, String...keys) { proxy.getEntities(context, SortOrder.CREATION_DATE, listener, keys); }
java
{ "resource": "" }
q169118
DefaultSocializeActivityLifecycleListener.onCreateContextMenu
validation
@Override public boolean onCreateContextMenu(SocializeUIActivity activity, ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { return false; }
java
{ "resource": "" }
q169119
SubscriptionUtils.subscribe
validation
public static void subscribe (Activity context, Entity e, SubscriptionType type, SubscriptionResultListener listener) { subscriptionUtils.subscribe(context, e, type, listener); }
java
{ "resource": "" }
q169120
SubscriptionUtils.isSubscribed
validation
public static void isSubscribed (Activity context, Entity e, SubscriptionType type, SubscriptionCheckListener listener) { subscriptionUtils.isSubscribed(context, e, type, listener); }
java
{ "resource": "" }
q169121
NotificationChecker.checkRegistrations
validation
public boolean checkRegistrations(Context context, SocializeSession session) { boolean checked = false; if(!checking) { checking = true; try { if(appUtils.isNotificationsAvailable(context)) { if(config.getBooleanProperty(SocializeConfig.SOCIALIZE_CHECK_NOTIFICATIONS, true)) { if(logger != null && logger.isDebugEnabled()) { logger.debug("Checking GCM registration state"); } boolean c2DMRegistered = notificationRegistrationSystem.isRegisteredC2DM(context); boolean socRegistered = notificationRegistrationSystem.isRegisteredSocialize(context, session.getUser()); if(!c2DMRegistered || !socRegistered) { // Reload notificationRegistrationState.reload(context); c2DMRegistered = notificationRegistrationSystem.isRegisteredC2DM(context); socRegistered = notificationRegistrationSystem.isRegisteredSocialize(context, session.getUser()); if(!c2DMRegistered || !socRegistered) { if(!c2DMRegistered && config.getBooleanProperty(SocializeConfig.GCM_REGISTRATION_ENABLED, true)) { if(notificationRegistrationSystem.isRegistrationPending()) { if(logger != null && logger.isDebugEnabled()) { logger.debug("GCM Registration already pending"); } } else { if(logger != null && logger.isInfoEnabled()) { logger.info("Not registered with GCM, sending registration request..."); } notificationRegistrationSystem.registerC2DMAsync(context); } } else if(!socRegistered && !StringUtils.isEmpty(notificationRegistrationState.getC2DMRegistrationId())) { if(notificationRegistrationSystem.isSocializeRegistrationPending()) { if(logger != null && logger.isDebugEnabled()) { logger.debug("Registration already pending with Socialize for GCM"); } } else { if(logger != null && logger.isInfoEnabled()) { logger.info("Not registered with Socialize for GCM, registering..."); } notificationRegistrationSystem.registerSocialize(context, notificationRegistrationState.getC2DMRegistrationId()); } } } else { if(logger != null && logger.isDebugEnabled()) { logger.debug("GCM registration OK"); } } } else { if(logger != null && logger.isDebugEnabled()) { logger.debug("GCM registration OK"); } } checked = true; } else { if(logger != null && logger.isWarnEnabled()) { logger.warn("GCM registration check skipped"); } } } else { if(logger != null && logger.isInfoEnabled()) { logger.info("Notifications not enabled. Check the AndroidManifest.xml for correct configuration."); } checked = true; } } finally { checking = false; } } return checked; }
java
{ "resource": "" }
q169122
JsonReader.peek
validation
public JsonToken peek() throws IOException { if (token != null) { return token; } switch (stack[stackSize - 1]) { case EMPTY_DOCUMENT: if (lenient) { consumeNonExecutePrefix(); } stack[stackSize - 1] = JsonScope.NONEMPTY_DOCUMENT; JsonToken firstToken = nextValue(); if (!lenient && token != JsonToken.BEGIN_ARRAY && token != JsonToken.BEGIN_OBJECT) { throw new IOException("Expected JSON document to start with '[' or '{' but was " + token + " at line " + getLineNumber() + " column " + getColumnNumber()); } return firstToken; case EMPTY_ARRAY: return nextInArray(true); case NONEMPTY_ARRAY: return nextInArray(false); case EMPTY_OBJECT: return nextInObject(true); case DANGLING_NAME: return objectValue(); case NONEMPTY_OBJECT: return nextInObject(false); case NONEMPTY_DOCUMENT: int c = nextNonWhitespace(false); if (c == -1) { return JsonToken.END_DOCUMENT; } pos--; if (!lenient) { throw syntaxError("Expected EOF"); } return nextValue(); case CLOSED: throw new IllegalStateException("JsonReader is closed"); default: throw new AssertionError(); } }
java
{ "resource": "" }
q169123
JsonReader.nextNull
validation
public void nextNull() throws IOException { peek(); if (token != JsonToken.NULL) { throw new IllegalStateException("Expected null but was " + token + " at line " + getLineNumber() + " column " + getColumnNumber()); } advance(); }
java
{ "resource": "" }
q169124
JsonReader.readEscapeCharacter
validation
private char readEscapeCharacter() throws IOException { if (pos == limit && !fillBuffer(1)) { throw syntaxError("Unterminated escape sequence"); } char escaped = buffer[pos++]; switch (escaped) { case 'u': if (pos + 4 > limit && !fillBuffer(4)) { throw syntaxError("Unterminated escape sequence"); } // Equivalent to Integer.parseInt(stringPool.get(buffer, pos, 4), 16); char result = 0; for (int i = pos, end = i + 4; i < end; i++) { char c = buffer[i]; result <<= 4; if (c >= '0' && c <= '9') { result += (c - '0'); } else if (c >= 'a' && c <= 'f') { result += (c - 'a' + 10); } else if (c >= 'A' && c <= 'F') { result += (c - 'A' + 10); } else { throw new NumberFormatException("\\u" + stringPool.get(buffer, pos, 4)); } } pos += 4; return result; case 't': return '\t'; case 'b': return '\b'; case 'n': return '\n'; case 'r': return '\r'; case 'f': return '\f'; case '\'': case '"': case '\\': default: return escaped; } }
java
{ "resource": "" }
q169125
ShareUtils.showShareDialog
validation
public static void showShareDialog (Activity context, Entity entity) { proxy.showShareDialog(context, entity, DEFAULT, null, null); }
java
{ "resource": "" }
q169126
ShareUtils.showShareDialog
validation
public static void showShareDialog (Activity context, Entity entity, SocialNetworkDialogListener listener) { proxy.showShareDialog(context, entity, DEFAULT, listener, listener); }
java
{ "resource": "" }
q169127
ShareUtils.shareViaEmail
validation
public static void shareViaEmail(Activity context, Entity entity, ShareAddListener listener) { proxy.shareViaEmail(context, entity, listener); }
java
{ "resource": "" }
q169128
ShareUtils.shareViaGooglePlus
validation
public static void shareViaGooglePlus(Activity context, Entity entity, ShareAddListener listener) { proxy.shareViaGooglePlus(context, entity, listener); }
java
{ "resource": "" }
q169129
ShareUtils.shareViaOther
validation
public static void shareViaOther(Activity context, Entity entity, ShareAddListener listener) { proxy.shareViaOther(context, entity, listener); }
java
{ "resource": "" }
q169130
ShareUtils.shareViaSMS
validation
public static void shareViaSMS(Activity context, Entity entity, ShareAddListener listener) { proxy.shareViaSMS(context, entity, listener); }
java
{ "resource": "" }
q169131
ShareUtils.shareViaSocialNetworks
validation
public static void shareViaSocialNetworks(Activity context, Entity entity, ShareOptions shareOptions, SocialNetworkShareListener listener, SocialNetwork...networks) { proxy.shareViaSocialNetworks(context, entity, shareOptions, listener, networks); }
java
{ "resource": "" }
q169132
ShareUtils.getShare
validation
public static void getShare (Activity context, ShareGetListener listener, long id) { proxy.getShare(context, listener, id); }
java
{ "resource": "" }
q169133
ShareUtils.getShares
validation
public static void getShares (Activity context, ShareListListener listener, long...ids) { proxy.getShares(context, listener, ids); }
java
{ "resource": "" }
q169134
ShareUtils.getSharesByUser
validation
public static void getSharesByUser (Activity context, User user, int start, int end, ShareListListener listener) { proxy.getSharesByUser(context, user, start, end, listener); }
java
{ "resource": "" }
q169135
ShareUtils.getSharesByEntity
validation
public static void getSharesByEntity (Activity context, String entityKey, int start, int end, ShareListListener listener) { proxy.getSharesByEntity(context, entityKey, start, end, listener); }
java
{ "resource": "" }
q169136
ShareUtils.getSharesByApplication
validation
public static void getSharesByApplication (Activity context, int start, int end, ShareListListener listener) { proxy.getSharesByApplication(context, start, end, listener); }
java
{ "resource": "" }
q169137
LikeUtils.like
validation
public static void like (Activity context, Entity entity, LikeAddListener listener) { proxy.like(context, entity, listener); }
java
{ "resource": "" }
q169138
LikeUtils.like
validation
public static void like (Activity context, Entity entity, LikeOptions likeOptions, LikeAddListener listener, SocialNetwork...networks) { proxy.like(context, entity, likeOptions, listener, networks); }
java
{ "resource": "" }
q169139
LikeUtils.unlike
validation
public static void unlike (Activity context, String entityKey, LikeDeleteListener listener) { proxy.unlike(context, entityKey, listener); }
java
{ "resource": "" }
q169140
LikeUtils.getLike
validation
public static void getLike (Activity context, String entityKey, LikeGetListener listener) { proxy.getLike(context, entityKey, listener); }
java
{ "resource": "" }
q169141
LikeUtils.getLike
validation
public static void getLike (Activity context, long id, LikeGetListener listener) { proxy.getLike(context, id, listener); }
java
{ "resource": "" }
q169142
LikeUtils.isLiked
validation
public static void isLiked(Activity context, String entityKey, IsLikedListener listener) { proxy.getLike(context, entityKey, listener); }
java
{ "resource": "" }
q169143
LikeUtils.getLikesByUser
validation
public static void getLikesByUser (Activity context, User user, int start, int end, LikeListListener listener) { proxy.getLikesByUser(context, user, start, end, listener); }
java
{ "resource": "" }
q169144
LikeUtils.getLikesByEntity
validation
public static void getLikesByEntity (Activity context, String entityKey, int start, int end, LikeListListener listener) { proxy.getLikesByEntity(context, entityKey, start, end, listener); }
java
{ "resource": "" }
q169145
FacebookUtilsImpl.getFacebook
validation
@Deprecated @Override public synchronized Facebook getFacebook(Context context) { if(facebook == null) { facebook = new Facebook(config.getProperty(SocializeConfig.FACEBOOK_APP_ID)); } return facebook; }
java
{ "resource": "" }
q169146
AbstractOAuthConsumer.collectHeaderParameters
validation
protected void collectHeaderParameters(HttpRequest request, HttpParameters out) { HttpParameters headerParams = OAuth.oauthHeaderToParamsMap(request.getHeader(OAuth.HTTP_AUTHORIZATION_HEADER)); out.putAll(headerParams, false); }
java
{ "resource": "" }
q169147
AbstractOAuthConsumer.collectBodyParameters
validation
protected void collectBodyParameters(HttpRequest request, HttpParameters out) throws IOException { // collect x-www-form-urlencoded body params String contentType = request.getContentType(); if (contentType != null && contentType.startsWith(OAuth.FORM_ENCODED)) { InputStream payload = request.getMessagePayload(); out.putAll(OAuth.decodeForm(payload), true); } }
java
{ "resource": "" }
q169148
AbstractOAuthConsumer.collectQueryParameters
validation
protected void collectQueryParameters(HttpRequest request, HttpParameters out) { String url = request.getRequestUrl(); int q = url.indexOf('?'); if (q >= 0) { // Combine the URL query string with the other parameters: out.putAll(OAuth.decodeForm(url.substring(q + 1)), true); } }
java
{ "resource": "" }
q169149
Gson.newJsonWriter
validation
private JsonWriter newJsonWriter(Writer writer) throws IOException { if (generateNonExecutableJson) { writer.write(JSON_NON_EXECUTABLE_PREFIX); } JsonWriter jsonWriter = new JsonWriter(writer); if (prettyPrinting) { jsonWriter.setIndent(" "); } jsonWriter.setSerializeNulls(serializeNulls); return jsonWriter; }
java
{ "resource": "" }
q169150
ConstructorConstructor.newDefaultImplementationConstructor
validation
@SuppressWarnings("unchecked") // use runtime checks to guarantee that 'T' is what it is private <T> ObjectConstructor<T> newDefaultImplementationConstructor(Class<? super T> rawType) { if (Collection.class.isAssignableFrom(rawType)) { if (SortedSet.class.isAssignableFrom(rawType)) { return new ObjectConstructor<T>() { public T construct() { return (T) new TreeSet<Object>(); } }; } else if (Set.class.isAssignableFrom(rawType)) { return new ObjectConstructor<T>() { public T construct() { return (T) new LinkedHashSet<Object>(); } }; } else if (Queue.class.isAssignableFrom(rawType)) { return new ObjectConstructor<T>() { public T construct() { return (T) new LinkedList<Object>(); } }; } else { return new ObjectConstructor<T>() { public T construct() { return (T) new ArrayList<Object>(); } }; } } if (Map.class.isAssignableFrom(rawType)) { return new ObjectConstructor<T>() { public T construct() { return (T) new LinkedHashMap<Object, Object>(); } }; // TODO: SortedMap ? } return null; }
java
{ "resource": "" }
q169151
StringUtils.replaceNewLines
validation
public static String replaceNewLines(String src, int from, int to) { if(src != null && from > 0 && to < from) { String strFrom = ""; String strTo = ""; for (int i = 0; i < from; i++) { strFrom+="\n"; } for (int i = 0; i < to; i++) { strTo+="\n"; } while (src.contains(strFrom)) { src = src.replaceAll(strFrom, strTo); } } return src; }
java
{ "resource": "" }
q169152
ActionBarReload.reload
validation
void reload() { //begin-snippet-1 // The in the Activity which renders the ActionBar Entity entity = Entity.newInstance("http://getsocialize.com", "Socialize"); // Setup a listener to retain a reference MyActionBarListener listener = new MyActionBarListener(); // Use the listener when you show the action bar // The "this" argument refers to the current Activity ActionBarUtils.showActionBar(this, R.layout.actionbar, entity, null, listener); // Later (After the action bar has loaded!), you can reference the view to refresh ActionBarView view = listener.getActionBarView(); if (view != null) { Entity newEntity = new Entity(); // This would be your new entity view.setEntity(newEntity); view.refresh(); } //end-snippet-1 }
java
{ "resource": "" }
q169153
GeoUtils.getSimpleLocation
validation
public String getSimpleLocation(Address address) { StringBuilder builder = new StringBuilder(); String locality = address.getLocality(); String countryName = address.getCountryName(); if(!StringUtils.isEmpty(locality)) { builder.append(locality); } else if(!StringUtils.isEmpty(countryName)) { builder.append(countryName); } return builder.toString(); }
java
{ "resource": "" }
q169154
FacebookFacadeV3.getUser
validation
protected void getUser(final Session session, final AuthProviderListener listener) { Request.executeMeRequestAsync(session, new Request.GraphUserCallback() { // callback after Graph API response with user object @Override public void onCompleted(GraphUser user, Response response) { if(response.getError() != null) { handleError(response.getError().getException(), listener); } else if (user != null) { handleResult(session, user, listener); } } }); }
java
{ "resource": "" }
q169155
ActionUtils.getActionsByApplication
validation
public static void getActionsByApplication (Activity context, int start, int end, ActionListListener listener) { proxy.getActionsByApplication(context, start, end, listener); }
java
{ "resource": "" }
q169156
ActionUtils.getActionsByUser
validation
public static void getActionsByUser (Activity context, long userId, int start, int end, ActionListListener listener) { proxy.getActionsByUser(context, userId, start, end, listener); }
java
{ "resource": "" }
q169157
ActionUtils.getActionsByEntity
validation
public static void getActionsByEntity (Activity context, String entityKey, int start, int end, ActionListListener listener) { proxy.getActionsByEntity(context, entityKey, start, end, listener); }
java
{ "resource": "" }
q169158
ActionUtils.getActionsByUserAndEntity
validation
public static void getActionsByUserAndEntity (Activity context, long userId, String entityKey, int start, int end, ActionListListener listener) { proxy.getActionsByUserAndEntity(context, userId, entityKey, start, end, listener); }
java
{ "resource": "" }
q169159
JsonWriter.close
validation
private JsonWriter close(JsonScope empty, JsonScope nonempty, String closeBracket) throws IOException { JsonScope context = peek(); if (context != nonempty && context != empty) { throw new IllegalStateException("Nesting problem: " + stack); } if (deferredName != null) { throw new IllegalStateException("Dangling name: " + deferredName); } stack.remove(stack.size() - 1); if (context == nonempty) { newline(); } out.write(closeBracket); return this; }
java
{ "resource": "" }
q169160
JsonWriter.name
validation
public JsonWriter name(String name) throws IOException { if (name == null) { throw new NullPointerException("name == null"); } if (deferredName != null) { throw new IllegalStateException(); } deferredName = name; return this; }
java
{ "resource": "" }
q169161
JsonParser.parse
validation
public JsonElement parse(Reader json) throws JsonIOException, JsonSyntaxException { try { JsonReader jsonReader = new JsonReader(json); JsonElement element = parse(jsonReader); if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) { throw new JsonSyntaxException("Did not consume the entire document."); } return element; } catch (MalformedJsonException e) { throw new JsonSyntaxException(e); } catch (IOException e) { throw new JsonIOException(e); } catch (NumberFormatException e) { throw new JsonSyntaxException(e); } }
java
{ "resource": "" }
q169162
JsonParser.parse
validation
public JsonElement parse(JsonReader json) throws JsonIOException, JsonSyntaxException { boolean lenient = json.isLenient(); json.setLenient(true); try { return Streams.parse(json); } catch (StackOverflowError e) { throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e); } catch (OutOfMemoryError e) { throw new JsonParseException("Failed parsing JSON source: " + json + " to Json", e); } catch (JsonParseException e) { if (e.getCause() instanceof EOFException) { return JsonNull.INSTANCE; } throw e; } finally { json.setLenient(lenient); } }
java
{ "resource": "" }
q169163
TwitterUtils.link
validation
public static void link (Activity context, String token, String secret, SocializeAuthListener listener) { proxy.link(context, token, secret, listener); }
java
{ "resource": "" }
q169164
TwitterUtils.setCredentials
validation
public static void setCredentials(Context context, String consumerKey, String consumerSecret) { proxy.setCredentials(context, consumerKey, consumerSecret); }
java
{ "resource": "" }
q169165
TwitterUtils.tweetEntity
validation
public static void tweetEntity(final Activity context, final Entity entity, final String text, final SocialNetworkShareListener listener) { if(proxy.isLinked(context)) { proxy.tweetEntity(context, entity, text, listener); } else { proxy.link(context, new SocializeAuthListener() { @Override public void onError(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.TWITTER, error); } } @Override public void onCancel() { if(listener != null) { listener.onCancel(); } } @Override public void onAuthSuccess(SocializeSession session) { proxy.tweetEntity(context, entity, text, listener); } @Override public void onAuthFail(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.TWITTER, error); } } }); } }
java
{ "resource": "" }
q169166
TwitterUtils.get
validation
public static void get(final Activity context, final String resource, final Map<String, Object> params, final SocialNetworkPostListener listener) { if(proxy.isLinked(context)) { proxy.get(context, resource, params, listener); } else { proxy.link(context, new SocializeAuthListener() { @Override public void onError(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.TWITTER, error); } } @Override public void onCancel() { if(listener != null) { listener.onCancel(); } } @Override public void onAuthSuccess(SocializeSession session) { proxy.get(context, resource, params, listener); } @Override public void onAuthFail(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.TWITTER, error); } } }); } }
java
{ "resource": "" }
q169167
TwitterUtils.tweet
validation
public static void tweet(final Activity context, final Tweet tweet, final SocialNetworkListener listener) { if(proxy.isLinked(context)) { proxy.tweet(context, tweet, listener); } else { proxy.link(context, new SocializeAuthListener() { @Override public void onError(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.TWITTER, error); } } @Override public void onCancel() { if(listener != null) { listener.onCancel(); } } @Override public void onAuthSuccess(SocializeSession session) { proxy.tweet(context, tweet, listener); } @Override public void onAuthFail(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.TWITTER, error); } } }); } }
java
{ "resource": "" }
q169168
TwitterUtils.tweetPhoto
validation
public static void tweetPhoto(final Activity context, final PhotoTweet photo, final SocialNetworkPostListener listener) { if(proxy.isLinked(context)) { proxy.tweetPhoto(context, photo, listener); } else { proxy.link(context, new SocializeAuthListener() { @Override public void onError(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.TWITTER, error); } } @Override public void onCancel() { if(listener != null) { listener.onCancel(); } } @Override public void onAuthSuccess(SocializeSession session) { proxy.tweetPhoto(context, photo, listener); } @Override public void onAuthFail(SocializeException error) { if(listener != null) { listener.onNetworkError(context, SocialNetwork.TWITTER, error); } } }); } }
java
{ "resource": "" }
q169169
BitmapUtils.getScaledBitmap
validation
public Bitmap getScaledBitmap(Bitmap bitmap, int scaleToWidth, int scaleToHeight, boolean recycleOriginal, int density) { bitmap.setDensity(density); Bitmap original = bitmap; if (scaleToWidth > 0 || scaleToHeight > 0) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); // scale lowest and crop highes if (height != scaleToHeight || width != scaleToWidth) { float ratio = 1.0f; // Scale to smallest if (height > width) { ratio = (float) scaleToWidth / (float) width; width = scaleToWidth; height = Math.round((float) height * ratio); bitmap = bitmapBuilder.scale(bitmap, width, height); width = bitmap.getWidth(); height = bitmap.getHeight(); if (height > scaleToHeight) { // crop height int diff = height - scaleToHeight; int half = Math.round((float) diff / 2.0f); bitmap = bitmapBuilder.crop(bitmap, 0, half, width, scaleToHeight); } } else { ratio = (float) scaleToHeight / (float) height; height = scaleToHeight; width = Math.round((float) width * ratio); bitmap = bitmapBuilder.scale(bitmap, width, height); width = bitmap.getWidth(); height = bitmap.getHeight(); if (width > scaleToWidth) { // crop width int diff = width - scaleToWidth; int half = Math.round((float) diff / 2.0f); bitmap = bitmapBuilder.crop(bitmap, half, 0, scaleToWidth, height); } } if(recycleOriginal) { original.recycle(); } } } return bitmap; }
java
{ "resource": "" }
q169170
SocializeApi.putAsPostAsync
validation
@SuppressWarnings("unchecked") public void putAsPostAsync(SocializeSession session, String endpoint, T object, SocializeActionListener listener) { AsyncPutter poster = new AsyncPutter(session, listener); SocializePutRequest<T> request = new SocializePutRequest<T>(); request.setRequestType(RequestType.PUT_AS_POST); request.setEndpoint(endpoint); request.setObject(object); poster.execute(request); }
java
{ "resource": "" }
q169171
SocializeButton.setTextSize
validation
public void setTextSize(int textSize) { if(textView != null) { textView.setTextSize(android.util.TypedValue.COMPLEX_UNIT_DIP, textSize); } this.textSize = textSize; }
java
{ "resource": "" }
q169172
ProfileView.onImageChange
validation
public void onImageChange(Bitmap bitmap, String localPath) { if(profileLayoutView != null) { profileLayoutView.onImageChange(bitmap); } // Set the image in the user settings try { UserUtils.getUserSettings(getContext()).setLocalImagePath(localPath); } catch (SocializeException e) { Log.e(SocializeLogger.LOG_TAG, "Error getting user settings", e); } }
java
{ "resource": "" }
q169173
UserUtils.saveUserAsync
validation
public static void saveUserAsync(Context context, User user, UserSaveListener listener) { proxy.saveUserAsync(context, user, listener); }
java
{ "resource": "" }
q169174
UserUtils.getUser
validation
public static void getUser(Context context, long id, UserGetListener listener) { proxy.getUser(context, id, listener); }
java
{ "resource": "" }
q169175
UserUtils.saveUserSettings
validation
public static void saveUserSettings (Context context, UserSettings userSettings, UserSaveListener listener) { proxy.saveUserSettings(context, userSettings, listener); }
java
{ "resource": "" }
q169176
User.setAutoPostPreferences
validation
@Deprecated public boolean setAutoPostPreferences(SocialNetwork...networks) { boolean tw = isAutoPostToTwitter(); boolean fb = isAutoPostToFacebook(); setAutoPostToFacebook(false); setAutoPostToTwitter(false); if(networks != null) { for (SocialNetwork network : networks) { if(network.equals(SocialNetwork.FACEBOOK)) { setAutoPostToFacebook(true); } else if(network.equals(SocialNetwork.TWITTER)) { setAutoPostToTwitter(true); } } } return tw != isAutoPostToTwitter() || fb != isAutoPostToFacebook(); }
java
{ "resource": "" }
q169177
FacebookService.authenticate
validation
@Deprecated public void authenticate(Activity context) { authenticate(context, FacebookFacade.DEFAULT_PERMISSIONS, true, false); }
java
{ "resource": "" }
q169178
FacebookService.authenticateForRead
validation
public void authenticateForRead(Activity context, boolean sso, String[] permissions) { authenticate(context, permissions, sso, true); }
java
{ "resource": "" }
q169179
ReflectionUtils.getStaticField
validation
@SuppressWarnings("unchecked") public static final <E extends Object> E getStaticField(String fieldName, Class<?> clazz) throws Exception { try { Field field = clazz.getField(fieldName); if(field != null) { return (E) field.get(null); } } catch (Exception e) { throw e; } return null; }
java
{ "resource": "" }
q169180
ReflectionUtils.getStaticFieldName
validation
public static final String getStaticFieldName(Object value, Class<?> clazz) throws Exception { Field[] fields = clazz.getFields(); for (Field field : fields) { Object fVal = field.get(null); if(fVal != null && fVal.equals(value)) { return field.getName(); } } return null; }
java
{ "resource": "" }
q169181
SmartAlertUtils.onMessage
validation
public static boolean onMessage(Context context, Intent intent) { assertInitialized(context); Bundle messageData = intent.getExtras(); if(messageData != null) { String source = messageData.getString(C2DMCallback.SOURCE_KEY); if(source != null && source.trim().equalsIgnoreCase(C2DMCallback.SOURCE_SOCIALIZE)) { handler.onMessage(context, intent); return true; } } return false; }
java
{ "resource": "" }
q169182
SmartAlertUtils.handleBroadcastIntent
validation
public static boolean handleBroadcastIntent(Context context, Intent intent) { return Socialize.getSocialize().handleBroadcastIntent(context, intent); }
java
{ "resource": "" }
q169183
Base64Utils.encode
validation
public byte[] encode(byte[] source, int off, int len, byte[] alphabet, int maxLineLength) { int lenDiv3 = (len + 2) / 3; // ceil(len / 3) int len43 = lenDiv3 * 4; byte[] outBuff = new byte[len43 // Main 4:3 + (len43 / maxLineLength)]; // New lines int d = 0; int e = 0; int len2 = len - 2; int lineLength = 0; for (; d < len2; d += 3, e += 4) { // The following block of code is the same as // encode3to4( source, d + off, 3, outBuff, e, alphabet ); // but inlined for faster encoding (~20% improvement) int inBuff = ((source[d + off] << 24) >>> 8) | ((source[d + 1 + off] << 24) >>> 16) | ((source[d + 2 + off] << 24) >>> 24); outBuff[e] = alphabet[(inBuff >>> 18)]; outBuff[e + 1] = alphabet[(inBuff >>> 12) & 0x3f]; outBuff[e + 2] = alphabet[(inBuff >>> 6) & 0x3f]; outBuff[e + 3] = alphabet[(inBuff) & 0x3f]; lineLength += 4; if (lineLength == maxLineLength) { outBuff[e + 4] = NEW_LINE; e++; lineLength = 0; } // end if: end of line } // end for: each piece of array if (d < len) { encode3to4(source, d + off, len - d, outBuff, e, alphabet); lineLength += 4; if (lineLength == maxLineLength) { // Add a last newline outBuff[e + 4] = NEW_LINE; e++; } e += 4; } assert (e == outBuff.length); return outBuff; }
java
{ "resource": "" }
q169184
Base64Utils.decode
validation
public byte[] decode(byte[] source, int off, int len, byte[] decodabet) throws Base64DecoderException { int len34 = len * 3 / 4; byte[] outBuff = new byte[2 + len34]; // Upper limit on size of output int outBuffPosn = 0; byte[] b4 = new byte[4]; int b4Posn = 0; int i = 0; byte sbiCrop = 0; byte sbiDecode = 0; for (i = 0; i < len; i++) { sbiCrop = (byte) (source[i + off] & 0x7f); // Only the low seven bits sbiDecode = decodabet[sbiCrop]; if (sbiDecode >= WHITE_SPACE_ENC) { // White space Equals sign or better if (sbiDecode >= EQUALS_SIGN_ENC) { // An equals sign (for padding) must not occur at position 0 or 1 // and must be the last byte[s] in the encoded value if (sbiCrop == EQUALS_SIGN) { int bytesLeft = len - i; byte lastByte = (byte) (source[len - 1 + off] & 0x7f); if (b4Posn == 0 || b4Posn == 1) { throw new Base64DecoderException( "invalid padding byte '=' at byte offset " + i); } else if ((b4Posn == 3 && bytesLeft > 2) || (b4Posn == 4 && bytesLeft > 1)) { throw new Base64DecoderException( "padding byte '=' falsely signals end of encoded value " + "at offset " + i); } else if (lastByte != EQUALS_SIGN && lastByte != NEW_LINE) { throw new Base64DecoderException( "encoded value has invalid trailing byte"); } break; } b4[b4Posn++] = sbiCrop; if (b4Posn == 4) { outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, decodabet); b4Posn = 0; } } } else { throw new Base64DecoderException("Bad Base64 input character at " + i + ": " + source[i + off] + "(decimal)"); } } // Because web safe encoding allows non padding base64 encodes, we // need to pad the rest of the b4 buffer with equal signs when // b4Posn != 0. There can be at most 2 equal signs at the end of // four characters, so the b4 buffer must have two or three // characters. This also catches the case where the input is // padded with EQUALS_SIGN if (b4Posn != 0) { if (b4Posn == 1) { throw new Base64DecoderException("single trailing character at offset " + (len - 1)); } b4[b4Posn++] = EQUALS_SIGN; outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, decodabet); } byte[] out = new byte[outBuffPosn]; System.arraycopy(outBuff, 0, out, 0, outBuffPosn); return out; }
java
{ "resource": "" }
q169185
ViewUtils.view
validation
public static void view (Activity context, Entity e, ViewAddListener listener) { proxy.view(context, e, listener); }
java
{ "resource": "" }
q169186
CommentListView.onProfileUpdate
validation
public void onProfileUpdate() { commentAdapter.notifyDataSetChanged(); if(commentEntrySlider != null) { commentEntrySlider.updateContent(); } if(notifyBox != null) { try { UserSettings user = userUtils.getUserSettings(getContext()); if(user.isNotificationsEnabled()) { notifyBox.setVisibility(View.VISIBLE); } else { notifyBox.setVisibility(View.GONE); } } catch (SocializeException e) { if(logger != null) { logger.error("Error getting user settings", e); } else { e.printStackTrace(); } notifyBox.setVisibility(View.GONE); } } }
java
{ "resource": "" }
q169187
OAuth.decodeForm
validation
public static HttpParameters decodeForm(String form) { HttpParameters params = new HttpParameters(); if (isEmpty(form)) { return params; } for (String nvp : form.split("\\&")) { int equals = nvp.indexOf('='); String name; String value; if (equals < 0) { name = percentDecode(nvp); value = null; } else { name = percentDecode(nvp.substring(0, equals)); value = percentDecode(nvp.substring(equals + 1)); } params.put(name, value); } return params; }
java
{ "resource": "" }
q169188
OAuth.toMap
validation
public static <T extends Map.Entry<String, String>> Map<String, String> toMap(Collection<T> from) { HashMap<String, String> map = new HashMap<String, String>(); if (from != null) { for (Map.Entry<String, String> entry : from) { String key = entry.getKey(); if (!map.containsKey(key)) { map.put(key, entry.getValue()); } } } return map; }
java
{ "resource": "" }
q169189
OAuth.toHeaderElement
validation
public static String toHeaderElement(String name, String value) { return OAuth.percentEncode(name) + "=\"" + OAuth.percentEncode(value) + "\""; }
java
{ "resource": "" }
q169190
TTLCache.put
validation
public boolean put(K strKey, E object, long ttl) { return put(strKey, object, ttl, false); }
java
{ "resource": "" }
q169191
TTLCache.put
validation
public boolean put(K strKey, E object, boolean eternal) { return put(strKey, object, defaultTTL, eternal); }
java
{ "resource": "" }
q169192
TTLCache.put
validation
protected synchronized boolean put(K k, E object, long ttl, boolean eternal) { // Check the key map first if(exists(k)) { TTLObject<K, E> ttlObject = getTTLObject(k); Key<K> key = keys.get(k); key.setTime(System.currentTimeMillis()); ttlObject.setEternal(eternal); ttlObject.extendLife(ttl); ttlObject.setObject(object); if(eventListener != null) { eventListener.onPut(object); } return true; } else { TTLObject<K, E> t = new TTLObject<K, E>(object, k, ttl); t.setEternal(eternal); long addedSize = object.getSizeInBytes(); long newSize = currentSizeInBytes + addedSize; boolean oversize = false; oversize = (hardByteLimit && maxCapacityBytes > 0 && newSize > maxCapacityBytes); if(!oversize) { Key<K> key = new Key<K>(k, System.currentTimeMillis()); keys.put(k, key); objects.put(key, t); t.getObject().onPut(k); // Increment size currentSizeInBytes = newSize; if(eventListener != null) { eventListener.onPut(object); } return true; } } return false; }
java
{ "resource": "" }
q169193
TTLCache.getRaw
validation
public synchronized E getRaw(K strKey) { TTLObject<K, E> obj = getTTLObject(strKey); if(obj != null && !isExpired(obj)) { return obj.getObject(); } return null; }
java
{ "resource": "" }
q169194
TTLCache.get
validation
public synchronized E get(K key) { TTLObject<K, E> obj = getTTLObject(key); if(obj != null && !isExpired(obj)) { if(extendOnGet) { extendTTL(key); } if(eventListener != null) { eventListener.onGet(obj.getObject()); } obj.getObject().onGet(); return obj.getObject(); } else if(obj != null) { // Expired destroy(obj.getKey()); obj = null; } if (obj == null) { if(objectFactory != null) { E object = objectFactory.create(key); if(object != null) { if(!put(key, object) && logger != null) { // We couldn't put this record.. just log a warning logger.warn("Failed to put object into cache. Cache size exceeded"); } } return object; } } return null; }
java
{ "resource": "" }
q169195
TTLCache.exists
validation
public boolean exists(K k) { Key<K> key = keys.get(k); if(key != null) { return objects.get(key) != null; } return false; }
java
{ "resource": "" }
q169196
TTLCache.extendTTL
validation
public synchronized void extendTTL(K strKey) { TTLObject<K, E> object = getTTLObject(strKey); if(object != null) { object.setLifeExpectancy(System.currentTimeMillis() + object.getTtl()); } }
java
{ "resource": "" }
q169197
ImageLoader.loadImageByData
validation
public void loadImageByData(final String name, final String encodedData, int width, int height, final ImageLoadListener listener) { ImageLoadRequest request = makeRequest(); request.setUrl(name); request.setEncodedImageData(encodedData); request.setType(ImageLoadType.ENCODED); loadImage(request, listener); }
java
{ "resource": "" }
q169198
ImageLoader.loadImageByUrl
validation
public void loadImageByUrl(final String url, int width, int height, final ImageLoadListener listener) { ImageLoadRequest request = makeRequest(); request.setUrl(url); request.setType(ImageLoadType.URL); request.setScaleWidth(width); request.setScaleHeight(height); loadImage(request, listener); }
java
{ "resource": "" }
q169199
OpenTsdbMetric.parseTags
validation
public static Map<String, String> parseTags(final String tagString) throws IllegalArgumentException { // delimit by whitespace or '=' Scanner scanner = new Scanner(tagString).useDelimiter("\\s+|="); Map<String, String> tagMap = new HashMap<String, String>(); try { while (scanner.hasNext()) { String tagName = scanner.next(); String tagValue = scanner.next(); tagMap.put(tagName, tagValue); } } catch (NoSuchElementException e) { // The tag string is corrupted. throw new IllegalArgumentException("Invalid tag string '" + tagString + "'"); } finally { scanner.close(); } return tagMap; }
java
{ "resource": "" }