14 changed files with 454 additions and 2 deletions
@ -0,0 +1,114 @@ |
|||
/* |
|||
* ************************************************************************ |
|||
* Bookmark.java |
|||
* ************************************************************************* |
|||
* Copyright © 2021 VLC authors and VideoLAN |
|||
* Author: Nicolas POMEPUY |
|||
* This program is free software; you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation; either version 2 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, write to the Free Software |
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
* ************************************************************************** |
|||
* |
|||
* |
|||
*/ |
|||
|
|||
package org.videolan.medialibrary.interfaces.media; |
|||
|
|||
import android.os.Parcel; |
|||
import android.os.Parcelable; |
|||
|
|||
import org.videolan.medialibrary.MLServiceLocator; |
|||
import org.videolan.medialibrary.media.MediaLibraryItem; |
|||
|
|||
abstract public class Bookmark extends MediaLibraryItem { |
|||
public long mediaId; |
|||
public long mTime; |
|||
|
|||
public Bookmark(long id, String name, String description, long mediaId, long time) { |
|||
super(id, name); |
|||
this.mediaId = mediaId; |
|||
this.mTime = time; |
|||
this.setDescription(description); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public MediaWrapper[] getTracks() { |
|||
return new MediaWrapper[0]; |
|||
} |
|||
|
|||
@Override |
|||
public int getTracksCount() { |
|||
return 0; |
|||
} |
|||
|
|||
@Override |
|||
public int getItemType() { |
|||
return TYPE_BOOKMARK; |
|||
} |
|||
|
|||
|
|||
public long getTime() { |
|||
return mTime; |
|||
} |
|||
|
|||
public void setTime(long time) { |
|||
this.mTime = time; |
|||
} |
|||
|
|||
abstract public boolean setName(String name); |
|||
abstract public boolean updateDescription(String description); |
|||
abstract public boolean setNameAndDescription(String name, String description); |
|||
abstract public boolean move(long time); |
|||
|
|||
|
|||
@Override |
|||
public void writeToParcel(Parcel parcel, int i) { |
|||
super.writeToParcel(parcel, i); |
|||
parcel.writeLong(mediaId); |
|||
} |
|||
|
|||
public static Parcelable.Creator<Bookmark> CREATOR = new Parcelable.Creator<Bookmark>() { |
|||
@Override |
|||
public Bookmark createFromParcel(Parcel in) { |
|||
return MLServiceLocator.getAbstractBookmark(in); |
|||
} |
|||
|
|||
@Override |
|||
public Bookmark[] newArray(int size) { |
|||
return new Bookmark[size]; |
|||
} |
|||
}; |
|||
|
|||
public Bookmark(Parcel in) { |
|||
super(in); |
|||
this.mediaId = in.readLong(); |
|||
this.mTime = in.readLong(); |
|||
} |
|||
|
|||
public boolean equals(Bookmark other) { |
|||
return mId == other.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public boolean equals(MediaLibraryItem other) { |
|||
if (other instanceof Bookmark) return equals((Bookmark)other); |
|||
return super.equals(other); |
|||
} |
|||
|
|||
@Override |
|||
public boolean equals(Object obj) { |
|||
if (obj instanceof Bookmark) return equals((Bookmark)obj); |
|||
return super.equals(obj); |
|||
} |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
/* |
|||
* ************************************************************************ |
|||
* BookmarkImpl.java |
|||
* ************************************************************************* |
|||
* Copyright © 2021 VLC authors and VideoLAN |
|||
* Author: Nicolas POMEPUY |
|||
* This program is free software; you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation; either version 2 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, write to the Free Software |
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
* ************************************************************************** |
|||
* |
|||
* |
|||
*/ |
|||
|
|||
package org.videolan.medialibrary.media; |
|||
|
|||
import android.os.Parcel; |
|||
|
|||
import org.videolan.medialibrary.interfaces.Medialibrary; |
|||
import org.videolan.medialibrary.interfaces.media.Bookmark; |
|||
|
|||
@SuppressWarnings("JniMissingFunction") |
|||
public class BookmarkImpl extends Bookmark { |
|||
|
|||
public BookmarkImpl(long id, String name, String description, long mediaId, long time) { |
|||
super(id, name,description, mediaId, time); |
|||
} |
|||
|
|||
public BookmarkImpl(Parcel in) { |
|||
super(in); |
|||
} |
|||
|
|||
@Override |
|||
public boolean setName(String name) { |
|||
final Medialibrary ml = Medialibrary.getInstance(); |
|||
return ml.isInitiated() && nativeSetName(ml, mId, name); |
|||
} |
|||
|
|||
@Override |
|||
public boolean updateDescription(String description) { |
|||
final Medialibrary ml = Medialibrary.getInstance(); |
|||
return ml.isInitiated() && nativeSetDescription(ml, mId, description); |
|||
} |
|||
|
|||
@Override |
|||
public boolean setNameAndDescription(String name, String description) { |
|||
final Medialibrary ml = Medialibrary.getInstance(); |
|||
return ml.isInitiated() && nativeSetNameAndDescription(ml, mId, name, description); |
|||
} |
|||
|
|||
@Override |
|||
public boolean move(long time) { |
|||
final Medialibrary ml = Medialibrary.getInstance(); |
|||
return ml.isInitiated() && nativeMove(ml, mId, time); |
|||
} |
|||
|
|||
private native boolean nativeSetName(Medialibrary ml, long mId, String name); |
|||
private native boolean nativeSetDescription(Medialibrary ml, long mId, String description); |
|||
private native boolean nativeSetNameAndDescription(Medialibrary ml, long mId, String name, String description); |
|||
private native boolean nativeMove(Medialibrary ml, long mId, long time); |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
/* |
|||
* ************************************************************************ |
|||
* StubBookmark.java |
|||
* ************************************************************************* |
|||
* Copyright © 2021 VLC authors and VideoLAN |
|||
* Author: Nicolas POMEPUY |
|||
* This program is free software; you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation; either version 2 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, write to the Free Software |
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
* ************************************************************************** |
|||
* |
|||
* |
|||
*/ |
|||
|
|||
package org.videolan.medialibrary.stubs; |
|||
|
|||
import android.os.Parcel; |
|||
|
|||
import org.videolan.medialibrary.interfaces.media.Bookmark; |
|||
|
|||
public class StubBookmark extends Bookmark { |
|||
|
|||
private StubDataSource dt = StubDataSource.getInstance(); |
|||
|
|||
public StubBookmark(long id, String name, String description, long mediaId, long time) { |
|||
super(id, name, description, mediaId, time); |
|||
} |
|||
|
|||
@Override |
|||
public boolean setName(String name) { |
|||
return false; |
|||
} |
|||
|
|||
@Override |
|||
public boolean updateDescription(String description) { |
|||
return false; |
|||
} |
|||
|
|||
@Override |
|||
public boolean setNameAndDescription(String name, String description) { |
|||
return false; |
|||
} |
|||
|
|||
@Override |
|||
public boolean move(long time) { |
|||
return false; |
|||
} |
|||
|
|||
public StubBookmark(Parcel in) { |
|||
super(in); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue