Example usage for android.util SparseArray get

List of usage examples for android.util SparseArray get

Introduction

In this page you can find the example usage for android.util SparseArray get.

Prototype

public E get(int key) 

Source Link

Document

Gets the Object mapped from the specified key, or null if no such mapping has been made.

Usage

From source file:org.telegraph.messenger.NotificationsController.java

public void processReadMessages(SparseArray<Long> inbox, long dialog_id, int max_date, int max_id,
        boolean isPopup) {
    int oldCount = popupMessages.size();
    if (inbox != null) {
        for (int b = 0; b < inbox.size(); b++) {
            int key = inbox.keyAt(b);
            long messageId = inbox.get(key);
            for (int a = 0; a < pushMessages.size(); a++) {
                MessageObject messageObject = pushMessages.get(a);
                if (messageObject.getDialogId() == key && messageObject.getId() <= (int) messageId) {
                    if (isPersonalMessage(messageObject)) {
                        personal_count--;
                    }/*from ww  w  .  ja v a 2s.co m*/
                    popupMessages.remove(messageObject);
                    pushMessagesDict.remove(messageObject.getId());
                    delayedPushMessages.remove(messageObject);
                    pushMessages.remove(a);
                    a--;
                }
            }
        }
        if (pushMessages.isEmpty() && !popupMessages.isEmpty()) {
            popupMessages.clear();
        }
    }
    if (dialog_id != 0 && (max_id != 0 || max_date != 0)) {
        for (int a = 0; a < pushMessages.size(); a++) {
            MessageObject messageObject = pushMessages.get(a);
            if (messageObject.getDialogId() == dialog_id) {
                boolean remove = false;
                if (max_date != 0) {
                    if (messageObject.messageOwner.date <= max_date) {
                        remove = true;
                    }
                } else {
                    if (!isPopup) {
                        if (messageObject.getId() <= max_id || max_id < 0) {
                            remove = true;
                        }
                    } else {
                        if (messageObject.getId() == max_id || max_id < 0) {
                            remove = true;
                        }
                    }
                }
                if (remove) {
                    if (isPersonalMessage(messageObject)) {
                        personal_count--;
                    }
                    pushMessages.remove(a);
                    delayedPushMessages.remove(messageObject);
                    popupMessages.remove(messageObject);
                    pushMessagesDict.remove(messageObject.getId());
                    a--;
                }
            }
        }
        if (pushMessages.isEmpty() && !popupMessages.isEmpty()) {
            popupMessages.clear();
        }
    }
    if (oldCount != popupMessages.size()) {
        NotificationCenter.getInstance().postNotificationName(NotificationCenter.pushMessagesUpdated);
    }
}

From source file:com.quarterfull.newsAndroid.ListView.SubscriptionExpandableListAdapter.java

public Tuple<ArrayList<AbstractItem>, SparseArray<ArrayList<ConcreteFeedItem>>> ReloadAdapter() {
    SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
    showOnlyUnread = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);

    ArrayList<AbstractItem> mCategoriesArrayListAsync = new ArrayList<>();
    mCategoriesArrayListAsync.add(new FolderSubscribtionItem(mContext.getString(R.string.allUnreadFeeds), null,
            ALL_UNREAD_ITEMS.getValue()));
    mCategoriesArrayListAsync.add(new FolderSubscribtionItem(mContext.getString(R.string.starredFeeds), null,
            ALL_STARRED_ITEMS.getValue()));

    StopWatch sw = new StopWatch();
    sw.start();/* w  w  w . j  a  v  a 2  s. co  m*/

    List<Folder> folderList;
    //if(showOnlyUnread) {
    //    folderList = dbConn.getListOfFoldersWithUnreadItems();
    //} else {
    folderList = dbConn.getListOfFolders();
    //}

    sw.stop();
    Log.v(TAG, "Time needed (fetch folder list): " + sw.toString());

    for (Folder folder : folderList) {
        mCategoriesArrayListAsync.add(new FolderSubscribtionItem(folder.getLabel(), null, folder.getId()));
    }

    for (Feed feed : dbConn.getListOfFeedsWithoutFolders(showOnlyUnread)) {
        mCategoriesArrayListAsync.add(new ConcreteFeedItem(feed.getFeedTitle(),
                (long) ITEMS_WITHOUT_FOLDER.getValue(), feed.getId(), feed.getFaviconUrl(), feed.getId()));
    }

    SparseArray<ArrayList<ConcreteFeedItem>> mItemsArrayListAsync = new SparseArray<>();

    for (int groupPosition = 0; groupPosition < mCategoriesArrayListAsync.size(); groupPosition++) {
        //int parent_id = (int)getGroupId(groupPosition);
        int parent_id = (int) mCategoriesArrayListAsync.get(groupPosition).id_database;
        mItemsArrayListAsync.append(parent_id, new ArrayList<ConcreteFeedItem>());

        List<Feed> feedItemList = null;

        if (parent_id == ALL_UNREAD_ITEMS.getValue()) {
            feedItemList = dbConn.getAllFeedsWithUnreadRssItems();
        } else if (parent_id == ALL_STARRED_ITEMS.getValue()) {
            feedItemList = dbConn.getAllFeedsWithStarredRssItems();
        } else {
            for (Folder folder : folderList) {//Find the current selected folder
                if (folder.getId() == parent_id) {//Current item
                    feedItemList = dbConn.getAllFeedsWithUnreadRssItemsForFolder(folder.getId());
                    break;
                }
            }
        }

        if (feedItemList != null) {
            for (Feed feed : feedItemList) {
                ConcreteFeedItem newItem = new ConcreteFeedItem(feed.getFeedTitle(), (long) parent_id,
                        feed.getId(), feed.getFaviconUrl(), feed.getId());
                mItemsArrayListAsync.get(parent_id).add(newItem);
            }
        }
    }

    return new Tuple<>(mCategoriesArrayListAsync, mItemsArrayListAsync);
}

From source file:com.staggeredgrid.library.StaggeredGridView.java

/***
 * Our mColumnTops and mColumnBottoms need to be re-built up to the
 * mSyncPosition - the following layout request will then
 * layout the that position and then fillUp and fillDown appropriately.
 *//*from w  ww .  ja  v  a 2  s  . co  m*/
private void onColumnSync() {
    // re-calc tops for new column count!
    int syncPosition = Math.min(mSyncPosition, getCount() - 1);

    SparseArray<Double> positionHeightRatios = new SparseArray<Double>(syncPosition);
    for (int pos = 0; pos < syncPosition; pos++) {
        // check for weirdness
        final GridItemRecord rec = mPositionData.get(pos);
        if (rec == null)
            break;

        Log.d(TAG, "onColumnSync:" + pos + " ratio:" + rec.heightRatio);
        positionHeightRatios.append(pos, rec.heightRatio);
    }

    mPositionData.clear();

    // re-calc our relative position while at the same time
    // rebuilding our GridItemRecord collection

    if (DBG)
        Log.d(TAG, "onColumnSync column width:" + mColumnWidth);

    for (int pos = 0; pos < syncPosition; pos++) {
        //Check for weirdness again
        final Double heightRatio = positionHeightRatios.get(pos);
        if (heightRatio == null) {
            break;
        }

        final GridItemRecord rec = getOrCreateRecord(pos);
        final int height = (int) (mColumnWidth * heightRatio);
        rec.heightRatio = heightRatio;

        int top;
        int bottom;
        // check for headers
        if (isHeaderOrFooter(pos)) {
            // the next top is the bottom for that column
            top = getLowestPositionedBottom();
            bottom = top + height;

            for (int i = 0; i < mColumnCount; i++) {
                mColumnTops[i] = top;
                mColumnBottoms[i] = bottom;
            }
        } else {
            // what's the next column down ?
            final int column = getHighestPositionedBottomColumn();
            // the next top is the bottom for that column
            top = mColumnBottoms[column];
            bottom = top + height + getChildTopMargin(pos) + getChildBottomMargin();

            mColumnTops[column] = top;
            mColumnBottoms[column] = bottom;

            rec.column = column;
        }

        if (DBG)
            Log.d(TAG, "onColumnSync position:" + pos + " top:" + top + " bottom:" + bottom + " height:"
                    + height + " heightRatio:" + heightRatio);
    }

    // our sync position will be displayed in this column
    final int syncColumn = getHighestPositionedBottomColumn();
    setPositionColumn(syncPosition, syncColumn);

    // we want to offset from height of the sync position
    // minus the offset
    int syncToBottom = mColumnBottoms[syncColumn];
    int offset = -syncToBottom + mSpecificTop;
    // offset all columns by
    offsetAllColumnsTopAndBottom(offset);

    // sync the distance to top
    mDistanceToTop = -syncToBottom;

    // stash our bottoms in our tops - though these will be copied back to the bottoms
    System.arraycopy(mColumnBottoms, 0, mColumnTops, 0, mColumnCount);
}

From source file:de.damdi.fitness.activity.settings.sync.WgerJSONParser.java

/**
 * Constructor. Will start download immediately.
 * /*from  w  w  w  .j av a2s  .  c  o m*/
 * @param exerciseJSONString
 *            The exercises as JSON-String
 * @param languageJSONString
 *            The languages as JSON-String
 * @param muscleJSONString
 *            The muscles as JSON-String
 * @param dataProvider
 * @throws JSONException
 */
public WgerJSONParser(String exerciseJSONString, String languageJSONString, String muscleJSONString,
        String equipmentJSONString, IDataProvider dataProvider) throws JSONException {
    mDataProvider = dataProvider;

    // parse languages
    SparseArray<Locale> localeSparseArray = parseLanguages(languageJSONString);
    // parse muscles
    SparseArray<Muscle> muscleSparseArray = parseMuscles(muscleJSONString);
    // parse equipment (not required until REST-API supports this)
    // SparseArray<SportsEquipment> equipmentSparseArray = parseEquipment(equipmentJSONString);

    JSONObject mainObject = new JSONObject(exerciseJSONString);
    Log.d(TAG, mainObject.toString());
    JSONArray exerciseArray = mainObject.getJSONArray("objects");

    // parse each exercise of the JSON Array
    for (int i = 0; i < exerciseArray.length(); i++) {

        JSONObject jsonExercise = exerciseArray.getJSONObject(i);
        // get name and check if exercise already exists
        String name = jsonExercise.getString("name");
        if (dataProvider.exerciseExists(name))
            continue;

        ExerciseType.Builder builder = new ExerciseType.Builder(name);

        // category (unused)
        // String category = jsonExercise.getString("category");

        // comments (unused)
        // JSONArray commentArray = jsonExercise.getJSONArray("comments");
        // for (int k = 0; k < commentArray.length(); k++) {
        //   String comment = commentArray.getString(k);
        //}

        // description
        String description = jsonExercise.getString("description");
        builder.description(description);

        // id (unused)
        //String id = jsonExercise.getString("id");

        // language
        // the json-language String might look like this:
        // '/api/v1/language/1/'
        // only the number at the end is required
        String language = jsonExercise.getString("language");
        int languageNumber = getLastNumberOfJson(language);

        Map<Locale, String> translationMap = new HashMap<Locale, String>();
        translationMap.put(localeSparseArray.get(languageNumber), name);
        builder.translationMap(translationMap);

        // resource_uri (unused)
        //String resource_uri = jsonExercise.getString("resource_uri");

        // muscles
        SortedSet<Muscle> muscleSet = new TreeSet<Muscle>();
        JSONArray muscleArray = jsonExercise.getJSONArray("muscles");
        for (int l = 0; l < muscleArray.length(); l++) {
            String muscleString = muscleArray.getString(l);
            Muscle muscle = muscleSparseArray.get(getLastNumberOfJson(muscleString));
            muscleSet.add(muscle);
        }
        builder.activatedMuscles(muscleSet);

        // equipment
        // not yet supported by REST-API
        /*SortedSet<SportsEquipment> equipmentSet = new TreeSet<SportsEquipment>();
        JSONArray equipmentArray = jsonExercise.getJSONArray("equipment");
        for (int l = 0; l < equipmentArray.length(); l++) {
           String equipmentString = equipmentArray.getString(l);
           SportsEquipment equipment = equipmentSparseArray.get(getLastNumberOfJson(equipmentString));
           equipmentSet.add(equipment);
        }*/

        builder.activatedMuscles(muscleSet);
        // images
        List<File> imageList = new ArrayList<File>();
        JSONArray imageArray = jsonExercise.getJSONArray("images");
        for (int l = 0; l < imageArray.length(); l++) {
            String imageString = imageArray.getString(l);
            imageList.add(new File(imageString));
        }
        builder.imagePath(imageList);

        mNewExerciseList.add(builder.build());
        mNewExerciseBuilderList.add(builder);
    }

}

From source file:com.oakesville.mythling.MediaActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v == getListView()) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        Listable listable = (Listable) getListView().getItemAtPosition(info.position);
        if (listable instanceof Item) {
            Item item = (Item) listable;
            menu.setHeaderTitle(item.getDialogTitle());
            if (isSplitView()) {
                getListView().performItemClick(getListView().getChildAt(info.position), info.position,
                        getListView().getAdapter().getItemId(info.position));
            } else {
                getListView().setItemChecked(info.position, true);
            }//  w  w w. j  a  v  a 2  s  .c o  m
            SparseArray<String> menuItems = getLongClickMenuItems(item);
            for (int i = 0; i < menuItems.size(); i++) {
                int id = menuItems.keyAt(i);
                menu.add(MEDIA_ACTIVITY_CONTEXT_MENU_GROUP_ID, id, id, menuItems.get(id));
            }
        }
    }
}

From source file:dev.ukanth.ufirewall.Api.java

/**
 * @param ctx application context (mandatory)
 * @return a list of applications/*from w w  w.j av a  2s  .c  om*/
 */
public static List<PackageInfoData> getApps(Context ctx, GetAppList appList) {

    initSpecial();
    if (applications != null && applications.size() > 0) {
        // return cached instance
        return applications;
    }

    final SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
    final boolean enableVPN = defaultPrefs.getBoolean("enableVPN", false);
    final boolean enableLAN = defaultPrefs.getBoolean("enableLAN", false);
    final boolean enableRoam = defaultPrefs.getBoolean("enableRoam", true);

    final SharedPreferences prefs = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);

    final String savedPkg_wifi_uid = prefs.getString(PREF_WIFI_PKG_UIDS, "");
    final String savedPkg_3g_uid = prefs.getString(PREF_3G_PKG_UIDS, "");
    final String savedPkg_roam_uid = prefs.getString(PREF_ROAMING_PKG_UIDS, "");
    final String savedPkg_vpn_uid = prefs.getString(PREF_VPN_PKG_UIDS, "");
    final String savedPkg_lan_uid = prefs.getString(PREF_LAN_PKG_UIDS, "");

    List<Integer> selected_wifi = new ArrayList<Integer>();
    List<Integer> selected_3g = new ArrayList<Integer>();
    List<Integer> selected_roam = new ArrayList<Integer>();
    List<Integer> selected_vpn = new ArrayList<Integer>();
    List<Integer> selected_lan = new ArrayList<Integer>();

    selected_wifi = getListFromPref(savedPkg_wifi_uid);
    selected_3g = getListFromPref(savedPkg_3g_uid);

    if (enableRoam) {
        selected_roam = getListFromPref(savedPkg_roam_uid);
    }
    if (enableVPN) {
        selected_vpn = getListFromPref(savedPkg_vpn_uid);
    }
    if (enableLAN) {
        selected_lan = getListFromPref(savedPkg_lan_uid);
    }
    //revert back to old approach

    //always use the defaul preferences to store cache value - reduces the application usage size
    final SharedPreferences cachePrefs = ctx.getSharedPreferences("AFWallPrefs", Context.MODE_PRIVATE);

    int count = 0;
    try {
        final PackageManager pkgmanager = ctx.getPackageManager();
        final List<ApplicationInfo> installed = pkgmanager
                .getInstalledApplications(PackageManager.GET_META_DATA);
        SparseArray<PackageInfoData> syncMap = new SparseArray<PackageInfoData>();
        final Editor edit = cachePrefs.edit();
        boolean changed = false;
        String name = null;
        String cachekey = null;
        final String cacheLabel = "cache.label.";
        PackageInfoData app = null;
        ApplicationInfo apinfo = null;

        for (int i = 0; i < installed.size(); i++) {
            //for (final ApplicationInfo apinfo : installed) {
            count = count + 1;
            apinfo = installed.get(i);

            if (appList != null) {
                appList.doProgress(count);
            }

            boolean firstseen = false;
            app = syncMap.get(apinfo.uid);
            // filter applications which are not allowed to access the Internet
            if (app == null && PackageManager.PERMISSION_GRANTED != pkgmanager
                    .checkPermission(Manifest.permission.INTERNET, apinfo.packageName)) {
                continue;
            }
            // try to get the application label from our cache - getApplicationLabel() is horribly slow!!!!
            cachekey = cacheLabel + apinfo.packageName;
            name = prefs.getString(cachekey, "");
            if (name.length() == 0) {
                // get label and put on cache
                name = pkgmanager.getApplicationLabel(apinfo).toString();
                edit.putString(cachekey, name);
                changed = true;
                firstseen = true;
            }
            if (app == null) {
                app = new PackageInfoData();
                app.uid = apinfo.uid;
                app.names = new ArrayList<String>();
                app.names.add(name);
                app.appinfo = apinfo;
                app.pkgName = apinfo.packageName;
                syncMap.put(apinfo.uid, app);
            } else {
                app.names.add(name);
            }
            app.firstseen = firstseen;
            // check if this application is selected
            if (!app.selected_wifi && Collections.binarySearch(selected_wifi, app.uid) >= 0) {
                app.selected_wifi = true;
            }
            if (!app.selected_3g && Collections.binarySearch(selected_3g, app.uid) >= 0) {
                app.selected_3g = true;
            }
            if (enableRoam && !app.selected_roam && Collections.binarySearch(selected_roam, app.uid) >= 0) {
                app.selected_roam = true;
            }
            if (enableVPN && !app.selected_vpn && Collections.binarySearch(selected_vpn, app.uid) >= 0) {
                app.selected_vpn = true;
            }
            if (enableLAN && !app.selected_lan && Collections.binarySearch(selected_lan, app.uid) >= 0) {
                app.selected_lan = true;
            }

        }

        List<PackageInfoData> specialData = new ArrayList<PackageInfoData>();
        specialData.add(new PackageInfoData(SPECIAL_UID_ANY, ctx.getString(R.string.all_item),
                "dev.afwall.special.any"));
        specialData.add(new PackageInfoData(SPECIAL_UID_KERNEL, ctx.getString(R.string.kernel_item),
                "dev.afwall.special.kernel"));
        specialData.add(new PackageInfoData(SPECIAL_UID_TETHER, ctx.getString(R.string.tethering_item),
                "dev.afwall.special.tether"));
        //specialData.add(new PackageInfoData(SPECIAL_UID_DNSPROXY, ctx.getString(R.string.dnsproxy_item), "dev.afwall.special.dnsproxy"));
        specialData.add(new PackageInfoData(SPECIAL_UID_NTP, ctx.getString(R.string.ntp_item),
                "dev.afwall.special.ntp"));
        specialData
                .add(new PackageInfoData("root", ctx.getString(R.string.root_item), "dev.afwall.special.root"));
        specialData.add(new PackageInfoData("media", "Media server", "dev.afwall.special.media"));
        specialData.add(new PackageInfoData("vpn", "VPN networking", "dev.afwall.special.vpn"));
        specialData.add(new PackageInfoData("shell", "Linux shell", "dev.afwall.special.shell"));
        specialData.add(new PackageInfoData("gps", "GPS", "dev.afwall.special.gps"));
        specialData.add(new PackageInfoData("adb", "ADB (Android Debug Bridge)", "dev.afwall.special.adb"));

        if (specialApps == null) {
            specialApps = new HashMap<String, Integer>();
        }
        for (int i = 0; i < specialData.size(); i++) {
            app = specialData.get(i);
            specialApps.put(app.pkgName, app.uid);
            //default DNS/NTP
            if (app.uid != -1 && syncMap.get(app.uid) == null) {
                // check if this application is allowed
                if (!app.selected_wifi && Collections.binarySearch(selected_wifi, app.uid) >= 0) {
                    app.selected_wifi = true;
                }
                if (!app.selected_3g && Collections.binarySearch(selected_3g, app.uid) >= 0) {
                    app.selected_3g = true;
                }
                if (enableRoam && !app.selected_roam && Collections.binarySearch(selected_roam, app.uid) >= 0) {
                    app.selected_roam = true;
                }
                if (enableVPN && !app.selected_vpn && Collections.binarySearch(selected_vpn, app.uid) >= 0) {
                    app.selected_vpn = true;
                }
                if (enableLAN && !app.selected_lan && Collections.binarySearch(selected_lan, app.uid) >= 0) {
                    app.selected_lan = true;
                }
                syncMap.put(app.uid, app);
            }
        }

        if (changed) {
            edit.commit();
        }
        /* convert the map into an array */
        applications = new ArrayList<PackageInfoData>();
        for (int i = 0; i < syncMap.size(); i++) {
            applications.add(syncMap.valueAt(i));
        }

        return applications;
    } catch (Exception e) {
        alert(ctx, ctx.getString(R.string.error_common) + e);
    }
    return null;
}

From source file:de.skubware.opentraining.activity.settings.sync.WgerJSONParser.java

/**
 * Constructor. Will start download immediately.
 * /*  w ww  .  j a  v a  2s. c  o m*/
 * @param exerciseJSONString
 *            The exercises as JSON-String
 * @param languageJSONString
 *            The languages as JSON-String
 * @param muscleJSONString
 *            The muscles as JSON-String
 * @param dataProvider
 * @throws JSONException
 */
public WgerJSONParser(String exerciseJSONString, String languageJSONString, String muscleJSONString,
        String equipmentJSONString, String licenseJSONString, IDataProvider dataProvider) throws JSONException {
    mDataProvider = dataProvider;

    // parse languages
    SparseArray<Locale> localeSparseArray = parseLanguages(languageJSONString);
    // parse muscles
    SparseArray<Muscle> muscleSparseArray = parseMuscles(muscleJSONString);
    // parse licenses
    SparseArray<LicenseType> licenseSparseArray = parseLicenses(licenseJSONString);

    // parse equipment (not required until REST-API supports this)
    // SparseArray<SportsEquipment> equipmentSparseArray = parseEquipment(equipmentJSONString);

    JSONObject mainObject = new JSONObject(exerciseJSONString);
    Log.d(TAG, mainObject.toString());
    JSONArray exerciseArray = mainObject.getJSONArray("objects");

    // parse each exercise of the JSON Array
    for (int i = 0; i < exerciseArray.length(); i++) {

        JSONObject jsonExercise = exerciseArray.getJSONObject(i);
        // get name and check if exercise already exists
        String name = jsonExercise.getString("name");
        if (dataProvider.exerciseExists(name))
            continue;

        ExerciseType.Builder builder = new ExerciseType.Builder(name, ExerciseSource.SYNCED);

        // category (unused)
        // String category = jsonExercise.getString("category");

        // comments (unused)
        // JSONArray commentArray = jsonExercise.getJSONArray("comments");
        // for (int k = 0; k < commentArray.length(); k++) {
        //   String comment = commentArray.getString(k);
        //}

        // description
        String description = jsonExercise.getString("description");
        builder.description(description);

        // id (unused)
        //String id = jsonExercise.getString("id");

        // language
        // the json-language String might look like this:
        // '/api/v1/language/1/'
        // only the number at the end is required
        String language = jsonExercise.getString("language");
        int languageNumber = getLastNumberOfJson(language);

        Map<Locale, String> translationMap = new HashMap<Locale, String>();
        translationMap.put(localeSparseArray.get(languageNumber), name);
        builder.translationMap(translationMap);

        // resource_uri (unused)
        //String resource_uri = jsonExercise.getString("resource_uri");

        // muscles
        SortedSet<Muscle> muscleSet = new TreeSet<Muscle>();
        JSONArray muscleArray = jsonExercise.getJSONArray("muscles");
        for (int l = 0; l < muscleArray.length(); l++) {
            String muscleString = muscleArray.getString(l);
            Muscle muscle = muscleSparseArray.get(getLastNumberOfJson(muscleString));
            muscleSet.add(muscle);
        }
        builder.activatedMuscles(muscleSet);

        // licenses
        // the json-language String might look like this:
        // '/api/v1/license/1/'
        // only the number at the end is required

        if (jsonExercise.has("license")) {
            int licenseNumber = getLastNumberOfJson(jsonExercise.getString("license"));
            LicenseType licenseType = licenseSparseArray.get(licenseNumber);
            String license_author = jsonExercise.getString("license_author");
            Log.v(TAG, "license=" + licenseType + " license_author=" + license_author);
        }

        // equipment
        // not yet supported by REST-API
        /*SortedSet<SportsEquipment> equipmentSet = new TreeSet<SportsEquipment>();
        JSONArray equipmentArray = jsonExercise.getJSONArray("equipment");
        for (int l = 0; l < equipmentArray.length(); l++) {
           String equipmentString = equipmentArray.getString(l);
           SportsEquipment equipment = equipmentSparseArray.get(getLastNumberOfJson(equipmentString));
           equipmentSet.add(equipment);
        }*/

        builder.activatedMuscles(muscleSet);
        // images
        List<File> imageList = new ArrayList<File>();
        JSONArray imageArray = jsonExercise.getJSONArray("images");
        for (int l = 0; l < imageArray.length(); l++) {
            String imageString = imageArray.getString(l);
            imageList.add(new File(imageString));
        }
        builder.imagePath(imageList);

        mNewExerciseList.add(builder.build());
        mNewExerciseBuilderList.add(builder);
    }

}

From source file:android.transitions.everywhere.Transition.java

/**
 * Match start/end values by Adapter view ID. Adds matched values to mStartValuesList
 * and mEndValuesList and removes them from unmatchedStart and unmatchedEnd, using
 * startIds and endIds as a guide for which Views have unique IDs.
 *//*from   w  ww  . j  a v a  2 s .  c  om*/
private void matchIds(ArrayMap<View, TransitionValues> unmatchedStart,
        ArrayMap<View, TransitionValues> unmatchedEnd, SparseArray<View> startIds, SparseArray<View> endIds) {
    int numStartIds = startIds.size();
    for (int i = 0; i < numStartIds; i++) {
        View startView = startIds.valueAt(i);
        if (startView != null && isValidTarget(startView)) {
            View endView = endIds.get(startIds.keyAt(i));
            if (endView != null && isValidTarget(endView)) {
                TransitionValues startValues = unmatchedStart.get(startView);
                TransitionValues endValues = unmatchedEnd.get(endView);
                if (startValues != null && endValues != null) {
                    mStartValuesList.add(startValues);
                    mEndValuesList.add(endValues);
                    unmatchedStart.remove(startView);
                    unmatchedEnd.remove(endView);
                }
            }
        }
    }
}

From source file:com.httrack.android.HTTrackActivity.java

/**
 * Return the project category of a given project.
 * //from   w ww.jav  a2s. co  m
 * @param projectName
 * @return the project category, or @c null if none (or there is no such
 *         project)
 */
private String getProjectCategory(final String projectName) {
    final SparseArray<String> projectMap = new SparseArray<String>();
    final File target = new File(getProjectRootFile(), projectName);
    try {
        OptionsMapper.unserialize(HTTrackActivity.getProfileFile(target), projectMap);
        final String description = projectMap.get(R.id.fieldProjectCategory);
        return description;
    } catch (final IOException e) {
        return null;
    }
}

From source file:com.android.launcher3.CellLayout.java

private ParcelableSparseArray getJailedArray(SparseArray<Parcelable> container) {
    final Parcelable parcelable = container.get(R.id.cell_layout_jail_id);
    return parcelable instanceof ParcelableSparseArray ? (ParcelableSparseArray) parcelable
            : new ParcelableSparseArray();
}