Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ekibun committed Apr 16, 2019
1 parent d6c9056 commit 5b427a4
Show file tree
Hide file tree
Showing 26 changed files with 271 additions and 131 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
implementation 'com.squareup.retrofit2:retrofit-adapters:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'jp.wasabeef:glide-transformations:3.3.0'
implementation 'com.oushangfeng:PinnedSectionItemDecoration:1.2.4'
implementation 'com.oushangfeng:PinnedSectionItemDecoration:1.3.2'
implementation 'com.github.siyamed:android-shape-imageview:0.9.3'
implementation 'org.apache.commons:commons-text:1.3'
implementation 'com.android.support:customtabs:28.0.0'
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/soko/ekibun/bangumi/ui/main/UserView.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package soko.ekibun.bangumi.ui.main

import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.nav_header.view.*
import soko.ekibun.bangumi.R
import soko.ekibun.bangumi.api.bangumi.bean.UserInfo
import soko.ekibun.bangumi.util.GlideUtil

class UserView(private val context: MainActivity, onUserFigureClickListener: View.OnClickListener){
private val headerView by lazy{context.nav_view.getHeaderView(0)}
Expand All @@ -18,11 +18,11 @@ class UserView(private val context: MainActivity, onUserFigureClickListener: Vie
fun setUser(user: UserInfo?){
context.runOnUiThread {
if(context.isDestroyed) return@runOnUiThread
Glide.with(headerView.user_figure)
.load(user?.avatar?.large)
.apply(RequestOptions.placeholderOf(R.drawable.akkarin))
.apply(RequestOptions.circleCropTransform())
.into(headerView.user_figure)
GlideUtil.with(headerView.user_figure)
?.load(user?.avatar?.large)
?.apply(RequestOptions.placeholderOf(R.drawable.akkarin))
?.apply(RequestOptions.circleCropTransform())
?.into(headerView.user_figure)
//val token = UserModel(context).getToken()
headerView.user_id.text = if(user?.username == null) "" else "@${user.username}"
headerView.user_name.text = user?.nickname?:context.getString(R.string.hint_login)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package soko.ekibun.bangumi.ui.main.fragment.cache

import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import kotlinx.android.synthetic.main.item_subject.view.*
import soko.ekibun.bangumi.R
import soko.ekibun.bangumi.util.GlideUtil
import soko.ekibun.bangumi.util.PlayerBridge

class CacheAdapter(data: MutableList<PlayerBridge.VideoCache>? = null) :
Expand All @@ -15,9 +15,9 @@ class CacheAdapter(data: MutableList<PlayerBridge.VideoCache>? = null) :
helper.setText(R.id.item_title, item.bangumi.getPrettyName())
helper.setText(R.id.item_name_jp, item.bangumi.name)
helper.setText(R.id.item_summary, helper.itemView.context.getString(R.string.parse_cache_eps, item.videoList.size))
Glide.with(helper.itemView.item_cover)
.load(item.bangumi.images?.getImage(helper.itemView.context))
.apply(RequestOptions.errorOf(R.drawable.err_404))
.into(helper.itemView.item_cover)
GlideUtil.with(helper.itemView.item_cover)
?.load(item.bangumi.images?.getImage(helper.itemView.context))
?.apply(RequestOptions.errorOf(R.drawable.err_404))
?.into(helper.itemView.item_cover)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package soko.ekibun.bangumi.ui.main.fragment.calendar
import android.annotation.SuppressLint
import android.preference.PreferenceManager
import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseSectionQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.chad.library.adapter.base.entity.SectionEntity
import kotlinx.android.synthetic.main.item_calendar.view.*
import soko.ekibun.bangumi.R
import soko.ekibun.bangumi.api.tinygrail.bean.OnAir
import soko.ekibun.bangumi.util.GlideUtil
import soko.ekibun.bangumi.util.ResourceUtil
import java.text.DecimalFormat
import java.util.*
Expand All @@ -24,10 +24,10 @@ class CalendarAdapter(data: MutableList<CalendarSection>? = null) :
helper.setText(R.id.item_title, item.t.subject.getPrettyName())
helper.setText(R.id.item_ep_name, item.t.episode?.parseSort(helper.itemView.context) + " " + (if(item.t.episode?.name_cn.isNullOrEmpty()) item.t.episode?.name?:"" else item.t.episode?.name_cn))
helper.addOnClickListener(R.id.item_layout)
Glide.with(helper.itemView.item_cover)
.load(item.t.subject.images?.small)
.apply(RequestOptions.errorOf(R.drawable.err_404))
.into(helper.itemView.item_cover)
GlideUtil.with(helper.itemView.item_cover)
?.load(item.t.subject.images?.small)
?.apply(RequestOptions.errorOf(R.drawable.err_404))
?.into(helper.itemView.item_cover)
helper.itemView.item_time.text = ""
helper.itemView.item_chase.visibility = if(item.t.subject.collect) View.VISIBLE else View.GONE

Expand All @@ -51,8 +51,6 @@ class CalendarAdapter(data: MutableList<CalendarSection>? = null) :
}
helper.itemView.item_now_time.visibility = View.VISIBLE



val cal = Calendar.getInstance()
val hour = cal.get(Calendar.HOUR_OF_DAY)
val hourNow = if(use30h) (hour -6 + 24) % 24 +6 else hour
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package soko.ekibun.bangumi.ui.main.fragment.calendar

import android.annotation.SuppressLint
import android.content.SharedPreferences
import android.preference.PreferenceManager
import android.support.v4.view.PagerAdapter
import android.support.v4.view.ViewPager
Expand All @@ -27,7 +28,7 @@ import java.util.*
import kotlin.collections.HashMap

class CalendarPagerAdapter(val fragment: CalendarFragment, private val pager: ViewPager, private val scrollTrigger: (Boolean)->Unit) : PagerAdapter(){
val sp by lazy { PreferenceManager.getDefaultSharedPreferences(pager.context) }
val sp:SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(pager.context) }

init{
pager.addOnPageChangeListener(object: ViewPager.OnPageChangeListener{
Expand Down Expand Up @@ -62,6 +63,7 @@ class CalendarPagerAdapter(val fragment: CalendarFragment, private val pager: Vi
}
}

@SuppressLint("UseSparseArrays")
private val items = HashMap<Int, Pair<CalendarAdapter, SwipeRefreshLayout>>()
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val item = getItem(CalendarAdapter.getCalendarInt(getPostDate(position)))
Expand All @@ -78,11 +80,12 @@ class CalendarPagerAdapter(val fragment: CalendarFragment, private val pager: Vi
val use30h = sp.getBoolean("calendar_use_30h", false)

val now = CalendarAdapter.getNowInt(use30h)
@SuppressLint("UseSparseArrays")
val onAir = HashMap<Int, HashMap<String, ArrayList<OnAir>>>()
val calWeek = CalendarAdapter.getIntCalendar(now)
calWeek.add(java.util.Calendar.DAY_OF_MONTH, -7)
calWeek.add(Calendar.DAY_OF_MONTH, -7)
val minDate = CalendarAdapter.getCalendarInt(calWeek)
calWeek.add(java.util.Calendar.DAY_OF_MONTH, +14)
calWeek.add(Calendar.DAY_OF_MONTH, +14)
val maxDate = CalendarAdapter.getCalendarInt(calWeek)
it.forEach {subject->
val bangumi = Subject(subject.id?:return@forEach, "${Bangumi.SERVER}/subject/${subject.id}", SubjectType.ANIME, subject.name, subject.name_cn, images = Images(
Expand Down Expand Up @@ -112,15 +115,15 @@ class CalendarPagerAdapter(val fragment: CalendarFragment, private val pager: Vi
val mFormatter = Formatter(mStrBuilder, Locale.getDefault())
mStrBuilder.setLength(0)
val time = mFormatter.format("%02d:%02d", if(use30h) (hour - 6 + 24) % 24 + 6 else (hour+24)%24, minute%60).toString()
val cal = java.util.Calendar.getInstance()
val cal = Calendar.getInstance()
cal.time = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(it.airdate)
val week = (when{
timeInt/100 < 5 -> -1
timeInt/100 < 5 -> 1
else -> 0
}) + if(!useCN || subject.timeCN.isNullOrEmpty()) 0 else Math.min(if(subject.timeCN?.toIntOrNull()?:0 < subject.timeJP?.toIntOrNull()?:0) 1 else 0, ((subject.weekDayCN?:0) - (subject.weekDayJP?:0) + 7) % 7)
}) + if(!useCN || subject.timeCN.isNullOrEmpty()) 0 else Math.min(if(subject.timeCN.toIntOrNull() ?:0 < subject.timeJP?.toIntOrNull()?:0) 1 else 0, ((subject.weekDayCN?:0) - (subject.weekDayJP?:0) + 7) % 7)
//(((if(!useCN || subject.timeCN.isNullOrEmpty()) subject.weekDayJP else subject.weekDayCN)?:0) - CalendarAdapter.getWeek(cal) + 7) % 7
val dayDif = week + dayCarry
cal.add(java.util.Calendar.DAY_OF_MONTH, dayDif)
cal.add(Calendar.DAY_OF_MONTH, dayDif)
val date = CalendarAdapter.getCalendarInt(cal)
if(date in minDate..maxDate)
onAir.getOrPut(date){HashMap()}.getOrPut(time){ArrayList()}.add(item)
Expand Down Expand Up @@ -175,7 +178,7 @@ class CalendarPagerAdapter(val fragment: CalendarFragment, private val pager: Vi
}

override fun getItemPosition(`object`: Any): Int {
return PagerAdapter.POSITION_NONE
return POSITION_NONE
}

override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
Expand All @@ -187,10 +190,10 @@ class CalendarPagerAdapter(val fragment: CalendarFragment, private val pager: Vi
return "${date/100%100}-${date%100}\n${CalendarAdapter.weekSmall[CalendarAdapter.getWeek(cal)]}(${CalendarAdapter.weekJp[CalendarAdapter.getWeek(cal)]})"
}

private fun getPostDate(pos: Int): java.util.Calendar{
private fun getPostDate(pos: Int): Calendar{
val cal = CalendarAdapter.getIntCalendar(CalendarAdapter.getNowInt(
sp.getBoolean("calendar_use_30h", false)))
cal.add(java.util.Calendar.DAY_OF_MONTH, pos-7)
cal.add(Calendar.DAY_OF_MONTH, pos-7)
return cal
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package soko.ekibun.bangumi.ui.main.fragment.home.fragment.collection

import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
Expand All @@ -10,6 +9,7 @@ import soko.ekibun.bangumi.api.bangumi.bean.Episode
import soko.ekibun.bangumi.api.bangumi.bean.SubjectCollection
import soko.ekibun.bangumi.api.bangumi.bean.SubjectProgress
import soko.ekibun.bangumi.api.bangumi.bean.SubjectType
import soko.ekibun.bangumi.util.GlideUtil
import soko.ekibun.bangumi.util.ResourceUtil

class CollectionListAdapter(data: MutableList<SubjectCollection>? = null) :
Expand Down Expand Up @@ -43,9 +43,9 @@ class CollectionListAdapter(data: MutableList<SubjectCollection>? = null) :
}
}
helper.setText(R.id.item_summary, if(item.ep_status == -1) item.subject?.summary else watchep)
Glide.with(helper.itemView.item_cover)
.load(item.subject?.images?.getImage(helper.itemView.context))
.apply(RequestOptions.errorOf(R.drawable.err_404))
.into(helper.itemView.item_cover)
GlideUtil.with(helper.itemView.item_cover)
?.load(item.subject?.images?.getImage(helper.itemView.context))
?.apply(RequestOptions.errorOf(R.drawable.err_404))
?.into(helper.itemView.item_cover)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package soko.ekibun.bangumi.ui.main.fragment.home.fragment.rakuen

import android.annotation.SuppressLint
import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import kotlinx.android.synthetic.main.item_topic.view.*
import soko.ekibun.bangumi.R
import soko.ekibun.bangumi.api.bangumi.bean.Rakuen
import soko.ekibun.bangumi.util.GlideUtil

class RakuenAdapter(data: MutableList<Rakuen>? = null) :
BaseQuickAdapter<Rakuen, BaseViewHolder>(R.layout.item_topic, data) {
Expand All @@ -22,9 +22,9 @@ class RakuenAdapter(data: MutableList<Rakuen>? = null) :
helper.itemView.item_group.visibility = View.VISIBLE
helper.itemView.item_group.text = it
}
Glide.with(helper.itemView.item_avatar)
.load(item.img)
.apply(RequestOptions.circleCropTransform().error(R.drawable.err_404))
.into(helper.itemView.item_avatar)
GlideUtil.with(helper.itemView.item_avatar)
?.load(item.img)
?.apply(RequestOptions.circleCropTransform().error(R.drawable.err_404))
?.into(helper.itemView.item_avatar)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.support.v7.app.AlertDialog
import android.text.Html
import android.text.method.LinkMovementMethod
import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseSectionQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
Expand All @@ -15,6 +14,7 @@ import soko.ekibun.bangumi.api.bangumi.Bangumi
import soko.ekibun.bangumi.api.bangumi.bean.TimeLine
import soko.ekibun.bangumi.ui.topic.PostAdapter
import soko.ekibun.bangumi.ui.web.WebActivity
import soko.ekibun.bangumi.util.GlideUtil
import soko.ekibun.bangumi.util.HttpUtil
import java.net.URI

Expand Down Expand Up @@ -71,10 +71,10 @@ class TimeLineAdapter(val ua: String, data: MutableList<TimeLine>? = null) :
WebActivity.launchUrl(helper.itemView.context, item.t.userUrl, "")
}
if(!userImage.isEmpty())
Glide.with(helper.itemView.item_avatar)
.load(userImage)
.apply(RequestOptions.circleCropTransform().error(R.drawable.err_404))
.into(helper.itemView.item_avatar)
GlideUtil.with(helper.itemView.item_avatar)
?.load(userImage)
?.apply(RequestOptions.circleCropTransform().error(R.drawable.err_404))
?.into(helper.itemView.item_avatar)
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package soko.ekibun.bangumi.ui.main.fragment.index

import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import kotlinx.android.synthetic.main.item_subject.view.*
import soko.ekibun.bangumi.R
import soko.ekibun.bangumi.api.bangumi.bean.Subject
import soko.ekibun.bangumi.util.GlideUtil

class SubjectAdapter(data: MutableList<Subject>? = null) :
BaseQuickAdapter<Subject, BaseViewHolder>(R.layout.item_subject, data) {
Expand All @@ -17,9 +17,9 @@ class SubjectAdapter(data: MutableList<Subject>? = null) :
helper.setText(R.id.item_name_jp, item.name)
helper.setText(R.id.item_summary, item.summary)
helper.itemView.item_chase.visibility = if(item.collect) View.VISIBLE else View.GONE
Glide.with(helper.itemView.item_cover)
.load(item.images?.getImage(helper.itemView.context))
.apply(RequestOptions.errorOf(R.drawable.err_404))
.into(helper.itemView.item_cover)
GlideUtil.with(helper.itemView.item_cover)
?.load(item.images?.getImage(helper.itemView.context))
?.apply(RequestOptions.errorOf(R.drawable.err_404))
?.into(helper.itemView.item_cover)
}
}
10 changes: 5 additions & 5 deletions app/src/main/java/soko/ekibun/bangumi/ui/search/MonoAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package soko.ekibun.bangumi.ui.search

import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import kotlinx.android.synthetic.main.item_mono.view.*
import soko.ekibun.bangumi.R
import soko.ekibun.bangumi.api.bangumi.bean.MonoInfo
import soko.ekibun.bangumi.util.GlideUtil

class MonoAdapter(data: MutableList<MonoInfo>? = null) :
BaseQuickAdapter<MonoInfo, BaseViewHolder>(R.layout.item_mono, data) {
Expand All @@ -15,9 +15,9 @@ class MonoAdapter(data: MutableList<MonoInfo>? = null) :
helper.setText(R.id.item_title, if(item.name_cn.isNullOrEmpty()) item.name else item.name_cn)
helper.setText(R.id.item_name_jp, item.name)
helper.setText(R.id.item_summary, item.summary)
Glide.with(helper.itemView.item_cover)
.load(item.img)
.apply(RequestOptions.errorOf(R.drawable.err_404))
.into(helper.itemView.item_cover)
GlideUtil.with(helper.itemView.item_cover)
?.load(item.img)
?.apply(RequestOptions.errorOf(R.drawable.err_404))
?.into(helper.itemView.item_cover)
}
}
10 changes: 5 additions & 5 deletions app/src/main/java/soko/ekibun/bangumi/ui/search/SearchAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package soko.ekibun.bangumi.ui.search

import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import kotlinx.android.synthetic.main.item_subject.view.*
import soko.ekibun.bangumi.R
import soko.ekibun.bangumi.api.bangumi.bean.Subject
import soko.ekibun.bangumi.api.bangumi.bean.SubjectType
import soko.ekibun.bangumi.util.GlideUtil

class SearchAdapter(data: MutableList<Subject>? = null) :
BaseQuickAdapter<Subject, BaseViewHolder>(R.layout.item_subject, data) {
Expand All @@ -18,9 +18,9 @@ class SearchAdapter(data: MutableList<Subject>? = null) :
helper.setText(R.id.item_name_jp, item.name)
helper.setText(R.id.item_summary, helper.itemView.context.getString(SubjectType.getDescription(item.type)))
helper.itemView.item_chase.visibility = if(item.collect) View.VISIBLE else View.GONE
Glide.with(helper.itemView.item_cover)
.load(item.images?.getImage(helper.itemView.context))
.apply(RequestOptions.errorOf(R.drawable.err_404))
.into(helper.itemView.item_cover)
GlideUtil.with(helper.itemView.item_cover)
?.load(item.images?.getImage(helper.itemView.context))
?.apply(RequestOptions.errorOf(R.drawable.err_404))
?.into(helper.itemView.item_cover)
}
}
Loading

0 comments on commit 5b427a4

Please sign in to comment.