Example usage for android.text TextUtils split

List of usage examples for android.text TextUtils split

Introduction

In this page you can find the example usage for android.text TextUtils split.

Prototype

public static String[] split(String text, Pattern pattern) 

Source Link

Document

Splits a string on a pattern.

Usage

From source file:net.kjmaster.cookiemom.settings.SettingsFragment.java

@AfterViews
void afterViews() {
    if (TextUtils.split(iSettings.CookieList().get(), ",").length != getResources()
            .getStringArray(R.array.cookie_names_array).length) {
        fillCookieList(TextUtils.join(",", getResources().getStringArray(R.array.cookie_names_array)));
        iSettings.CookieList()/*from   w  w w.ja va  2 s  .  c o m*/
                .put(TextUtils.join(",", getResources().getStringArray(R.array.cookie_names_array)));
    } else {
        fillCookieList(iSettings.CookieList().get());
    }
    setChecks();
    createHooks();
    setting_cookie_list.setEnabled(iSettings.useCustomCookies().get());
    settings_edit_cookie.setEnabled(iSettings.useCustomCookies().get());
    setting_save_cookie.setEnabled(iSettings.useCustomCookies().get());
}

From source file:cn.caimatou.canting.utils.http.asynchttp.PersistentCookieStore.java

/**
 * Construct a persistent cookie store.// w ww .j a v a  2 s .  c o  m
 */
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());
    }
}

From source file:com.gwm.android.PreferencesCookieStore.java

/**
 * Construct a persistent cookie store./*www . j  a va 2s . c  om*/
 */
private PreferencesCookieStore(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());
    }
}

From source file:com.blazeroni.reddit.http.PersistentCookieStore.java

/**
* Construct a persistent cookie store.//from  w  ww . j  a  v a2 s  .c  o  m
*/
public PersistentCookieStore(Context context) {
    this.cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, MODE_PRIVATE);
    this.cookies = new ConcurrentHashMap<String, Cookie>();

    // Load any previously stored cookies into the store
    String storedCookieNames = this.cookiePrefs.getString(COOKIE_NAME_STORE, null);

    if (storedCookieNames != null) {
        String[] cookieNames = TextUtils.split(storedCookieNames, ",");
        for (String name : cookieNames) {
            String encodedCookie = this.cookiePrefs.getString(COOKIE_NAME_PREFIX + name, null);
            if (encodedCookie != null) {
                Cookie decodedCookie = decodeCookie(encodedCookie);
                if (decodedCookie != null) {
                    this.cookies.put(name, decodedCookie);
                }
            }
        }

        // Clear out expired cookies
        clearExpired(new Date());
    }
}

From source file:gr.ellak.ma.emergencyroad.PersistentCookieStore.java

/**
 * Construct a persistent cookie store.//from  w  w w.  j av a  2  s .co  m
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new ConcurrentHashMap<>();

    // 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());
    }
}

From source file:com.library.loopj.android.http.PersistentCookieStore.java

/**
 * Construct a persistent cookie store./*from www. j a va 2  s .  co  m*/
 *
 * @param context Context to attach cookie store to
 */
public PersistentCookieStore(Context context) {
    cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
    cookies = new ConcurrentHashMap();

    // 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());
    }
}

From source file:net.kjmaster.cookiemom.settings.SettingsActivity.java

public void SaveCookie(String oldCookieName, String newCookieName) {
    cookieList = cookieList.replace(oldCookieName, newCookieName);
    if (TextUtils.split(cookieList, ",").length != getResources()
            .getStringArray(R.array.cookie_names_array).length) {
        cookieList = iSettings.CookieList().get();
    } else {/*  ww  w . j av  a  2 s .c om*/
        iSettings.CookieList().put(cookieList);

        updateOrdes(oldCookieName, newCookieName);
        updateTrans(oldCookieName, newCookieName);
        Constants.updateCookieTypes(TextUtils.split(cookieList, ","));
        Main.mCookieTypes = TextUtils.split(cookieList, ",");
    }

    settingsFragment.fillCookieList(cookieList);
}

From source file:net.vleu.par.android.rpc.PersistentCookieStore.java

/**
 * Construct a persistent cookie store./*  w w  w .j  ava  2s .  c  o  m*/
 */
public PersistentCookieStore(final SharedPreferences cookiePrefs) {
    this.cookiePrefs = cookiePrefs;
    this.cookies = new ConcurrentHashMap<String, Cookie>();

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

        // Clear out expired cookies
        clearExpired(new Date());
    }
}

From source file:com.appsimobile.appsihomeplugins.dashclock.phone.SmsExtension.java

@Override
public void onUpdateData(FieldValues.Builder builder) {
    long lastUnreadThreadId = 0;
    Set<Long> unreadThreadIds = new HashSet<Long>();
    Set<String> unreadThreadParticipantNames = new HashSet<String>();
    boolean showingAllConversationParticipants = false;

    Cursor cursor = tryOpenSimpleThreadsCursor();
    if (cursor != null) {
        while (cursor.moveToNext()) {
            if (cursor.getInt(SimpleThreadsQuery.READ) == 0) {
                long threadId = cursor.getLong(SimpleThreadsQuery._ID);
                unreadThreadIds.add(threadId);
                lastUnreadThreadId = threadId;

                // Some devices will fail on tryOpenMmsSmsCursor below, so
                // store a list of participants on unread threads as a fallback.
                String recipientIdsStr = cursor.getString(SimpleThreadsQuery.RECIPIENT_IDS);
                if (!TextUtils.isEmpty(recipientIdsStr)) {
                    String[] recipientIds = TextUtils.split(recipientIdsStr, " ");
                    for (String recipientId : recipientIds) {
                        Cursor canonAddrCursor = tryOpenCanonicalAddressCursorById(Long.parseLong(recipientId));
                        if (canonAddrCursor == null) {
                            continue;
                        }/*from   w  w  w .j a v  a 2s.c  o m*/
                        if (canonAddrCursor.moveToFirst()) {
                            String address = canonAddrCursor.getString(CanonicalAddressQuery.ADDRESS);
                            String displayName = getDisplayNameForContact(0, address);
                            if (!TextUtils.isEmpty(displayName)) {
                                unreadThreadParticipantNames.add(displayName);
                            }
                        }
                        canonAddrCursor.close();
                    }
                }
            }
        }
        cursor.close();

        LOGD(TAG, "Unread thread IDs: [" + TextUtils.join(", ", unreadThreadIds) + "]");
    }

    int unreadConversations = 0;
    StringBuilder names = new StringBuilder();
    cursor = tryOpenMmsSmsCursor();
    if (cursor != null) {
        // Most devices will hit this code path.
        while (cursor.moveToNext()) {
            // Get display name. SMS's are easy; MMS's not so much.
            long id = cursor.getLong(MmsSmsQuery._ID);
            long contactId = cursor.getLong(MmsSmsQuery.PERSON);
            String address = cursor.getString(MmsSmsQuery.ADDRESS);
            long threadId = cursor.getLong(MmsSmsQuery.THREAD_ID);
            if (unreadThreadIds != null && !unreadThreadIds.contains(threadId)) {
                // We have the list of all thread IDs (same as what the messaging app uses), and
                // this supposedly unread message's thread isn't in the list. This message is
                // likely an orphaned message whose thread was deleted. Not skipping it is
                // likely the cause of http://code.google.com/p/dashclock/issues/detail?id=8
                LOGD(TAG, "Skipping probably orphaned message " + id + " with thread ID " + threadId);
                continue;
            }

            ++unreadConversations;
            lastUnreadThreadId = threadId;

            if (contactId == 0 && TextUtils.isEmpty(address) && id != 0) {
                // Try MMS addr query
                Cursor addrCursor = tryOpenMmsAddrCursor(id);
                if (addrCursor != null) {
                    if (addrCursor.moveToFirst()) {
                        contactId = addrCursor.getLong(MmsAddrQuery.CONTACT_ID);
                        address = addrCursor.getString(MmsAddrQuery.ADDRESS);
                    }
                    addrCursor.close();
                }
            }

            String displayName = getDisplayNameForContact(contactId, address);

            if (names.length() > 0) {
                names.append(", ");
            }
            names.append(displayName);
        }
        cursor.close();

    } else {
        // In case the cursor is null (some Samsung devices like the Galaxy S4), use the
        // fall back on the list of participants in unread threads.
        unreadConversations = unreadThreadIds.size();
        names.append(TextUtils.join(", ", unreadThreadParticipantNames));
        showingAllConversationParticipants = true;
    }

    Intent clickIntent;
    if (unreadConversations == 1 && lastUnreadThreadId > 0) {
        clickIntent = new Intent(Intent.ACTION_VIEW, TelephonyProviderConstants.MmsSms.CONTENT_CONVERSATIONS_URI
                .buildUpon().appendPath(Long.toString(lastUnreadThreadId)).build());
    } else {
        clickIntent = IntentCompat.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_MESSAGING);
    }

    PendingIntent pendingIntent = PendingIntent.getActivity(getContext(),
            DashClockHomeExtension.DASHCLOCK_EXTENSION_SMS, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    builder.leftImageResId(R.drawable.ic_extension_sms).intent(pendingIntent).header(getResources()
            .getQuantityString(R.plurals.sms_title_template, unreadConversations, unreadConversations));
    if (unreadConversations > 0) {
        builder.text(getString(showingAllConversationParticipants ? R.string.sms_body_all_participants_template
                : R.string.sms_body_template, names.toString()));
    }

    /*
            
    publishUpdate(new ExtensionData()
        .visible(unreadConversations > 0)
        .icon(R.drawable.ic_extension_sms)
        .status(Integer.toString(unreadConversations))
        .expandedTitle(
                getResources().getQuantityString(
                        R.plurals.sms_title_template, unreadConversations,
                        unreadConversations))
        .expandedBody(getString(showingAllConversationParticipants
                ? R.string.sms_body_all_participants_template
                : R.string.sms_body_template,
                names.toString()))
        .clickIntent(clickIntent));
    */
}

From source file:com.anysoftkeyboard.quicktextkeys.QuickTextKeyFactory.java

public static List<QuickTextKey> getOrderedEnabledQuickKeys(Context applicationContext) {
    List<QuickTextKey> quickTextKeys = new ArrayList<>(getAllAvailableQuickKeys(applicationContext));

    //now, reading the ordered array of active keys
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext);
    String settingKey = applicationContext.getString(R.string.settings_key_ordered_active_quick_text_keys);

    List<String> quickKeyIdDefaultOrder = new ArrayList<>(quickTextKeys.size());
    for (QuickTextKey key : quickTextKeys) {
        quickKeyIdDefaultOrder.add(key.getId());
    }//from ww w .  j ava  2s.  c o m
    String quickKeyIdsOrderValue = sharedPreferences.getString(settingKey,
            TextUtils.join(",", quickKeyIdDefaultOrder));
    String[] quickKeyIdsOrder = TextUtils.split(quickKeyIdsOrderValue, ",");

    ArrayList<QuickTextKey> orderedQuickTextKeys = new ArrayList<>(quickKeyIdsOrder.length);
    for (String keyId : quickKeyIdsOrder) {
        QuickTextKey addOn = msInstance.getAddOnById(keyId, applicationContext);
        if (addOn != null)
            orderedQuickTextKeys.add(addOn);
    }

    //forcing at least one key
    if (orderedQuickTextKeys.size() == 0)
        orderedQuickTextKeys.add(quickTextKeys.get(0));

    return orderedQuickTextKeys;
}