code stringlengths 73 34.1k | label stringclasses 1 value |
|---|---|
public BoxRequestsFile.GetCollaborations getCollaborationsRequest(String id) {
BoxRequestsFile.GetCollaborations request = new BoxRequestsFile.GetCollaborations(id, getFileCollaborationsUrl(id), mSession);
return request;
} | java |
public BoxRequestsFile.GetFileVersions getVersionsRequest(String id) {
BoxRequestsFile.GetFileVersions request = new BoxRequestsFile.GetFileVersions(id, getFileVersionsUrl(id), mSession);
return request;
} | java |
public BoxRequestsFile.DeleteFileVersion getDeleteVersionRequest(String id, String versionId) {
BoxRequestsFile.DeleteFileVersion request = new BoxRequestsFile.DeleteFileVersion(versionId, getDeleteFileVersionUrl(id, versionId), mSession);
return request;
} | java |
public BoxRequestsFile.AddFileToCollection getAddToCollectionRequest(String fileId, String collectionId) {
BoxRequestsFile.AddFileToCollection request = new BoxRequestsFile.AddFileToCollection(fileId, collectionId, getFileInfoUrl(fileId), mSession);
return request;
} | java |
public BoxRequestsFile.DeleteFileFromCollection getDeleteFromCollectionRequest(String id) {
BoxRequestsFile.DeleteFileFromCollection request = new BoxRequestsFile.DeleteFileFromCollection(id, getFileInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsFile.FilePreviewed getFilePreviewedRequest(String fileId) {
return new BoxRequestsFile.FilePreviewed(fileId, getPreviewFileUrl(), mSession);
} | java |
public BoxRequestsFile.GetUploadSession getUploadSession(String uploadSessionId) {
return new BoxRequestsFile.GetUploadSession(uploadSessionId, getUploadSessionInfoUrl(uploadSessionId), mSession);
} | java |
public R setLimit(final int limit){
mQueryMap.put(FIELD_LIMIT, Integer.toString(limit));
return (R)this;
} | java |
public R setPreviousListEvents(E listEvents){
mListEvents = listEvents;
this.setStreamPosition(((IStreamPosition)mListEvents).getNextStreamPosition().toString());
return (R)this;
} | java |
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
// Write out capacity and any hidden stuff
s.defaultWriteObject();
} | java |
public static BoxFolder createFromIdAndName(String folderId, String name) {
JsonObject object = new JsonObject();
object.add(BoxItem.FIELD_ID, folderId);
object.add(BoxItem.FIELD_TYPE, BoxFolder.TYPE);
if (!TextUtils.isEmpty(name)) {
object.add(BoxItem.FIELD_NAME, name);
}
return new BoxFolder(object);
} | java |
public static BoxBookmark createFromId(String bookmarkId) {
JsonObject object = new JsonObject();
object.add(FIELD_ID, bookmarkId);
object.add(FIELD_TYPE, TYPE);
return new BoxBookmark(object);
} | java |
public BoxHttpRequest addHeader(String key, String value) {
mUrlConnection.addRequestProperty(key, value);
return this;
} | java |
public BoxHttpRequest setBody(InputStream body) throws IOException {
mUrlConnection.setDoOutput(true);
OutputStream output = mUrlConnection.getOutputStream();
int b = body.read();
while (b != -1) {
output.write(b);
b = body.read();
}
output.close();
return this;
} | java |
public BoxRequestsUser.GetUserInfo getCurrentUserInfoRequest() {
BoxRequestsUser.GetUserInfo request = new BoxRequestsUser.GetUserInfo(getUserInformationUrl("me"), mSession);
return request;
} | java |
public BoxRequestsUser.GetUserInfo getUserInfoRequest(String id) {
BoxRequestsUser.GetUserInfo request = new BoxRequestsUser.GetUserInfo(getUserInformationUrl(id), mSession);
return request;
} | java |
public BoxRequestsUser.GetEnterpriseUsers getEnterpriseUsersRequest() {
BoxRequestsUser.GetEnterpriseUsers request = new BoxRequestsUser.GetEnterpriseUsers(getUsersUrl(), mSession);
return request;
} | java |
public BoxRequestsUser.CreateEnterpriseUser getCreateEnterpriseUserRequest(String login, String name) {
BoxRequestsUser.CreateEnterpriseUser request = new BoxRequestsUser.CreateEnterpriseUser(getUsersUrl(), mSession, login, name);
return request;
} | java |
public BoxRequestsUser.DeleteEnterpriseUser getDeleteEnterpriseUserRequest(String userId) {
BoxRequestsUser.DeleteEnterpriseUser request = new BoxRequestsUser.DeleteEnterpriseUser(getUserInformationUrl(userId), mSession, userId);
return request;
} | java |
public BoxRequestsFile.DownloadAvatar getDownloadAvatarRequest(File target, String userId) throws IOException{
if (!target.exists()){
throw new FileNotFoundException();
}
BoxRequestsFile.DownloadAvatar request = new BoxRequestsFile.DownloadAvatar(userId, target, getAvatarDownloadUrl(userId), mSession)
.setAvatarType(BoxRequestsFile.DownloadAvatar.LARGE);
return request;
} | java |
public BoxRequestsFile.DownloadFile getDownloadAvatarRequest(OutputStream outputStream, String userId) {
BoxRequestsFile.DownloadFile request = new BoxRequestsFile.DownloadFile(userId, outputStream, getAvatarDownloadUrl(userId), mSession);
return request;
} | java |
public R setName(String name) {
mBodyMap.put(BoxUser.FIELD_NAME, name);
return (R) this;
} | java |
public R setRole(BoxUser.Role role) {
mBodyMap.put(BoxUser.FIELD_ROLE, role);
return (R) this;
} | java |
public R setJobTitle(String jobTitle) {
mBodyMap.put(BoxUser.FIELD_JOB_TITLE, jobTitle);
return (R) this;
} | java |
public R setPhone(String phone) {
mBodyMap.put(BoxUser.FIELD_PHONE, phone);
return (R) this;
} | java |
public R setAddress(String address) {
mBodyMap.put(BoxUser.FIELD_ADDRESS, address);
return (R) this;
} | java |
public R setStatus(BoxUser.Status status) {
mBodyMap.put(BoxUser.FIELD_STATUS, status);
return (R) this;
} | java |
public R setTimezone(String timezone) {
mBodyMap.put(BoxUser.FIELD_TIMEZONE, timezone);
return (R) this;
} | java |
public BoxRequestRecentItems.GetRecentItems getRecentItemsRequest() {
BoxRequestRecentItems.GetRecentItems request = new BoxRequestRecentItems.GetRecentItems(getRecentItemsUrl(), mSession);
return request;
} | java |
public boolean isEmbedLinkUrlExpired(){
Long urlCreationTime = getUrlCreationTime();
if (urlCreationTime == null){
return true;
}
return (System.currentTimeMillis() - urlCreationTime) < (60 * 1000);
} | java |
public boolean isPreviewSessionExpired(){
Long urlCreationTime = getUrlCreationTime();
if (urlCreationTime == null){
return true;
}
return (System.currentTimeMillis() - urlCreationTime) < (60 * 60 * 1000);
} | java |
public BoxRequestsBookmark.GetBookmarkInfo getInfoRequest(final String id) {
BoxRequestsBookmark.GetBookmarkInfo request = new BoxRequestsBookmark.GetBookmarkInfo(id, getBookmarkInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsBookmark.CreateBookmark getCreateRequest(String parentId, String url) {
BoxRequestsBookmark.CreateBookmark request = new BoxRequestsBookmark.CreateBookmark(parentId, url, getBookmarksUrl(), mSession);
return request;
} | java |
public BoxRequestsBookmark.UpdateBookmark getUpdateRequest(String id) {
BoxRequestsBookmark.UpdateBookmark request = new BoxRequestsBookmark.UpdateBookmark(id, getBookmarkInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsBookmark.CopyBookmark getCopyRequest(String id, String parentId) {
BoxRequestsBookmark.CopyBookmark request = new BoxRequestsBookmark.CopyBookmark(id, parentId, getBookmarkCopyUrl(id), mSession);
return request;
} | java |
public BoxRequestsBookmark.UpdateBookmark getRenameRequest(String id, String newName) {
BoxRequestsBookmark.UpdateBookmark request = new BoxRequestsBookmark.UpdateBookmark(id, getBookmarkInfoUrl(id), mSession);
request.setName(newName);
return request;
} | java |
public BoxRequestsBookmark.UpdateBookmark getMoveRequest(String id, String parentId) {
BoxRequestsBookmark.UpdateBookmark request = new BoxRequestsBookmark.UpdateBookmark(id, getBookmarkInfoUrl(id), mSession);
request.setParentId(parentId);
return request;
} | java |
public BoxRequestsBookmark.DeleteBookmark getDeleteRequest(String id) {
BoxRequestsBookmark.DeleteBookmark request = new BoxRequestsBookmark.DeleteBookmark(id, getBookmarkInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsBookmark.UpdateSharedBookmark getCreateSharedLinkRequest(String id) {
BoxRequestsBookmark.UpdateSharedBookmark request = new BoxRequestsBookmark.UpdateSharedBookmark(id, getBookmarkInfoUrl(id), mSession)
.setAccess(null);
return request;
} | java |
public BoxRequestsBookmark.UpdateBookmark getDisableSharedLinkRequest(String id) {
BoxRequestsBookmark.UpdateBookmark request = new BoxRequestsBookmark.UpdateBookmark(id, getBookmarkInfoUrl(id), mSession)
.setSharedLink(null);
return request;
} | java |
public BoxRequestsBookmark.AddCommentToBookmark getAddCommentRequest(String bookmarkId, String message) {
BoxRequestsBookmark.AddCommentToBookmark request = new BoxRequestsBookmark.AddCommentToBookmark(bookmarkId, message, getCommentUrl(), mSession);
return request;
} | java |
public BoxRequestsBookmark.GetTrashedBookmark getTrashedBookmarkRequest(String id) {
BoxRequestsBookmark.GetTrashedBookmark request = new BoxRequestsBookmark.GetTrashedBookmark(id, getTrashedBookmarkUrl(id), mSession);
return request;
} | java |
public BoxRequestsBookmark.DeleteTrashedBookmark getDeleteTrashedBookmarkRequest(String id) {
BoxRequestsBookmark.DeleteTrashedBookmark request = new BoxRequestsBookmark.DeleteTrashedBookmark(id, getTrashedBookmarkUrl(id), mSession);
return request;
} | java |
public BoxRequestsBookmark.RestoreTrashedBookmark getRestoreTrashedBookmarkRequest(String id) {
BoxRequestsBookmark.RestoreTrashedBookmark request = new BoxRequestsBookmark.RestoreTrashedBookmark(id, getBookmarkInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsBookmark.GetBookmarkComments getCommentsRequest(String id) {
BoxRequestsBookmark.GetBookmarkComments request = new BoxRequestsBookmark.GetBookmarkComments(id, getBookmarkCommentsUrl(id), mSession);
return request;
} | java |
public BoxRequestsBookmark.AddBookmarkToCollection getAddToCollectionRequest(String bookmarkId, String collectionId) {
BoxRequestsBookmark.AddBookmarkToCollection request = new BoxRequestsBookmark.AddBookmarkToCollection(bookmarkId, collectionId, getBookmarkInfoUrl(bookmarkId), mSession);
return request;
} | java |
public BoxRequestsBookmark.DeleteBookmarkFromCollection getDeleteFromCollectionRequest(String id) {
BoxRequestsBookmark.DeleteBookmarkFromCollection request = new BoxRequestsBookmark.DeleteBookmarkFromCollection(id, getBookmarkInfoUrl(id), mSession);
return request;
} | java |
public BoxSimpleMessage connect() {
mRetries = 0;
try {
BoxIteratorRealTimeServers servers = (BoxIteratorRealTimeServers)mRequest.send();
mBoxRealTimeServer = servers.get(0);
} catch (BoxException e){
mChangeListener.onException(e, this);
return null;
}
BoxRequestsEvent.LongPollMessageRequest messageRequest = new BoxRequestsEvent.LongPollMessageRequest(mBoxRealTimeServer.getUrl(),mSession);
messageRequest.setTimeOut(mBoxRealTimeServer.getFieldRetryTimeout().intValue() * 1000 );
boolean shouldRetry = true;
do {
BoxFutureTask<BoxSimpleMessage> task = null;
try {
task = messageRequest.toTask().addOnCompletedListener(this);
mExecutor.submit(task);
BoxResponse<BoxSimpleMessage> response = task.get(mBoxRealTimeServer.getFieldRetryTimeout().intValue(), TimeUnit.SECONDS);
if (response.isSuccess() && !response.getResult().getMessage().equals(BoxSimpleMessage.MESSAGE_RECONNECT)){
return response.getResult();
}
} catch (TimeoutException e) {
if (task != null) {
try {
// if the timeout is coming from the task then cancel the task (as httpurlconnection timeout is unreliable).
task.cancel(true);
} catch (CancellationException e1){
}
}
} catch (InterruptedException e){
mChangeListener.onException(e,this);
} catch (ExecutionException e){
mChangeListener.onException(e,this);
}
mRetries++;
if (mBoxRealTimeServer.getMaxRetries() < mRetries) {
shouldRetry = false;
}
} while(shouldRetry);
mChangeListener.onException(new BoxException.MaxAttemptsExceeded("Max retries exceeded, ", mRetries), this);
return null;
} | java |
public void putField(String key, Date value) {
this.fields.put(key, BoxDateFormat.format(value));
} | java |
public void setFile(InputStream inputStream, String filename, long fileSize) {
this.setFile(inputStream, filename);
this.fileSize = fileSize;
} | java |
public static String getRepresentationHintString(String repType, String repSize) {
StringBuffer sb = new StringBuffer(repType);
if(TYPE_JPG.equals(repType) || TYPE_PNG.equals(repType)) {
if(TextUtils.isEmpty(repSize)) {
throw new InvalidParameterException("Size is not optional when creating representation hints for images");
}
sb.append("?" + BoxRepPropertiesMap.FIELD_PROPERTIES_DIMENSIONS + "=" + repSize);
}
return sb.toString();
} | java |
public Long getNextStreamPosition() {
String longValue = getPropertyAsString(FIELD_NEXT_STREAM_POSITION);
return Long.parseLong(longValue.replace("\"", ""));
} | java |
public static BoxFile createFromIdAndName(String fileId, String name) {
JsonObject object = new JsonObject();
object.add(BoxItem.FIELD_ID, fileId);
object.add(BoxItem.FIELD_TYPE, BoxFile.TYPE);
if (!TextUtils.isEmpty(name)) {
object.add(BoxItem.FIELD_NAME, name);
}
return new BoxFile(object);
} | java |
private void loadRootFolder() {
new Thread() {
@Override
public void run() {
try {
//Api to fetch root folder
final BoxIteratorItems folderItems = mFolderApi.getItemsRequest(BoxConstants.ROOT_FOLDER_ID).send();
runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.clear();
for (BoxItem boxItem: folderItems) {
mAdapter.add(boxItem);
}
}
});
} catch (BoxException e) {
e.printStackTrace();
}
}
}.start();
} | java |
private void uploadSampleFile() {
mDialog = ProgressDialog.show(MainActivity.this, getText(R.string.boxsdk_Please_wait), getText(R.string.boxsdk_Please_wait));
new Thread() {
@Override
public void run() {
try {
String uploadFileName = "box_logo.png";
InputStream uploadStream = getResources().getAssets().open(uploadFileName);
String destinationFolderId = "0";
String uploadName = "BoxSDKUpload.png";
BoxRequestsFile.UploadFile request = mFileApi.getUploadRequest(uploadStream, uploadName, destinationFolderId);
final BoxFile uploadFileInfo = request.send();
showToast("Uploaded " + uploadFileInfo.getName());
loadRootFolder();
} catch (IOException e) {
e.printStackTrace();
} catch (BoxException e) {
e.printStackTrace();
BoxError error = e.getAsBoxError();
if (error != null && error.getStatus() == HttpURLConnection.HTTP_CONFLICT) {
ArrayList<BoxEntity> conflicts = error.getContextInfo().getConflicts();
if (conflicts != null && conflicts.size() == 1 && conflicts.get(0) instanceof BoxFile) {
uploadNewVersion((BoxFile) conflicts.get(0));
return;
}
}
showToast("Upload failed");
} finally {
mDialog.dismiss();
}
}
}.start();
} | java |
private void uploadNewVersion(final BoxFile file) {
new Thread() {
@Override
public void run() {
try {
String uploadFileName = "box_logo.png";
InputStream uploadStream = getResources().getAssets().open(uploadFileName);
BoxRequestsFile.UploadNewVersion request = mFileApi.getUploadNewVersionRequest(uploadStream, file.getId());
final BoxFile uploadFileVersionInfo = request.send();
showToast("Uploaded new version of " + uploadFileVersionInfo.getName());
} catch (IOException e) {
e.printStackTrace();
} catch (BoxException e) {
e.printStackTrace();
showToast("Upload failed");
} finally {
mDialog.dismiss();
}
}
}.start();
} | java |
public static void copyStream(final InputStream inputStream, final OutputStream outputStream) throws IOException,
InterruptedException {
copyStream(inputStream, outputStream, null);
} | java |
public static String copyStreamAndComputeSha1(final InputStream inputStream, final OutputStream outputStream)
throws NoSuchAlgorithmException, IOException, InterruptedException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
copyStream(inputStream, outputStream, md);
return new String(encodeHex(md.digest()));
} | java |
private static void copyStream(final InputStream inputStream, final OutputStream outputStream, MessageDigest messageDigest) throws IOException,
InterruptedException {
// Read the rest of the stream and write to the destination OutputStream.
final byte[] buffer = new byte[BUFFER_SIZE];
int bufferLength = 0;
Exception exception = null;
try {
while ((bufferLength = inputStream.read(buffer)) > 0) {
if (Thread.currentThread().isInterrupted()) {
InterruptedException e = new InterruptedException();
throw e;
}
outputStream.write(buffer, 0, bufferLength);
if (messageDigest != null) {
messageDigest.update(buffer, 0, bufferLength);
}
}
} catch (Exception e) {
exception = e;
if (exception instanceof IOException) {
throw (IOException) e;
}
if (exception instanceof InterruptedException) {
throw (InterruptedException) e;
}
} finally {
// Try to flush the OutputStream
if (exception == null) {
outputStream.flush();
}
}
} | java |
public static OutputStream createArrayOutputStream(final OutputStream[] outputStreams) {
return new OutputStream() {
@Override
public void close() throws IOException {
for (OutputStream o : outputStreams) {
o.close();
}
super.close();
}
@Override
public void flush() throws IOException {
for (OutputStream o : outputStreams) {
o.flush();
}
super.flush();
}
@Override
public void write(int oneByte) throws IOException {
for (OutputStream o : outputStreams) {
o.write(oneByte);
}
}
@Override
public void write(byte[] buffer) throws IOException {
for (OutputStream o : outputStreams) {
o.write(buffer);
}
}
@Override
public void write(byte[] buffer, int offset, int count) throws IOException {
for (OutputStream o : outputStreams) {
o.write(buffer, offset, count);
}
}
};
} | java |
public static String sha1(final InputStream inputStream) throws IOException, NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] bytes = new byte[8192];
int byteCount;
while ((byteCount = inputStream.read(bytes)) > 0) {
md.update(bytes, 0, byteCount);
}
inputStream.close();
return new String(encodeHex(md.digest()));
} | java |
public static long parseJsonValueToLong(JsonValue value) {
try {
return value.asLong();
} catch (UnsupportedOperationException e) {
String s = value.asString().replace("\"", "");
return Long.parseLong(s);
}
} | java |
public static long parseJsonValueToInteger(JsonValue value) {
try {
return value.asInt();
} catch (UnsupportedOperationException e) {
String s = value.asString().replace("\"", "");
return Integer.parseInt(s);
}
} | java |
public static String concatStringWithDelimiter(String[] strings, String delimiter) {
StringBuilder sbr = new StringBuilder();
int size = strings.length;
for (int i = 0; i < size - 1; i++) {
sbr.append(strings[i]).append(delimiter);
}
sbr.append(strings[size - 1]);
return sbr.toString();
} | java |
public static <T extends Object> T cloneSerializable(T source) {
ByteArrayOutputStream baos = null;
ObjectOutputStream oos = null;
ByteArrayInputStream bais = null;
ObjectInputStream ois = null;
try {
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(source);
bais = new ByteArrayInputStream(baos.toByteArray());
ois = new ObjectInputStream(bais);
return (T) ois.readObject();
} catch (IOException e) {
return null;
} catch (ClassNotFoundException e) {
return null;
} finally {
closeQuietly(baos, oos, bais, ois);
}
} | java |
public static String convertSerializableToString(Serializable obj) {
ByteArrayOutputStream baos = null;
ObjectOutputStream oos = null;
try {
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
return new String(baos.toByteArray());
} catch (IOException e) {
return null;
} finally {
closeQuietly(baos, oos);
closeQuietly(oos);
}
} | java |
public static boolean deleteFolderRecursive(final File f) {
if (f.isDirectory()) {
File[] files = f.listFiles();
if (files == null) {
return false;
}
for (File c : files) {
deleteFolderRecursive(c);
}
}
return f.delete();
} | java |
public static boolean isInternetAvailable(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return isInternetAvailable(connectivityManager);
} else {
return isInternetAvailablePreLollipop(connectivityManager);
}
} | java |
public static String getAssetFile(final Context context, final String assetName) {
// if the file is not found create it and return that.
// if we do not have a file we copy our asset out to create one.
AssetManager assetManager = context.getAssets();
BufferedReader in = null;
try {
StringBuilder buf = new StringBuilder();
InputStream is = assetManager.open(assetName);
in = new BufferedReader(new InputStreamReader(is));
String str;
boolean isFirst = true;
while ((str = in.readLine()) != null) {
if (isFirst)
isFirst = false;
else
buf.append('\n');
buf.append(str);
}
return buf.toString();
} catch (IOException e) {
BoxLogUtils.e("getAssetFile", assetName, e);
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e) {
BoxLogUtils.e("getAssetFile", assetName, e);
}
}
// should never get here unless the asset file is inaccessible or cannot be copied out.
return null;
} | java |
public static void toastSafely(final Context context, final int resId, final int duration) {
Long lastToastTime = LAST_TOAST_TIME.get(resId);
if (lastToastTime != null && (lastToastTime + TOAST_MIN_REPEAT_DELAY) < System.currentTimeMillis()) {
return;
}
Looper mainLooper = Looper.getMainLooper();
if (Thread.currentThread().equals(mainLooper.getThread())) {
LAST_TOAST_TIME.put(resId, System.currentTimeMillis());
Toast.makeText(context, resId, duration).show();
} else {
Handler handler = new Handler(mainLooper);
handler.post(new Runnable() {
@Override
public void run() {
LAST_TOAST_TIME.put(resId, System.currentTimeMillis());
Toast.makeText(context, resId, duration).show();
}
});
}
} | java |
public static void setInitialsThumb(Context context, TextView initialsView, String fullName) {
char initial1 = '\u0000';
char initial2 = '\u0000';
if (fullName != null) {
String[] nameParts = fullName.split(" ");
if (nameParts[0].length() > 0) {
initial1 = nameParts[0].charAt(0);
}
if (nameParts.length > 1) {
initial2 = nameParts[nameParts.length - 1].charAt(0);
}
}
setColorForInitialsThumb(initialsView, initial1 + initial2);
initialsView.setText(initial1 + "" + initial2);
initialsView.setTextColor(Color.WHITE);
} | java |
public static void setCollabNumberThumb(Context context, TextView initialsView, int collabNumber) {
String collabNumberDisplay = (collabNumber >= 100) ? "+99" : "+" + Integer.toString(collabNumber);
setColorForCollabNumberThumb(initialsView);
initialsView.setTextColor(COLLAB_NUMBER_THUMB_COLOR);
initialsView.setText(collabNumberDisplay);
} | java |
public static void setColorsThumb(TextView initialsView, int backgroundColor, int strokeColor) {
GradientDrawable drawable = (GradientDrawable) initialsView.getResources().getDrawable(R.drawable.boxsdk_thumb_background);
drawable.setColorFilter(backgroundColor, PorterDuff.Mode.MULTIPLY);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
drawable.setStroke(3, strokeColor);
initialsView.setBackground(drawable);
} else {
drawable.setStroke(3, strokeColor);
initialsView.setBackgroundDrawable(drawable);
}
} | java |
public static void setColorForInitialsThumb(TextView initialsView, int position) {
int backgroundColor = THUMB_COLORS[(position) % THUMB_COLORS.length];
setColorsThumb(initialsView, backgroundColor, Color.WHITE);
} | java |
public static String getLocalizedFileSize(final Context context, double numSize) {
String localeLanguage = Locale.getDefault().getLanguage();
if (!SIZE_LANGUAGE.equals(localeLanguage) && context != null && context.getResources() != null) {
Resources resources = context.getResources();
SIZE_BYTES = resources.getString(R.string.boxsdk_bytes);
SIZE_KILOBYTES = resources.getString(R.string.boxsdk_kilobytes);
SIZE_MEGABYTES = resources.getString(R.string.boxsdk_megabytes);
SIZE_GIGABYTES = resources.getString(R.string.boxsdk_gigabytes);
SIZE_TERABYTES = resources.getString(R.string.boxsdk_terabytes);
SIZE_LANGUAGE = localeLanguage;
}
String textSize = null;
double size;
if (numSize < constKB) {
textSize = String.format(Locale.getDefault(), SIZE_BYTES, numSize);
} else if ((numSize >= constKB) && (numSize < constMB)) {
size = numSize / floatKB;
textSize = String.format(Locale.getDefault(), SIZE_KILOBYTES, size);
} else if ((numSize >= constMB) && (numSize < constGB)) {
size = numSize / floatMB;
textSize = String.format(Locale.getDefault(), SIZE_MEGABYTES, size);
} else if (numSize >= constGB && (numSize < constTB)) {
size = numSize / floatGB;
textSize = String.format(Locale.getDefault(), SIZE_GIGABYTES, size);
} else if (numSize >= constTB) {
size = numSize / floatTB;
textSize = String.format(Locale.getDefault(), SIZE_TERABYTES, size);
}
return textSize;
} | java |
protected R setCollectionId(String id) {
JsonArray jsonArray = new JsonArray();
if (!TextUtils.isEmpty(id)) {
BoxCollection col = BoxCollection.createFromId(id);
jsonArray.add(col.toJsonObject());
}
mBodyMap.put(FIELD_COLLECTIONS, jsonArray);
return (R) this;
} | java |
public BoxRequestsFolder.GetFolderInfo getInfoRequest(String id) {
BoxRequestsFolder.GetFolderInfo request = new BoxRequestsFolder.GetFolderInfo(id, getFolderInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsFolder.GetFolderItems getItemsRequest(String id) {
BoxRequestsFolder.GetFolderItems request = new BoxRequestsFolder.GetFolderItems(id, getFolderItemsUrl(id), mSession);
return request;
} | java |
public BoxRequestsFolder.CreateFolder getCreateRequest(String parentId, String name) {
BoxRequestsFolder.CreateFolder request = new BoxRequestsFolder.CreateFolder(parentId, name, getFoldersUrl(), mSession);
return request;
} | java |
public BoxRequestsFolder.UpdateFolder getUpdateRequest(String id) {
BoxRequestsFolder.UpdateFolder request = new BoxRequestsFolder.UpdateFolder(id, getFolderInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsFolder.UpdateFolder getRenameRequest(String id, String newName) {
BoxRequestsFolder.UpdateFolder request = new BoxRequestsFolder.UpdateFolder(id, getFolderInfoUrl(id), mSession)
.setName(newName);
return request;
} | java |
public BoxRequestsFolder.UpdateFolder getMoveRequest(String id, String parentId) {
BoxRequestsFolder.UpdateFolder request = new BoxRequestsFolder.UpdateFolder(id, getFolderInfoUrl(id), mSession)
.setParentId(parentId);
return request;
} | java |
public BoxRequestsFolder.CopyFolder getCopyRequest(String id, String parentId) {
BoxRequestsFolder.CopyFolder request = new BoxRequestsFolder.CopyFolder(id, parentId, getFolderCopyUrl(id), mSession);
return request;
} | java |
public BoxRequestsFolder.GetCollaborations getCollaborationsRequest(String id) {
BoxRequestsFolder.GetCollaborations request = new BoxRequestsFolder.GetCollaborations(id, getFolderCollaborationsUrl(id), mSession);
return request;
} | java |
public BoxRequestsFolder.UpdateSharedFolder getCreateSharedLinkRequest(String id) {
BoxRequestsFolder.UpdateSharedFolder request = new BoxRequestsFolder.UpdateSharedFolder(id, getFolderInfoUrl(id), mSession)
.setAccess(null);
return request;
} | java |
public BoxRequestsFolder.AddFolderToCollection getAddToCollectionRequest(String folderId, String collectionId) {
BoxRequestsFolder.AddFolderToCollection request = new BoxRequestsFolder.AddFolderToCollection(folderId, collectionId, getFolderInfoUrl(folderId), mSession);
return request;
} | java |
public BoxRequestsFolder.DeleteFolderFromCollection getDeleteFromCollectionRequest(String id) {
BoxRequestsFolder.DeleteFolderFromCollection request = new BoxRequestsFolder.DeleteFolderFromCollection(id, getFolderInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsFolder.GetTrashedItems getTrashedItemsRequest() {
BoxRequestsFolder.GetTrashedItems request = new BoxRequestsFolder.GetTrashedItems(getTrashedItemsUrl(), mSession);
return request;
} | java |
public BoxRequestsFolder.GetTrashedFolder getTrashedFolderRequest(String id) {
BoxRequestsFolder.GetTrashedFolder request = new BoxRequestsFolder.GetTrashedFolder(id, getTrashedFolderUrl(id), mSession);
return request;
} | java |
public BoxRequestsFolder.DeleteTrashedFolder getDeleteTrashedFolderRequest(String id) {
BoxRequestsFolder.DeleteTrashedFolder request = new BoxRequestsFolder.DeleteTrashedFolder(id, getTrashedFolderUrl(id), mSession);
return request;
} | java |
public BoxRequestsFolder.RestoreTrashedFolder getRestoreTrashedFolderRequest(String id) {
BoxRequestsFolder.RestoreTrashedFolder request = new BoxRequestsFolder.RestoreTrashedFolder(id, getFolderInfoUrl(id), mSession);
return request;
} | java |
public BoxRequestsShare.GetCollaborationInfo getInfoRequest(String collaborationId) {
BoxRequestsShare.GetCollaborationInfo collab = new BoxRequestsShare.GetCollaborationInfo(collaborationId, getCollaborationInfoUrl(collaborationId), mSession);
return collab;
} | java |
public BoxRequestsShare.AddCollaboration getAddRequest(BoxCollaborationItem collaborationItem, BoxCollaboration.Role role, String login) {
BoxRequestsShare.AddCollaboration collab = new BoxRequestsShare.AddCollaboration(getCollaborationsUrl(),
createStubItem(collaborationItem), role, login, mSession);
return collab;
} | java |
public BoxRequestsShare.GetPendingCollaborations getPendingCollaborationsRequest() {
BoxRequestsShare.GetPendingCollaborations request = new BoxRequestsShare.GetPendingCollaborations(getCollaborationsUrl(), mSession);
return request;
} | java |
public BoxRequestsShare.DeleteCollaboration getDeleteRequest(String collaborationId) {
BoxRequestsShare.DeleteCollaboration collab = new BoxRequestsShare.DeleteCollaboration(collaborationId, getCollaborationInfoUrl(collaborationId), mSession);
return collab;
} | java |
public BoxRequestsShare.UpdateOwner getUpdateOwnerRequest(String collaborationId) {
BoxRequestsShare.UpdateOwner collab = new BoxRequestsShare.UpdateOwner(collaborationId, getCollaborationInfoUrl(collaborationId), mSession);
return collab;
} | java |
public static String format(Date date) {
String format = LOCAL_DATE_FORMAT.format(date);
// Java 6 does not have a convenient way of having the colon in the timezone offset
return format.substring(0,22) + ":" + format.substring(22);
} | java |
public static String getTimeRangeString(Date fromDate, Date toDate) {
if (fromDate == null && toDate == null) {
return null;
}
StringBuilder sbr = new StringBuilder();
if (fromDate != null) {
sbr.append(format(fromDate));
}
sbr.append(",");
if (toDate != null) {
sbr.append(format(toDate));
}
return sbr.toString();
} | java |
public BoxError getAsBoxError() {
try {
BoxError error = new BoxError();
error.createFromJson(getResponse());
return error;
} catch (Exception e) {
return null;
}
} | java |
public String getDescription() {
return mBodyMap.containsKey(BoxItem.FIELD_DESCRIPTION) ?
(String) mBodyMap.get(BoxItem.FIELD_DESCRIPTION) :
null;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.