Skip to content

Commit

Permalink
[mozik] add update play model event
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrxxy committed Nov 25, 2017
1 parent 9d07905 commit 0b6c9c6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/main/java/com/stockholm/common/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public final class Constant {

public static final String APP_PACKAGE_NAME_DISPLAY = "com.stockholm.display";

public static final String APP_PACKAGE_NAME_MOZIK = "com.stockholm.mozik";

public static final String ACTION_DEVELOP_ENV = "com.stockholm.develop.env";

public static final String KEY_DEV_ENV = "key_dev_env";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.stockholm.common.sound.event.AudioPlayHistoryEvent;
import com.stockholm.common.sound.event.AudioPlayListEvent;
import com.stockholm.common.sound.event.AudioPlayModelEvent;
import com.stockholm.common.sound.event.AudioPlayModelUpdateEvent;
import com.stockholm.common.sound.event.AudioPlayProgressEvent;
import com.stockholm.common.sound.event.AudioPlayStatusEvent;
import com.stockholm.common.sound.event.AudioPlayVolumeEvent;
Expand Down Expand Up @@ -105,6 +106,7 @@ private void subscribeEventBus() {
eventBus.subscribe(AudioPlayListEvent.class, this::handlePlaylistEvent);
eventBus.subscribe(AudioPlayControlEvent.class, this::handlePlayControlEvent);
eventBus.subscribe(AudioPlayHistoryEvent.class, this::handlePlayHistoryEvent);
eventBus.subscribe(AudioPlayModelUpdateEvent.class, this::handlePlayModelUpdateEvent);
}

private void initAudioManger() {
Expand Down Expand Up @@ -169,6 +171,10 @@ private void handlePlayHistoryEvent(AudioPlayHistoryEvent event) {
playList.setIndex(event.getIndex());
}

private void handlePlayModelUpdateEvent(AudioPlayModelUpdateEvent event) {
playList.update(event.getIndex(), event.getAudioPlayModel());
}

@Override
public void onAudioFocusChange(int focusChange) {
switch (focusChange) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public void insert(int index, T t) {
modelList.add(index, t);
}

public void update(int index, T t) {
if (modelList.isEmpty()) return;
if (index > modelList.size()) return;
modelList.set(index, t);
}

public boolean play() {
if (modelList != null && modelList.size() != 0)
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.stockholm.common.sound.event;


import com.stockholm.common.sound.AudioPlayModel;

public class AudioPlayModelUpdateEvent {

private int index;
private AudioPlayModel audioPlayModel;

public AudioPlayModelUpdateEvent(int index, AudioPlayModel audioPlayModel) {
this.index = index;
this.audioPlayModel = audioPlayModel;
}

public int getIndex() {
return index;
}

public void setIndex(int index) {
this.index = index;
}

public AudioPlayModel getAudioPlayModel() {
return audioPlayModel;
}

public void setAudioPlayModel(AudioPlayModel audioPlayModel) {
this.audioPlayModel = audioPlayModel;
}

}

0 comments on commit 0b6c9c6

Please sign in to comment.