File: RemoveCorrelatedMediaCmd.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (52 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package tim.prune.cmd;

import java.util.ArrayList;

import tim.prune.DataSubscriber;
import tim.prune.data.AudioClip;
import tim.prune.data.Photo;
import tim.prune.data.TrackInfo;

/**
 * Command to remove all correlated photos and audio objects
 */
public class RemoveCorrelatedMediaCmd extends Command
{
	public RemoveCorrelatedMediaCmd() {
		super(null);
	}

	@Override
	protected boolean executeCommand(TrackInfo inInfo)
	{
		inInfo.getPhotoList().removeCorrelatedMedia();
		inInfo.getAudioList().removeCorrelatedMedia();
		return true;
	}

	@Override
	protected Command makeInverse(TrackInfo inInfo)
	{
		ArrayList<MediaInsertion> media = new ArrayList<>();
		for (int i=0; i<inInfo.getPhotoList().getCount(); i++)
		{
			Photo photo = inInfo.getPhotoList().get(i);
			if (photo.getDataPoint() != null) {
				media.add(new MediaInsertion(photo, i));
			}
		}
		for (int i=0; i<inInfo.getAudioList().getCount(); i++)
		{
			AudioClip audio = inInfo.getAudioList().get(i);
			if (audio.getDataPoint() != null) {
				media.add(new MediaInsertion(audio, i));
			}
		}
		return new InsertMediaCmd(this, media);
	}

	@Override
	public int getUpdateFlags() {
		return DataSubscriber.MEDIA_MODIFIED;
	}
}