Skip to content

Commit

Permalink
Fix minor issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Sep 6, 2018
1 parent 0e021ad commit fe90b25
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Habitica/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.habitrpg.android.habitica"
android:versionCode="1992"
android:versionCode="1994"
android:versionName="1.5"
android:screenOrientation="portrait"
android:installLocation="auto" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ open class Task : RealmObject, Parcelable {
var parsedText: CharSequence? = null
@Ignore
var parsedNotes: CharSequence? = null
set(value) {
field = value
repeat?.taskId = id
}

var isDue: Boolean? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.habitrpg.android.habitica.helpers.RxErrorHandler
import com.habitrpg.android.habitica.models.user.User
import com.habitrpg.android.habitica.proxy.CrashlyticsProxy
import com.habitrpg.android.habitica.ui.activities.GemPurchaseActivity
import com.habitrpg.android.habitica.ui.helpers.bindOptionalView
import com.habitrpg.android.habitica.ui.helpers.bindView
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import com.habitrpg.android.habitica.ui.views.subscriptions.SubscriptionDetailsView
Expand Down Expand Up @@ -62,7 +63,7 @@ class SubscriptionFragment : BaseFragment(), GemPurchaseActivity.CheckoutFragmen
private val subscription6MonthView: SubscriptionOptionView? by bindView(R.id.subscription6month)
private val subscription12MonthView: SubscriptionOptionView? by bindView(R.id.subscription12month)

private val subscriptionButton: Button? by bindView(R.id.subscribeButton)
private val subscriptionButton: Button? by bindOptionalView(R.id.subscribeButton)
private val subscriptionDetailsView: SubscriptionDetailsView? by bindView(R.id.subscriptionDetails)
private val subscribeBenefitsTitle: TextView? by bindView(R.id.subscribeBenefitsTitle)
private val supportTextView: TextView? by bindView(R.id.supportTextView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ open class TaskRecyclerViewFragment : BaseFragment(), View.OnClickListener, Swip
if (fromPosition == null) {
fromPosition = viewHolder.adapterPosition
}
if (movingTaskID == null) {
if (movingTaskID == null && (viewHolder as? BaseTaskViewHolder)?.task?.isValid == true) {
movingTaskID = (viewHolder as? BaseTaskViewHolder)?.task?.id
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class BaseTaskViewHolder constructor(itemView: View) : RecyclerView.Vie
var errorButtonClicked: Action? = null
protected var context: Context
private val titleTextView: EllipsisTextView by bindView(itemView, R.id.checkedTextView)
private val notesTextView: EllipsisTextView by bindView(itemView, R.id.notesTextView)
private val notesTextView: EllipsisTextView? by bindView(itemView, R.id.notesTextView)
internal val rightBorderView: View? by bindOptionalView(itemView, R.id.rightBorderView)
protected val specialTaskTextView: TextView? by bindOptionalView(itemView, R.id.specialTaskText)
private val iconViewChallenge: ImageView? by bindView(itemView, R.id.iconviewChallenge)
Expand Down Expand Up @@ -79,7 +79,7 @@ abstract class BaseTaskViewHolder constructor(itemView: View) : RecyclerView.Vie
//titleTextView.movementMethod = LinkMovementMethod.getInstance()

expandNotesButton?.setOnClickListener { expandTask() }
notesTextView.addEllipsesListener(object : EllipsisTextView.EllipsisListener {
notesTextView?.addEllipsesListener(object : EllipsisTextView.EllipsisListener {
override fun ellipsisStateChanged(ellipses: Boolean) {
Single.just(ellipses)
.subscribeOn(Schedulers.io())
Expand All @@ -96,10 +96,10 @@ abstract class BaseTaskViewHolder constructor(itemView: View) : RecyclerView.Vie
private fun expandTask() {
notesExpanded = !notesExpanded
if (notesExpanded) {
notesTextView.maxLines = 100
notesTextView?.maxLines = 100
expandNotesButton?.text = context.getString(R.string.collapse_notes)
} else {
notesTextView.maxLines = 3
notesTextView?.maxLines = 3
expandNotesButton?.text = context.getString(R.string.expand_notes)
}
}
Expand All @@ -109,43 +109,50 @@ abstract class BaseTaskViewHolder constructor(itemView: View) : RecyclerView.Vie
itemView.setBackgroundResource(R.color.white)

if (newTask.notes?.isNotEmpty() == true) {
notesTextView.visibility = View.VISIBLE
notesTextView?.visibility = View.VISIBLE
//expandNotesButton.visibility = if (notesTextView.hadEllipses() || notesExpanded) View.VISIBLE else View.GONE
} else {
notesTextView.visibility = View.GONE
notesTextView?.visibility = View.GONE
expandNotesButton?.visibility = View.GONE
}

if (canContainMarkdown()) {
if (newTask.parsedText != null) {
titleTextView.text = newTask.parsedText
notesTextView.text = newTask.parsedNotes
} else {
titleTextView.text = newTask.text
notesTextView.text = newTask.notes
Single.just(newTask.text)
.map { MarkdownParser.parseMarkdown(it) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer{ parsedText ->
newTask.parsedText = parsedText
titleTextView.text = newTask.parsedText
}, RxErrorHandler.handleEmptyError())
if (newTask.text.isNotEmpty()) {
Single.just(newTask.text)
.map { MarkdownParser.parseMarkdown(it) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer{ parsedText ->
newTask.parsedText = parsedText
titleTextView.text = parsedText
}, RxErrorHandler.handleEmptyError())
}
if (newTask.parsedNotes != null) {
notesTextView?.text = newTask.parsedNotes
} else {
notesTextView?.text = newTask.notes
newTask.notes.notNull {notes ->
if (notes.isEmpty()) {
return@notNull
}
Single.just(notes)
.map { MarkdownParser.parseMarkdown(it) }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer { parsedNotes ->
newTask.parsedNotes = parsedNotes
notesTextView.text = newTask.parsedNotes
notesTextView?.text = parsedNotes
}, RxErrorHandler.handleEmptyError())
}

}
}
} else {
titleTextView.text = newTask.text
notesTextView.text = newTask.notes
notesTextView?.text = newTask.notes
}

rightBorderView?.setBackgroundResource(newTask.lightTaskColor)
Expand Down

0 comments on commit fe90b25

Please sign in to comment.