Skip to content

Commit

Permalink
Release 0.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Sep 4, 2018
1 parent 7c02296 commit 50cbdd8
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 27 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ android {
applicationId "io.github.feelfreelinux.wykopmobilny"
minSdkVersion 15
targetSdkVersion 28
vectorDrawables.useSupportLibrary = true
versionCode project.ext.versionMajor * 10000 + project.ext.versionMinor * 1000 + project.ext.versionPatch * 100 + project.ext.versionBuild
versionName "${project.ext.versionMajor}.${project.ext.versionMinor}.${project.ext.versionPatch}.${project.ext.versionBuild}"
multiDexEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ class WykopImageFile(val uri: Uri, val context: Context) {
fun getFileMultipart(): MultipartBody.Part {
val contentResolver = context.contentResolver
val filename = uri.queryFileName(contentResolver)
var file: File? = FileUtils.getFile(context, uri)
var mimetype = contentResolver.getType(uri)
if (file == null) {
var file: File? = null
try {
file = FileUtils.getFile(context, uri)
if (file == null) {
file = saveUri(uri, filename)
}
} catch (e: Throwable) {
file = saveUri(uri, filename)
}

var mimetype = contentResolver.getType(uri)


file?.let {
val opt = BitmapFactory.Options()
opt.inJustDecodeBounds = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EntriesAdapter @Inject constructor(val userManagerApi: UserManagerApi, val
var replyListener : EntryListener? = null

override fun getViewType(position: Int): Int {
val entry = data[position]
val entry = dataset[position]!!
return EntryViewHolder.getViewTypeForEntry(entry)
}

Expand All @@ -41,14 +41,14 @@ class EntriesAdapter @Inject constructor(val userManagerApi: UserManagerApi, val

override fun bindHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
if (holder is EntryViewHolder) {
holder.bindView(data[position])
holder.bindView(dataset[position]!!)
} else if (holder is BlockedViewHolder) {
holder.bindView(data[position])
holder.bindView(dataset[position]!!)
}
}

fun updateEntry(entry : Entry) {
val position = data.indexOf(entry)
val position = dataset.indexOf(entry)
dataset[position] = entry
notifyItemChanged(position)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EntryCommentAdapter @Inject constructor(
lateinit var entryCommentActionListener : EntryCommentActionListener

override fun getViewType(position: Int): Int {
return EntryCommentViewHolder.getViewTypeForEntryComment(data[position])
return EntryCommentViewHolder.getViewTypeForEntryComment(dataset[position]!!)
}

override fun addData(items: List<EntryComment>, shouldClearAdapter: Boolean) {
Expand All @@ -40,13 +40,13 @@ class EntryCommentAdapter @Inject constructor(

override fun bindHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
when (holder) {
is EntryCommentViewHolder -> holder.bindView(data[position], null)
is BlockedViewHolder -> { holder.bindView(data[position]) }
is EntryCommentViewHolder -> holder.bindView(dataset[position]!!, null)
is BlockedViewHolder -> { holder.bindView(dataset[position]!!) }
}
}

fun updateComment(comment : EntryComment) {
val position = data.indexOf(comment)
val position = dataset.indexOf(comment)
dataset[position] = comment
notifyItemChanged(position)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class EntryLinksAdapter @Inject constructor(val userManagerApi: UserManagerApi,
lateinit var linkActionListener : LinkActionListener

override fun getViewType(position: Int): Int {
val entryLink = data[position]
return if (entryLink.DATA_TYPE == EntryLink.TYPE_ENTRY) {
val entryLink = dataset[position]
return if (entryLink?.DATA_TYPE == EntryLink.TYPE_ENTRY) {
EntryViewHolder.getViewTypeForEntry(entryLink.entry!!)
} else {
LinkViewHolder.getViewTypeForLink(entryLink.link!!, settingsPreferencesApi)
LinkViewHolder.getViewTypeForLink(entryLink!!.link!!, settingsPreferencesApi)
}
}

Expand All @@ -47,14 +47,14 @@ class EntryLinksAdapter @Inject constructor(val userManagerApi: UserManagerApi,
is EntryViewHolder -> {
dataset[position]?.entry?.let { holder.bindView(it) }
}
is LinkViewHolder -> data[position].link?.let { holder.bindView(it) }
is LinkViewHolder -> dataset[position]?.link?.let { holder.bindView(it) }
is BlockedViewHolder -> {
val data = data[position]
data.link?.let {
val data = dataset[position]
data?.link?.let {
holder.bindView(it)
}

data.entry?.let {
data?.entry?.let {
holder.bindView(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class LinksAdapter @Inject constructor(val userManagerApi: UserManagerApi, val s

override fun getViewType(position: Int): Int {
return if (settingsPreferencesApi.linkSimpleList) {
SimpleLinkViewHolder.getViewTypeForLink(data[position])
SimpleLinkViewHolder.getViewTypeForLink(dataset[position]!!)
} else {
LinkViewHolder.getViewTypeForLink(data[position], settingsPreferencesApi)
LinkViewHolder.getViewTypeForLink(dataset[position]!!, settingsPreferencesApi)
}
}

Expand All @@ -45,14 +45,14 @@ class LinksAdapter @Inject constructor(val userManagerApi: UserManagerApi, val s

override fun bindHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
when (holder) {
is LinkViewHolder -> holder.bindView(data[position])
is SimpleLinkViewHolder -> holder.bindView(data[position])
is BlockedViewHolder -> holder.bindView(data[position])
is LinkViewHolder -> holder.bindView(dataset[position]!!)
is SimpleLinkViewHolder -> holder.bindView(dataset[position]!!)
is BlockedViewHolder -> holder.bindView(dataset[position]!!)
}
}

fun updateLink(link : Link) {
val position = data.indexOf(link)
val position = dataset.indexOf(link)
dataset[position] = link
notifyItemChanged(position)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ interface NotificationsListView : BaseView {
fun addNotifications(notifications : List<Notification>, shouldClearAdapter : Boolean)
fun disableLoading()
fun showReadToast()
fun showTooManyNotifications()
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,8 @@ class HashTagsNotificationsListFragment : BaseNotificationsListFragment() {
PagedDataModel(presenter.page, notificationAdapter.data)
}

override fun showTooManyNotifications() {
Toast.makeText(context, "Zbyt wiele powiadomień, funkcja grupowania wyłączona", Toast.LENGTH_LONG).show()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ class HashTagsNotificationsListPresenter(val schedulers: Schedulers, val notific
}

fun loadAllNotifications(shouldRefresh: Boolean) {
compositeObservable.add(
notificationsApi.getHashTagNotificationCount()
.subscribeOn(schedulers.backgroundThread())
.observeOn(schedulers.mainThread())
.subscribe({
if (it.count > 325) {
view?.showTooManyNotifications()
} else {
fetchAllPages(shouldRefresh)
}
}, { view?.showErrorDialog(it) })
)

}

fun fetchAllPages(shouldRefresh: Boolean) {
if (shouldRefresh) page = 1
val allData = arrayListOf<Notification>()
var dataEmpty = false
Expand Down Expand Up @@ -64,6 +80,5 @@ class HashTagsNotificationsListPresenter(val schedulers: Schedulers, val notific
view?.disableLoading()
}
}, { view?.showErrorDialog(it) }))

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ class NotificationsListFragment : BaseNotificationsListFragment() {
super.onSaveInstanceState(outState)
entryFragmentData.data = PagedDataModel(presenter.page, notificationAdapter.data)
}

override fun showTooManyNotifications() {
}
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ allprojects {
project.ext {
versionMajor = 0
versionMinor = 9
versionPatch = 5
versionBuild = 1
versionPatch = 6
versionBuild = 0
}
}

Expand Down

0 comments on commit 50cbdd8

Please sign in to comment.