Example usage for android.support.v4.util LongSparseArray LongSparseArray

List of usage examples for android.support.v4.util LongSparseArray LongSparseArray

Introduction

In this page you can find the example usage for android.support.v4.util LongSparseArray LongSparseArray.

Prototype

public LongSparseArray() 

Source Link

Usage

From source file:de.vanita5.twittnuker.util.collection.LongSparseMap.java

public LongSparseMap() {
    internalArray = new LongSparseArray<>();
}

From source file:ru.orangesoftware.financisto2.model.MyEntity.java

public static <T extends MyEntity> LongSparseArray<T> asMap(List<T> list) {
    LongSparseArray<T> map = new LongSparseArray<T>();
    for (T e : list) {
        map.put(e.id, e);/*from   w  w w  .  j  av a 2s .c o  m*/
    }
    return map;
}

From source file:com.wikaba.ogapp.AgentService.java

@Override
public void onCreate() {
    super.onCreate();
    if (ogameSessions == null) {
        ogameSessions = new LongSparseArray<OgameAgent>();
    }/*from   ww w.  j a v  a  2s  . c  om*/

    if (dbman == null) {
        dbman = new DatabaseManager(this);
    }

    CustomCookieManager cookieman = new CustomCookieManager();
    CookieStore cookiestore = cookieman.getCookieStore();

    //Retrieve all cookies from database.
    //Warning: This is currently done on the main thread.
    ArrayList<HttpCookie> cookieList = dbman.getCookies();
    for (Iterator<HttpCookie> cookieIter = cookieList.iterator(); cookieIter.hasNext();) {
        HttpCookie cookie = cookieIter.next();
        cookiestore.add(null, cookie);
    }

    CookieHandler.setDefault(cookieman);
}

From source file:com.example.martin.maps.clustering.algo.GridBasedAlgorithm.java

@Override
public Set<? extends Cluster<T>> getClusters(double zoom) {
    long numCells = (long) Math.ceil(256 * Math.pow(2, zoom) / GRID_SIZE);
    SphericalMercatorProjection proj = new SphericalMercatorProjection(numCells);

    HashSet<Cluster<T>> clusters = new HashSet<Cluster<T>>();
    LongSparseArray<StaticCluster<T>> sparseArray = new LongSparseArray<StaticCluster<T>>();

    synchronized (mItems) {
        for (T item : mItems) {
            Point p = proj.toPoint(item.getPosition());

            long coord = getCoord(numCells, p.x, p.y);

            StaticCluster<T> cluster = sparseArray.get(coord);
            if (cluster == null) {
                cluster = new StaticCluster<T>(
                        proj.toLatLng(new Point(Math.floor(p.x) + .5, Math.floor(p.y) + .5)));
                sparseArray.put(coord, cluster);
                clusters.add(cluster);//from  ww  w.  j a v a  2 s .  c  o  m
            }
            cluster.add(item);
        }
    }

    return clusters;
}

From source file:ru.orangesoftware.financisto2.model.CategoryTree.java

public static LongSparseArray<Category> asDeepMap(List<Category> categories) {
    LongSparseArray<Category> map = new LongSparseArray<Category>();
    initializeMap(map, categories);//from  ww  w  .  j a va2s.  c  o  m
    return map;
}

From source file:com.google.maps.android.clustering.algo.GridBasedAlgorithm.java

@Override
public Set<? extends Cluster<T>> getClusters(double zoom, LatLngBounds visibleBounds) {
    if (mItems.size() == 0) {
        return null;
    }//from ww w .  j a v  a  2 s.  c om
    double minZoom = getMinZoom();
    double maxZoom = getMaxZoom();
    if ((minZoom >= 0 && zoom < minZoom) || (maxZoom >= 0 && zoom > maxZoom)) {
        return null;
    }
    long numCells = (long) Math.ceil(256 * Math.pow(2, zoom) / gridSize);
    SphericalMercatorProjection proj = new SphericalMercatorProjection(numCells);

    HashSet<Cluster<T>> clusters = new HashSet<Cluster<T>>();
    LongSparseArray<StaticCluster<T>> sparseArray = new LongSparseArray<StaticCluster<T>>();

    synchronized (mItems) {
        for (T item : mItems) {
            LatLng pos = item.getPosition();
            //                if (!visibleBounds.contains(pos) || !item.isVisible()) {
            if (!item.isVisible()) {
                continue;
            }

            if (!item.canBeClustered()) {
                StaticCluster<T> cluster = createCluster();
                cluster.add(item);
                clusters.add(cluster);
                continue;
            }
            Point p = proj.toPoint(pos);

            long coord = getCoord(numCells, p.x, p.y);

            StaticCluster<T> cluster = sparseArray.get(coord);
            if (cluster == null) {
                cluster = createCluster();
                sparseArray.put(coord, cluster);
                clusters.add(cluster);
            }
            cluster.add(item);
        }
    }

    for (Cluster<T> cluster : clusters) {
        if (cluster instanceof StaticCluster) {
            ((StaticCluster<T>) cluster).update();
        }
    }

    return clusters;
}

From source file:com.sky.drovik.player.media.MediaSet.java

public MediaSet(DataSource dataSource) {
    mItems = new ArrayList<MediaItem>(16);
    mItemsLookup = new LongSparseArray<MediaItem>();
    mItemsLookup.clear();//from w  ww. ja  v a  2  s . c  o  m
    mItemsLookupVideo = new LongSparseArray<MediaItem>();
    mItemsLookupVideo.clear();
    mDataSource = dataSource;
    // TODO(Venkat): Can we move away from this dummy item setup?
    MediaItem item = new MediaItem();
    item.mId = Shared.INVALID;
    item.mParentMediaSet = this;
    mItems.add(item);
    mNumExpectedItems = 16;
}

From source file:de.dreier.mytargets.features.statistics.StatisticsActivity.java

@Override
public Loader<List<Pair<Training, Round>>> onCreateLoader(int i, Bundle bundle) {
    final long[] roundIds = getIntent().getLongArrayExtra(ROUND_IDS);
    return new AsyncTaskLoader<List<Pair<Training, Round>>>(this) {
        @Override// w w w  .  j a  v a2 s. co m
        public List<Pair<Training, Round>> loadInBackground() {
            final List<Round> rounds = Round.getAll(roundIds);
            LongSparseArray<Training> trainingsMap = new LongSparseArray<>();
            Stream.of(rounds).map(round -> round.trainingId).distinct().map(Training::get)
                    .forEach(training -> trainingsMap.append(training.getId(), training));
            return Stream.of(rounds).map(round -> new Pair<>(trainingsMap.get(round.trainingId), round))
                    .collect(Collectors.toList());
        }
    };
}

From source file:com.topfeeds4j.sample.utils.Prefs.java

/**
 * Get all blogger meta information.// w  w w  . j  av a 2s .c om
 *
 * @return A list of [blogger-id : blogger-name].
 */
public LongSparseArray<String> getBloggersMeta() {
    LongSparseArray<String> lst = new LongSparseArray<>();
    String ids = getString(KEY_BLOGGER_ID_LIST, null);
    String names = getString(KEY_BLOGGER_NAME_LIST, null);
    String[] idList = ids.split(",");
    String[] nameList = names.split(",");
    int i = 0;
    for (String id : idList) {
        lst.put(Long.valueOf(id), nameList[i++]);
    }
    return lst;
}

From source file:com.vuze.android.remote.SessionInfo.java

public SessionInfo(final Activity activity, final RemoteProfile _remoteProfile) {
    this.remoteProfile = _remoteProfile;
    this.mapOriginal = new LongSparseArray<>();

    VuzeRemoteApp.getNetworkState().addListener(this);

    // Bind and Open take a while, do it on the non-UI thread
    Thread thread = new Thread("bindAndOpen") {
        public void run() {
            String host = remoteProfile.getHost();
            if (host != null && host.length() > 0
                    && remoteProfile.getRemoteType() != RemoteProfile.TYPE_LOOKUP) {
                open(activity, remoteProfile.getUser(), remoteProfile.getAC(), remoteProfile.getProtocol(),
                        host, remoteProfile.getPort());
            } else {
                bindAndOpen(activity, remoteProfile.getAC(), remoteProfile.getUser());
            }/*from w ww . j  a  v a 2s  .co  m*/
        }
    };
    thread.setDaemon(true);
    thread.start();

}