Fix lint errors automated
This commit is contained in:
parent
96d8ae19c6
commit
b6e1a979ca
|
@ -0,0 +1,2 @@
|
|||
[*.{kt,kts}]
|
||||
ktlint_code_style = intellij_idea
|
|
@ -1,6 +1,5 @@
|
|||
package org.libre.agosto.p2play
|
||||
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import kotlinx.android.synthetic.main.activity_about.*
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.libre.agosto.p2play
|
||||
|
||||
import androidx.appcompat.app.ActionBar
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceActivity
|
||||
|
@ -8,6 +7,7 @@ import android.view.MenuInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.app.ActionBar
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.libre.agosto.p2play
|
||||
|
||||
import android.os.AsyncTask
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.View
|
||||
import com.squareup.picasso.Picasso
|
||||
import kotlinx.android.synthetic.main.activity_channel.*
|
||||
import org.libre.agosto.p2play.adapters.VideosAdapter
|
||||
|
@ -60,11 +60,12 @@ class ChannelActivity : AppCompatActivity() {
|
|||
usernameProfile.text = channel.name
|
||||
hostTxt.text = channel.host
|
||||
subcriptionsTxt.text = channel.followers.toString()
|
||||
if(channel.channelImg != "")
|
||||
if (channel.channelImg != "") {
|
||||
Picasso.get().load("https://${ManagerSingleton.url}${channel.channelImg}").into(channelImg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun subscribe() {
|
||||
AsyncTask.execute {
|
||||
|
@ -74,8 +75,7 @@ class ChannelActivity : AppCompatActivity() {
|
|||
subcriptionBtn.text = getString(R.string.unSubscribeBtn)
|
||||
ManagerSingleton.Toast(getString(R.string.subscribeMsg), this)
|
||||
getSubscription()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ManagerSingleton.Toast(getString(R.string.errorMsg), this)
|
||||
}
|
||||
}
|
||||
|
@ -90,8 +90,7 @@ class ChannelActivity : AppCompatActivity() {
|
|||
subcriptionBtn.text = getString(R.string.subscribeBtn)
|
||||
ManagerSingleton.Toast(getString(R.string.unSubscribeMsg), this)
|
||||
getSubscription()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ManagerSingleton.Toast(getString(R.string.errorMsg), this)
|
||||
}
|
||||
}
|
||||
|
@ -99,11 +98,12 @@ class ChannelActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun subscribeAction() {
|
||||
if(isSubcribed)
|
||||
if (isSubcribed) {
|
||||
unSubscribe()
|
||||
else
|
||||
} else {
|
||||
subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSubscription() {
|
||||
AsyncTask.execute {
|
||||
|
@ -111,8 +111,7 @@ class ChannelActivity : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
if (isSubcribed) {
|
||||
subcriptionBtn.text = getText(R.string.unSubscribeBtn)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
subcriptionBtn.text = getText(R.string.subscribeBtn)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,6 @@ class Database(context:Context): SQLiteOpenHelper(context,"p2play",null,1) {
|
|||
cursor.close()
|
||||
|
||||
return token
|
||||
|
||||
} catch (e: SQLiteException) {
|
||||
db?.execSQL(dbTokens)
|
||||
} catch (e: Exception) {
|
||||
|
@ -103,7 +102,6 @@ class Database(context:Context): SQLiteOpenHelper(context,"p2play",null,1) {
|
|||
cursor.close()
|
||||
|
||||
return user
|
||||
|
||||
} catch (e: SQLiteException) {
|
||||
db?.execSQL(dbTokens)
|
||||
} catch (e: Exception) {
|
||||
|
@ -126,5 +124,4 @@ class Database(context:Context): SQLiteOpenHelper(context,"p2play",null,1) {
|
|||
closeUsers()
|
||||
closeTokens()
|
||||
}
|
||||
|
||||
}
|
|
@ -3,9 +3,9 @@ package org.libre.agosto.p2play
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.AsyncTask
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.preference.PreferenceManager
|
||||
import kotlinx.android.synthetic.main.activity_host.*
|
||||
import org.libre.agosto.p2play.ajax.Auth
|
||||
|
@ -58,8 +58,9 @@ class HostActivity : AppCompatActivity() {
|
|||
host = host.replace("/", "")
|
||||
ManagerSingleton.url = host
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper()==null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
val keys = client.getKeys()
|
||||
if (keys.client_id != "") {
|
||||
|
@ -67,8 +68,7 @@ class HostActivity : AppCompatActivity() {
|
|||
editor.putString("client_secret", keys.client_secret)
|
||||
editor.apply()
|
||||
saveHost(host)
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
runOnUiThread {
|
||||
ManagerSingleton.Toast(getString(R.string.errorMsg), this)
|
||||
button.isEnabled = true
|
||||
|
|
|
@ -3,11 +3,11 @@ package org.libre.agosto.p2play
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.AsyncTask
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.widget.EditText
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.preference.PreferenceManager
|
||||
import kotlinx.android.synthetic.main.activity_login.*
|
||||
import org.libre.agosto.p2play.ajax.Auth
|
||||
|
@ -35,13 +35,14 @@ class LoginActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
fun tryLogin() {
|
||||
loginBtn.isEnabled = false;
|
||||
loginBtn.isEnabled = false
|
||||
val username = userText.text.toString()
|
||||
val password = passwordText.text.toString()
|
||||
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper()==null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
val token = _auth.login(username, password, client_id, client_secret, optCode)
|
||||
|
||||
|
@ -90,7 +91,6 @@ class LoginActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,8 +103,7 @@ class LoginActivity : AppCompatActivity() {
|
|||
ManagerSingleton.Toast(getString(R.string.loginSuccess_msg), this)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
runOnUiThread {
|
||||
ManagerSingleton.Toast(getString(R.string.loginError_msg), this)
|
||||
}
|
||||
|
|
|
@ -2,13 +2,10 @@ package org.libre.agosto.p2play
|
|||
|
||||
import android.content.Intent
|
||||
import android.os.AsyncTask
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.WindowManager
|
||||
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.SearchView
|
||||
|
@ -39,7 +36,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
var searchVal: String = ""
|
||||
var pagination = 0
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
@ -134,13 +130,14 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
"sub" -> this.getSubscriptionVideos()
|
||||
"search" -> this.searchVideos()
|
||||
"my_videos" -> {
|
||||
if(ManagerSingleton.token.token != "")
|
||||
if (ManagerSingleton.token.token != "") {
|
||||
this.getMyVideos()
|
||||
else
|
||||
} else {
|
||||
this.getLastVideos()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSubscriptionVideos() {
|
||||
if (ManagerSingleton.user.status != 1) {
|
||||
|
@ -253,13 +250,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
override fun onBackPressed() {
|
||||
if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer_layout.closeDrawer(GravityCompat.START)
|
||||
}
|
||||
else if(!section.equals("trending")) {
|
||||
} else if (!section.equals("trending")) {
|
||||
// Hot fix
|
||||
pagination = 0
|
||||
this.getTrengindVideos()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
@ -285,10 +280,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
myMenu = menu
|
||||
setSideData()
|
||||
return true
|
||||
|
@ -374,7 +367,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
if (::myMenu.isInitialized) {
|
||||
myMenu.findItem(R.id.action_login).isVisible = false
|
||||
myMenu.findItem(R.id.action_logout).isVisible = true
|
||||
|
||||
}
|
||||
} else {
|
||||
nav_view.menu.findItem(R.id.ml).isVisible = false
|
||||
|
@ -411,11 +403,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
"sub" -> this.getSubscriptionVideos()
|
||||
"search" -> this.searchVideos()
|
||||
"my_videos" -> {
|
||||
if(ManagerSingleton.token.token != "")
|
||||
if (ManagerSingleton.token.token != "") {
|
||||
this.getMyVideos()
|
||||
else
|
||||
} else {
|
||||
this.getLastVideos()
|
||||
}
|
||||
}
|
||||
"liked" -> this.getMostLiked()
|
||||
}
|
||||
}
|
||||
|
@ -431,5 +424,4 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package org.libre.agosto.p2play
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Handler
|
||||
import org.libre.agosto.p2play.models.TokenModel
|
||||
import org.libre.agosto.p2play.models.UserModel
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package org.libre.agosto.p2play
|
|||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.AsyncTask
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import kotlinx.android.synthetic.main.activity_register.*
|
||||
import org.libre.agosto.p2play.ajax.Auth
|
||||
|
||||
|
@ -34,8 +34,9 @@ class RegisterActivity : AppCompatActivity() {
|
|||
val password = passwordText2.text.toString()
|
||||
val email = emailText.text.toString()
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper()==null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
val res = _auth.register(username, password, email)
|
||||
Log.d("Res register", res.toString())
|
||||
|
|
|
@ -5,17 +5,16 @@ import android.content.Intent
|
|||
import android.content.pm.ActivityInfo
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.media.Image
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.webkit.WebChromeClient
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.media3.common.MediaItem
|
||||
|
@ -83,11 +82,11 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
hostTxt.text = this.video.userHost
|
||||
|
||||
// Check if user had profile image
|
||||
if (this.video.userImageUrl != "")
|
||||
if (this.video.userImageUrl != "") {
|
||||
Picasso.get().load("https://" + ManagerSingleton.url + this.video.userImageUrl).into(userImg)
|
||||
}
|
||||
// Load the video
|
||||
videoView.loadUrl("https://" + ManagerSingleton.url + this.video.embedUrl)
|
||||
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
}
|
||||
|
@ -113,7 +112,6 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
startActivity(intent)
|
||||
}
|
||||
|
||||
|
||||
AsyncTask.execute {
|
||||
val video = this.clientVideo.getVideo(this.video.uuid)
|
||||
// TODO: Make this configurable
|
||||
|
@ -149,8 +147,9 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
|
||||
private fun subscribe() {
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper() == null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val res = this._actions.subscribe(ManagerSingleton.token.token, video.getChannel())
|
||||
if (res == 1) {
|
||||
runOnUiThread {
|
||||
|
@ -163,8 +162,9 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
|
||||
private fun unSubscribe() {
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper() == null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val res = this._actions.unSubscribe(ManagerSingleton.token.token, video.getChannel())
|
||||
if (res == 1) {
|
||||
runOnUiThread {
|
||||
|
@ -177,8 +177,9 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
|
||||
private fun rate(rate: String) {
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper() == null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val res = this._actions.rate(ManagerSingleton.token.token, this.video.id, rate)
|
||||
if (res == 1) {
|
||||
runOnUiThread {
|
||||
|
@ -197,8 +198,9 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
|
||||
private fun getRate() {
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper() == null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val rate = this._actions.getRate(ManagerSingleton.token.token, this.video.id)
|
||||
runOnUiThread {
|
||||
when (rate) {
|
||||
|
@ -222,8 +224,9 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
private fun getSubscription() {
|
||||
val account = this.video.nameChannel + "@" + this.video.userHost
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper() == null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
val isSubscribed = this._actions.getSubscription(ManagerSingleton.token.token, account)
|
||||
runOnUiThread {
|
||||
this.changeSubscribeBtn(isSubscribed)
|
||||
|
@ -350,8 +353,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
if (res) {
|
||||
ManagerSingleton.Toast(getText(R.string.reportDialogMsg).toString(), this)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ManagerSingleton.Toast(getText(R.string.errorMsg).toString(), this)
|
||||
}
|
||||
}
|
||||
|
@ -373,8 +375,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
|
||||
|
||||
isFullscreen = false
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
val matchParent = WindowManager.LayoutParams.MATCH_PARENT
|
||||
|
||||
nonFullScreen.visibility = View.GONE
|
||||
|
@ -408,7 +409,9 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
|
||||
return if (mCustomView == null) {
|
||||
null
|
||||
} else BitmapFactory.decodeResource(this@ReproductorActivity.resources, 2130837573)
|
||||
} else {
|
||||
BitmapFactory.decodeResource(this@ReproductorActivity.resources, 2130837573)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHideCustomView() {
|
||||
|
@ -429,8 +432,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
attrs.flags = attrs.flags and WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON.inv()
|
||||
window.attributes = attrs
|
||||
this@ReproductorActivity.window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
@ -455,8 +457,7 @@ class ReproductorActivity : AppCompatActivity() {
|
|||
setFullscreen(this@ReproductorActivity.window)
|
||||
|
||||
this@ReproductorActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import android.annotation.TargetApi
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.media.RingtoneManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.preference.ListPreference
|
||||
|
@ -13,9 +11,6 @@ import android.preference.Preference
|
|||
import android.preference.PreferenceActivity
|
||||
import android.preference.PreferenceFragment
|
||||
import android.preference.PreferenceManager
|
||||
import android.preference.RingtonePreference
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
|
||||
/**
|
||||
|
@ -67,8 +62,8 @@ class SettingsActivity : AppCompatPreferenceActivity() {
|
|||
* Make sure to deny any unknown fragments here.
|
||||
*/
|
||||
override fun isValidFragment(fragmentName: String): Boolean {
|
||||
return PreferenceFragment::class.java.name == fragmentName
|
||||
|| GeneralPreferenceFragment::class.java.name == fragmentName
|
||||
return PreferenceFragment::class.java.name == fragmentName ||
|
||||
GeneralPreferenceFragment::class.java.name == fragmentName
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,11 +111,12 @@ class SettingsActivity : AppCompatPreferenceActivity() {
|
|||
|
||||
// Set the summary to reflect the new value.
|
||||
preference.setSummary(
|
||||
if (index >= 0)
|
||||
if (index >= 0) {
|
||||
listPreference.entries[index]
|
||||
else
|
||||
null)
|
||||
|
||||
} else {
|
||||
null
|
||||
},
|
||||
)
|
||||
} else {
|
||||
// For all other preferences, set the summary to the value's
|
||||
// simple string representation.
|
||||
|
@ -152,10 +148,12 @@ class SettingsActivity : AppCompatPreferenceActivity() {
|
|||
|
||||
// Trigger the listener immediately with the preference's
|
||||
// current value.
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(
|
||||
preference,
|
||||
PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.context)
|
||||
.getString(preference.key, ""))
|
||||
.getString(preference.key, ""),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ package org.libre.agosto.p2play
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.AsyncTask
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.preference.PreferenceManager
|
||||
import org.libre.agosto.p2play.ajax.Auth
|
||||
import java.lang.Exception
|
||||
|
||||
|
@ -51,8 +51,9 @@ class SplashActivity : AppCompatActivity() {
|
|||
val token = _db.getToken()
|
||||
val user = _db.getUser()
|
||||
AsyncTask.execute {
|
||||
if (Looper.myLooper() == null)
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
if (token.status == 1 && user.status == 1) {
|
||||
val clientId = settings.getString("client_id", "")!!
|
||||
|
@ -72,11 +73,9 @@ class SplashActivity : AppCompatActivity() {
|
|||
ManagerSingleton.logout()
|
||||
}
|
||||
|
||||
|
||||
startApp()
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
Handler().postDelayed({
|
||||
startApp()
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package org.libre.agosto.p2play.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.text.Html
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
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.*
|
||||
|
@ -37,10 +36,11 @@ class CommentariesAdapter(private val myDataset: ArrayList<CommentaryModel>) :
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Create new views (invoked by the layout manager)
|
||||
override fun onCreateViewHolder(parent: ViewGroup,
|
||||
viewType: Int): CommentariesAdapter.ViewHolder {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int,
|
||||
): CommentariesAdapter.ViewHolder {
|
||||
// create a new view
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.view_commentary, parent, false) as View
|
||||
|
@ -61,8 +61,9 @@ class CommentariesAdapter(private val myDataset: ArrayList<CommentaryModel>) :
|
|||
// holder.context.startActivity(intent)
|
||||
// }
|
||||
|
||||
if(myDataset[position].userImageUrl!="")
|
||||
Picasso.get().load("https://"+ManagerSingleton.url+myDataset[position].userImageUrl).into(holder.userImg);
|
||||
if (myDataset[position].userImageUrl != "") {
|
||||
Picasso.get().load("https://" + ManagerSingleton.url + myDataset[position].userImageUrl).into(holder.userImg)
|
||||
}
|
||||
|
||||
holder.commentary.text = Html.fromHtml(myDataset[position].commentary)
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@ package org.libre.agosto.p2play.adapters
|
|||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
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.helpers.mapSeconds
|
||||
|
@ -17,7 +17,6 @@ import java.io.Serializable
|
|||
class VideosAdapter(private val myDataset: ArrayList<VideoModel>) :
|
||||
RecyclerView.Adapter<VideosAdapter.ViewHolder>() {
|
||||
|
||||
|
||||
// Provide a reference to the views for each data item
|
||||
// Complex data items may need more than one view per item, and
|
||||
// you provide access to all the views for a data item in a view holder.
|
||||
|
@ -60,13 +59,14 @@ class VideosAdapter(private val myDataset: ArrayList<VideoModel>) :
|
|||
holder.context.startActivity(intent)
|
||||
}
|
||||
|
||||
if(myDataset[position].userImageUrl!="")
|
||||
if (myDataset[position].userImageUrl != "") {
|
||||
Picasso.get().load("https://" + ManagerSingleton.url + myDataset[position].userImageUrl).into(holder.userImg)
|
||||
else
|
||||
} else {
|
||||
Picasso.get().load(R.drawable.default_avatar).into(holder.userImg)
|
||||
}
|
||||
|
||||
val viewsText = holder.context.getString(R.string.view_text)
|
||||
val seconds = myDataset[position].duration.toInt();
|
||||
val seconds = myDataset[position].duration.toInt()
|
||||
val timeString = mapSeconds(seconds)
|
||||
|
||||
holder.duration.text = timeString
|
||||
|
|
|
@ -15,8 +15,7 @@ class Actions: Client() {
|
|||
if (con.responseCode == 204) {
|
||||
response = 1
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
response = -1
|
||||
}
|
||||
|
@ -33,8 +32,7 @@ class Actions: Client() {
|
|||
if (con.responseCode == 204) {
|
||||
response = 1
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
response = -1
|
||||
}
|
||||
|
@ -65,8 +63,7 @@ class Actions: Client() {
|
|||
}
|
||||
data.close()
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
isSubscribed = false
|
||||
}
|
||||
|
@ -85,8 +82,7 @@ class Actions: Client() {
|
|||
if (con.responseCode == 204) {
|
||||
response = 1
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
response = -1
|
||||
}
|
||||
|
@ -117,8 +113,7 @@ class Actions: Client() {
|
|||
}
|
||||
con.disconnect()
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
rating = "none"
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ package org.libre.agosto.p2play.ajax
|
|||
import android.util.JsonReader
|
||||
import android.util.JsonToken
|
||||
import android.util.Log
|
||||
import org.libre.agosto.p2play.ManagerSingleton
|
||||
import org.libre.agosto.p2play.models.TokenModel
|
||||
import org.libre.agosto.p2play.models.UserModel
|
||||
import java.io.InputStreamReader
|
||||
|
@ -24,7 +23,6 @@ class Auth: Client() {
|
|||
val token = TokenModel()
|
||||
|
||||
try {
|
||||
|
||||
when (con.responseCode) {
|
||||
200 -> {
|
||||
val response = InputStreamReader(con.inputStream)
|
||||
|
@ -43,7 +41,6 @@ class Auth: Client() {
|
|||
data.endObject()
|
||||
data.close()
|
||||
token.status = 1
|
||||
|
||||
}
|
||||
401 -> {
|
||||
// User require 2FA code
|
||||
|
@ -53,8 +50,7 @@ class Auth: Client() {
|
|||
Log.d("Status", con.responseMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
token.status = 0
|
||||
}
|
||||
|
@ -74,15 +70,13 @@ class Auth: Client() {
|
|||
if (con.responseCode == 204) {
|
||||
response = 1
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
response = -1
|
||||
}
|
||||
|
||||
con.disconnect()
|
||||
return response
|
||||
|
||||
}
|
||||
|
||||
fun refreshToken(token: TokenModel, client_id: String, client_secret: String): TokenModel {
|
||||
|
@ -109,13 +103,10 @@ class Auth: Client() {
|
|||
data.endObject()
|
||||
data.close()
|
||||
token.status = 1
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
Log.d("Status", con.responseMessage)
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
token.status = 0
|
||||
}
|
||||
|
@ -129,7 +120,6 @@ class Auth: Client() {
|
|||
val user = UserModel()
|
||||
|
||||
try {
|
||||
|
||||
if (con.responseCode == 200) {
|
||||
val response = InputStreamReader(con.inputStream)
|
||||
val data = JsonReader(response)
|
||||
|
@ -159,8 +149,7 @@ class Auth: Client() {
|
|||
}
|
||||
}
|
||||
data.endObject()
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
data.skipValue()
|
||||
}
|
||||
}
|
||||
|
@ -176,13 +165,10 @@ class Auth: Client() {
|
|||
data.endObject()
|
||||
data.close()
|
||||
user.status = 1
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
Log.d("Status", con.responseMessage)
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
user.status = 0
|
||||
}
|
||||
|
@ -190,5 +176,4 @@ class Auth: Client() {
|
|||
con.disconnect()
|
||||
return user
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
package org.libre.agosto.p2play.ajax
|
||||
|
||||
import android.util.JsonReader
|
||||
import android.util.JsonToken
|
||||
import org.libre.agosto.p2play.models.ChannelModel
|
||||
import org.libre.agosto.p2play.models.CommentaryModel
|
||||
import java.io.InputStreamReader
|
||||
|
||||
class Channels : Client() {
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.util.Log
|
|||
import org.libre.agosto.p2play.ManagerSingleton
|
||||
import org.libre.agosto.p2play.models.HostModel
|
||||
import java.io.InputStreamReader
|
||||
import java.io.Reader
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
|
||||
|
@ -26,8 +25,9 @@ open class Client {
|
|||
con.connectTimeout = 60000
|
||||
con.readTimeout = 60000
|
||||
|
||||
if(method == "POST")
|
||||
if (method == "POST") {
|
||||
con.doOutput = true
|
||||
}
|
||||
|
||||
Log.d("Petition", url.toString())
|
||||
return con
|
||||
|
@ -64,5 +64,4 @@ open class Client {
|
|||
con.disconnect()
|
||||
return keys
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package org.libre.agosto.p2play.ajax
|
||||
|
||||
import android.util.JsonReader
|
||||
import android.util.JsonToken
|
||||
import android.util.Log
|
||||
import org.libre.agosto.p2play.models.CommentaryModel
|
||||
import java.io.InputStreamReader
|
||||
|
@ -59,13 +58,11 @@ class Comments: Client() {
|
|||
if (con.responseCode == 200) {
|
||||
con.disconnect()
|
||||
response = true
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
Log.d("Status", con.responseMessage)
|
||||
response = false
|
||||
}
|
||||
}
|
||||
catch (err: Exception){
|
||||
} catch (err: Exception) {
|
||||
err.printStackTrace()
|
||||
response = false
|
||||
}
|
||||
|
@ -73,5 +70,4 @@ class Comments: Client() {
|
|||
con.disconnect()
|
||||
return response
|
||||
}
|
||||
|
||||
}
|
|
@ -12,7 +12,7 @@ class ChannelModel (
|
|||
var name: String = "",
|
||||
var description: String = "",
|
||||
var support: String = "",
|
||||
var channelImg: String = ""
|
||||
var channelImg: String = "",
|
||||
) {
|
||||
fun getAccount(): String {
|
||||
return "$nameChannel@$host"
|
||||
|
@ -22,7 +22,6 @@ class ChannelModel (
|
|||
data.beginObject()
|
||||
|
||||
while (data.hasNext()) {
|
||||
|
||||
when (data.nextName()) {
|
||||
"id" -> this.id = data.nextInt()
|
||||
"url" -> this.url = data.nextString()
|
||||
|
@ -31,17 +30,19 @@ class ChannelModel (
|
|||
"followersCount" -> this.followers = data.nextInt()
|
||||
"displayName" -> this.name = data.nextString()
|
||||
"description" -> {
|
||||
if(data.peek() == JsonToken.STRING)
|
||||
if (data.peek() == JsonToken.STRING) {
|
||||
this.description = data.nextString()
|
||||
else
|
||||
} else {
|
||||
data.skipValue()
|
||||
}
|
||||
}
|
||||
"support" -> {
|
||||
if(data.peek() == JsonToken.STRING)
|
||||
if (data.peek() == JsonToken.STRING) {
|
||||
this.support = data.nextString()
|
||||
else
|
||||
} else {
|
||||
data.skipValue()
|
||||
}
|
||||
}
|
||||
"avatar" -> {
|
||||
if (data.peek() == JsonToken.BEGIN_OBJECT) {
|
||||
data.beginObject()
|
||||
|
@ -52,10 +53,10 @@ class ChannelModel (
|
|||
}
|
||||
}
|
||||
data.endObject()
|
||||
}
|
||||
else
|
||||
} else {
|
||||
data.skipValue()
|
||||
}
|
||||
}
|
||||
else -> data.skipValue()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class CommentaryModel (
|
|||
var commentary: String = "",
|
||||
var userHost: String = "",
|
||||
var replies: Int = 0,
|
||||
var nameChannel: String = ""
|
||||
var nameChannel: String = "",
|
||||
) {
|
||||
fun parseCommentary(data: JsonReader) {
|
||||
data.beginObject()
|
||||
|
@ -40,10 +40,9 @@ class CommentaryModel (
|
|||
}
|
||||
}
|
||||
data.endObject()
|
||||
}
|
||||
else
|
||||
} else {
|
||||
data.skipValue()
|
||||
|
||||
}
|
||||
}
|
||||
"uuid" -> this.userUuid = data.nextString()
|
||||
"host" -> this.userHost = data.nextString()
|
||||
|
@ -62,5 +61,4 @@ class CommentaryModel (
|
|||
fun getAccount(): String {
|
||||
return "$nameChannel@$userHost"
|
||||
}
|
||||
|
||||
}
|
|
@ -3,5 +3,5 @@ package org.libre.agosto.p2play.models
|
|||
class TokenModel(
|
||||
var token: String = "",
|
||||
var refresh_token: String = "",
|
||||
var status: Int = -1
|
||||
var status: Int = -1,
|
||||
)
|
|
@ -8,5 +8,5 @@ class UserModel (
|
|||
var nsfw: Boolean = true,
|
||||
var followers: Int = 0,
|
||||
var avatar: String = "",
|
||||
var status: Int = -1
|
||||
var status: Int = -1,
|
||||
)
|
|
@ -19,7 +19,7 @@ class VideoModel(
|
|||
var userHost: String = "",
|
||||
var nameChannel: String = "",
|
||||
var isLive: Boolean = false,
|
||||
var streamingData: StreamingModel? = null
|
||||
var streamingData: StreamingModel? = null,
|
||||
) : Serializable {
|
||||
fun getChannel(): String {
|
||||
return "$nameChannel@$userHost"
|
||||
|
@ -40,11 +40,12 @@ class VideoModel(
|
|||
this.name = data.nextString()
|
||||
}
|
||||
"description" -> {
|
||||
if(data.peek() == JsonToken.STRING)
|
||||
if (data.peek() == JsonToken.STRING) {
|
||||
this.description = data.nextString()
|
||||
else
|
||||
} else {
|
||||
data.skipValue()
|
||||
}
|
||||
}
|
||||
"duration" -> {
|
||||
this.duration = data.nextInt()
|
||||
}
|
||||
|
@ -106,10 +107,9 @@ class VideoModel(
|
|||
}
|
||||
}
|
||||
data.endObject()
|
||||
}
|
||||
else
|
||||
} else {
|
||||
data.skipValue()
|
||||
|
||||
}
|
||||
}
|
||||
"uuid" -> this.userUuid = data.nextString()
|
||||
"host" -> this.userHost = data.nextString()
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.libre.agosto.p2play
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
|
|
|
@ -12,6 +12,7 @@ android.useAndroidX=true
|
|||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
org.gradle.configuration-cache=true
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
|
|
Loading…
Reference in New Issue