diff --git a/build.gradle b/build.gradle index 0ca0af3..a9275fc 100644 --- a/build.gradle +++ b/build.gradle @@ -17,12 +17,13 @@ detekt { config = files("$projectDir/detekt.yml") parallel = true setSource(files(projectDir)) - reports { - xml.required.set(true) - html.required.set(true) - txt.required.set(false) - sarif.required.set(true) - } +// DEPRECATED +// reports { +// xml.required.set(true) +// html.required.set(true) +// txt.required.set(false) +// sarif.required.set(true) +// } } dependencies { diff --git a/gradle.properties b/gradle.properties index 4347da0..7b13495 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,11 +20,11 @@ android.enableJetifier=false # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official # Declare versions -agp_version=7.0.2 -kotlin_version=1.6.10 -compilesdk_version=31 -buildtools_version=30.0.2 -minsdk_version=14 -targetsdk_version=31 -project_version=0.6.0 -project_version_code=600 +agp_version=7.3.1 +kotlin_version=1.8.10 +compilesdk_version=33 +buildtools_version=31.0.0 +minsdk_version=26 +targetsdk_version=33 +project_version=0.7.5 +project_version_code=705 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fbce071..60072b8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Wed Sep 21 10:44:36 CEST 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/parserss/src/main/java/com/github/muhrifqii/parserss/ParseRSSKeyword.kt b/parserss/src/main/java/com/github/muhrifqii/parserss/ParseRSSKeyword.kt index d016882..aa1959c 100644 --- a/parserss/src/main/java/com/github/muhrifqii/parserss/ParseRSSKeyword.kt +++ b/parserss/src/main/java/com/github/muhrifqii/parserss/ParseRSSKeyword.kt @@ -13,7 +13,7 @@ internal object ParseRSSKeyword { const val TITLE = "title" const val DESCRIPTION = "description" const val IMAGE = "image" - const val PUBLISH_DATE = "pubdate" + const val PUBLISH_DATE = "pubDate" const val GUID = "guid" const val LINK = "link" const val URL = "url" @@ -22,7 +22,7 @@ internal object ParseRSSKeyword { const val AUTHOR = "author" const val COPYRIGHT = "copyright" const val RIGHTS = "rights" - const val LAST_BUILD_DATE = "lastbuilddate" + const val LAST_BUILD_DATE = "lastBuildDate" const val GROUP = "group" const val CONTENT = "content" const val CREDIT = "credit" @@ -48,6 +48,11 @@ internal object ParseRSSKeyword { const val ATTR_URI = "uri" const val ATTR_HREF = "href" const val ATTR_REL = "rel" + + const val ENCLOSURE = "enclosure" + const val ENCLOSURE_URL = "url" + const val DC_NS_DATE = "date" + const val DC_NS_TYPE = "type" } enum class RSSVersion(val elementName: String, val xmlns: String) { diff --git a/parserss/src/main/java/com/github/muhrifqii/parserss/ParserExecutor.kt b/parserss/src/main/java/com/github/muhrifqii/parserss/ParserExecutor.kt index c9d32e5..41cb9a0 100644 --- a/parserss/src/main/java/com/github/muhrifqii/parserss/ParserExecutor.kt +++ b/parserss/src/main/java/com/github/muhrifqii/parserss/ParserExecutor.kt @@ -6,6 +6,7 @@ import com.github.muhrifqii.parserss.utils.getRSSAttributeElement import com.github.muhrifqii.parserss.utils.getRSSElement import com.github.muhrifqii.parserss.utils.nextTextTrimmed import org.xmlpull.v1.XmlPullParser +import org.xmlpull.v1.XmlPullParserException import org.xmlpull.v1.XmlPullParserFactory import java.io.Reader @@ -13,7 +14,7 @@ class ParserExecutor( factory: XmlPullParserFactory, private val input: Reader, strictMode: Boolean, - feedSupplier: () -> T + feedSupplier: () -> T, ) where T : RSSFeed { private val parser: XmlPullParser @@ -52,7 +53,9 @@ class ParserExecutor( if (element.name != RSSVersion.RSS_V1.elementName && element.name != RSSVersion.RSS_V2.elementName && element.name != RSSVersion.RSS_ATOM.elementName - ) return element + ) { + return element + } val attrCount = parser.attributeCount for (i in 0 until attrCount) { val attribute = parser.getRSSAttributeElement(i, pullParserNSAware) @@ -93,74 +96,134 @@ class ParserExecutor( } private fun parseNSDefault(element: ParseRSSElement) { - when (element.name) { - ParseRSSKeyword.TITLE -> mode[TitleEnabledObject::class.java] = { - it?.title = parser.nextTextTrimmed() - } - ParseRSSKeyword.DESCRIPTION -> mode[DescriptionEnabledObject::class.java] = { - it?.description = parser.nextTextTrimmed() - } - ParseRSSKeyword.LINK -> mode[LinkEnabledObject::class.java] = { - it?.link = parser.nextTextTrimmed() - } - ParseRSSKeyword.PUBLISH_DATE -> mode[PublishDateEnabledObject::class.java] = { - it?.publishDate = parser.nextTextTrimmed() - } - ParseRSSKeyword.LAST_BUILD_DATE -> mode[LastUpdatedEnabledObject::class.java] = { - it?.lastUpdated = parser.nextTextTrimmed() - } - ParseRSSKeyword.URL -> mode[UrlEnabledObject::class.java] = { - it?.url = parser.nextTextTrimmed() - } - ParseRSSKeyword.LANG -> mode[LangEnabledObject::class.java] = { - it?.language = parser.nextTextTrimmed() - } - ParseRSSKeyword.GUID -> mode[GUIdEnabledObject::class.java] = { - val isPerma = - (parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_PERMALINK) ?: "true") - .toBoolean() - it?.guId = GUId(parser.nextTextTrimmed(), isPerma) - } - ParseRSSKeyword.AUTHOR -> mode[AuthorEnabledObject::class.java] = { - it?.author = RSSPersonAwareObject(parser.nextTextTrimmed()) - } - ParseRSSKeyword.CATEGORY -> mode[CategoryEnabledObject::class.java] = { - val domain = parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_DOMAIN) - it?.category?.add( - RSSCategoryObject(domain, parser.nextTextTrimmed()) - ) - } - ParseRSSKeyword.COPYRIGHT -> mode[CopyrightsEnabledObject::class.java] = { - it?.copyright = parser.nextTextTrimmed() - } - ParseRSSKeyword.COMMENTS -> mode[CommentEnabledObject::class.java] = { - it?.comments = parser.nextTextTrimmed() + try { + when (element.name) { + ParseRSSKeyword.TITLE -> mode[TitleEnabledObject::class.java] = { + it?.title = parser.nextTextTrimmed() + } + ParseRSSKeyword.DESCRIPTION -> mode[DescriptionEnabledObject::class.java] = { + it?.description = parser.nextTextTrimmed() + } + ParseRSSKeyword.LINK -> mode[LinkEnabledObject::class.java] = { + it?.link = parser.nextTextTrimmed() + } + ParseRSSKeyword.PUBLISH_DATE -> mode[PublishDateEnabledObject::class.java] = { + val date = parser.nextTextTrimmed() + if (date.isNotEmpty()) { + it?.publishDate = date + } + } + ParseRSSKeyword.LAST_BUILD_DATE -> mode[LastUpdatedEnabledObject::class.java] = { + it?.lastUpdated = parser.nextTextTrimmed() + } + ParseRSSKeyword.URL -> mode[UrlEnabledObject::class.java] = { + it?.url = parser.nextTextTrimmed() + } + ParseRSSKeyword.LANG -> mode[LangEnabledObject::class.java] = { + it?.language = parser.nextTextTrimmed() + } + ParseRSSKeyword.GUID -> mode[GUIdEnabledObject::class.java] = { + val isPermanent = ( + parser.getAttributeValue( + XmlPullParser.NO_NAMESPACE, + ParseRSSKeyword.ATTR_PERMALINK, + ) ?: "true" + ).toBoolean() + it?.guId = GUId(parser.nextTextTrimmed(), isPermanent) + } + ParseRSSKeyword.AUTHOR -> mode[AuthorEnabledObject::class.java] = { + val parsed = parser.nextTextTrimmed() + it?.author = RSSPersonAwareObject(parsed) + } + ParseRSSKeyword.CATEGORY -> mode[CategoryEnabledObject::class.java] = { + val domain = parser.getAttributeValue( + XmlPullParser.NO_NAMESPACE, + ParseRSSKeyword.ATTR_DOMAIN, + ) + it?.categories?.add(RSSCategoryObject(domain, parser.nextTextTrimmed())) + } + ParseRSSKeyword.COPYRIGHT -> mode[CopyrightsEnabledObject::class.java] = { + it?.copyright = parser.nextTextTrimmed() + } + ParseRSSKeyword.COMMENTS -> mode[CommentEnabledObject::class.java] = { + it?.comments = parser.nextTextTrimmed() + } + ParseRSSKeyword.ENCLOSURE -> mode[ImageUrlEnabledObject::class.java] = { + val imageUrl = parser.getAttributeValue( + XmlPullParser.NO_NAMESPACE, + ParseRSSKeyword.ENCLOSURE_URL, + ) + it?.imageUrls?.add(imageUrl.trim()) + } + ParseRSSKeyword.DC_NS_DATE -> mode[PublishDateEnabledObject::class.java] = { + val date = parser.nextTextTrimmed() + if (date.isNotEmpty()) { + it?.publishDate = date + } + } + ParseRSSKeyword.DC_NS_TYPE -> mode[CategoryEnabledObject::class.java] = { + val domain = parser.getAttributeValue( + XmlPullParser.NO_NAMESPACE, + ParseRSSKeyword.ATTR_DOMAIN, + ) + it?.categories?.add(RSSCategoryObject(domain, parser.nextTextTrimmed())) + } } + } catch (ignored: XmlPullParserException) { + // Note: added try/catch to handle RSS with broken and not valid structures, so we + // can continue the parsing instead of return a brutal exception + if (BuildConfig.DEBUG) { println("[ParseRSS] Ignored XmlPullParserException on parseNSDefault: $ignored") } + } catch (ignored: Exception) { + // Note: added try/catch to handle RSS with broken and not valid structures, so we + // can continue the parsing instead of return a brutal exception + if (BuildConfig.DEBUG) { println("[ParseRSS] Ignored Exception on parseNSDefault: $ignored") } } } private fun parseNSMedia(element: ParseRSSElement) { when (element.name) { ParseRSSKeyword.CONTENT -> mode[MediaEnabledObject::class.java] = { - val media = RSSMediaObject() - media.url = parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_URL) - media.medium = MediaType.from( - parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_MEDIUM) - ) - media.width = - parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_WIDTH).toInt() - media.height = - parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_HEIGHT).toInt() - it?.media?.add(media) + try { + val media = RSSMediaObject() + media.url = parser.getAttributeValue( + XmlPullParser.NO_NAMESPACE, + ParseRSSKeyword.ATTR_URL, + ) + media.medium = MediaType.from( + parser.getAttributeValue( + XmlPullParser.NO_NAMESPACE, + ParseRSSKeyword.ATTR_MEDIUM, + ), + ) + media.width = + parser.getAttributeValue( + XmlPullParser.NO_NAMESPACE, + ParseRSSKeyword.ATTR_WIDTH, + ).toInt() + media.height = + parser.getAttributeValue( + XmlPullParser.NO_NAMESPACE, + ParseRSSKeyword.ATTR_HEIGHT, + ).toInt() + it?.medias?.add(media) + } catch (ignored: NumberFormatException) { + if (BuildConfig.DEBUG) { + println("[ParseRSS] Ignored NumberFormatException error: ${ignored.localizedMessage}") + } + } catch (ignored: Exception) { + // Note: added try/catch to handle RSS with broken and not valid structures, so we + // can continue the parsing instead of return a brutal exception + if (BuildConfig.DEBUG) { println("[ParseRSS] Ignored Exception on parseNSMedia: $ignored") } + } } ParseRSSKeyword.DESCRIPTION -> mode[MediaEnabledObject::class.java] = { it?.apply { - media.lastOrNull()?.description = parser.nextTextTrimmed() + medias.lastOrNull()?.description = parser.nextTextTrimmed() } } ParseRSSKeyword.CREDIT -> mode[MediaEnabledObject::class.java] = { it?.apply { - media.lastOrNull()?.credit = parser.nextTextTrimmed() + medias.lastOrNull()?.credit = parser.nextTextTrimmed() } } } @@ -186,10 +249,11 @@ class ParserExecutor( ParseRSSKeyword.LINK -> mode[LinkEnabledObject::class.java] = { val rel = parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_REL) ?: "" val href = parser.getAttributeValue(XmlPullParser.NO_NAMESPACE, ParseRSSKeyword.ATTR_HREF) - if (rel == "self" && it is RSSFeed) + if (rel == "self" && it is RSSFeed) { it.link = href - else if (rel == "alternate" && it is RSSItem) + } else if (rel == "alternate" && it is RSSItem) { it.link = href + } } ParseRSSKeyword.RIGHTS -> mode[CopyrightsEnabledObject::class.java] = { it?.copyright = parser.nextTextTrimmed() diff --git a/parserss/src/main/java/com/github/muhrifqii/parserss/ParsingMode.kt b/parserss/src/main/java/com/github/muhrifqii/parserss/ParsingMode.kt index 1f6bca2..f00c89b 100644 --- a/parserss/src/main/java/com/github/muhrifqii/parserss/ParsingMode.kt +++ b/parserss/src/main/java/com/github/muhrifqii/parserss/ParsingMode.kt @@ -113,9 +113,11 @@ sealed class ParsingMode(val nameToken: String) : ParsingModeOperation { is Read -> return is MediaNS.Group -> { val item = modes.lastValue() - if (item !is Item) throw ParseRSSException( - "Error ${other.nameToken} should be under the item element", - ) + if (item !is Item) { + throw ParseRSSException( + "Error ${other.nameToken} should be under the item element", + ) + } other.rssObject = item.rssObject } is Author -> { @@ -123,7 +125,7 @@ sealed class ParsingMode(val nameToken: String) : ParsingModeOperation { val channel = (authorHolder as? Channel)?.rssObject val item = (authorHolder as? Item)?.rssObject other.rssObject = item ?: channel ?: throw ParseRSSException( - "Error ${other.nameToken} should be under item/atom:entry or atom:feed" + "Error ${other.nameToken} should be under item/atom:entry or atom:feed", ) } is Channel -> { @@ -166,10 +168,16 @@ sealed class ParsingMode(val nameToken: String) : ParsingModeOperation { else -> return } } catch (err: ClassCastException) { - throw ParseRSSException( - "Error on casting ${mode.nameToken} element to ${clazz.name}", - err - ) + if (mode.nameToken == ParseRSSKeyword.IMAGE) { + if (BuildConfig.DEBUG) { + println("[ParseRSS] Ignored error on casting ${mode.nameToken} element to ${clazz.name} with err ${err.localizedMessage}") + } + } else { + throw ParseRSSException( + "Error on casting ${mode.nameToken} element to ${clazz.name}", + err, + ) + } } } @@ -188,7 +196,7 @@ sealed class ParsingMode(val nameToken: String) : ParsingModeOperation { } catch (err: ClassCastException) { throw ParseRSSException( "Error on casting rss object to ${clazz.name}", - err + err, ) } } diff --git a/parserss/src/main/java/com/github/muhrifqii/parserss/RSSObject.kt b/parserss/src/main/java/com/github/muhrifqii/parserss/RSSObject.kt index 4d993a2..6ff213e 100644 --- a/parserss/src/main/java/com/github/muhrifqii/parserss/RSSObject.kt +++ b/parserss/src/main/java/com/github/muhrifqii/parserss/RSSObject.kt @@ -21,16 +21,17 @@ data class RSSItemObject( override var link: String? = null, override var publishDate: String? = null, override var guId: GUId? = null, - override var media: MutableList = mutableListOf(), + override var medias: MutableList = mutableListOf(), override var author: RSSPersonAware? = null, - override var category: MutableList = mutableListOf(), + override var categories: MutableList = mutableListOf(), override var comments: String? = null, override var lastUpdated: String? = null, - override var summary: String? = null + override var summary: String? = null, + override var imageUrls: MutableList = mutableListOf() ) : RSSItem data class RSSImageObject( - override var url: String = "", + override var url: String? = "", override var link: String? = null, override var title: String? = null ) : RSSImage diff --git a/parserss/src/main/java/com/github/muhrifqii/parserss/RSSObjectBase.kt b/parserss/src/main/java/com/github/muhrifqii/parserss/RSSObjectBase.kt index cd52f91..7aa908f 100644 --- a/parserss/src/main/java/com/github/muhrifqii/parserss/RSSObjectBase.kt +++ b/parserss/src/main/java/com/github/muhrifqii/parserss/RSSObjectBase.kt @@ -4,6 +4,10 @@ import java.io.Serializable interface RSSObject : Serializable +interface ImageUrlEnabledObject : RSSObject { + var imageUrls: MutableList +} + interface TitleEnabledObject : RSSObject { var title: String? } @@ -21,7 +25,7 @@ interface PublishDateEnabledObject : RSSObject { } interface UrlEnabledObject : RSSObject { - var url: String + var url: String? } interface LangEnabledObject : RSSObject { @@ -33,7 +37,7 @@ interface AuthorEnabledObject : RSSObject { } interface CategoryEnabledObject : RSSObject { - var category: MutableList + var categories: MutableList } interface GUIdEnabledObject : RSSObject { @@ -41,7 +45,7 @@ interface GUIdEnabledObject : RSSObject { } interface MediaEnabledObject : RSSObject { - var media: MutableList + var medias: MutableList } interface CommentEnabledObject : RSSObject { @@ -88,7 +92,8 @@ interface RSSItem : MediaEnabledObject, CommentEnabledObject, LastUpdatedEnabledObject, - SummaryEnabledObject + SummaryEnabledObject, + ImageUrlEnabledObject interface RSSImage : RSSObject, diff --git a/retrofit/src/main/java/com/github/muhrifqii/parserss/retrofit/ParseRSSConverter.kt b/retrofit/src/main/java/com/github/muhrifqii/parserss/retrofit/ParseRSSConverter.kt index e713b37..1c019d4 100644 --- a/retrofit/src/main/java/com/github/muhrifqii/parserss/retrofit/ParseRSSConverter.kt +++ b/retrofit/src/main/java/com/github/muhrifqii/parserss/retrofit/ParseRSSConverter.kt @@ -21,7 +21,6 @@ class ParseRSSConverterFactory private constructor() : Converter.Fa annotations: Array, retrofit: Retrofit ): Converter { - return ParseRSSConverter() } diff --git a/sample/build.gradle b/sample/build.gradle index 3d4ed76..e08d40d 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -11,6 +11,7 @@ android { targetSdkVersion targetsdk_version versionCode project_version_code as int versionName project_version + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -23,10 +24,14 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.3' - implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'com.google.android.material:material:1.8.0' + + // [NETWORKING] Retrofit, Moshi and Sandwich + implementation "com.squareup.retrofit2:retrofit:2.9.0" + implementation 'com.github.skydoves:sandwich:1.3.2' implementation 'com.github.kittinunf.fuel:fuel:2.3.1' @@ -35,6 +40,7 @@ dependencies { implementation project(':retrofit') testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test:runner:1.4.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + testImplementation group: 'xmlpull', name: 'xmlpull', version: '1.1.3.1' } diff --git a/sample/src/androidTest/java/com/github/muhrifqii/parserss/sample/ExampleInstrumentedTest.kt b/sample/src/androidTest/java/com/github/muhrifqii/parserss/sample/ExampleInstrumentedTest.kt index 6712224..204a78e 100644 --- a/sample/src/androidTest/java/com/github/muhrifqii/parserss/sample/ExampleInstrumentedTest.kt +++ b/sample/src/androidTest/java/com/github/muhrifqii/parserss/sample/ExampleInstrumentedTest.kt @@ -2,11 +2,17 @@ package com.github.muhrifqii.parserss.sample import androidx.test.InstrumentationRegistry import androidx.test.runner.AndroidJUnit4 - +import com.github.muhrifqii.parserss.ParseRSS +import com.github.muhrifqii.parserss.RSSFeedObject +import com.github.muhrifqii.parserss.retrofit.ParseRSSConverterFactory +import kotlinx.coroutines.runBlocking +import org.junit.Assert.* // ktlint-disable no-wildcard-imports import org.junit.Test import org.junit.runner.RunWith - -import org.junit.Assert.* +import org.xmlpull.v1.XmlPullParserFactory +import retrofit2.* // ktlint-disable no-wildcard-imports +import retrofit2.http.GET +import retrofit2.http.Url /** * Instrumented test, which will execute on an Android device. @@ -21,4 +27,50 @@ class ExampleInstrumentedTest { val appContext = InstrumentationRegistry.getTargetContext() assertEquals("com.github.muhrifqii.parserss.sample", appContext.packageName) } + + @Test + fun testGetRss() { + // Init ParseRSS + ParseRSS.init(XmlPullParserFactory.newInstance()) + + // Init params + val url = "https://www.albipretori.it/Public/Rss?Codice=192" + val baseUrl = "https://www.google.com/" + + // Init retrofit + val retrofit = Retrofit.Builder() + .baseUrl(baseUrl) + .addConverterFactory(ParseRSSConverterFactory.create()) + .build() + .create(RssApiInterface::class.java) + + // Make the request + runBlocking { + val response = RssApi.getRss(retrofit, url).awaitResponse().body() + println("HERE full response $response") + println( + "HERE image urls ${ response!!.items.joinToString(", ") { + it.imageUrls.joinToString(" --- ") + } + }" + ) + println( + "HERE publishDate ${ + response.items.joinToString(", ") { it.publishDate ?: "" } + }" + ) + assert(true) + } + } +} + +interface RssApiInterface { + @GET + fun getRss(@Url url: String): Call +} + +object RssApi { + fun getRss(service: RssApiInterface, url: String): Call { + return service.getRss(url) + } } diff --git a/sample/src/main/java/com/github/muhrifqii/parserss/sample/MainActivity.kt b/sample/src/main/java/com/github/muhrifqii/parserss/sample/MainActivity.kt index e896e6b..5a7689c 100644 --- a/sample/src/main/java/com/github/muhrifqii/parserss/sample/MainActivity.kt +++ b/sample/src/main/java/com/github/muhrifqii/parserss/sample/MainActivity.kt @@ -11,7 +11,7 @@ import com.github.muhrifqii.parserss.fuel.responseRss class MainActivity : AppCompatActivity() { - var adapter = RVAdapter(listOf()) + private var adapter = RVAdapter(listOf()) private val toolbar by lazy { findViewById(R.id.toolbar) } @@ -28,7 +28,7 @@ class MainActivity : AppCompatActivity() { loadFeedUsingFuel() } - fun loadFeedUsingFuel() { + private fun loadFeedUsingFuel() { Fuel.get("http://dp3ap2.jogjaprov.go.id/rss") .responseRss { result -> result.fold({ diff --git a/sample/src/main/java/com/github/muhrifqii/parserss/sample/MyApplication.kt b/sample/src/main/java/com/github/muhrifqii/parserss/sample/MyApplication.kt index e398c49..143c6a9 100644 --- a/sample/src/main/java/com/github/muhrifqii/parserss/sample/MyApplication.kt +++ b/sample/src/main/java/com/github/muhrifqii/parserss/sample/MyApplication.kt @@ -10,7 +10,7 @@ class MyApplication: Application() { override fun onCreate() { super.onCreate() - // initalize ParseRSS with XMLPullParser + // initialize ParseRSS with XMLPullParser try { ParseRSS.init(XmlPullParserFactory.newInstance()) } catch (e: XmlPullParserException) { diff --git a/sample/src/main/java/com/github/muhrifqii/parserss/sample/RVAdapter.kt b/sample/src/main/java/com/github/muhrifqii/parserss/sample/RVAdapter.kt index 4bdc1b5..517758c 100644 --- a/sample/src/main/java/com/github/muhrifqii/parserss/sample/RVAdapter.kt +++ b/sample/src/main/java/com/github/muhrifqii/parserss/sample/RVAdapter.kt @@ -21,7 +21,6 @@ class RVAdapter(var items: List) : RecyclerView.Adapter() { holder.title.text = items[position].title holder.subtitle.text = items[position].description } - } class RVHolder(view: View) : RecyclerView.ViewHolder(view) { diff --git a/sample/src/test/java/com/github/muhrifqii/parserss/sample/ExampleUnitTest.kt b/sample/src/test/java/com/github/muhrifqii/parserss/sample/ExampleUnitTest.kt index f7ad092..692ebc2 100644 --- a/sample/src/test/java/com/github/muhrifqii/parserss/sample/ExampleUnitTest.kt +++ b/sample/src/test/java/com/github/muhrifqii/parserss/sample/ExampleUnitTest.kt @@ -1,8 +1,14 @@ package com.github.muhrifqii.parserss.sample +import com.github.kittinunf.fuel.Fuel +import com.github.muhrifqii.parserss.ParseRSS +import com.github.muhrifqii.parserss.RSSFeedObject +import com.github.muhrifqii.parserss.fuel.responseRss import org.junit.Test import org.junit.Assert.* +import org.junit.Before +import org.xmlpull.v1.XmlPullParserFactory /** * Example local unit test, which will execute on the development machine (host).