...
This commit is contained in:
parent
a4f0cecfa4
commit
e250a06d39
@ -97,6 +97,7 @@ import rasel.lunar.launcher.utils.RssList.jGuruMain
|
||||
import rasel.lunar.launcher.utils.beforeDay
|
||||
import rasel.lunar.launcher.utils.make0H
|
||||
import rasel.lunar.launcher.workers.ArcaGetter
|
||||
import rasel.lunar.launcher.workers.ClienGetter
|
||||
import rasel.lunar.launcher.workers.DCGetter
|
||||
import rasel.lunar.launcher.workers.DotaxGetter
|
||||
import rasel.lunar.launcher.workers.FmKoreaGetter
|
||||
@ -104,6 +105,8 @@ import rasel.lunar.launcher.workers.NewsFeedsGetter
|
||||
import rasel.lunar.launcher.workers.RecentCallGetter
|
||||
import rasel.lunar.launcher.workers.RecentSmsGetter
|
||||
import rasel.lunar.launcher.workers.RedditGetter
|
||||
import rasel.lunar.launcher.workers.RuliWebGetter
|
||||
import rasel.lunar.launcher.workers.TheQooGetter
|
||||
import rasel.lunar.launcher.workers.WorkersDb
|
||||
import rasel.lunar.launcher.workers.YoutubeGetter
|
||||
import java.text.SimpleDateFormat
|
||||
@ -214,6 +217,17 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
}, 2, TimeUnit.SECONDS)
|
||||
}
|
||||
fun refreshComics3() {
|
||||
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(ClienGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
ClienGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<ClienGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(ClienGetter.TAG)
|
||||
.build())
|
||||
refreshArca()
|
||||
}, 2, TimeUnit.SECONDS)
|
||||
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(DCGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
@ -223,6 +237,28 @@ internal class LauncherActivity : AppCompatActivity() {
|
||||
.build())
|
||||
refreshArca()
|
||||
}, 2, TimeUnit.SECONDS)
|
||||
|
||||
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(RuliWebGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
RuliWebGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<RuliWebGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(RuliWebGetter.TAG)
|
||||
.build())
|
||||
refreshArca()
|
||||
}, 2, TimeUnit.SECONDS)
|
||||
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
mWorkManager?.cancelAllWorkByTag(TheQooGetter.TAG)
|
||||
mWorkManager?.enqueueUniquePeriodicWork(
|
||||
TheQooGetter.TAG, ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
|
||||
PeriodicWorkRequestBuilder<TheQooGetter>(midTimePeriod, TimeUnit.MINUTES)
|
||||
.addTag(TheQooGetter.TAG)
|
||||
.build())
|
||||
refreshArca()
|
||||
}, 2, TimeUnit.SECONDS)
|
||||
|
||||
}
|
||||
|
||||
fun refreshArca() {
|
||||
|
||||
@ -254,7 +254,10 @@ internal class LauncherHome : Fragment() {
|
||||
mNotificationResult = null
|
||||
try {
|
||||
System.gc()
|
||||
}catch (e : Exception){e.printStackTrace()}
|
||||
}catch (e : Exception){
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
mNotificationResult = WorkersDb.getRealm().query<NotificationItem>().sort("postTime",Sort.DESCENDING).find()
|
||||
noticeJob = CoroutineScope(Dispatchers.Default).launch {
|
||||
mNotificationResult?.asFlow()?.collect { changes: ResultsChange<NotificationItem> ->
|
||||
@ -276,10 +279,10 @@ internal class LauncherHome : Fragment() {
|
||||
}
|
||||
mNotificationResult?.let { mNotiAdapter?.updateData(it) }
|
||||
|
||||
noticeJob.start()
|
||||
noticeJob?.start()
|
||||
}
|
||||
|
||||
fun queryInfos(filter: Collection<RssDataType>? = arrayListOf(RssDataType.GURU,RssDataType.Most)) {
|
||||
fun queryInfos(filter: Collection<RssDataType>? = arrayListOf(RssDataType.GURU,RssDataType.Most,RssDataType.REDDIT_nsfw)) {
|
||||
BLog.LOGE("${this} ::::: queryInfos >>>> ${filter}")
|
||||
try { infosJob?.cancel() } catch (e:Exception) {e.printStackTrace()}
|
||||
mRssDataResult = null
|
||||
@ -291,11 +294,11 @@ internal class LauncherHome : Fragment() {
|
||||
delete(query<RssData>().query("pubDate < $0",beforeDay(Date(),3)).query("category != $0 || category != $1 ", RssDataType.GURU.name,RssDataType.Most.name).find())
|
||||
}}
|
||||
BLog.LOGE("${this} ::::: queryInfos after delete >>>> ")
|
||||
var rQ = WorkersDb.getRealm().query<RssData>().sort("pubDate ", Sort.DESCENDING).query("pubDate > $0",beforeDay(Date(),3))
|
||||
var rQ = WorkersDb.getRealm().query<RssData>().query("pubDate > $0", beforeDay(Date(),3))
|
||||
filter!!.forEach {
|
||||
rQ = rQ.query("category != $0", it.name)
|
||||
}
|
||||
mRssDataResult = rQ.limit(1000).find()
|
||||
mRssDataResult = rQ.sort("pubDate ", Sort.DESCENDING).limit(1000).find()
|
||||
BLog.LOGE("${this} ::::: queryInfos after query find >>>> ")
|
||||
infosJob = CoroutineScope(Dispatchers.Default).launch {
|
||||
mRssDataResult?.asFlow()?.collect { changes: ResultsChange<RssData> ->
|
||||
@ -322,11 +325,11 @@ internal class LauncherHome : Fragment() {
|
||||
// commandHandler.postDelayed(infoUpdate, UPDATE_DELAY * 3)
|
||||
mRssAdapter.updateData(it)
|
||||
}
|
||||
infosJob.start()
|
||||
infosJob?.start()
|
||||
}
|
||||
|
||||
lateinit var infosJob : Job
|
||||
lateinit var noticeJob : Job
|
||||
var infosJob : Job? = null
|
||||
var noticeJob : Job? = null
|
||||
|
||||
lateinit var mMissedCallsAdapter : MissedCallsAdapter
|
||||
lateinit var mSmsLogsAdapter : SmsLogsAdapter
|
||||
@ -516,7 +519,6 @@ internal class LauncherHome : Fragment() {
|
||||
binding.notiList.visibility = View.VISIBLE
|
||||
binding.notice.text = "알림 센터[${lastedNoti?.size ?: "-"}]"
|
||||
lastedNoti?.let { mNotiAdapter.updateData(it)}
|
||||
|
||||
}
|
||||
}
|
||||
commandHandler.postDelayed(hideListView, UPDATE_DELAY * 5)
|
||||
|
||||
27
app/src/main/kotlin/rasel/lunar/launcher/model/Clien.kt
Normal file
27
app/src/main/kotlin/rasel/lunar/launcher/model/Clien.kt
Normal file
@ -0,0 +1,27 @@
|
||||
package rasel.lunar.launcher.model
|
||||
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
|
||||
class Clien : DcInside() {
|
||||
companion object{
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
override fun category(): RssDataType {
|
||||
return RssDataType.Clien
|
||||
}
|
||||
|
||||
|
||||
override fun pubDate(): Long {
|
||||
if (dateTiemL < 1L) {
|
||||
if (dateTiem?.length ?: 0 < 1) return 0L
|
||||
return dateFormat.parse(dateTiem!!).time.apply {
|
||||
dateTiemL = this
|
||||
}
|
||||
} else {
|
||||
return dateTiemL
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,6 +15,7 @@ import java.util.TimeZone
|
||||
|
||||
|
||||
fun Elements.getT() = if (size > 0) get(0).text() else ""
|
||||
fun Elements.getHref() = if (size > 0) get(0).attr("href") else ""
|
||||
val dateFormat = SimpleDateFormat("hh:mm / yy - MM - dd")
|
||||
class Arca : RssDataInterface {
|
||||
var link : String? = null
|
||||
@ -108,7 +109,7 @@ class Arca : RssDataInterface {
|
||||
|
||||
|
||||
|
||||
class DcInside : RssDataInterface {
|
||||
open class DcInside : RssDataInterface {
|
||||
var link : String? = null
|
||||
var title : String? = null
|
||||
var thumbnail : String? = null
|
||||
@ -141,7 +142,7 @@ class DcInside : RssDataInterface {
|
||||
return if (dateTiem?.contains(":") == true) {
|
||||
val cal: Calendar = Calendar.getInstance()
|
||||
cal.setTime(Date())
|
||||
cal.set(Calendar.HOUR_OF_DAY, dateTiem!!.split(":")[0].toInt()- 1)
|
||||
cal.set(Calendar.HOUR_OF_DAY, dateTiem!!.split(":")[0].toInt())
|
||||
cal.set(Calendar.MINUTE, dateTiem!!.split(":")[1].toInt())
|
||||
// cal.set(Calendar.MINUTE, dateTiem!!.split(":")[1].toI nt())
|
||||
dateTiemL = cal.timeInMillis
|
||||
@ -151,7 +152,7 @@ class DcInside : RssDataInterface {
|
||||
cal.setTime(Date())
|
||||
cal.set(Calendar.MONTH, dateTiem!!.split("-")[0].toInt() - 1)
|
||||
cal.set(Calendar.DAY_OF_MONTH, dateTiem!!.split("-")[1].toInt())
|
||||
cal.add(Calendar.DAY_OF_MONTH, -1)
|
||||
// cal.add(Calendar.DAY_OF_MONTH, -1)
|
||||
dateTiemL = cal.timeInMillis
|
||||
dateTiemL
|
||||
} else {
|
||||
@ -168,6 +169,19 @@ class DcInside : RssDataInterface {
|
||||
|
||||
}
|
||||
|
||||
|
||||
class RuliWeb : DcInside() {
|
||||
override fun category(): RssDataType {
|
||||
return RssDataType.RuliWeb
|
||||
}
|
||||
}
|
||||
class TheQoo : DcInside() {
|
||||
override fun category(): RssDataType {
|
||||
return RssDataType.TheQoo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class RssData : RealmObject, RssDataInterface {
|
||||
|
||||
@PrimaryKey
|
||||
|
||||
@ -271,7 +271,9 @@ class Data : RssDataInterface {
|
||||
}
|
||||
|
||||
override fun category(): RssDataType {
|
||||
return RssDataType.REDDIT
|
||||
return if (description()?.contains("nsfw") == true) {
|
||||
RssDataType.REDDIT_nsfw
|
||||
} else RssDataType.REDDIT
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package rasel.lunar.launcher.model
|
||||
|
||||
import android.view.View
|
||||
import rasel.lunar.launcher.R
|
||||
|
||||
enum class RssDataType {
|
||||
NO_DATA,
|
||||
YOUTUBE,
|
||||
@ -8,10 +11,37 @@ enum class RssDataType {
|
||||
Most,
|
||||
TAGS,
|
||||
REDDIT,
|
||||
REDDIT_nsfw,
|
||||
Dotax,
|
||||
FmKorae,
|
||||
DcInside,
|
||||
Arca,
|
||||
RuliWeb,
|
||||
Clien,
|
||||
TheQoo,
|
||||
Arca;
|
||||
|
||||
fun getResId() = when (this) {
|
||||
YOUTUBE -> R.drawable.youtube
|
||||
REDDIT, REDDIT_nsfw -> R.drawable.reddit
|
||||
Dotax -> R.drawable.daum
|
||||
FmKorae -> R.drawable.fmk
|
||||
DcInside -> R.drawable.dcinside
|
||||
Arca -> R.drawable.arca
|
||||
else -> {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fun defaultImgSize() = when (this) {
|
||||
YOUTUBE -> 200
|
||||
REDDIT_nsfw,GURU,Most -> 360
|
||||
else -> { 120 }
|
||||
}
|
||||
|
||||
fun getDefaultVisibiliy() = when (this) {
|
||||
REDDIT_nsfw,GURU,Most,NewsFeed -> View.GONE
|
||||
else -> { View.VISIBLE }
|
||||
}
|
||||
}
|
||||
|
||||
interface RssDataInterface {
|
||||
@ -21,4 +51,6 @@ interface RssDataInterface {
|
||||
fun description() : String
|
||||
fun pubDate() : Long
|
||||
fun category() : RssDataType
|
||||
|
||||
|
||||
}
|
||||
@ -22,7 +22,6 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -30,6 +29,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.net.toUri
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.squareup.picasso.Picasso
|
||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||
import rasel.lunar.launcher.R
|
||||
@ -53,155 +53,72 @@ internal class RssItemAdapter (
|
||||
return rssDataItemLis.size
|
||||
}
|
||||
|
||||
val dateFormat = SimpleDateFormat("hh:mm / yy - MM - dd")
|
||||
val dateFormat = SimpleDateFormat("a HH:mm / yy - MM - dd")
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onBindViewHolder(holder: RssTag, position: Int) {
|
||||
val todo = rssDataItemLis[position]
|
||||
Picasso.get().cancelRequest(holder.view.circlePreview)
|
||||
holder.view.date.text = dateFormat.format(Date(todo.pubDate()))
|
||||
holder.view.date.setOnClickListener { }
|
||||
when(todo.category()) {
|
||||
val rssData = rssDataItemLis[position]
|
||||
|
||||
if (rssData.pubDate() > 1000L) {
|
||||
holder.view.date.text = dateFormat.format(Date(rssData.pubDate()))
|
||||
} else {
|
||||
holder.view.date.text = ""
|
||||
}
|
||||
|
||||
holder.view.title.text = rssData.title()
|
||||
when(rssData.category()) {
|
||||
RssDataType.YOUTUBE -> {
|
||||
if(todo.thumbnailUrl()?.length ?: 0 > 6) {
|
||||
Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview)
|
||||
holder.view.circlePreview.visibility = View.VISIBLE
|
||||
}
|
||||
var param = holder.view.circlePreview.layoutParams
|
||||
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(280,param.height)
|
||||
holder.view.title.text = "${todo.title()}"
|
||||
holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.date.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.desc.visibility = View.VISIBLE
|
||||
holder.view.desc.text = if(todo.description().contains("게시자")) todo.description().split("게시자")[0] else todo.description()
|
||||
holder.view.root.setOnClickListener {
|
||||
|
||||
}
|
||||
holder.view.root.setOnLongClickListener {
|
||||
|
||||
openYouTube(todo.originPage())
|
||||
|
||||
true
|
||||
}
|
||||
holder.view.desc.text = if(rssData.description().contains("게시자")) rssData.description().split("게시자")[0] else rssData.description()
|
||||
}
|
||||
RssDataType.NewsFeed -> {
|
||||
holder.view.desc.text = todo.category().name
|
||||
holder.view.circlePreview.visibility = View.GONE
|
||||
holder.view.title.text = if(todo.title().length > 30)todo.title().substring(0,30).plus("...") else todo.title()
|
||||
holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.date.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.root.setOnClickListener {
|
||||
|
||||
}
|
||||
holder.view.root.setOnLongClickListener {
|
||||
openNews(todo.originPage())
|
||||
true
|
||||
}
|
||||
holder.view.desc.text = rssData.category().name
|
||||
holder.view.title.text = if(rssData.title().length > 30)rssData.title().substring(0,30).plus("...") else rssData.title()
|
||||
}
|
||||
RssDataType.NO_DATA -> {}
|
||||
else -> {
|
||||
holder.view.title.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.desc.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.date.gravity = Gravity.CENTER_VERTICAL.plus(Gravity.RIGHT)
|
||||
holder.view.title.text = todo.title()
|
||||
if (todo.pubDate() > 1000L) {
|
||||
holder.view.date.text = dateFormat.format(Date(todo.pubDate()))
|
||||
holder.view.desc.text = rssData.description().plus(" ").plus(rssData.category().name)
|
||||
}
|
||||
}
|
||||
var param = holder.view.circlePreview.layoutParams
|
||||
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(rssData.category().defaultImgSize(), param.height)
|
||||
holder.view.circlePreview.visibility = rssData.category().getDefaultVisibiliy()
|
||||
if(rssData.thumbnailUrl()?.length ?: 0 > 6) {
|
||||
Picasso.get().load(rssData.thumbnailUrl().replace("&","&").toUri()).into(holder.view.circlePreview)
|
||||
} else if (rssData.category().getResId() > 0 ) {
|
||||
holder.view.circlePreview.setImageResource(rssData.category().getResId())
|
||||
} else {
|
||||
holder.view.circlePreview.setImageDrawable(null)
|
||||
Picasso.get().cancelRequest(holder.view.circlePreview)
|
||||
}
|
||||
holder.view.root.tag = position
|
||||
holder.view.root.setOnClickListener(dateViewClick)
|
||||
holder.view.root.setOnLongClickListener(mLongClickListener)
|
||||
}
|
||||
|
||||
if(todo.description().contains("nsfw") || todo.category().equals(RssDataType.GURU) || todo.category().equals(RssDataType.Most)) {
|
||||
holder.view.circlePreview.visibility = View.GONE
|
||||
var param = holder.view.circlePreview.layoutParams
|
||||
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(360,param.height)
|
||||
} else if( todo.category().equals(RssDataType.Dotax)) {
|
||||
holder.view.circlePreview.setImageResource(R.drawable.daum)
|
||||
holder.view.circlePreview.visibility = View.VISIBLE
|
||||
var param = holder.view.circlePreview.layoutParams
|
||||
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
|
||||
} else if( todo.category().equals(RssDataType.REDDIT)) {
|
||||
holder.view.circlePreview.setImageResource(R.drawable.reddit)
|
||||
holder.view.circlePreview.visibility = View.VISIBLE
|
||||
var param = holder.view.circlePreview.layoutParams
|
||||
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
|
||||
} else if( todo.category().equals(RssDataType.FmKorae) ) {
|
||||
holder.view.circlePreview.setImageResource(R.drawable.fmk)
|
||||
holder.view.circlePreview.visibility = View.VISIBLE
|
||||
var param = holder.view.circlePreview.layoutParams
|
||||
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
|
||||
} else if(todo.category().equals(RssDataType.DcInside)) {
|
||||
holder.view.circlePreview.setImageResource(R.drawable.dcinside)
|
||||
holder.view.circlePreview.visibility = View.VISIBLE
|
||||
var param = holder.view.circlePreview.layoutParams
|
||||
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
|
||||
} else if(todo.category().equals(RssDataType.Arca)) {
|
||||
holder.view.circlePreview.setImageResource(R.drawable.arca)
|
||||
holder.view.circlePreview.visibility = View.VISIBLE
|
||||
var param = holder.view.circlePreview.layoutParams
|
||||
holder.view.circlePreview.layoutParams = ConstraintLayout.LayoutParams(120,param.height)
|
||||
}
|
||||
|
||||
|
||||
if(todo.thumbnailUrl()?.length ?: 0 > 6) {
|
||||
Picasso.get().load(todo.thumbnailUrl().toUri()).into(holder.view.circlePreview)
|
||||
}
|
||||
|
||||
holder.view.desc.text = todo.description().plus(" ").plus(todo.category().name)
|
||||
holder.view.desc.visibility = View.VISIBLE
|
||||
holder.view.date.setOnClickListener {
|
||||
if (holder.view.circlePreview.visibility == View.GONE) {
|
||||
holder.view.circlePreview.visibility = View.VISIBLE
|
||||
holder.view.circlePreview.postDelayed({
|
||||
holder.view.circlePreview.visibility = View.GONE
|
||||
val dateViewClick = View.OnClickListener {
|
||||
it.findViewById<ShapeableImageView>(R.id.circle_preview)?.let {
|
||||
if (it.visibility == View.GONE) {
|
||||
it.visibility = View.VISIBLE
|
||||
it.postDelayed({
|
||||
it.visibility = View.GONE
|
||||
}, 1000L)
|
||||
}
|
||||
}
|
||||
// holder.view.date.setOnTouchListener { v,e ->
|
||||
// if (holder.view.date.equals(v)) {
|
||||
// when(e.action) {
|
||||
// MotionEvent.ACTION_DOWN -> {holder.view.circlePreview.visibility = View.VISIBLE}
|
||||
// MotionEvent.ACTION_UP -> {holder.view.circlePreview.visibility = View.GONE}
|
||||
// MotionEvent.ACTION_UP -> {holder.view.circlePreview.visibility = View.GONE}
|
||||
// }
|
||||
// }
|
||||
// false
|
||||
// }
|
||||
}
|
||||
|
||||
holder.view.title.setOnLongClickListener {
|
||||
BLog.LOGE("holder.view.root ${holder.view.root}")
|
||||
if ( todo.category().equals(RssDataType.GURU)) {
|
||||
openOpera(todo.originPage())
|
||||
} else if( todo.category().equals(RssDataType.REDDIT)) {
|
||||
openReddit(todo.originPage())
|
||||
} else if( todo.category().equals(RssDataType.Dotax)) {
|
||||
openDotax(todo.originPage())
|
||||
}else if(todo.category().equals(RssDataType.FmKorae)|| todo.category().equals(
|
||||
RssDataType.DcInside)|| todo.category().equals(RssDataType.Arca)) {
|
||||
openNews(todo.originPage())
|
||||
} else {
|
||||
openOpera(todo.originPage())
|
||||
val mLongClickListener = View.OnLongClickListener { v ->
|
||||
(v?.tag as? Int)?.let { idx ->
|
||||
val rss = rssDataItemLis[idx]
|
||||
when (rss.category()) {
|
||||
RssDataType.GURU ,RssDataType.Most , RssDataType.TAGS-> { openOpera(rss.originPage()) }
|
||||
RssDataType.REDDIT -> { openReddit(rss.originPage()) }
|
||||
RssDataType.Dotax -> { openDotax(rss.originPage()) }
|
||||
RssDataType.YOUTUBE -> { openYouTube(rss.originPage()) }
|
||||
else -> { openNews(rss.originPage()) }
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
holder.view.root.setOnLongClickListener {
|
||||
BLog.LOGE("holder.view.root ${holder.view.root}")
|
||||
if ( todo.category().equals(RssDataType.GURU)) {
|
||||
openOpera(todo.originPage())
|
||||
} else if( todo.category().equals(RssDataType.REDDIT)) {
|
||||
openReddit(todo.originPage())
|
||||
} else if( todo.category().equals(RssDataType.Dotax)) {
|
||||
openDotax(todo.originPage())
|
||||
}else if(todo.category().equals(RssDataType.FmKorae)|| todo.category().equals(
|
||||
RssDataType.DcInside)|| todo.category().equals(RssDataType.Arca)) {
|
||||
openNews(todo.originPage())
|
||||
} else {
|
||||
openOpera(todo.originPage())
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun openOpera(schemeString : String) {
|
||||
BLog.LOGE("openOpera ${schemeString}")
|
||||
@ -266,7 +183,7 @@ internal class RssItemAdapter (
|
||||
// return px
|
||||
//}
|
||||
|
||||
internal class RssTag(var view: ListItemWithBinding) : RecyclerView.ViewHolder(view.root)
|
||||
internal class RssTag(var view: ListItemWithBinding) : RecyclerView.ViewHolder(view.root) {}
|
||||
internal class RssItemDiffUtil(
|
||||
var oldList: List<RssDataInterface>, var newList: List<RssDataInterface>
|
||||
) : DiffUtil.Callback() {
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
package rasel.lunar.launcher.workers
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.work.WorkerParameters
|
||||
import org.jsoup.Jsoup
|
||||
import rasel.lunar.launcher.model.Clien
|
||||
import rasel.lunar.launcher.model.TheQoo
|
||||
import rasel.lunar.launcher.model.getHref
|
||||
import rasel.lunar.launcher.model.getRssData
|
||||
import rasel.lunar.launcher.model.getT
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
|
||||
class ClienGetter : BaseGetter {
|
||||
companion object {
|
||||
val TAG = "ClienGetter"
|
||||
}
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
}
|
||||
|
||||
fun parseClien(div_clien : org.jsoup.nodes.Element) {
|
||||
BLog.LOGE("div_clien >>>> ${div_clien}")
|
||||
|
||||
BLog.LOGE("div_clien >>>> ${div_clien.getElementsByClass("subject_fixed").getT()}")
|
||||
BLog.LOGE("div_clien >>>> ${div_clien.getElementsByClass("shortname fixed").getT()}")
|
||||
BLog.LOGE("div_clien >>>> ${div_clien.getElementsByClass("list_subject").getHref()}")
|
||||
BLog.LOGE("div_clien >>>> ${div_clien.getElementsByClass("timestamp").getT()}")
|
||||
|
||||
val title = div_clien.getElementsByClass("subject_fixed").getT()
|
||||
val desc = div_clien.getElementsByClass("shortname fixed").getT()
|
||||
val link = div_clien.getElementsByClass("list_subject").getHref()
|
||||
val timeStamp = div_clien.getElementsByClass("timestamp").getT()
|
||||
if (title.length > 0 && timeStamp.length > 0) {
|
||||
Clien().let { c ->
|
||||
c.title = title
|
||||
c.link = "https://www.clien.net".plus(link)
|
||||
c.desc = desc
|
||||
c.dateTiem = timeStamp
|
||||
if (c.pubDate() > limitDateTime) {
|
||||
temp.add(c.getRssData())
|
||||
}
|
||||
}
|
||||
}
|
||||
// var desc = tq_tr.getElementsByClass("cate").getT()
|
||||
// var title = tq_tr.getElementsByClass("title").getT()
|
||||
// var pageLink = tq_tr.getElementsByTag("a").getHref()
|
||||
// var dateTime = tq_tr.getElementsByClass("time").getT()
|
||||
|
||||
// BLog.LOGE("${TAG} :::: desc >>> $desc")
|
||||
// BLog.LOGE("${TAG} :::: title >>> $title")
|
||||
// BLog.LOGE("${TAG} :::: pageLink >>> $pageLink")
|
||||
// BLog.LOGE("${TAG} :::: dateTime >>> $dateTime")
|
||||
|
||||
// if (title.length > 0 && pageLink.length > 0) {
|
||||
// TheQoo().let { tq ->
|
||||
// tq.title = title
|
||||
// tq.link = "https://theqoo.net".plus(pageLink)
|
||||
// tq.dateTiem = dateTime
|
||||
// tq.desc = desc
|
||||
// if (tq.pubDate() > limitDateTime) {
|
||||
// temp.add(tq.getRssData())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun doWork(): Result {
|
||||
|
||||
try {
|
||||
val testUrl2 = arrayListOf("https://www.clien.net/service/group/community")
|
||||
testUrl2.forEach { url ->
|
||||
Jsoup.connect(url)
|
||||
.userAgent(USAGT)
|
||||
.get().let { ruli ->
|
||||
BLog.LOGE("test ${url} >> ${ruli.title()}")
|
||||
ruli.getElementsByClass("list_item symph_row ").forEach { ruli_tr ->
|
||||
parseClien(ruli_tr)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e:Exception){e.printStackTrace()}
|
||||
return Result.success().apply {
|
||||
BLog.LOGE("ClienGetter temp >>>> ${temp.size}")
|
||||
WorkersDb.insertBulkData(temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ import rasel.lunar.launcher.model.DcInside
|
||||
import rasel.lunar.launcher.model.RssData
|
||||
import rasel.lunar.launcher.model.getRssData
|
||||
import rasel.lunar.launcher.model.RssDataInterface
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
|
||||
class DCGetter : BaseGetter {
|
||||
companion object {
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
package rasel.lunar.launcher.workers
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.work.WorkerParameters
|
||||
import org.jsoup.Jsoup
|
||||
import rasel.lunar.launcher.model.DcInside
|
||||
import rasel.lunar.launcher.model.RssData
|
||||
import rasel.lunar.launcher.model.getRssData
|
||||
import rasel.lunar.launcher.model.RssDataInterface
|
||||
import rasel.lunar.launcher.model.RuliWeb
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
|
||||
class RuliWebGetter : BaseGetter {
|
||||
companion object {
|
||||
val TAG = "RuliWebGetter"
|
||||
}
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
}
|
||||
|
||||
fun parseRuli(ruli_tr : org.jsoup.nodes.Element) {
|
||||
var aTags = ruli_tr.getElementsByTag("a")
|
||||
var tagIdx = 0
|
||||
var pageLink = ""
|
||||
var thumbnailUrl = ""
|
||||
var title = ""
|
||||
var desc = ""
|
||||
var dateTimeTxt = ""
|
||||
if(ruli_tr.getElementsByTag("a").size > tagIdx) {
|
||||
pageLink = aTags.get(tagIdx).attr("href").replace("&","&")
|
||||
thumbnailUrl = aTags.get(tagIdx).attr("style").split("(")[1].replace(");","")
|
||||
}
|
||||
tagIdx = 1
|
||||
if(ruli_tr.getElementsByTag("a").size > tagIdx) { title = aTags.get(tagIdx).text() }
|
||||
tagIdx = 2
|
||||
if(ruli_tr.getElementsByTag("a").size > tagIdx) { desc = aTags.get(tagIdx).text().plus(" / ") }
|
||||
tagIdx = 3
|
||||
if(ruli_tr.getElementsByTag("a").size > tagIdx) { desc = desc.plus(aTags.get(tagIdx).text()) }
|
||||
var timeClass = ruli_tr.getElementsByClass("time")
|
||||
if(timeClass.size > 0) { dateTimeTxt = timeClass.get(0).text() }
|
||||
|
||||
// BLog.LOGE("pageLink >>>> $pageLink ")
|
||||
// BLog.LOGE("thumbnailUrl >>>> $thumbnailUrl ")
|
||||
// BLog.LOGE("title >>>> $title ")
|
||||
// BLog.LOGE("desc >>>> $desc ")
|
||||
// BLog.LOGE("dateTimeTxt >>>> $dateTimeTxt ")
|
||||
if (title.length > 0 && pageLink.length > 0) {
|
||||
RuliWeb().let { ru ->
|
||||
ru.title = title
|
||||
ru.link = pageLink
|
||||
ru.desc = desc
|
||||
ru.thumbnail = thumbnailUrl
|
||||
ru.dateTiem = dateTimeTxt.replace("날짜","").trim()
|
||||
if (ru.pubDate() > limitDateTime) {
|
||||
temp.add(ru.getRssData())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun doWork(): Result {
|
||||
|
||||
try {
|
||||
val testUrl2 = arrayListOf("https://bbs.ruliweb.com/best/humor_only","https://bbs.ruliweb.com/best/humor_only/now?m=humor_only&t=default&page=2")
|
||||
testUrl2.forEach { url ->
|
||||
Jsoup.connect(url)
|
||||
.userAgent(USAGT)
|
||||
.get().let { ruli ->
|
||||
BLog.LOGE("test ${testUrl2} >> ${ruli.title()}")
|
||||
ruli.getElementsByTag("tr").forEach { ruli_tr ->
|
||||
parseRuli(ruli_tr)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e:Exception){e.printStackTrace()}
|
||||
return Result.success().apply {
|
||||
// BLog.LOGE("Ruli temp >>>> ${temp.size}")
|
||||
WorkersDb.insertBulkData(temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package rasel.lunar.launcher.workers
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.work.WorkerParameters
|
||||
import org.jsoup.Jsoup
|
||||
import rasel.lunar.launcher.model.TheQoo
|
||||
import rasel.lunar.launcher.model.getHref
|
||||
import rasel.lunar.launcher.model.getRssData
|
||||
import rasel.lunar.launcher.model.getT
|
||||
import rasel.lunar.launcher.utils.BLog
|
||||
|
||||
class TheQooGetter : BaseGetter {
|
||||
companion object {
|
||||
val TAG = "TheQooGetter"
|
||||
}
|
||||
constructor(context: Context, workerParams: WorkerParameters) : super(context, workerParams) {
|
||||
}
|
||||
|
||||
fun parseTQoo(tq_tr : org.jsoup.nodes.Element) {
|
||||
// BLog.LOGE("tq_tr >>>> ${tq_tr}")
|
||||
var desc = tq_tr.getElementsByClass("cate").getT()
|
||||
var title = tq_tr.getElementsByClass("title").getT()
|
||||
var pageLink = tq_tr.getElementsByTag("a").getHref()
|
||||
var dateTime = tq_tr.getElementsByClass("time").getT()
|
||||
|
||||
// BLog.LOGE("${TAG} :::: desc >>> $desc")
|
||||
// BLog.LOGE("${TAG} :::: title >>> $title")
|
||||
// BLog.LOGE("${TAG} :::: pageLink >>> $pageLink")
|
||||
// BLog.LOGE("${TAG} :::: dateTime >>> $dateTime")
|
||||
|
||||
if (title.length > 0 && pageLink.length > 0) {
|
||||
TheQoo().let { tq ->
|
||||
tq.title = title
|
||||
tq.link = "https://theqoo.net".plus(pageLink)
|
||||
tq.dateTiem = dateTime
|
||||
tq.desc = desc
|
||||
if (tq.pubDate() > limitDateTime) {
|
||||
temp.add(tq.getRssData())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun doWork(): Result {
|
||||
|
||||
try {
|
||||
val testUrl2 = arrayListOf("https://theqoo.net/hot")
|
||||
testUrl2.forEach { url ->
|
||||
Jsoup.connect(url)
|
||||
.userAgent(USAGT)
|
||||
.get().let { ruli ->
|
||||
BLog.LOGE("test ${testUrl2} >> ${ruli.title()}")
|
||||
ruli.getElementsByTag("tr").forEach { ruli_tr ->
|
||||
parseTQoo(ruli_tr)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e:Exception){e.printStackTrace()}
|
||||
return Result.success().apply {
|
||||
// BLog.LOGE("theqoo temp >>>> ${temp.size}")
|
||||
WorkersDb.insertBulkData(temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ object WorkersDb {
|
||||
try {
|
||||
getRealm().writeBlocking {
|
||||
try {
|
||||
this.copyToRealm(it, UpdatePolicy.ERROR)
|
||||
this.copyToRealm(it, UpdatePolicy.ALL)
|
||||
} catch (e : Exception) {
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
|
||||
app:layout_constraintTop_toTopOf="@id/title"
|
||||
app:shapeAppearanceOverlay="@style/roundedImageView"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
@ -24,11 +23,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="24sp"
|
||||
android:maxLines="2"
|
||||
android:gravity="center_vertical|right"
|
||||
android:includeFontPadding="false"
|
||||
android:ellipsize="middle"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@id/circle_preview"
|
||||
app:layout_constraintRight_toRightOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/desc"
|
||||
android:layout_width="@dimen/zero"
|
||||
@ -36,17 +37,20 @@
|
||||
android:textSize="16sp"
|
||||
android:maxLines="2"
|
||||
android:includeFontPadding="false"
|
||||
android:gravity="center_vertical|right"
|
||||
android:ellipsize="middle"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"
|
||||
app:layout_constraintBottom_toTopOf="@id/date"
|
||||
app:layout_constraintLeft_toRightOf="@id/circle_preview"
|
||||
app:layout_constraintRight_toRightOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
android:layout_width="@dimen/zero"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:lines="1"
|
||||
android:gravity="center_vertical|right"
|
||||
android:includeFontPadding="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@id/circle_preview"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user