Archived
Fixed a bug that would make certain recycled cells carry the PSA cell's onClickListener
This commit is contained in:
@@ -19,7 +19,8 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
|
||||
private var colour = 0
|
||||
private var colorCheck = ""
|
||||
|
||||
class CardViewHolder (view: View) : RecyclerView.ViewHolder(view) {
|
||||
class CardViewHolder (view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {
|
||||
|
||||
var mImageView: ImageView = itemView.findViewById(R.id.iconView)
|
||||
var mGroup: TextView = itemView.findViewById(R.id.group)
|
||||
var mDate: TextView = itemView.findViewById(R.id.date)
|
||||
@@ -28,6 +29,17 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
|
||||
var mRoom: TextView = itemView.findViewById(R.id.room)
|
||||
var mAdditional: TextView = itemView.findViewById(R.id.additional)
|
||||
var mCard = itemView.findViewById<MaterialCardView>(R.id.planCard)
|
||||
init { view.setOnClickListener(this) }
|
||||
override fun onClick(v: View?) {
|
||||
if (mDate.text.toString().length > 7 && mDate.text.toString().substring(3, 7) == "http") {
|
||||
try {
|
||||
CustomTabsIntent.Builder().build().launchUrl(mCard.context,
|
||||
Uri.parse(mDate.text.toString().substring(3)))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(mCard.context, mCard.context.getString(R.string.chromeCompatibleNotFound), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CardViewHolder {
|
||||
@@ -49,20 +61,12 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
|
||||
|
||||
if (currentItem.date.isNotEmpty() && currentItem.date.substring(0, 3) == "psa") {
|
||||
psa = true
|
||||
holder.mDate.text = ""
|
||||
holder.mDate.visibility = View.GONE
|
||||
holder.mDate.text = currentItem.date
|
||||
holder.mImageView.setImageResource(R.drawable.ic_idea)
|
||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mImageView.context, R.color.colorAccent))
|
||||
if (currentItem.date.substring(3, 7) == "http") {
|
||||
holder.mCard.setOnClickListener {
|
||||
try {
|
||||
CustomTabsIntent.Builder().build().launchUrl(holder.mCard.context,
|
||||
Uri.parse(currentItem.date.substring(3)))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(holder.mCard.context, holder.mCard.context.getString(R.string.chromeCompatibleNotFound), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
holder.mDate.visibility = View.VISIBLE
|
||||
holder.mDate.text = currentItem.date
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,11 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
private val edit = prefs.edit()
|
||||
private var currentTime = ""
|
||||
private var currentFoodTime = ""
|
||||
private val substUrl = "https://djd4rkn355.github.io/subst_test.html"
|
||||
private val substUrl = "https://djd4rkn355.github.io/subst.html"
|
||||
private val foodUrl = "https://djd4rkn355.github.io/food.html"
|
||||
|
||||
override fun doInBackground(vararg params: Void?): Void? {
|
||||
// try {
|
||||
try {
|
||||
if (menu) {
|
||||
val docFood = Jsoup.connect(foodUrl).get()
|
||||
currentFoodTime = docFood.select("h1")[0].text()
|
||||
@@ -221,12 +221,12 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
Snackbar.make(snackBarView, snackText, Snackbar.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
// } catch (e: Exception) {
|
||||
// mView?.let { v: View ->
|
||||
// val snackBarView = v.findViewById<View>(R.id.coordination)
|
||||
// Snackbar.make(snackBarView, mContext.getString(R.string.noInternet), Snackbar.LENGTH_LONG).setBackgroundTint(ContextCompat.getColor(mContext, R.color.colorError)).show()
|
||||
// }
|
||||
// }
|
||||
} catch (e: Exception) {
|
||||
mView?.let { v: View ->
|
||||
val snackBarView = v.findViewById<View>(R.id.coordination)
|
||||
Snackbar.make(snackBarView, mContext.getString(R.string.noInternet), Snackbar.LENGTH_LONG).setBackgroundTint(ContextCompat.getColor(mContext, R.color.colorError)).show()
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.preference.PreferenceManager
|
||||
import android.view.*
|
||||
import android.widget.TextView
|
||||
@@ -22,7 +21,6 @@ import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.jaredrummler.android.device.DeviceName
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
@@ -5,8 +5,6 @@ import android.app.job.JobService
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.preference.PreferenceManager
|
||||
import org.jsoup.Jsoup
|
||||
import java.net.URL
|
||||
|
||||
class NotificationService : JobService() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user