Java Code Examples for android.text.TextUtils.join()

The following are Jave code examples for showing how to use join() of the android.text.TextUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: MyGeofencer   File: GeofenceTransitionsIntentService.java   View Source Code Vote up 7 votes
/**
 * Gets transition details and returns them as a formatted string.
 *
 * @param context               The app context.
 * @param geofenceTransition    The ID of the geofence transition.
 * @param triggeringGeofences   The geofence(s) triggered.
 * @return                      The transition details formatted as String.
 */
private String getGeofenceTransitionDetails(
        Context context,
        int geofenceTransition,
        List<Geofence> triggeringGeofences) {

    String geofenceTransitionString = getTransitionString(geofenceTransition);

    // Get the Ids of each geofence that was triggered.
    ArrayList triggeringGeofencesIdsList = new ArrayList();
    for (Geofence geofence : triggeringGeofences) {
        triggeringGeofencesIdsList.add(geofence.getRequestId());
    }
    String triggeringGeofencesIdsString = TextUtils.join(", ",  triggeringGeofencesIdsList);

    return geofenceTransitionString + ": " + triggeringGeofencesIdsString;
}
 
Example 2
Project: android-runas   File: FunctionRunner.java   View Source Code Vote up 7 votes
/**
 * Initialization; needs a context to find the classpath.
 * @param ctx
 */
public FunctionRunner(Context ctx) {
    /*
     * It would be nicer if we could just look at the classloaders for this class and
     * the one being run, but the details we need aren't publicly exposed there as far as
     * I can see. I'd rather do this than hack around with reflection or parsing classloaders'
     * toString().
     */
    ApplicationInfo appInfo = ctx.getApplicationInfo();
    mClassPath = appInfo.sourceDir + File.pathSeparator +
            TextUtils.join(File.pathSeparator, appInfo.splitSourceDirs);

    // and I guess there's really no better way for this either
    // TODO let caller optionally configure this?
    mCodeCacheDir = ctx.getCodeCacheDir().getPath();
}
 
Example 3
Project: GitJourney   File: RepoContentLoader.java   View Source Code Vote up 6 votes
public RepoContentLoader(Context context, String path, String repoName, String userName) {
    super(context);

    if (repoName == null || userName == null || repoName.isEmpty() || userName.isEmpty()) {
        isRepoReady = false;
    }

    String[] pathList = path.split("/");
    for (int i = 0; i < pathList.length; i++) {
        pathList[i] = Uri.encode(pathList[i]);
    }
    this.path = TextUtils.join("/", pathList);
    this.repoName = repoName;
    this.userName = userName;
    firebaseAnalytics = new FirebaseAnalyticsWrapper(context);
}
 
Example 4
Project: li-android-sdk-core   File: LiCoreSDKUtils.java   View Source Code Vote up 6 votes
@Nullable
public static String iterableToString(@Nullable Iterable<String> strings) {
    if (strings == null) {
        return null;
    }

    Set<String> stringSet = new LinkedHashSet<>();
    for (String str : strings) {
        LiCoreSDKUtils.checkArgument(!TextUtils.isEmpty(str),
                "individual scopes cannot be null or empty");
        stringSet.add(str);
    }

    if (stringSet.isEmpty()) {
        return null;
    }

    return TextUtils.join(" ", stringSet);
}
 
Example 5
Project: orgzly-android   File: NotesClient.java   View Source Code Vote up 5 votes
public static void updateScheduledTime(Context context, Set<Long> noteIds, OrgDateTime time) {
    ArrayList<ContentProviderOperation> ops = new ArrayList<>();

    String noteIdsCommaSeparated = TextUtils.join(",", noteIds);

    /* Update notes. */
    ContentValues values = new ContentValues();

    if (time != null) {
        values.put(ProviderContract.Notes.UpdateParam.SCHEDULED_STRING, new OrgRange(time).toString());
    } else {
        values.putNull(ProviderContract.Notes.UpdateParam.SCHEDULED_STRING);
    }

    ops.add(ContentProviderOperation
            .newUpdate(ProviderContract.Notes.ContentUri.notes())
            .withValues(values)
            .withSelection(ProviderContract.Notes.UpdateParam._ID + " IN (" + noteIdsCommaSeparated + ")", null)
            .build());

    updateBooksMtimeForNotes(context, noteIdsCommaSeparated, ops);

    /*
     * Apply batch.
     */
    try {
        context.getContentResolver().applyBatch(ProviderContract.AUTHORITY, ops);
    } catch (RemoteException | OperationApplicationException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
 
Example 6
Project: unity-obb-downloader   File: ResponseData.java   View Source Code Vote up 5 votes
@Override
public String toString() {
    return TextUtils.join("|", new Object[] {
            responseCode, nonce, packageName, versionCode,
            userId, timestamp
    });
}
 
Example 7
Project: q-mail   File: StoreSchemaDefinitionTest.java   View Source Code Vote up 5 votes
private String sortTableColumns(String sql) {
    int positionOfColumnDefinitions = sql.indexOf('(');
    String columnDefinitionsSql = sql.substring(positionOfColumnDefinitions + 1, sql.length() - 1);
    String[] columnDefinitions = columnDefinitionsSql.split(" *, *(?![^(]*\\))");
    Arrays.sort(columnDefinitions);

    String sqlPrefix = sql.substring(0, positionOfColumnDefinitions + 1);
    String sortedColumnDefinitionsSql = TextUtils.join(", ", columnDefinitions);
    return sqlPrefix + sortedColumnDefinitionsSql + ")";
}
 
Example 8
Project: GreenDao-Migrator   File: MigrationHelper.java   View Source Code Vote up 5 votes
private static void restoreData(StandardDatabase db, List<Class<? extends AbstractDao<?, ?>>> daoClasses) {
    for (Class<? extends AbstractDao<?, ?>> daoClass : daoClasses) {
        DaoConfig daoConfig = new DaoConfig(db, daoClass);
        String tableName = daoConfig.tablename;
        String tempTableName = daoConfig.tablename.concat("_TEMP");
        // get all columns from tempTable, take careful to use the columns list
        List<String> columns = getColumns(db, tempTableName);
        ArrayList<String> properties = new ArrayList<>(columns.size());
        for (int j = 0; j < daoConfig.properties.length; j++) {
            String columnName = daoConfig.properties[j].columnName;
            if (columns.contains(columnName)) {
                properties.add(columnName);
            }
        }
        if (properties.size() > 0) {
            final String columnSQL = TextUtils.join(",", properties);

            String insertTableStringBuilder = "INSERT INTO " + tableName + " (" +
                    columnSQL +
                    ") SELECT " +
                    columnSQL +
                    " FROM " + tempTableName + ";";
            try {
                db.execSQL(insertTableStringBuilder);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        db.execSQL("DROP TABLE " + tempTableName);
    }
}
 
Example 9
Project: easyfilemanager   File: MediaDocumentsProvider.java   View Source Code Vote up 4 votes
private static String joinNewline(String... args) {
    return TextUtils.join("\n", args);
}
 
Example 10
Project: AndroidBackendlessChat   File: BPath.java   View Source Code Vote up 4 votes
private String getObjectIdentifier(){
    return TextUtils.join("", keys);
}
 
Example 11
Project: chat-sdk-android-push-firebase   File: AuthorizationClient.java   View Source Code Vote up 4 votes
static Result createErrorResult(AuthorizationRequest request, String errorType, String errorDescription,
        String errorCode) {
    String message = TextUtils.join(": ", Utility.asListNoNulls(errorType, errorDescription));
    return new Result(request, Code.ERROR, null, message, errorCode);
}
 
Example 12
Project: mobile-store   File: QueryBuilder.java   View Source Code Vote up 4 votes
private String orderBySql() {
    if (orderBys.size() == 0) {
        return "";
    }
    return " ORDER BY " + TextUtils.join(", ", orderBys);
}
 
Example 13
Project: RNLearn_Project1   File: ARTTextShadowNode.java   View Source Code Vote up 4 votes
@Override
public void draw(Canvas canvas, Paint paint, float opacity) {
  if (mFrame == null) {
    return;
  }
  opacity *= mOpacity;
  if (opacity <= MIN_OPACITY_FOR_DRAW) {
    return;
  }
  if (!mFrame.hasKey(PROP_LINES)) {
    return;
  }
  ReadableArray linesProp = mFrame.getArray(PROP_LINES);
  if (linesProp == null || linesProp.size() == 0) {
    return;
  }

  // only set up the canvas if we have something to draw
  saveAndSetupCanvas(canvas);
  String[] lines = new String[linesProp.size()];
  for (int i = 0; i < lines.length; i++) {
    lines[i] = linesProp.getString(i);
  }
  String text = TextUtils.join("\n", lines);
  if (setupStrokePaint(paint, opacity)) {
    applyTextPropertiesToPaint(paint);
    if (mPath == null) {
      canvas.drawText(text, 0, -paint.ascent(), paint);
    } else {
      canvas.drawTextOnPath(text, mPath, 0, 0, paint);
    }
  }
  if (setupFillPaint(paint, opacity)) {
    applyTextPropertiesToPaint(paint);
    if (mPath == null) {
      canvas.drawText(text, 0, -paint.ascent(), paint);
    } else {
      canvas.drawTextOnPath(text, mPath, 0, 0, paint);
    }
  }
  restoreCanvas(canvas);
  markUpdateSeen();
}
 
Example 14
Project: android-crond   File: IO.java   View Source Code Vote up 4 votes
CommandResult(int returnCode, List<String> output) {
    this.exitCode = returnCode;
    this.output = TextUtils.join("\n", output);
}
 
Example 15
Project: SlotNSlot_Android   File: ResponseData.java   View Source Code Vote up 4 votes
@Override
public String toString() {
    return TextUtils.join("|", new Object [] { responseCode, nonce, packageName, versionCode,
        userId, timestamp });
}
 
Example 16
Project: simple-stack   File: Chat.java   View Source Code Vote up 4 votes
@Override
public String toString() {
    return TextUtils.join(", ", users.toArray(new User[users.size()]));
}
 
Example 17
Project: RxFacebook   File: RxFacebookGraphRequestSingle.java   View Source Code Vote up 4 votes
RxFacebookGraphRequestSingle(AccessToken accessToken, String... fields) {
    mAccessToken = accessToken;
    mFields = TextUtils.join(",", fields);
}
 
Example 18
Project: q-mail   File: Utility.java   View Source Code Vote up 3 votes
/**
 * Combines the given array of Objects into a single String using
 * each Object's toString() method and the separator character
 * between each part.
 *
 * @param parts
 * @param separator
 * @return new String
 */
public static String combine(Object[] parts, char separator) {
    if (parts == null) {
        return null;
    }
    return TextUtils.join(String.valueOf(separator), parts);
}
 
Example 19
Project: q-mail   File: Utility.java   View Source Code Vote up 3 votes
/**
 * Combines the given Objects into a single String using
 * each Object's toString() method and the separator character
 * between each part.
 *
 * @param parts
 * @param separator
 * @return new String
 */
public static String combine(Iterable<?> parts, char separator) {
    if (parts == null) {
        return null;
    }
    return TextUtils.join(String.valueOf(separator), parts);
}
 
Example 20
Project: EazyBaseMVP   File: ListUtils.java   View Source Code Vote up 2 votes
/**
 * join list to string. if separator is null, use {@link #DEFAULT_JOIN_SEPARATOR}
 * 
 * <pre>
 * join(null, "#")     =   "";
 * join({}, "#$")      =   "";
 * join({a,b,c}, null) =   "a,b,c";
 * join({a,b,c}, "")   =   "abc";
 * join({a,b,c}, "#")  =   "a#b#c";
 * join({a,b,c}, "#$") =   "a#$b#$c";
 * </pre>
 * 
 * @param list
 * @param separator
 * @return join list to string with separator. if list is empty, return ""
 */
public static String join(List<String> list, String separator) {
    return list == null ? "" : TextUtils.join(separator, list);
}