From ec1e746a2215cdc0907674821d084ba9d622609f Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 4 Oct 2020 05:56:09 +0530 Subject: [PATCH] Convert License to Kotlin and use the Parcelize annotation. --- .../org/schabi/newpipe/about/License.java | 80 ------------------- .../java/org/schabi/newpipe/about/License.kt | 19 +++++ 2 files changed, 19 insertions(+), 80 deletions(-) delete mode 100644 app/src/main/java/org/schabi/newpipe/about/License.java create mode 100644 app/src/main/java/org/schabi/newpipe/about/License.kt diff --git a/app/src/main/java/org/schabi/newpipe/about/License.java b/app/src/main/java/org/schabi/newpipe/about/License.java deleted file mode 100644 index 6670e12ac..000000000 --- a/app/src/main/java/org/schabi/newpipe/about/License.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.schabi.newpipe.about; - -import android.net.Uri; -import android.os.Parcel; -import android.os.Parcelable; - -import java.io.Serializable; - -/** - * Class for storing information about a software license. - */ -public class License implements Parcelable, Serializable { - public static final Creator CREATOR = new Creator() { - @Override - public License createFromParcel(final Parcel source) { - return new License(source); - } - - @Override - public License[] newArray(final int size) { - return new License[size]; - } - }; - private final String abbreviation; - private final String name; - private final String filename; - - public License(final String name, final String abbreviation, final String filename) { - if (name == null) { - throw new NullPointerException("name is null"); - } - if (abbreviation == null) { - throw new NullPointerException("abbreviation is null"); - } - if (filename == null) { - throw new NullPointerException("filename is null"); - } - this.name = name; - this.filename = filename; - this.abbreviation = abbreviation; - } - - protected License(final Parcel in) { - this.filename = in.readString(); - this.abbreviation = in.readString(); - this.name = in.readString(); - } - - public Uri getContentUri() { - return new Uri.Builder() - .scheme("file") - .path("/android_asset") - .appendPath(filename) - .build(); - } - - public String getAbbreviation() { - return abbreviation; - } - - public String getFilename() { - return filename; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(final Parcel dest, final int flags) { - dest.writeString(this.filename); - dest.writeString(this.abbreviation); - dest.writeString(this.name); - } - - public String getName() { - return name; - } -} diff --git a/app/src/main/java/org/schabi/newpipe/about/License.kt b/app/src/main/java/org/schabi/newpipe/about/License.kt new file mode 100644 index 000000000..00a66c84a --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/about/License.kt @@ -0,0 +1,19 @@ +package org.schabi.newpipe.about + +import android.net.Uri +import android.os.Parcelable +import java.io.Serializable +import kotlinx.android.parcel.Parcelize + +/** + * Class for storing information about a software license. + */ +@Parcelize +class License(val name: String, val abbreviation: String, val filename: String) : Parcelable, Serializable { + val contentUri: Uri + get() = Uri.Builder() + .scheme("file") + .path("/android_asset") + .appendPath(filename) + .build() +}