コード整形
This commit is contained in:
parent
0955dff8db
commit
fb59239edd
|
@ -26,7 +26,6 @@ import jp.juggler.util.data.notZero
|
||||||
import jp.juggler.util.data.toJsonArray
|
import jp.juggler.util.data.toJsonArray
|
||||||
import jp.juggler.util.int
|
import jp.juggler.util.int
|
||||||
import jp.juggler.util.log.LogCategory
|
import jp.juggler.util.log.LogCategory
|
||||||
import jp.juggler.util.log.showToast
|
|
||||||
import jp.juggler.util.ui.attrColor
|
import jp.juggler.util.ui.attrColor
|
||||||
import jp.juggler.util.ui.setNavigationBack
|
import jp.juggler.util.ui.setNavigationBack
|
||||||
import jp.juggler.util.ui.vg
|
import jp.juggler.util.ui.vg
|
||||||
|
@ -116,19 +115,19 @@ class ActColumnList : AppCompatActivity() {
|
||||||
) {
|
) {
|
||||||
// 左にスワイプした(右端に青が見えた) なら要素を削除する
|
// 左にスワイプした(右端に青が見えた) なら要素を削除する
|
||||||
if (swipedDirection == ListSwipeItem.SwipeDirection.LEFT) {
|
if (swipedDirection == ListSwipeItem.SwipeDirection.LEFT) {
|
||||||
val adapterItem = (item.tag as MyViewHolder).lastItem ?:return
|
val adapterItem = (item.tag as MyViewHolder).lastItem ?: return
|
||||||
launchMain {
|
launchMain {
|
||||||
try{
|
try {
|
||||||
if (adapterItem.json.optBoolean(ColumnEncoder.KEY_DONT_CLOSE, false)) {
|
if (adapterItem.json.optBoolean(ColumnEncoder.KEY_DONT_CLOSE, false)) {
|
||||||
confirm(R.string.confirm_remove_column_mark_as_dont_close)
|
confirm(R.string.confirm_remove_column_mark_as_dont_close)
|
||||||
}
|
}
|
||||||
listAdapter.removeItem(listAdapter.getPositionForItem(adapterItem))
|
listAdapter.removeItem(listAdapter.getPositionForItem(adapterItem))
|
||||||
}catch(ex:Throwable){
|
} catch (ex: Throwable) {
|
||||||
showApiError(ex)
|
showApiError(ex)
|
||||||
}finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
views.listView.resetSwipedViews(null)
|
views.listView.resetSwipedViews(null)
|
||||||
}catch(_:Throwable) {
|
} catch (_: Throwable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ class ActMainTabletViews(val actMain: ActMain) {
|
||||||
// if( animator is DefaultItemAnimator){
|
// if( animator is DefaultItemAnimator){
|
||||||
// animator.supportsChangeAnimations = false
|
// animator.supportsChangeAnimations = false
|
||||||
// }
|
// }
|
||||||
if(PrefB.bpTabletSnap()){
|
if (PrefB.bpTabletSnap()) {
|
||||||
GravitySnapHelper(Gravity.START).attachToRecyclerView(this.tabletPager)
|
GravitySnapHelper(Gravity.START).attachToRecyclerView(this.tabletPager)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ private class TootTaskRunner2<ReturnType : Any?>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun <T : Any?,A : Context> A.runApiTask2(
|
suspend fun <T : Any?, A : Context> A.runApiTask2(
|
||||||
accessInfo: SavedAccount,
|
accessInfo: SavedAccount,
|
||||||
progressStyle: Int = ApiTask.PROGRESS_SPINNER,
|
progressStyle: Int = ApiTask.PROGRESS_SPINNER,
|
||||||
progressPrefix: String? = null,
|
progressPrefix: String? = null,
|
||||||
|
|
|
@ -210,7 +210,7 @@ class MastodonAuth(override val client: TootApiClient) : AuthBase() {
|
||||||
"random:${System.currentTimeMillis()}",
|
"random:${System.currentTimeMillis()}",
|
||||||
when (accountDbId) {
|
when (accountDbId) {
|
||||||
null -> "host:${apiHost.ascii}"
|
null -> "host:${apiHost.ascii}"
|
||||||
else -> "db:${accountDbId}"
|
else -> "db:$accountDbId"
|
||||||
}
|
}
|
||||||
).joinToString(",")
|
).joinToString(",")
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class MisskeyAuthApi10(val client: TootApiClient) {
|
||||||
"appSecret" to appSecret,
|
"appSecret" to appSecret,
|
||||||
"token" to token,
|
"token" to token,
|
||||||
).toPostRequestBuilder()
|
).toPostRequestBuilder()
|
||||||
.url("https://${apiHost}/api/auth/session/userkey")
|
.url("https://${apiHost.ascii}/api/auth/session/userkey")
|
||||||
.build()
|
.build()
|
||||||
.send(client, errorSuffix = apiHost.pretty)
|
.send(client, errorSuffix = apiHost.pretty)
|
||||||
.readJsonObject()
|
.readJsonObject()
|
||||||
|
|
|
@ -39,10 +39,8 @@ class MisskeyAuthApi13(val client: TootApiClient) {
|
||||||
sessionId: String,
|
sessionId: String,
|
||||||
): JsonObject = JsonObject(/*empty*/)
|
): JsonObject = JsonObject(/*empty*/)
|
||||||
.toPostRequestBuilder()
|
.toPostRequestBuilder()
|
||||||
.url("https://${apiHost.ascii}/api/miauth/${sessionId}/check")
|
.url("https://${apiHost.ascii}/api/miauth/$sessionId/check")
|
||||||
.build()
|
.build()
|
||||||
.send(client, errorSuffix = apiHost.pretty)
|
.send(client, errorSuffix = apiHost.pretty)
|
||||||
.readJsonObject()
|
.readJsonObject()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package jp.juggler.subwaytooter.column
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import jp.juggler.subwaytooter.App1
|
import jp.juggler.subwaytooter.App1
|
||||||
import jp.juggler.subwaytooter.DedupMode
|
import jp.juggler.subwaytooter.DedupMode
|
||||||
import jp.juggler.subwaytooter.api.TootApiClient
|
|
||||||
import jp.juggler.subwaytooter.api.auth.AuthBase
|
import jp.juggler.subwaytooter.api.auth.AuthBase
|
||||||
import jp.juggler.subwaytooter.api.entity.*
|
import jp.juggler.subwaytooter.api.entity.*
|
||||||
import jp.juggler.subwaytooter.columnviewholder.*
|
import jp.juggler.subwaytooter.columnviewholder.*
|
||||||
|
|
|
@ -104,7 +104,7 @@ class LoginForm(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initServerNameList() {
|
private fun initServerNameList() {
|
||||||
val instance_list = HashSet<String>().apply {
|
val instanceList = HashSet<String>().apply {
|
||||||
try {
|
try {
|
||||||
activity.resources.openRawResource(R.raw.server_list).use { inStream ->
|
activity.resources.openRawResource(R.raw.server_list).use { inStream ->
|
||||||
val br = BufferedReader(InputStreamReader(inStream, "UTF-8"))
|
val br = BufferedReader(InputStreamReader(inStream, "UTF-8"))
|
||||||
|
@ -135,7 +135,7 @@ class LoginForm(
|
||||||
val key = constraint.toString().lowercase()
|
val key = constraint.toString().lowercase()
|
||||||
// suggestions リストは毎回生成する必要がある。publishResultsと同時にアクセスされる場合がある
|
// suggestions リストは毎回生成する必要がある。publishResultsと同時にアクセスされる場合がある
|
||||||
val suggestions = StringArray()
|
val suggestions = StringArray()
|
||||||
for (s in instance_list) {
|
for (s in instanceList) {
|
||||||
if (s.contains(key)) {
|
if (s.contains(key)) {
|
||||||
suggestions.add(s)
|
suggestions.add(s)
|
||||||
if (suggestions.size >= 20) break
|
if (suggestions.size >= 20) break
|
||||||
|
|
|
@ -589,7 +589,6 @@ class ItemViewHolder(
|
||||||
)
|
)
|
||||||
contentDescription = context.getString(R.string.hide)
|
contentDescription = context.getString(R.string.hide)
|
||||||
imageResource = R.drawable.ic_close
|
imageResource = R.drawable.ic_close
|
||||||
|
|
||||||
}.lparams(dip(32), matchParent) {
|
}.lparams(dip(32), matchParent) {
|
||||||
startMargin = dip(4)
|
startMargin = dip(4)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@ class TestColumnMeta {
|
||||||
val columnList = SavedAccount.columnList
|
val columnList = SavedAccount.columnList
|
||||||
val actual = columnList.createTableSql()
|
val actual = columnList.createTableSql()
|
||||||
.joinToString(";")
|
.joinToString(";")
|
||||||
val expect ="create table if not exists access_info (_id INTEGER PRIMARY KEY,a text not null,confirm_boost integer default 1,confirm_favourite integer default 1,confirm_follow integer default 1,confirm_follow_locked integer default 1,confirm_post integer default 1,confirm_reaction integer default 1,confirm_unbookmark integer default 1,confirm_unboost integer default 1,confirm_unfavourite integer default 1,confirm_unfollow integer default 1,d text,default_sensitive integer default 0,default_text text default '',dont_hide_nsfw integer default 0,dont_show_timeout integer default 0,expand_cw integer default 0,extra_json text default null,h text not null,image_max_megabytes text default null,image_resize text default null,is_misskey integer default 0,last_notification_error text,last_push_endpoint text,last_subscription_error text,max_toot_chars integer default 0,movie_max_megabytes text default null,notification_boost integer default 1,notification_favourite integer default 1,notification_follow integer default 1,notification_follow_request integer default 1,notification_mention integer default 1,notification_post integer default 1,notification_reaction integer default 1,notification_server text default '',notification_update integer default 1,notification_vote integer default 1,push_policy text default null,register_key text default '',register_time integer default 0,sound_uri text default '',t text not null,u text not null,visibility text);create index if not exists access_info_user on access_info(u);create index if not exists access_info_host on access_info(h,u)"
|
val expect =
|
||||||
|
"create table if not exists access_info (_id INTEGER PRIMARY KEY,a text not null,confirm_boost integer default 1,confirm_favourite integer default 1,confirm_follow integer default 1,confirm_follow_locked integer default 1,confirm_post integer default 1,confirm_reaction integer default 1,confirm_unbookmark integer default 1,confirm_unboost integer default 1,confirm_unfavourite integer default 1,confirm_unfollow integer default 1,d text,default_sensitive integer default 0,default_text text default '',dont_hide_nsfw integer default 0,dont_show_timeout integer default 0,expand_cw integer default 0,extra_json text default null,h text not null,image_max_megabytes text default null,image_resize text default null,is_misskey integer default 0,last_notification_error text,last_push_endpoint text,last_subscription_error text,max_toot_chars integer default 0,movie_max_megabytes text default null,notification_boost integer default 1,notification_favourite integer default 1,notification_follow integer default 1,notification_follow_request integer default 1,notification_mention integer default 1,notification_post integer default 1,notification_reaction integer default 1,notification_server text default '',notification_update integer default 1,notification_vote integer default 1,push_policy text default null,register_key text default '',register_time integer default 0,sound_uri text default '',t text not null,u text not null,visibility text);create index if not exists access_info_user on access_info(u);create index if not exists access_info_host on access_info(h,u)"
|
||||||
assertEquals("SavedAccount createParams()", expect, actual)
|
assertEquals("SavedAccount createParams()", expect, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,8 +135,8 @@ class TestJson {
|
||||||
fun testNumberEncode() {
|
fun testNumberEncode() {
|
||||||
fun x(
|
fun x(
|
||||||
n: Number,
|
n: Number,
|
||||||
expectValue:Number = n,
|
expectValue: Number = n,
|
||||||
expectClass:Class<*> = expectValue.javaClass,
|
expectClass: Class<*> = expectValue.javaClass,
|
||||||
) {
|
) {
|
||||||
val encodedObject = jsonObjectOf("n" to n).toString()
|
val encodedObject = jsonObjectOf("n" to n).toString()
|
||||||
val decodedObject = encodedObject.decodeJsonObject()
|
val decodedObject = encodedObject.decodeJsonObject()
|
||||||
|
@ -145,7 +145,7 @@ class TestJson {
|
||||||
assertEquals("$n value $encodedObject", expectValue, decoded)
|
assertEquals("$n value $encodedObject", expectValue, decoded)
|
||||||
}
|
}
|
||||||
x(0)
|
x(0)
|
||||||
x(0f ,expectValue = 0)
|
x(0f, expectValue = 0)
|
||||||
x(0.0, expectValue = 0)
|
x(0.0, expectValue = 0)
|
||||||
x(-0)
|
x(-0)
|
||||||
x(-0f, expectValue = -0.0)
|
x(-0f, expectValue = -0.0)
|
||||||
|
@ -165,6 +165,5 @@ class TestJson {
|
||||||
// 誤差が出て上限/下限が合わないので、デコード時にはdouble解釈になる
|
// 誤差が出て上限/下限が合わないので、デコード時にはdouble解釈になる
|
||||||
// x(Float.MAX_VALUE, expectValue = Float.MAX_VALUE.toDouble())
|
// x(Float.MAX_VALUE, expectValue = Float.MAX_VALUE.toDouble())
|
||||||
// x(Float.MIN_VALUE, expectValue = Float.MIN_VALUE.toDouble())
|
// x(Float.MIN_VALUE, expectValue = Float.MIN_VALUE.toDouble())
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,7 +281,7 @@ fun String.encodePercent(allow: String? = null): String = Uri.encode(this, allow
|
||||||
|
|
||||||
// %HH エンコードした後に %20 を + に変換する
|
// %HH エンコードした後に %20 を + に変換する
|
||||||
fun String.encodePercentPlus(allow: String? = null): String =
|
fun String.encodePercentPlus(allow: String? = null): String =
|
||||||
Uri.encode(this, allow).replace("""%20""".toRegex(),"+")
|
Uri.encode(this, allow).replace("""%20""".toRegex(), "+")
|
||||||
|
|
||||||
// replace + to %20, then decode it.
|
// replace + to %20, then decode it.
|
||||||
fun String.decodePercent(): String =
|
fun String.decodePercent(): String =
|
||||||
|
|
Loading…
Reference in New Issue