@@ -0,0 +1,1920 @@
+package org.ccci.gto.android.sync.widget;%0A%0Aimport android.os.Bundle;%0Aimport android.support.annotation.NonNull;%0Aimport android.support.annotation.Nullable;%0Aimport android.support.v4.widget.SwipeRefreshLayout;%0A%0Aimport org.ccci.gto.android.common.util.LongSparseBooleanArray;%0Aimport org.ccci.gto.android.sync.ThreadedSyncIntentService;%0A%0Apublic final class SwipeRefreshSyncHelper %7B%0A    private static final String EXTRA_ACTIVE_SYNCS = SwipeRefreshSyncHelper.class.getName() + %22.ACTIVE_SYNCS%22;%0A%0A    @Nullable%0A    private SwipeRefreshLayout mRefreshLayout;%0A%0A    @NonNull%0A    private LongSparseBooleanArray mActiveSyncIds = new LongSparseBooleanArray();%0A%0A    /* BEGIN lifecycle */%0A%0A    protected final void onRestoreInstanceState(@Nullable final Bundle state) %7B%0A        if (state != null) %7B%0A            final LongSparseBooleanArray activeSyncs = state.getParcelable(EXTRA_ACTIVE_SYNCS);%0A            if (activeSyncs != null) %7B%0A                mActiveSyncIds = activeSyncs;%0A            %7D%0A        %7D%0A    %7D%0A%0A    public final Bundle onSaveInstanceState() %7B%0A        final Bundle bundle = new Bundle(1);%0A        bundle.putParcelable(EXTRA_ACTIVE_SYNCS, mActiveSyncIds);%0A        return bundle;%0A    %7D%0A%0A    /* END lifecycle */%0A%0A    public void setRefreshLayout(@Nullable final SwipeRefreshLayout layout) %7B%0A        mRefreshLayout = layout;%0A        updateState();%0A    %7D%0A%0A    public void updateState() %7B%0A        if (mRefreshLayout != null) %7B%0A            boolean refreshing = false;%0A            for (int i = mActiveSyncIds.size() - 1; i %3E= 0; i--) %7B%0A                if (mActiveSyncIds.valueAt(i) &&%0A                        ThreadedSyncIntentService.isSyncRunning((int) mActiveSyncIds.keyAt(i))) %7B%0A                    refreshing = true;%0A                    break;%0A                %7D else %7B%0A                    mActiveSyncIds.removeAt(i);%0A                %7D%0A            %7D%0A%0A            mRefreshLayout.setRefreshing(refreshing);%0A        %7D%0A    %7D%0A%7D%0A

create a SwipeRefreshLayout sync helper util