fix all lint errors

This commit is contained in:
Ivan Agosto 2024-04-06 18:03:23 -06:00
parent b6e1a979ca
commit 48738f100a
20 changed files with 112 additions and 111 deletions

View File

@ -14,14 +14,13 @@ import org.libre.agosto.p2play.ajax.Channels
import org.libre.agosto.p2play.ajax.Videos
import org.libre.agosto.p2play.models.ChannelModel
import org.libre.agosto.p2play.models.VideoModel
class ChannelActivity : AppCompatActivity() {
private lateinit var channelId: String
private lateinit var channel: ChannelModel
private var isSubcribed: Boolean = false
private val _channel = Channels()
private val _videos = Videos()
private val _actions = Actions()
private val channelService = Channels()
private val videosService = Videos()
private val actionsService = Actions()
private lateinit var recyclerView: RecyclerView
private lateinit var viewAdapter: RecyclerView.Adapter<VideosAdapter.ViewHolder>
@ -55,7 +54,7 @@ class ChannelActivity : AppCompatActivity() {
private fun getChannel() {
AsyncTask.execute {
channel = _channel.getChannelInfo(channelId)
channel = channelService.getChannelInfo(channelId)
runOnUiThread {
usernameProfile.text = channel.name
hostTxt.text = channel.host
@ -69,14 +68,14 @@ class ChannelActivity : AppCompatActivity() {
private fun subscribe() {
AsyncTask.execute {
val res = _actions.subscribe(ManagerSingleton.token.token, channel.getAccount())
val res = actionsService.subscribe(ManagerSingleton.token.token, channel.getAccount())
runOnUiThread {
if (res == 1) {
subcriptionBtn.text = getString(R.string.unSubscribeBtn)
ManagerSingleton.Toast(getString(R.string.subscribeMsg), this)
ManagerSingleton.toast(getString(R.string.subscribeMsg), this)
getSubscription()
} else {
ManagerSingleton.Toast(getString(R.string.errorMsg), this)
ManagerSingleton.toast(getString(R.string.errorMsg), this)
}
}
}
@ -84,14 +83,14 @@ class ChannelActivity : AppCompatActivity() {
private fun unSubscribe() {
AsyncTask.execute {
val res = _actions.unSubscribe(ManagerSingleton.token.token, channel.getAccount())
val res = actionsService.unSubscribe(ManagerSingleton.token.token, channel.getAccount())
runOnUiThread {
if (res == 1) {
subcriptionBtn.text = getString(R.string.subscribeBtn)
ManagerSingleton.Toast(getString(R.string.unSubscribeMsg), this)
ManagerSingleton.toast(getString(R.string.unSubscribeMsg), this)
getSubscription()
} else {
ManagerSingleton.Toast(getString(R.string.errorMsg), this)
ManagerSingleton.toast(getString(R.string.errorMsg), this)
}
}
}
@ -107,7 +106,7 @@ class ChannelActivity : AppCompatActivity() {
private fun getSubscription() {
AsyncTask.execute {
isSubcribed = _actions.getSubscription(ManagerSingleton.token.token, channel.getAccount())
isSubcribed = actionsService.getSubscription(ManagerSingleton.token.token, channel.getAccount())
runOnUiThread {
if (isSubcribed) {
subcriptionBtn.text = getText(R.string.unSubscribeBtn)
@ -120,7 +119,7 @@ class ChannelActivity : AppCompatActivity() {
private fun getVideos() {
AsyncTask.execute {
val videos = _videos.channelVideos(channel.getAccount(), 0)
val videos = videosService.channelVideos(channel.getAccount(), 0)
runOnUiThread {
initRecycler(videos)
}

View File

@ -14,7 +14,7 @@ class HostActivity : AppCompatActivity() {
lateinit var settings: SharedPreferences
lateinit var editor: SharedPreferences.Editor
val client: Auth = Auth()
val _db = Database(this)
private val db = Database(this)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -31,7 +31,7 @@ class HostActivity : AppCompatActivity() {
val lastHost = settings.getString("last_host", "")
if (host != "") {
if (lastHost != host) {
_db.logout()
db.logout()
ManagerSingleton.logout()
getKeys(host!!)
} else {
@ -45,7 +45,7 @@ class HostActivity : AppCompatActivity() {
editor.putString("last_host", host)
editor.putString("hostP2play", host)
editor.apply()
ManagerSingleton.Toast(getString(R.string.finallyMsg), this)
ManagerSingleton.toast(getString(R.string.finallyMsg), this)
ManagerSingleton.url = host
startApp()
}
@ -70,7 +70,7 @@ class HostActivity : AppCompatActivity() {
saveHost(host)
} else {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.errorMsg), this)
ManagerSingleton.toast(getString(R.string.errorMsg), this)
button.isEnabled = true
}
}

View File

@ -13,22 +13,22 @@ import kotlinx.android.synthetic.main.activity_login.*
import org.libre.agosto.p2play.ajax.Auth
class LoginActivity : AppCompatActivity() {
private val _auth = Auth()
private val auth = Auth()
lateinit var settings: SharedPreferences
lateinit var client_id: String
lateinit var client_secret: String
private lateinit var _db: Database
lateinit var clientId: String
lateinit var clientSecret: String
private lateinit var db: Database
private var optCode: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
setTitle(R.string.action_login)
_db = Database(this)
db = Database(this)
settings = PreferenceManager.getDefaultSharedPreferences(this)
client_id = settings.getString("client_id", "")!!
client_secret = settings.getString("client_secret", "")!!
clientId = settings.getString("client_id", "")!!
clientSecret = settings.getString("client_secret", "")!!
registerActionBtn.setOnClickListener { startActivity(Intent(this, RegisterActivity::class.java)) }
loginBtn.setOnClickListener { tryLogin() }
@ -44,26 +44,26 @@ class LoginActivity : AppCompatActivity() {
Looper.prepare()
}
val token = _auth.login(username, password, client_id, client_secret, optCode)
val token = auth.login(username, password, clientId, clientSecret, optCode)
// Log.d("token", token.token )
// Log.d("status", token.status.toString() )
when (token.status.toString()) {
"1" -> {
_db.newToken(token)
db.newToken(token)
ManagerSingleton.token = token
getUser()
}
"0" -> {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.loginError_msg), this)
ManagerSingleton.toast(getString(R.string.loginError_msg), this)
}
}
"-1" -> {
runOnUiThread {
loginBtn.isEnabled = true
ManagerSingleton.Toast(getString(R.string.loginFailed_msg), this)
ManagerSingleton.toast(getString(R.string.loginFailed_msg), this)
}
}
"-2" -> {
@ -95,17 +95,17 @@ class LoginActivity : AppCompatActivity() {
}
fun getUser() {
val user = _auth.me(ManagerSingleton.token.token)
val user = auth.me(ManagerSingleton.token.token)
if (user.status == 1) {
_db.newUser(user)
db.newUser(user)
ManagerSingleton.user = user
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.loginSuccess_msg), this)
ManagerSingleton.toast(getString(R.string.loginSuccess_msg), this)
finish()
}
} else {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.loginError_msg), this)
ManagerSingleton.toast(getString(R.string.loginError_msg), this)
}
}
}

View File

@ -29,9 +29,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private lateinit var viewManager: RecyclerView.LayoutManager
private val client: Videos = Videos()
private lateinit var lastItem: MenuItem
private lateinit var subItem: MenuItem
lateinit var myMenu: Menu
private val _db = Database(this)
private val db = Database(this)
var section: String = ""
var searchVal: String = ""
var pagination = 0
@ -113,7 +112,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
(viewAdapter as VideosAdapter).addData(videos)
} catch (err: Exception) {
err.printStackTrace()
ManagerSingleton.Toast(getString(R.string.errorMsg), this)
ManagerSingleton.toast(getString(R.string.errorMsg), this)
}
this.swipeContainer.isRefreshing = false
@ -141,7 +140,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
private fun getSubscriptionVideos() {
if (ManagerSingleton.user.status != 1) {
ManagerSingleton.Toast("Inicia session primero", this)
ManagerSingleton.toast("Inicia session primero", this)
startActivity(Intent(this, LoginActivity::class.java))
return
}
@ -383,17 +382,17 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
side_emailTxt?.text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName
side_imageView?.setImageResource(R.drawable.default_avatar)
side_imageView?.setOnClickListener { }
_db.logout()
db.logout()
ManagerSingleton.logout()
this.refresh()
ManagerSingleton.Toast(getString(R.string.logout_msg), this)
ManagerSingleton.toast(getString(R.string.logout_msg), this)
setSideData()
}
private fun loadMore() {
swipeContainer.isRefreshing = true
this.pagination += ManagerSingleton.videos_count
this.pagination += ManagerSingleton.videosCount
when (section) {
"local" -> this.getLocalVideos()

View File

@ -10,10 +10,10 @@ object ManagerSingleton {
var user: UserModel = UserModel()
var token: TokenModel = TokenModel()
var nfsw: Boolean = false
var videos_count: Int = 0
var videosCount: Int = 0
lateinit var settings: SharedPreferences
lateinit var db: Database
fun Toast(text: String?, context: Context) {
fun toast(text: String?, context: Context) {
android.widget.Toast.makeText(context, text, android.widget.Toast.LENGTH_SHORT).show()
}
@ -34,6 +34,6 @@ object ManagerSingleton {
}
nfsw = settings.getBoolean("show_nsfw", false)
videos_count = settings.getString("videos_count", "15")!!.toInt()
videosCount = settings.getString("videos_count", "15")!!.toInt()
}
}

View File

@ -4,17 +4,17 @@ import android.content.SharedPreferences
import android.os.AsyncTask
import android.os.Bundle
import android.os.Looper
import android.preference.PreferenceManager
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import kotlinx.android.synthetic.main.activity_register.*
import org.libre.agosto.p2play.ajax.Auth
class RegisterActivity : AppCompatActivity() {
private val _auth = Auth()
private val auth = Auth()
lateinit var settings: SharedPreferences
lateinit var client_id: String
lateinit var client_secret: String
lateinit var clientId: String
lateinit var clientSecret: String
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -22,13 +22,13 @@ class RegisterActivity : AppCompatActivity() {
setTitle(R.string.registerActionBtn)
settings = PreferenceManager.getDefaultSharedPreferences(this)
client_id = settings.getString("client_id", "")!!
client_secret = settings.getString("client_secret", "")!!
clientId = settings.getString("client_id", "")!!
clientSecret = settings.getString("client_secret", "")!!
registerBtn.setOnClickListener { registerUser() }
}
fun registerUser() {
private fun registerUser() {
registerBtn.isEnabled = false
val username = userText2.text.toString()
val password = passwordText2.text.toString()
@ -38,16 +38,16 @@ class RegisterActivity : AppCompatActivity() {
Looper.prepare()
}
val res = _auth.register(username, password, email)
val res = auth.register(username, password, email)
Log.d("Res register", res.toString())
runOnUiThread {
when (res) {
1 -> {
ManagerSingleton.Toast(getString(R.string.registerSuccess_msg), this)
ManagerSingleton.toast(getString(R.string.registerSuccess_msg), this)
finish()
}
0 -> ManagerSingleton.Toast(getString(R.string.registerFailed_msg), this)
-1 -> ManagerSingleton.Toast(getString(R.string.registerError_msg), this)
0 -> ManagerSingleton.toast(getString(R.string.registerFailed_msg), this)
-1 -> ManagerSingleton.toast(getString(R.string.registerError_msg), this)
}
registerBtn.isEnabled = true
}

View File

@ -37,7 +37,7 @@ import org.libre.agosto.p2play.models.VideoModel
class ReproductorActivity : AppCompatActivity() {
private val clientVideo: Videos = Videos()
lateinit var video: VideoModel
private val _actions: Actions = Actions()
private val actions: Actions = Actions()
private val client: Comments = Comments()
private val videos: Videos = Videos()
@ -150,10 +150,10 @@ class ReproductorActivity : AppCompatActivity() {
if (Looper.myLooper() == null) {
Looper.prepare()
}
val res = this._actions.subscribe(ManagerSingleton.token.token, video.getChannel())
val res = this.actions.subscribe(ManagerSingleton.token.token, video.getChannel())
if (res == 1) {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.subscribeMsg), this)
ManagerSingleton.toast(getString(R.string.subscribeMsg), this)
this.changeSubscribeBtn(true)
}
}
@ -165,10 +165,10 @@ class ReproductorActivity : AppCompatActivity() {
if (Looper.myLooper() == null) {
Looper.prepare()
}
val res = this._actions.unSubscribe(ManagerSingleton.token.token, video.getChannel())
val res = this.actions.unSubscribe(ManagerSingleton.token.token, video.getChannel())
if (res == 1) {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.unSubscribeMsg), this)
ManagerSingleton.toast(getString(R.string.unSubscribeMsg), this)
this.changeSubscribeBtn(false)
}
}
@ -180,10 +180,10 @@ class ReproductorActivity : AppCompatActivity() {
if (Looper.myLooper() == null) {
Looper.prepare()
}
val res = this._actions.rate(ManagerSingleton.token.token, this.video.id, rate)
val res = this.actions.rate(ManagerSingleton.token.token, this.video.id, rate)
if (res == 1) {
runOnUiThread {
ManagerSingleton.Toast(getString(R.string.rateMsg), this)
ManagerSingleton.toast(getString(R.string.rateMsg), this)
if (rate == "like") {
textViewLike.setTextColor(ContextCompat.getColor(this, R.color.colorLike))
textViewDislike.setTextColor(ContextCompat.getColor(this, R.color.primary_dark_material_light))
@ -201,7 +201,7 @@ class ReproductorActivity : AppCompatActivity() {
if (Looper.myLooper() == null) {
Looper.prepare()
}
val rate = this._actions.getRate(ManagerSingleton.token.token, this.video.id)
val rate = this.actions.getRate(ManagerSingleton.token.token, this.video.id)
runOnUiThread {
when (rate) {
"like" -> {
@ -227,7 +227,7 @@ class ReproductorActivity : AppCompatActivity() {
if (Looper.myLooper() == null) {
Looper.prepare()
}
val isSubscribed = this._actions.getSubscription(ManagerSingleton.token.token, account)
val isSubscribed = this.actions.getSubscription(ManagerSingleton.token.token, account)
runOnUiThread {
this.changeSubscribeBtn(isSubscribed)
}
@ -272,7 +272,7 @@ class ReproductorActivity : AppCompatActivity() {
private fun makeComment() {
if (commentaryText.text.toString() == "") {
ManagerSingleton.Toast(getString(R.string.emptyCommentaryMsg), this)
ManagerSingleton.toast(getString(R.string.emptyCommentaryMsg), this)
return
}
val text = commentaryText.text.toString()
@ -280,11 +280,11 @@ class ReproductorActivity : AppCompatActivity() {
val res = this.client.makeCommentary(ManagerSingleton.token.token, this.video.id, text)
runOnUiThread {
if (res) {
ManagerSingleton.Toast(getString(R.string.makedCommentaryMsg), this)
ManagerSingleton.toast(getString(R.string.makedCommentaryMsg), this)
commentaryText.text?.clear()
this.getComments()
} else {
ManagerSingleton.Toast(getString(R.string.errorCommentaryMsg), this)
ManagerSingleton.toast(getString(R.string.errorCommentaryMsg), this)
}
}
}
@ -348,13 +348,13 @@ class ReproductorActivity : AppCompatActivity() {
private fun reportVideo(reason: String) {
AsyncTask.execute {
val res = _actions.reportVideo(video.id, reason, ManagerSingleton.token.token)
val res = actions.reportVideo(video.id, reason, ManagerSingleton.token.token)
runOnUiThread {
if (res) {
ManagerSingleton.Toast(getText(R.string.reportDialogMsg).toString(), this)
ManagerSingleton.toast(getText(R.string.reportDialogMsg).toString(), this)
} else {
ManagerSingleton.Toast(getText(R.string.errorMsg).toString(), this)
ManagerSingleton.toast(getText(R.string.errorMsg).toString(), this)
}
}
}
@ -404,7 +404,7 @@ class ReproductorActivity : AppCompatActivity() {
override fun getDefaultVideoPoster(): Bitmap? {
AsyncTask.execute {
this@ReproductorActivity._actions.watchVideo(this@ReproductorActivity.video.id, ManagerSingleton.token.token)
this@ReproductorActivity.actions.watchVideo(this@ReproductorActivity.video.id, ManagerSingleton.token.token)
}
return if (mCustomView == null) {
@ -447,12 +447,12 @@ class ReproductorActivity : AppCompatActivity() {
this.mOriginalSystemUiVisibility = this@ReproductorActivity.window.decorView.systemUiVisibility
this.mOriginalOrientation = this@ReproductorActivity.requestedOrientation
this.mCustomViewCallback = paramCustomViewCallback
val match_parent = WindowManager.LayoutParams.MATCH_PARENT
val matchParent = WindowManager.LayoutParams.MATCH_PARENT
this@ReproductorActivity.nonFullScreen.visibility = View.GONE
this@ReproductorActivity.fullScreen.visibility = View.VISIBLE
this@ReproductorActivity.fullScreen.addView(paramView, FrameLayout.LayoutParams(match_parent, match_parent))
this@ReproductorActivity.fullScreen.addView(paramView, FrameLayout.LayoutParams(matchParent, matchParent))
setFullscreen(this@ReproductorActivity.window)

View File

@ -32,7 +32,7 @@ class SettingsActivity : AppCompatPreferenceActivity() {
override fun onBackPressed() {
super.onBackPressed()
ManagerSingleton.Toast(getString(R.string.pref_message_exit), this)
ManagerSingleton.toast(getString(R.string.pref_message_exit), this)
}
/**

View File

@ -15,7 +15,7 @@ import java.lang.Exception
class SplashActivity : AppCompatActivity() {
lateinit var settings: SharedPreferences
val client: Auth = Auth()
val _db = Database(this)
val db = Database(this)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -23,7 +23,7 @@ class SplashActivity : AppCompatActivity() {
settings = PreferenceManager.getDefaultSharedPreferences(this)
ManagerSingleton.settings = settings
ManagerSingleton.db = _db
ManagerSingleton.db = db
ManagerSingleton.reloadSettings()
@ -48,8 +48,8 @@ class SplashActivity : AppCompatActivity() {
private fun checkUser() {
Log.d("was", "Checked")
try {
val token = _db.getToken()
val user = _db.getUser()
val token = db.getToken()
val user = db.getUser()
AsyncTask.execute {
if (Looper.myLooper() == null) {
Looper.prepare()
@ -63,7 +63,7 @@ class SplashActivity : AppCompatActivity() {
when (token.status.toString()) {
"1" -> {
_db.newToken(newToken)
db.newToken(newToken)
ManagerSingleton.token = newToken
ManagerSingleton.user = user
}

View File

@ -9,8 +9,8 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.view_video.view.userImg
import org.libre.agosto.p2play.*
import org.libre.agosto.p2play.ManagerSingleton
import org.libre.agosto.p2play.R
import org.libre.agosto.p2play.models.CommentaryModel
@Suppress("DEPRECATION")

View File

@ -9,7 +9,10 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import org.libre.agosto.p2play.*
import org.libre.agosto.p2play.ChannelActivity
import org.libre.agosto.p2play.ManagerSingleton
import org.libre.agosto.p2play.R
import org.libre.agosto.p2play.ReproductorActivity
import org.libre.agosto.p2play.helpers.mapSeconds
import org.libre.agosto.p2play.models.VideoModel
import java.io.Serializable

View File

@ -6,7 +6,7 @@ import java.io.InputStreamReader
class Actions : Client() {
fun subscribe(token: String, account: String): Int {
val con = this._newCon("users/me/subscriptions", "POST", token)
val con = this.newCon("users/me/subscriptions", "POST", token)
val params: String = "uri=$account"
con.outputStream.write(params.toByteArray())
var response = 0
@ -25,7 +25,7 @@ class Actions : Client() {
}
fun unSubscribe(token: String, account: String): Int {
val con = this._newCon("users/me/subscriptions/$account", "DELETE", token)
val con = this.newCon("users/me/subscriptions/$account", "DELETE", token)
var response = 0
try {
@ -42,7 +42,7 @@ class Actions : Client() {
}
fun getSubscription(token: String, account: String): Boolean {
val con = this._newCon("users/me/subscriptions/exist?uris=$account", "GET", token)
val con = this.newCon("users/me/subscriptions/exist?uris=$account", "GET", token)
var isSubscribed = false
try {
@ -73,7 +73,7 @@ class Actions : Client() {
}
fun rate(token: String, id_video: Int, rate: String): Int {
val con = this._newCon("videos/$id_video/rate", "PUT", token)
val con = this.newCon("videos/$id_video/rate", "PUT", token)
val params = "rating=$rate"
con.outputStream.write(params.toByteArray())
var response = 0
@ -92,7 +92,7 @@ class Actions : Client() {
}
fun getRate(token: String, id_video: Int): String {
val con = this._newCon("users/me/videos/$id_video/rating", "GET", token)
val con = this.newCon("users/me/videos/$id_video/rating", "GET", token)
var rating = "none"
try {
@ -123,7 +123,7 @@ class Actions : Client() {
}
fun reportVideo(videoId: Int, reason: String, token: String): Boolean {
val con = this._newCon("videos/$videoId/abuse", "POST", token)
val con = this.newCon("videos/$videoId/abuse", "POST", token)
val params = "reason=$reason"
con.outputStream.write(params.toByteArray())
@ -141,7 +141,7 @@ class Actions : Client() {
}
fun watchVideo(videoId: Int, token: String): Boolean {
val con = this._newCon("videos/$videoId/watching", "PUT", token)
val con = this.newCon("videos/$videoId/watching", "PUT", token)
val params = "currentTime=1"
con.outputStream.write(params.toByteArray())

View File

@ -12,7 +12,7 @@ class Auth : Client() {
private val stockParams = "grant_type=password"
fun login(username: String, password: String, client_id: String, client_secret: String, twoFactorCode: String? = null): TokenModel {
val con = this._newCon("users/token", "POST")
val con = this.newCon("users/token", "POST")
val params = "$stockParams&username=$username&password=$password&client_id=$client_id&client_secret=$client_secret"
if (twoFactorCode !== null) {
@ -60,7 +60,7 @@ class Auth : Client() {
}
fun register(username: String, password: String, email: String): Int {
val con = this._newCon("users/register", "POST")
val con = this.newCon("users/register", "POST")
val params = "username=$username&password=$password&email=$email"
con.outputStream.write(params.toByteArray())
@ -80,7 +80,7 @@ class Auth : Client() {
}
fun refreshToken(token: TokenModel, client_id: String, client_secret: String): TokenModel {
val con = this._newCon("users/token", "POST", token.token)
val con = this.newCon("users/token", "POST", token.token)
val params = "refresh_token=${token.refresh_token}&response_type=code&grant_type=refresh_token&client_id=$client_id&client_secret=$client_secret"
con.outputStream.write(params.toByteArray())
// val token = TokenModel()
@ -116,7 +116,7 @@ class Auth : Client() {
}
fun me(token: String): UserModel {
val con = this._newCon("users/me", "GET", token)
val con = this.newCon("users/me", "GET", token)
val user = UserModel()
try {

View File

@ -15,7 +15,7 @@ class Channels : Client() {
}
fun getChannelInfo(account: String): ChannelModel {
val con = this._newCon("video-channels/$account", "GET")
val con = this.newCon("video-channels/$account", "GET")
var channel = ChannelModel()
try {
if (con.responseCode == 200) {

View File

@ -9,7 +9,7 @@ import java.net.HttpURLConnection
import java.net.URL
open class Client {
protected fun _newCon(uri: String, method: String, token: String = ""): HttpURLConnection {
protected fun newCon(uri: String, method: String, token: String = ""): HttpURLConnection {
val url = URL("https://${ManagerSingleton.url}/api/v1/$uri")
val con = url.openConnection() as HttpURLConnection
@ -34,7 +34,7 @@ open class Client {
}
fun getKeys(): HostModel {
val con = this._newCon("oauth-clients/local", "GET")
val con = this.newCon("oauth-clients/local", "GET")
val keys = HostModel("", "")
try {
if (con.responseCode == 200) {

View File

@ -31,7 +31,7 @@ class Comments : Client() {
fun getCommentaries(videoId: Int): ArrayList<CommentaryModel> {
var commentaries = arrayListOf<CommentaryModel>()
val con = this._newCon("videos/$videoId/comment-threads", "GET")
val con = this.newCon("videos/$videoId/comment-threads", "GET")
try {
if (con.responseCode == 200) {
@ -48,7 +48,7 @@ class Comments : Client() {
}
fun makeCommentary(token: String, videoId: Int, text: String): Boolean {
val con = this._newCon("videos/$videoId/comment-threads", "POST", token)
val con = this.newCon("videos/$videoId/comment-threads", "POST", token)
val params = "text=$text"
con.outputStream.write(params.toByteArray())

View File

@ -31,10 +31,10 @@ class Videos : Client() {
private fun getVideos(start: Int, sort: String = "-publishedAt", isLocal: Boolean = false): ArrayList<VideoModel> {
val nsfw = ManagerSingleton.nfsw
val count = ManagerSingleton.videos_count
val count = ManagerSingleton.videosCount
var params = "start=$start&count=$count&sort=$sort&nsfw=$nsfw&isLocal=$isLocal"
val con = this._newCon("videos?$params", "GET")
val con = this.newCon("videos?$params", "GET")
var videos = arrayListOf<VideoModel>()
try {
if (con.responseCode == 200) {
@ -67,9 +67,9 @@ class Videos : Client() {
}
fun myVideos(token: String, start: Int = 0): ArrayList<VideoModel> {
val count = ManagerSingleton.videos_count
val count = ManagerSingleton.videosCount
val params = "start=$start&count=$count"
val con = this._newCon("users/me/videos?$params", "GET", token)
val con = this.newCon("users/me/videos?$params", "GET", token)
var videos = arrayListOf<VideoModel>()
try {
if (con.responseCode == 200) {
@ -87,9 +87,9 @@ class Videos : Client() {
}
fun videoSubscriptions(token: String, start: Int = 0): ArrayList<VideoModel> {
val count = ManagerSingleton.videos_count
val count = ManagerSingleton.videosCount
val params = "start=$start&count=$count"
val con = this._newCon("users/me/subscriptions/videos?$params", "GET", token)
val con = this.newCon("users/me/subscriptions/videos?$params", "GET", token)
var videos = arrayListOf<VideoModel>()
try {
if (con.responseCode == 200) {
@ -111,9 +111,9 @@ class Videos : Client() {
}
fun videoHistory(token: String, start: Int = 0): ArrayList<VideoModel> {
val count = ManagerSingleton.videos_count
val count = ManagerSingleton.videosCount
val params = "start=$start&count=$count"
val con = this._newCon("users/me/history/videos?$params", "GET", token)
val con = this.newCon("users/me/history/videos?$params", "GET", token)
var videos = arrayListOf<VideoModel>()
try {
if (con.responseCode == 200) {
@ -131,10 +131,10 @@ class Videos : Client() {
}
fun search(text: String, start: Int = 0): ArrayList<VideoModel> {
val count = ManagerSingleton.videos_count
val count = ManagerSingleton.videosCount
val nsfw = ManagerSingleton.nfsw
val params = "search=$text&start=$start&count=$count&nsfw=$nsfw"
val con = this._newCon("search/videos?$params", "GET")
val con = this.newCon("search/videos?$params", "GET")
var videos = arrayListOf<VideoModel>()
try {
if (con.responseCode == 200) {
@ -151,7 +151,7 @@ class Videos : Client() {
}
fun fullDescription(videoId: Int): String {
val con = this._newCon("videos/$videoId/description", "GET")
val con = this.newCon("videos/$videoId/description", "GET")
var description = ""
try {
if (con.responseCode == 200) {
@ -178,9 +178,9 @@ class Videos : Client() {
}
fun channelVideos(account: String, start: Int): ArrayList<VideoModel> {
val count = ManagerSingleton.videos_count
val count = ManagerSingleton.videosCount
val params = "start=$start&count=$count"
val con = this._newCon("video-channels/$account/videos?$params", "GET")
val con = this.newCon("video-channels/$account/videos?$params", "GET")
var videos = arrayListOf<VideoModel>()
try {
if (con.responseCode == 200) {
@ -202,7 +202,7 @@ class Videos : Client() {
}
fun getVideo(uuid: String): VideoModel {
val con = this._newCon("videos/$uuid", "GET")
val con = this.newCon("videos/$uuid", "GET")
val video = VideoModel()
try {
if (con.responseCode == 200) {

View File

@ -1,6 +1,6 @@
package org.libre.agosto.p2play
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Test
/**