Search in sources :

Example 1 with ArrayMap

use of android.support.v4.util.ArrayMap in project PocketHub by pockethub.

the class GistFilesViewActivityTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    RoboGuice.injectMembers(getInstrumentation().getTargetContext().getApplicationContext(), this);
    Map<String, GistFile> files = new ArrayMap<>();
    GistFile a = GistFile.builder().content("aa").filename("a").build();
    GistFile b = GistFile.builder().content("bb").filename("b").build();
    files.put("a", a);
    files.put("b", b);
    gist = Gist.builder().id("abcd").files(files).build();
    store.addGist(gist);
    setActivityIntent(GistFilesViewActivity.createIntent(gist, 0));
}
Also used : ArrayMap(android.support.v4.util.ArrayMap) GistFile(com.meisolsson.githubsdk.model.GistFile)

Example 2 with ArrayMap

use of android.support.v4.util.ArrayMap in project Transitions-Everywhere by andkulikov.

the class Transition method createAnimators.

/**
     * This method, essentially a wrapper around all calls to createAnimator for all
     * possible target views, is called with the entire set of start/end
     * values. The implementation in Transition iterates through these lists
     * and calls {@link #createAnimator(ViewGroup, TransitionValues, TransitionValues)}
     * with each set of start/end values on this transition. The
     * TransitionSet subclass overrides this method and delegates it to
     * each of its children in succession.
     *
     * @hide
     */
protected void createAnimators(ViewGroup sceneRoot, TransitionValuesMaps startValues, TransitionValuesMaps endValues, ArrayList<TransitionValues> startValuesList, ArrayList<TransitionValues> endValuesList) {
    if (DBG) {
        Log.d(LOG_TAG, "createAnimators() for " + this);
    }
    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    long minStartDelay = Long.MAX_VALUE;
    int minAnimator = mAnimators.size();
    SparseArray<Long> startDelays = new SparseArray<Long>();
    int startValuesListCount = startValuesList.size();
    for (int i = 0; i < startValuesListCount; ++i) {
        TransitionValues start = startValuesList.get(i);
        TransitionValues end = endValuesList.get(i);
        if (start != null && !start.targetedTransitions.contains(this)) {
            start = null;
        }
        if (end != null && !end.targetedTransitions.contains(this)) {
            end = null;
        }
        if (start == null && end == null) {
            continue;
        }
        // Only bother trying to animate with values that differ between start/end
        boolean isChanged = start == null || end == null || isTransitionRequired(start, end);
        if (isChanged) {
            if (DBG) {
                View view = (end != null) ? end.view : start.view;
                Log.d(LOG_TAG, "  differing start/end values for view " + view);
                if (start == null || end == null) {
                    Log.d(LOG_TAG, "    " + ((start == null) ? "start null, end non-null" : "start non-null, end null"));
                } else {
                    for (String key : start.values.keySet()) {
                        Object startValue = start.values.get(key);
                        Object endValue = end.values.get(key);
                        if (startValue != endValue && !startValue.equals(endValue)) {
                            Log.d(LOG_TAG, "    " + key + ": start(" + startValue + "), end(" + endValue + ")");
                        }
                    }
                }
            }
            // TODO: what to do about targetIds and itemIds?
            Animator animator = createAnimator(sceneRoot, start, end);
            if (animator != null) {
                // Save animation info for future cancellation purposes
                View view;
                TransitionValues infoValues = null;
                if (end != null) {
                    view = end.view;
                    String[] properties = getTransitionProperties();
                    if (view != null && properties != null && properties.length > 0) {
                        infoValues = new TransitionValues();
                        infoValues.view = view;
                        TransitionValues newValues = endValues.viewValues.get(view);
                        if (newValues != null) {
                            for (int j = 0; j < properties.length; ++j) {
                                infoValues.values.put(properties[j], newValues.values.get(properties[j]));
                            }
                        }
                        synchronized (sRunningAnimators) {
                            int numExistingAnims = runningAnimators.size();
                            for (int j = 0; j < numExistingAnims; ++j) {
                                Animator anim = runningAnimators.keyAt(j);
                                AnimationInfo info = runningAnimators.get(anim);
                                if (info.values != null && info.view == view && ((info.name == null && getName() == null) || (info.name != null && info.name.equals(getName())))) {
                                    if (info.values.equals(infoValues)) {
                                        // Favor the old animator
                                        animator = null;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    view = start.view;
                }
                if (animator != null) {
                    if (mPropagation != null) {
                        long delay = mPropagation.getStartDelay(sceneRoot, this, start, end);
                        startDelays.put(mAnimators.size(), delay);
                        minStartDelay = Math.min(delay, minStartDelay);
                    }
                    AnimationInfo info = new AnimationInfo(view, getName(), this, ViewUtils.getWindowId(sceneRoot), infoValues);
                    runningAnimators.put(animator, info);
                    mAnimators.add(animator);
                }
            }
        }
    }
    if (startDelays.size() != 0) {
        for (int i = 0; i < startDelays.size(); i++) {
            int index = startDelays.keyAt(i);
            Animator animator = mAnimators.get(index);
            long delay = startDelays.valueAt(i) - minStartDelay + animator.getStartDelay();
            animator.setStartDelay(delay);
        }
    }
}
Also used : SurfaceView(android.view.SurfaceView) View(android.view.View) TextureView(android.view.TextureView) ListView(android.widget.ListView) LongSparseArray(android.support.v4.util.LongSparseArray) SparseArray(android.util.SparseArray) Animator(android.animation.Animator)

Example 3 with ArrayMap

use of android.support.v4.util.ArrayMap in project ride-read-android by Ride-Read.

the class AppUtils method getVersion.

/**
     * 获取版本信息
     *
     * @return
     */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static ArrayMap getVersion() {
    ArrayMap vInfo = new ArrayMap<>();
    try {
        PackageManager pm = Utils.getAppContext().getPackageManager();
        PackageInfo info = pm.getPackageInfo(Utils.getAppContext().getPackageName(), 0);
        vInfo.put("VERSION_CODE", info.versionCode);
        vInfo.put("VERSION_NAME", info.versionName);
        vInfo.put(Version.VERSION_CODE, info.versionCode);
        vInfo.put(Version.VERSION_NAME, info.versionName);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return vInfo;
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) ArrayMap(android.support.v4.util.ArrayMap)

Example 4 with ArrayMap

use of android.support.v4.util.ArrayMap in project AntennaPod by AntennaPod.

the class DBReader method getFeedImages.

/**
     * Searches the DB for a FeedImage of the given id.
     *
     * @param imageIds The ids of the images
     * @return Map that associates the id of an image with the image itself
     */
private static Map<Long, FeedImage> getFeedImages(PodDBAdapter adapter, final long... imageIds) {
    String[] ids = new String[imageIds.length];
    for (int i = 0, len = imageIds.length; i < len; i++) {
        ids[i] = String.valueOf(imageIds[i]);
    }
    Cursor cursor = adapter.getImageCursor(ids);
    Map<Long, FeedImage> result = new ArrayMap<>(cursor.getCount());
    try {
        if ((cursor.getCount() == 0) || !cursor.moveToFirst()) {
            return Collections.emptyMap();
        }
        do {
            FeedImage image = FeedImage.fromCursor(cursor);
            result.put(image.getId(), image);
        } while (cursor.moveToNext());
    } finally {
        cursor.close();
    }
    return result;
}
Also used : FeedImage(de.danoeh.antennapod.core.feed.FeedImage) ArrayMap(android.support.v4.util.ArrayMap) Cursor(android.database.Cursor)

Example 5 with ArrayMap

use of android.support.v4.util.ArrayMap in project AntennaPod by AntennaPod.

the class GpodnetEpisodeActionPostResponse method fromJSONObject.

/**
     * Creates a new GpodnetUploadChangesResponse-object from a JSON object that was
     * returned by an uploadChanges call.
     *
     * @throws org.json.JSONException If the method could not parse the JSONObject.
     */
public static GpodnetEpisodeActionPostResponse fromJSONObject(String objectString) throws JSONException {
    final JSONObject object = new JSONObject(objectString);
    final long timestamp = object.getLong("timestamp");
    JSONArray urls = object.getJSONArray("update_urls");
    Map<String, String> updatedUrls = new ArrayMap<>(urls.length());
    for (int i = 0; i < urls.length(); i++) {
        JSONArray urlPair = urls.getJSONArray(i);
        updatedUrls.put(urlPair.getString(0), urlPair.getString(1));
    }
    return new GpodnetEpisodeActionPostResponse(timestamp, updatedUrls);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ArrayMap(android.support.v4.util.ArrayMap)

Aggregations

ArrayMap (android.support.v4.util.ArrayMap)11 Cursor (android.database.Cursor)2 FeedMedia (de.danoeh.antennapod.core.feed.FeedMedia)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 Animator (android.animation.Animator)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 LongSparseArray (android.support.v4.util.LongSparseArray)1 Pair (android.util.Pair)1 SparseArray (android.util.SparseArray)1 SurfaceView (android.view.SurfaceView)1 TextureView (android.view.TextureView)1 View (android.view.View)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 JSONObject (com.alibaba.fastjson.JSONObject)1 GistFile (com.meisolsson.githubsdk.model.GistFile)1 WXSDKInstance (com.taobao.weex.WXSDKInstance)1 FeedImage (de.danoeh.antennapod.core.feed.FeedImage)1