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

The following are Jave code examples for showing how to use split() 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: lineagex86   File: NotificationLightSettings.java   View Source Code Vote up 6 votes
private boolean parsePackageList() {
    final String baseString = CMSettings.System.getString(getContentResolver(),
            CMSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_VALUES);

    if (TextUtils.equals(mPackageList, baseString)) {
        return false;
    }

    mPackageList = baseString;
    mPackages.clear();

    if (baseString != null) {
        final String[] array = TextUtils.split(baseString, "\\|");
        for (String item : array) {
            if (TextUtils.isEmpty(item)) {
                continue;
            }
            Package pkg = Package.fromString(item);
            if (pkg != null) {
                mPackages.put(pkg.name, pkg);
            }
        }
    }

    return true;
}
 
Example 2
Project: GitHub   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
/**
 * Construct a persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new ConcurrentHashMap<String, Cookie>();

    // Load any previously stored cookies into the store
    String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null);
    if (storedCookieNames != null) {
        String[] cookieNames = TextUtils.split(storedCookieNames, ",");
        for (String name : cookieNames) {
            String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
            if (encodedCookie != null) {
                Cookie decodedCookie = decodeCookie(encodedCookie);
                if (decodedCookie != null) {
                    cookies.put(name, decodedCookie);
                }
            }
        }

        // Clear out expired cookies
        clearExpired(new Date());
    }
}
 
Example 3
Project: GitHub   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
/**
 * Construct a persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new ConcurrentHashMap<String, Cookie>();

    // Load any previously stored cookies into the store
    String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null);
    if (storedCookieNames != null) {
        String[] cookieNames = TextUtils.split(storedCookieNames, ",");
        for (String name : cookieNames) {
            String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
            if (encodedCookie != null) {
                Cookie decodedCookie = decodeCookie(encodedCookie);
                if (decodedCookie != null) {
                    cookies.put(name, decodedCookie);
                }
            }
        }

        // Clear out expired cookies
        clearExpired(new Date());
    }
}
 
Example 4
Project: rongyunDemo   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
/**
 * Construct a persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new ConcurrentHashMap<String, Cookie>();

    // Load any previously stored cookies into the store
    String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null);
    if (storedCookieNames != null) {
        String[] cookieNames = TextUtils.split(storedCookieNames, ",");
        for (String name : cookieNames) {
            String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
            if (encodedCookie != null) {
                Cookie decodedCookie = decodeCookie(encodedCookie);
                if (decodedCookie != null) {
                    cookies.put(name, decodedCookie);
                }
            }
        }

        // Clear out expired cookies
        clearExpired(new Date());
    }
}
 
Example 5
Project: stynico   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
/**
 * Construct a persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new HashMap<String, ConcurrentHashMap<String, Cookie>>();

    // Load any previously stored cookies into the store
    Map<String, ?> prefsMap = cookiePrefs.getAll();
    for (Map.Entry<String, ?> entry : prefsMap.entrySet()) {
        if (entry.getValue() != null && !((String) entry.getValue()).startsWith(COOKIE_NAME_PREFIX)) {
            String[] cookieNames = TextUtils.split((String) entry.getValue(), ",");
            for (String name : cookieNames) {
                String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
                if (encodedCookie != null) {
                    Cookie decodedCookie = decodeCookie(encodedCookie);
                    if (decodedCookie != null) {
                        if (!cookies.containsKey(entry.getKey()))
                            cookies.put(entry.getKey(), new ConcurrentHashMap<String, Cookie>());
                        cookies.get(entry.getKey()).put(name, decodedCookie);
                    }
                }
            }
        }
    }
}
 
Example 6
Project: IdealMedia   File: StringUtils.java   View Source Code Vote up 6 votes
public static String capitalizeFully(String str) {
    if (str == null || str.length() == 0) {
        return str;
    }
    String [] s = TextUtils.split(str, " ");
    if (s.length == 0) {
        return capitalize(str);
    }
    else {
        StringBuilder stringBuilder = new StringBuilder();
        for (String ss:s){
            stringBuilder.append(capitalize(ss));
            stringBuilder.append(" ");
        }
        return stringBuilder.toString();
    }
}
 
Example 7
Project: letv   File: PersistentCookieStore.java   View Source Code Vote up 6 votes
public PersistentCookieStore(Context context) {
    int i = 0;
    this.cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    String storedCookieNames = this.cookiePrefs.getString(COOKIE_NAME_STORE, null);
    if (storedCookieNames != null) {
        String[] cookieNames = TextUtils.split(storedCookieNames, ",");
        int length = cookieNames.length;
        while (i < length) {
            String name = cookieNames[i];
            String encodedCookie = this.cookiePrefs.getString(new StringBuilder(COOKIE_NAME_PREFIX).append(name).toString(), null);
            if (encodedCookie != null) {
                Cookie decodedCookie = decodeCookie(encodedCookie);
                if (decodedCookie != null) {
                    this.cookies.put(name, decodedCookie);
                }
            }
            i++;
        }
        clearExpired(new Date());
    }
}
 
Example 8
Project: AndroidBasicLibs   File: CookiesStore.java   View Source Code Vote up 6 votes
public CookiesStore(Context context) {
    cookiePrefs = context.getSharedPreferences(JConfig.COOKIE_PREFS, 0);
    cookies = new HashMap<>();
    Map<String, ?> prefsMap = cookiePrefs.getAll();
    for (Map.Entry<String, ?> entry : prefsMap.entrySet()) {
        String[] cookieNames = TextUtils.split((String) entry.getValue(), ",");
        for (String name : cookieNames) {
            String encodedCookie = cookiePrefs.getString(name, null);
            if (encodedCookie != null) {
                Cookie decodedCookie = decodeCookie(encodedCookie);
                if (decodedCookie != null) {
                    if (!cookies.containsKey(entry.getKey())) {
                        cookies.put(entry.getKey(), new ConcurrentHashMap<String, Cookie>());
                    }
                    cookies.get(entry.getKey()).put(name, decodedCookie);
                }
            }
        }
    }
}
 
Example 9
Project: ForeverLibrary   File: MyCookieStore.java   View Source Code Vote up 6 votes
public MyCookieStore() {
    cookiePrefs = ToolCache.getContext().getSharedPreferences(COOKIE_PREFS, Context.MODE_PRIVATE);
    cookies = new HashMap<>();

    //将持久化的cookies缓存到内存中,数据结构为 Map<Url.host, Map<Cookie.name, Cookie>>
    Map<String, ?> prefsMap = cookiePrefs.getAll();
    for (Map.Entry<String, ?> entry : prefsMap.entrySet()) {
        if ((entry.getValue()) != null && !entry.getKey().startsWith(COOKIE_NAME_PREFIX)) {
            //获取url对应的所有cookie的key,用","分割
            String[] cookieNames = TextUtils.split((String) entry.getValue(), ",");
            for (String name : cookieNames) {
                //根据对应cookie的Key,从xml中获取cookie的真实值
                String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
                if (encodedCookie != null) {
                    Cookie decodedCookie = decodeCookie(encodedCookie);
                    if (decodedCookie != null) {
                        if (!cookies.containsKey(entry.getKey()))
                            cookies.put(entry.getKey(), new ConcurrentHashMap<String, Cookie>());
                        cookies.get(entry.getKey()).put(name, decodedCookie);
                    }
                }
            }
        }
    }
}
 
Example 10
Project: GitHub   File: PersistentCookieStore.java   View Source Code Vote up 5 votes
/**
 * Construct a persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context)
{
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new HashMap<String, ConcurrentHashMap<String, Cookie>>();

    // Load any previously stored cookies into the store
    Map<String, ?> prefsMap = cookiePrefs.getAll();
    for (Map.Entry<String, ?> entry : prefsMap.entrySet())
    {
        if (((String) entry.getValue()) != null && !((String) entry.getValue()).startsWith(COOKIE_NAME_PREFIX))
        {
            String[] cookieNames = TextUtils.split((String) entry.getValue(), ",");
            for (String name : cookieNames)
            {
                String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
                if (encodedCookie != null)
                {
                    Cookie decodedCookie = decodeCookie(encodedCookie);
                    if (decodedCookie != null)
                    {
                        if (!cookies.containsKey(entry.getKey()))
                            cookies.put(entry.getKey(), new ConcurrentHashMap<String, Cookie>());
                        cookies.get(entry.getKey()).put(name, decodedCookie);
                    }
                }
            }

        }
    }
}
 
Example 11
Project: cniao5   File: PersistentCookieStore.java   View Source Code Vote up 5 votes
/**
 * Construct a persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context)
{
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new HashMap<String, ConcurrentHashMap<String, Cookie>>();

    // Load any previously stored cookies into the store
    Map<String, ?> prefsMap = cookiePrefs.getAll();
    for (Map.Entry<String, ?> entry : prefsMap.entrySet())
    {
        if (((String) entry.getValue()) != null && !((String) entry.getValue()).startsWith(COOKIE_NAME_PREFIX))
        {
            String[] cookieNames = TextUtils.split((String) entry.getValue(), ",");
            for (String name : cookieNames)
            {
                String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
                if (encodedCookie != null)
                {
                    Cookie decodedCookie = decodeCookie(encodedCookie);
                    if (decodedCookie != null)
                    {
                        if (!cookies.containsKey(entry.getKey()))
                            cookies.put(entry.getKey(), new ConcurrentHashMap<String, Cookie>());
                        cookies.get(entry.getKey()).put(name, decodedCookie);
                    }
                }
            }

        }
    }
}
 
Example 12
Project: PeSanKita-android   File: DynamicLanguage.java   View Source Code Vote up 5 votes
private static Locale getSelectedLocale(Context context) {
  String language[] = TextUtils.split(TextSecurePreferences.getLanguage(context), "_");

  if (language[0].equals(DEFAULT)) {
    return new Locale("in");
  } else if (language.length == 2) {
    return new Locale(language[0], language[1]);
  } else {
    return new Locale(language[0]);
  }
}
 
Example 13
Project: secretknock   File: MainActivity.java   View Source Code Vote up 5 votes
private List<Long> retrievePattern() {
	String[] list = TextUtils.split(sharedPreferences.getString(DURATIONS, null), ",");
	ArrayList<String> arrayListString = new ArrayList<>(Arrays.asList(list));
	ArrayList<Long> arrayListLong = new ArrayList<>();

	for (String str : arrayListString) {
		arrayListLong.add(Long.parseLong(str));
	}

	Timber.v("retrieved list of durations:%s", arrayListLong.toString());

	return arrayListLong;

}
 
Example 14
Project: text_converter   File: ResponseData.java   View Source Code Vote up 5 votes
/**
 * Parses response string into ResponseData.
 *
 * @param responseData response data string
 * @throws IllegalArgumentException upon parsing error
 * @return ResponseData object
 */
public static ResponseData parse(String responseData) {
    // Must parse out main response data and response-specific data.
	int index = responseData.indexOf(':');
	String mainData, extraData;
	if ( -1 == index ) {
		mainData = responseData;
		extraData = "";
	} else {
		mainData = responseData.substring(0, index);
		extraData = index >= responseData.length() ? "" : responseData.substring(index+1);
	}

    String [] fields = TextUtils.split(mainData, Pattern.quote("|"));
    if (fields.length < 6) {
        throw new IllegalArgumentException("Wrong number of fields.");
    }

    ResponseData data = new ResponseData();
    data.extra = extraData;
    data.responseCode = Integer.parseInt(fields[0]);
    data.nonce = Integer.parseInt(fields[1]);
    data.packageName = fields[2];
    data.versionCode = fields[3];
    // Application-specific user identifier.
    data.userId = fields[4];
    data.timestamp = Long.parseLong(fields[5]);

    return data;
}
 
Example 15
Project: AndroidBackendlessChat   File: PickerFragment.java   View Source Code Vote up 5 votes
@Override
void readSelectionFromBundle(Bundle inBundle, String key) {
    if (inBundle != null) {
        String ids = inBundle.getString(key);
        if (ids != null) {
            String[] splitIds = TextUtils.split(ids, ",");
            selectedIds.clear();
            Collections.addAll(selectedIds, splitIds);
        }
    }
}
 
Example 16
Project: chat-sdk-android-push-firebase   File: PickerFragment.java   View Source Code Vote up 5 votes
@Override
void readSelectionFromBundle(Bundle inBundle, String key) {
    if (inBundle != null) {
        String ids = inBundle.getString(key);
        if (ids != null) {
            String[] splitIds = TextUtils.split(ids, ",");
            selectedIds.clear();
            Collections.addAll(selectedIds, splitIds);
        }
    }
}
 
Example 17
Project: XDroid-Databinding   File: PersistentCookieStore.java   View Source Code Vote up 5 votes
/**
 * Construct a persistent cookie store.
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context)
{
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new HashMap<String, ConcurrentHashMap<String, Cookie>>();

    // Load any previously stored cookies into the store
    Map<String, ?> prefsMap = cookiePrefs.getAll();
    for (Map.Entry<String, ?> entry : prefsMap.entrySet())
    {
        if (((String) entry.getValue()) != null && !((String) entry.getValue()).startsWith(COOKIE_NAME_PREFIX))
        {
            String[] cookieNames = TextUtils.split((String) entry.getValue(), ",");
            for (String name : cookieNames)
            {
                String encodedCookie = cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
                if (encodedCookie != null)
                {
                    Cookie decodedCookie = decodeCookie(encodedCookie);
                    if (decodedCookie != null)
                    {
                        if (!cookies.containsKey(entry.getKey()))
                            cookies.put(entry.getKey(), new ConcurrentHashMap<String, Cookie>());
                        cookies.get(entry.getKey()).put(name, decodedCookie);
                    }
                }
            }

        }
    }
}
 
Example 18
Project: Chorus-RF-Laptimer   File: AppPreferences.java   View Source Code Vote up 5 votes
public static void applyInAppPreferences() {
    AppState app = AppState.getInstance();

    app.changeShouldSpeakLapTimes(app.preferences.getBoolean(SPEAK_LAP_TIMES, true));
    app.changeShouldSpeakMessages(app.preferences.getBoolean(SPEAK_MESSAGES, true));
    app.changeShouldSpeakEnglishOnly(app.preferences.getBoolean(SPEAK_ENGLISH_ONLY, false));
    app.changeTimeToPrepareForRace(app.preferences.getInt(PREPARATION_TIME, 5));
    app.changeRaceLaps(app.preferences.getInt(LAPS_TO_GO, 5));
    app.changeAdjustmentConst(app.preferences.getInt(LIPO_ADJUSTMENT_CONST, 0));
    app.changeEnableLiPoMonitor(app.preferences.getBoolean(LIPO_MONITOR_ENABLED, true));

    if (app.deviceStates != null) {
        String pilots = app.preferences.getString(DEVICE_PILOTS, "");
        if (!pilots.equals("")) {
            String[] pilotsArray = TextUtils.split(pilots, STRING_ITEMS_DELIMITER);
            int pilotsCount = pilotsArray.length;
            for(int i = 0; i < app.deviceStates.size(); i++) {
                if (i < pilotsCount) {
                    app.changeDevicePilot(i, pilotsArray[i]);
                }
            }
            app.updatePilotNamesInEdits(); //because pilot names in UI are not updated via changeDevicePilot()
        }
    }

    if (app.deviceStates != null) {
        String statuses = app.preferences.getString(DEVICE_ENABLED, "");
        if (!statuses.equals("")) {
            String[] statusesArray = TextUtils.split(statuses, STRING_ITEMS_DELIMITER);
            int statusesCount = statusesArray.length;
            for(int i = 0; i < app.deviceStates.size(); i++) {
                if (i < statusesCount) {
                    app.changeDeviceEnabled(i, Boolean.parseBoolean(statusesArray[i]));
                }
            }
        }
    }
}
 
Example 19
Project: AI-Powered-Intelligent-Banking-Platform   File: RecognitionServiceManager.java   View Source Code Vote up 4 votes
public static String[] getServiceAndLang(String str) {
    return TextUtils.split(str, SEPARATOR);
}
 
Example 20
Project: CSipSimple   File: PreferencesWrapper.java   View Source Code Vote up 2 votes
/**
 * Get list of video codecs registered in preference system by
 * 
 * @return List of possible video codecs
 * @see PreferencesProviderWrapper#setVideoCodecList(java.util.List)
 */
public String[] getVideoCodecList() {
    return TextUtils.split(prefs.getString(CODECS_VIDEO_LIST, ""),  Pattern.quote(CODECS_SEPARATOR) );
}