Merge pull request #1387 from mfietz/issue/1386-cached-queue

Play episodes in correct order after reordering
This commit is contained in:
Tom Hennen 2015-11-17 17:51:46 -05:00
commit 1ae2e822e0
2 changed files with 9 additions and 5 deletions

View File

@ -25,7 +25,6 @@ import android.widget.Toast;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
import java.util.Collections;
import java.util.List;
import de.danoeh.antennapod.R;
@ -165,8 +164,12 @@ public class QueueFragment extends Fragment {
case MOVED:
int from = FeedItemUtil.indexOfItemWithId(queue, event.item.getId());
int to = event.position;
queue.add(to, queue.remove(from));
recyclerAdapter.notifyItemMoved(from, to);
if(from != to) {
queue.add(to, queue.remove(from));
recyclerAdapter.notifyItemMoved(from, to);
} else {
// QueueFragment itself sent the event and already moved the item
}
break;
}
onFragmentLoaded();
@ -367,7 +370,7 @@ public class QueueFragment extends Fragment {
Log.d(TAG, "move(" + from + ", " + to + ")");
queue.add(to, queue.remove(from));
recyclerAdapter.notifyItemMoved(from, to);
DBWriter.moveQueueItem(from, to, false);
DBWriter.moveQueueItem(from, to, true);
return true;
}

View File

@ -31,7 +31,7 @@ import de.greenrobot.event.EventBus;
* to notify the PlaybackService about updates from the running tasks.
*/
public class PlaybackServiceTaskManager {
private static final String TAG = "PlaybackServiceTaskManager";
private static final String TAG = "PlaybackServiceTaskMgr";
/**
* Update interval of position saver in milliseconds.
@ -81,6 +81,7 @@ public class PlaybackServiceTaskManager {
}
public void onEvent(QueueEvent event) {
Log.d(TAG, "onEvent(QueueEvent " + event +")");
cancelQueueLoader();
loadQueue();
}