Skip to content

Commit

Permalink
Merge pull request #3511 from wb9688/ktlint
Browse files Browse the repository at this point in the history
Ktlint
  • Loading branch information
wb9688 authored May 4, 2020
2 parents 40b1cd8 + b0415a5 commit b630f26
Show file tree
Hide file tree
Showing 58 changed files with 402 additions and 290 deletions.
31 changes: 23 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,40 @@ task runCheckstyle(type: Checkstyle) {
}
}

tasks.withType(Checkstyle).each {
checkstyleTask -> checkstyleTask.doLast {
reports.all { report ->
def outputFile = report.destination
if (outputFile.exists() && outputFile.text.contains("severity=\"error\"")) {
throw new GradleException("There were checkstyle errors! For more info check $outputFile")
}
runCheckstyle.doLast {
reports.all { report ->
def outputFile = report.destination
if (outputFile.exists() && outputFile.text.contains("severity=\"error\"")) {
throw new GradleException("There were checkstyle errors! For more info check $outputFile")
}
}
}

configurations {
ktlint
}

task runKtlint(type: JavaExec) {
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
}

task formatKtlint(type: JavaExec) {
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}

afterEvaluate {
preDebugBuild.dependsOn runCheckstyle
preDebugBuild.dependsOn runCheckstyle, runKtlint
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

debugImplementation "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
ktlint "com.pinterest:ktlint:0.35.0"

androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation "android.arch.persistence.room:testing:1.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ class AppDatabaseTest {
testHelper.closeWhenFinished(database)
return database
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
import org.schabi.newpipe.player.playqueue.PlaylistPlayQueue;
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.AndroidTvUtils;
import org.schabi.newpipe.util.Constants;
import org.schabi.newpipe.util.ExtractorHelper;
import org.schabi.newpipe.util.AndroidTvUtils;
import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.views.FocusOverlayView;
import org.schabi.newpipe.util.urlfinder.UrlFinder;
import org.schabi.newpipe.views.FocusOverlayView;

import java.io.Serializable;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package org.schabi.newpipe.database.feed.dao

import androidx.room.*
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Transaction
import androidx.room.Update
import io.reactivex.Flowable
import java.util.Date
import org.schabi.newpipe.database.feed.model.FeedEntity
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity
import org.schabi.newpipe.database.stream.model.StreamEntity
import org.schabi.newpipe.database.subscription.SubscriptionEntity
import java.util.*

@Dao
abstract class FeedDAO {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.schabi.newpipe.database.feed.dao

import androidx.room.*
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Transaction
import androidx.room.Update
import io.reactivex.Flowable
import io.reactivex.Maybe
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity
]
)
data class FeedEntity(
@ColumnInfo(name = STREAM_ID)
var streamId: Long,
@ColumnInfo(name = STREAM_ID)
var streamId: Long,

@ColumnInfo(name = SUBSCRIPTION_ID)
var subscriptionId: Long
@ColumnInfo(name = SUBSCRIPTION_ID)
var subscriptionId: Long
) {

companion object {
Expand All @@ -40,4 +40,4 @@ data class FeedEntity(
const val STREAM_ID = "stream_id"
const val SUBSCRIPTION_ID = "subscription_id"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import org.schabi.newpipe.local.subscription.FeedGroupIcon
indices = [Index(SORT_ORDER)]
)
data class FeedGroupEntity(
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = ID)
val uid: Long,
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = ID)
val uid: Long,

@ColumnInfo(name = NAME)
var name: String,
@ColumnInfo(name = NAME)
var name: String,

@ColumnInfo(name = ICON)
var icon: FeedGroupIcon,
@ColumnInfo(name = ICON)
var icon: FeedGroupIcon,

@ColumnInfo(name = SORT_ORDER)
var sortOrder: Long = -1
@ColumnInfo(name = SORT_ORDER)
var sortOrder: Long = -1
) {
companion object {
const val FEED_GROUP_TABLE = "feed_group"
Expand All @@ -36,4 +36,4 @@ data class FeedGroupEntity(

const val GROUP_ALL_ID = -1L
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity
]
)
data class FeedGroupSubscriptionEntity(
@ColumnInfo(name = GROUP_ID)
var feedGroupId: Long,
@ColumnInfo(name = GROUP_ID)
var feedGroupId: Long,

@ColumnInfo(name = SUBSCRIPTION_ID)
var subscriptionId: Long
@ColumnInfo(name = SUBSCRIPTION_ID)
var subscriptionId: Long
) {

companion object {
Expand All @@ -42,4 +42,4 @@ data class FeedGroupSubscriptionEntity(
const val GROUP_ID = "group_id"
const val SUBSCRIPTION_ID = "subscription_id"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.PrimaryKey
import java.util.Date
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity.Companion.FEED_LAST_UPDATED_TABLE
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity.Companion.SUBSCRIPTION_ID
import org.schabi.newpipe.database.subscription.SubscriptionEntity
import java.util.*

@Entity(
tableName = FEED_LAST_UPDATED_TABLE,
Expand All @@ -20,12 +20,12 @@ import java.util.*
]
)
data class FeedLastUpdatedEntity(
@PrimaryKey
@ColumnInfo(name = SUBSCRIPTION_ID)
var subscriptionId: Long,
@PrimaryKey
@ColumnInfo(name = SUBSCRIPTION_ID)
var subscriptionId: Long,

@ColumnInfo(name = LAST_UPDATED)
var lastUpdated: Date? = null
@ColumnInfo(name = LAST_UPDATED)
var lastUpdated: Date? = null
) {

companion object {
Expand All @@ -34,4 +34,4 @@ data class FeedLastUpdatedEntity(
const val SUBSCRIPTION_ID = "subscription_id"
const val LAST_UPDATED = "last_updated"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package org.schabi.newpipe.database.history.model

import androidx.room.ColumnInfo
import androidx.room.Embedded
import java.util.Date
import org.schabi.newpipe.database.stream.model.StreamEntity
import java.util.*

data class StreamHistoryEntry(
@Embedded
val streamEntity: StreamEntity,
@Embedded
val streamEntity: StreamEntity,

@ColumnInfo(name = StreamHistoryEntity.JOIN_STREAM_ID)
val streamId: Long,
@ColumnInfo(name = StreamHistoryEntity.JOIN_STREAM_ID)
val streamId: Long,

@ColumnInfo(name = StreamHistoryEntity.STREAM_ACCESS_DATE)
val accessDate: Date,
@ColumnInfo(name = StreamHistoryEntity.STREAM_ACCESS_DATE)
val accessDate: Date,

@ColumnInfo(name = StreamHistoryEntity.STREAM_REPEAT_COUNT)
val repeatCount: Long
@ColumnInfo(name = StreamHistoryEntity.STREAM_REPEAT_COUNT)
val repeatCount: Long
) {

fun toStreamHistoryEntity(): StreamHistoryEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import org.schabi.newpipe.database.stream.model.StreamEntity
import org.schabi.newpipe.extractor.stream.StreamInfoItem

class PlaylistStreamEntry(
@Embedded
val streamEntity: StreamEntity,
@Embedded
val streamEntity: StreamEntity,

@ColumnInfo(name = PlaylistStreamEntity.JOIN_STREAM_ID)
val streamId: Long,
@ColumnInfo(name = PlaylistStreamEntity.JOIN_STREAM_ID)
val streamId: Long,

@ColumnInfo(name = PlaylistStreamEntity.JOIN_INDEX)
val joinIndex: Int
@ColumnInfo(name = PlaylistStreamEntity.JOIN_INDEX)
val joinIndex: Int
) : LocalItem {

@Throws(IllegalArgumentException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ package org.schabi.newpipe.database.stream

import androidx.room.ColumnInfo
import androidx.room.Embedded
import java.util.Date
import org.schabi.newpipe.database.LocalItem
import org.schabi.newpipe.database.history.model.StreamHistoryEntity
import org.schabi.newpipe.database.stream.model.StreamEntity
import org.schabi.newpipe.extractor.stream.StreamInfoItem
import java.util.*

class StreamStatisticsEntry(
@Embedded
val streamEntity: StreamEntity,
@Embedded
val streamEntity: StreamEntity,

@ColumnInfo(name = StreamHistoryEntity.JOIN_STREAM_ID)
val streamId: Long,
@ColumnInfo(name = StreamHistoryEntity.JOIN_STREAM_ID)
val streamId: Long,

@ColumnInfo(name = STREAM_LATEST_DATE)
val latestAccessDate: Date,
@ColumnInfo(name = STREAM_LATEST_DATE)
val latestAccessDate: Date,

@ColumnInfo(name = STREAM_WATCH_COUNT)
val watchCount: Long
@ColumnInfo(name = STREAM_WATCH_COUNT)
val watchCount: Long
) : LocalItem {

fun toStreamInfoItem(): StreamInfoItem {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package org.schabi.newpipe.database.stream.dao

import androidx.room.*
import androidx.room.ColumnInfo
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Transaction
import io.reactivex.Flowable
import java.util.Date
import org.schabi.newpipe.database.BasicDAO
import org.schabi.newpipe.database.stream.model.StreamEntity
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_ID
import org.schabi.newpipe.extractor.stream.StreamType
import org.schabi.newpipe.extractor.stream.StreamType.AUDIO_LIVE_STREAM
import org.schabi.newpipe.extractor.stream.StreamType.LIVE_STREAM
import java.util.*
import kotlin.collections.ArrayList

@Dao
abstract class StreamDAO : BasicDAO<StreamEntity> {
Expand Down Expand Up @@ -94,7 +98,6 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
if (existentMinimalStream.duration > 0 && newerStream.duration < 0) {
newerStream.duration = existentMinimalStream.duration
}

}
}

Expand All @@ -116,21 +119,22 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
* Minimal entry class used when comparing/updating an existent stream.
*/
internal data class StreamCompareFeed(
@ColumnInfo(name = STREAM_ID)
var uid: Long = 0,
@ColumnInfo(name = STREAM_ID)
var uid: Long = 0,

@ColumnInfo(name = StreamEntity.STREAM_TYPE)
var streamType: StreamType,
@ColumnInfo(name = StreamEntity.STREAM_TYPE)
var streamType: StreamType,

@ColumnInfo(name = StreamEntity.STREAM_TEXTUAL_UPLOAD_DATE)
var textualUploadDate: String? = null,
@ColumnInfo(name = StreamEntity.STREAM_TEXTUAL_UPLOAD_DATE)
var textualUploadDate: String? = null,

@ColumnInfo(name = StreamEntity.STREAM_UPLOAD_DATE)
var uploadDate: Date? = null,
@ColumnInfo(name = StreamEntity.STREAM_UPLOAD_DATE)
var uploadDate: Date? = null,

@ColumnInfo(name = StreamEntity.STREAM_IS_UPLOAD_DATE_APPROXIMATION)
var isUploadDateApproximation: Boolean? = null,
@ColumnInfo(name = StreamEntity.STREAM_IS_UPLOAD_DATE_APPROXIMATION)
var isUploadDateApproximation: Boolean? = null,

@ColumnInfo(name = StreamEntity.STREAM_DURATION)
var duration: Long)
@ColumnInfo(name = StreamEntity.STREAM_DURATION)
var duration: Long
)
}
Loading

0 comments on commit b630f26

Please sign in to comment.