Skip to content
Snippets Groups Projects
Commit 03d76d15 authored by John Carlson's avatar John Carlson
Browse files

No more TextUtils

parent b1d0faa7
No related branches found
No related tags found
No related merge requests found
Showing
with 49 additions and 68 deletions
Loading
Loading
@@ -10,7 +10,6 @@ import android.support.design.widget.TextInputLayout
import android.support.v7.app.AlertDialog
import android.support.v7.widget.SwitchCompat
import android.support.v7.widget.Toolbar
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
Loading
Loading
@@ -28,6 +27,7 @@ import com.commit451.gitlab.adapter.AssigneeSpinnerAdapter
import com.commit451.gitlab.adapter.MilestoneSpinnerAdapter
import com.commit451.gitlab.event.IssueChangedEvent
import com.commit451.gitlab.event.IssueCreatedEvent
import com.commit451.gitlab.extension.checkValid
import com.commit451.gitlab.extension.setup
import com.commit451.gitlab.model.api.*
import com.commit451.gitlab.navigation.Navigator
Loading
Loading
@@ -218,10 +218,10 @@ class AddIssueActivity : MorphActivity() {
}
 
private fun bindIssue() {
if (!TextUtils.isEmpty(issue!!.title)) {
if (!issue?.title.isNullOrEmpty()) {
textInputLayoutTitle.editText!!.setText(issue!!.title)
}
if (!TextUtils.isEmpty(issue!!.description)) {
if (!issue?.description.isNullOrEmpty()) {
textDescription.setText(issue!!.description)
}
switchConfidential.isChecked = issue!!.isConfidential
Loading
Loading
@@ -278,9 +278,8 @@ class AddIssueActivity : MorphActivity() {
}
 
private fun save() {
if (!TextUtils.isEmpty(textInputLayoutTitle.editText!!.text)) {
if (textInputLayoutTitle.checkValid()) {
teleprinter.hideKeyboard()
textInputLayoutTitle.error = null
showLoading()
var assigneeId: Long? = null
if (spinnerAssignee.adapter != null) {
Loading
Loading
@@ -312,8 +311,6 @@ class AddIssueActivity : MorphActivity() {
milestoneId,
labelsCommaSeperated,
switchConfidential.isChecked)
} else {
textInputLayoutTitle.error = getString(R.string.required_field)
}
}
 
Loading
Loading
Loading
Loading
@@ -7,7 +7,6 @@ import android.os.Parcelable
import android.support.design.widget.Snackbar
import android.support.design.widget.TextInputLayout
import android.support.v7.widget.Toolbar
import android.text.TextUtils
import android.view.View
import android.widget.Button
import android.widget.EditText
Loading
Loading
@@ -20,6 +19,7 @@ import com.commit451.gitlab.App
import com.commit451.gitlab.R
import com.commit451.gitlab.event.MilestoneChangedEvent
import com.commit451.gitlab.event.MilestoneCreatedEvent
import com.commit451.gitlab.extension.checkValid
import com.commit451.gitlab.extension.setup
import com.commit451.gitlab.model.api.Milestone
import com.commit451.gitlab.rx.CustomSingleObserver
Loading
Loading
@@ -115,8 +115,7 @@ class AddMilestoneActivity : MorphActivity() {
 
fun createMilestone() {
teleprinter.hideKeyboard()
if (TextUtils.isEmpty(textTitle.text)) {
textInputLayoutTitle.error = getString(R.string.required_field)
if (!textInputLayoutTitle.checkValid()) {
return
}
 
Loading
Loading
Loading
Loading
@@ -9,7 +9,6 @@ import android.support.annotation.ColorInt
import android.support.design.widget.Snackbar
import android.support.design.widget.TextInputLayout
import android.support.v7.widget.Toolbar
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
Loading
Loading
@@ -21,6 +20,7 @@ import com.afollestad.materialdialogs.color.ColorChooserDialog
import com.commit451.gitlab.App
import com.commit451.gitlab.R
import com.commit451.gitlab.extension.checkValid
import com.commit451.gitlab.extension.text
import com.commit451.gitlab.model.api.Label
import com.commit451.gitlab.rx.CustomResponseSingleObserver
import com.commit451.gitlab.util.ColorUtil
Loading
Loading
@@ -105,9 +105,9 @@ class AddNewLabelActivity : BaseActivity(), ColorChooserDialog.ColorCallback {
.show()
return
}
val title = textInputLayoutTitle.editText!!.text.toString()
val title = textInputLayoutTitle.text()
var description: String? = null
if (!TextUtils.isEmpty(textDescription.text)) {
if (!textDescription.text.isNullOrEmpty()) {
description = textDescription.text.toString()
}
var color: String? = null
Loading
Loading
Loading
Loading
@@ -10,7 +10,6 @@ import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.Toolbar
import android.text.TextUtils
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
Loading
Loading
@@ -87,8 +86,8 @@ class AddUserActivity : MorphActivity() {
}
 
@OnEditorAction(R.id.search)
internal fun onEditorAction(): Boolean {
if (!TextUtils.isEmpty(textSearch.text)) {
fun onEditorAction(): Boolean {
if (!textSearch.text.isNullOrEmpty()) {
query = textSearch.text.toString()
loadData()
}
Loading
Loading
@@ -96,8 +95,8 @@ class AddUserActivity : MorphActivity() {
}
 
@OnTextChanged(R.id.search)
internal fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
if (TextUtils.isEmpty(s)) {
fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
if (s.isNullOrEmpty()) {
buttonClear.animate()
.alpha(0.0f)
.withEndAction(HideRunnable(buttonClear))
Loading
Loading
Loading
Loading
@@ -6,7 +6,6 @@ import android.os.Bundle
import android.support.design.widget.TabLayout
import android.support.v4.view.ViewPager
import android.support.v7.widget.Toolbar
import android.text.TextUtils
import android.view.View
import android.widget.EditText
import butterknife.*
Loading
Loading
@@ -56,7 +55,7 @@ class SearchActivity : BaseActivity() {
 
@OnEditorAction(R.id.search)
fun onSearchEditorAction(): Boolean {
if (TextUtils.isEmpty(textSearch.text)) {
if (textSearch.text.isNullOrEmpty()) {
textSearch.setText("labcoat")
}
search()
Loading
Loading
@@ -66,7 +65,7 @@ class SearchActivity : BaseActivity() {
 
@OnTextChanged(R.id.search)
fun onSearchTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
if (TextUtils.isEmpty(s)) {
if (s.isNullOrEmpty()) {
buttonClear.animate().alpha(0.0f).withEndAction { buttonClear.visibility = View.GONE }
} else if (count == 1) {
buttonClear.visibility = View.VISIBLE
Loading
Loading
package com.commit451.gitlab.api.converter
import com.bluelinelabs.logansquare.typeconverters.DateTypeConverter
import com.commit451.gitlab.model.api.Milestone
import java.text.DateFormat
/**
* Converts due dates
*/
class DueDateTypeConverter() : DateTypeConverter() {
override fun getDateFormat(): DateFormat {
return Milestone.DUE_DATE_FORMAT
}
}
\ No newline at end of file
Loading
Loading
@@ -4,7 +4,6 @@ import android.os.Bundle
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Loading
Loading
@@ -99,7 +98,7 @@ class CommitsFragment : ButterKnifeFragment() {
return
}
 
if (project == null || TextUtils.isEmpty(branchName)) {
if (project == null || branchName.isNullOrEmpty()) {
swipeRefreshLayout.isRefreshing = false
return
}
Loading
Loading
@@ -145,7 +144,7 @@ class CommitsFragment : ButterKnifeFragment() {
return
}
 
if (project == null || TextUtils.isEmpty(branchName) || page < 0) {
if (project == null || branchName.isNullOrEmpty() || page < 0) {
return
}
 
Loading
Loading
Loading
Loading
@@ -8,7 +8,6 @@ import android.support.design.widget.Snackbar
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Loading
Loading
@@ -139,7 +138,7 @@ class FilesFragment : ButterKnifeFragment() {
return
}
 
if (project == null || TextUtils.isEmpty(branchName)) {
if (project == null || branchName.isNullOrEmpty()) {
swipeRefreshLayout.isRefreshing = false
return
}
Loading
Loading
Loading
Loading
@@ -6,7 +6,6 @@ import android.support.design.widget.Snackbar
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.app.AlertDialog
import android.text.Html
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Loading
Loading
@@ -177,7 +176,7 @@ class ProjectFragment : ButterKnifeFragment() {
return
}
 
if (project == null || TextUtils.isEmpty(branchName)) {
if (project == null || branchName.isNullOrEmpty()) {
swipeRefreshLayout.isRefreshing = false
return
}
Loading
Loading
Loading
Loading
@@ -5,7 +5,6 @@ import android.os.Bundle
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Loading
Loading
@@ -100,7 +99,7 @@ class UsersFragment : ButterKnifeFragment() {
return
}
 
if (TextUtils.isEmpty(query)) {
if (query.isNullOrEmpty()) {
swipeRefreshLayout.isRefreshing = false
return
}
Loading
Loading
Loading
Loading
@@ -2,22 +2,19 @@ package com.commit451.gitlab.model.api;
 
import android.support.annotation.Nullable;
import android.support.annotation.StringDef;
import android.text.TextUtils;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.commit451.gitlab.api.converter.DueDateTypeConverter;
 
import org.parceler.Parcel;
 
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
 
import timber.log.Timber;
@Parcel
@JsonObject
public class Milestone {
Loading
Loading
@@ -53,8 +50,8 @@ public class Milestone {
Date createdAt;
@JsonField(name = "updated_at")
Date updatedAt;
@JsonField(name = "due_date")
String dueDate;
@JsonField(name = "due_date", typeConverter = DueDateTypeConverter.class)
Date dueDate;
 
public Milestone() {}
 
Loading
Loading
@@ -78,7 +75,6 @@ public class Milestone {
return description;
}
 
@State
public String getState() {
return state;
Loading
Loading
@@ -94,15 +90,7 @@ public class Milestone {
 
@Nullable
public Date getDueDate() {
if (TextUtils.isEmpty(dueDate)) {
return null;
}
try {
return DUE_DATE_FORMAT.parse(dueDate);
} catch (ParseException e) {
Timber.e(e);
}
return null;
return dueDate;
}
 
@Override
Loading
Loading
Loading
Loading
@@ -3,7 +3,6 @@ package com.commit451.gitlab.util
import android.content.Intent
import android.net.Uri
import android.support.design.widget.Snackbar
import android.text.TextUtils
import android.view.View
import com.commit451.easel.Easel
import com.commit451.gitlab.R
Loading
Loading
@@ -21,7 +20,7 @@ object IntentUtil {
if (!activity.hasBrowsableLinks()) {
throw IllegalStateException("You need to override hasBrowsableLinks and return true!")
}
if (TextUtils.isEmpty(url)) {
if (url.isNullOrEmpty()) {
return
}
 
Loading
Loading
package com.commit451.gitlab.viewHolder
 
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Loading
Loading
@@ -63,10 +62,10 @@ class DiffHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
* This extracts the trailing part of the textTitle as it is displayed in the GitLabService web interface
* (the commit message also contains the commit textTitle)
*/
private fun extractMessage(title: String, message: String): String {
if (!TextUtils.isEmpty(message)) {
val ellipsis = title.endsWith("\u2026") && message[title.length - 1] != '\u2026'
val trailing = message.substring(title.length - if (ellipsis) 1 else 0)
private fun extractMessage(title: String, message: String?): String {
if (!message.isNullOrEmpty()) {
val ellipsis = title.endsWith("\u2026") && message!![title.length - 1] != '\u2026'
val trailing = message!!.substring(title.length - if (ellipsis) 1 else 0)
return if (trailing == "\u2026") "" else ((if (ellipsis) "\u2026" else "") + trailing).trim { it <= ' ' }
}
return title
Loading
Loading
Loading
Loading
@@ -2,7 +2,6 @@ package com.commit451.gitlab.viewHolder
 
import `in`.uncod.android.bypass.Bypass
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Loading
Loading
@@ -49,7 +48,7 @@ class IssueHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
 
fun bind(issue: Issue, project: Project) {
 
if (TextUtils.isEmpty(issue.description)) {
if (issue.description.isNullOrEmpty()) {
textDescription.visibility = View.GONE
} else {
textDescription.visibility = View.VISIBLE
Loading
Loading
Loading
Loading
@@ -2,7 +2,6 @@ package com.commit451.gitlab.viewHolder
 
import `in`.uncod.android.bypass.Bypass
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Loading
Loading
@@ -44,7 +43,7 @@ class MergeRequestHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
}
 
fun bind(mergeRequest: MergeRequest, bypass: Bypass, project: Project) {
if (TextUtils.isEmpty(mergeRequest.description)) {
if (mergeRequest.description.isNullOrEmpty()) {
textDescription.visibility = View.GONE
} else {
textDescription.visibility = View.VISIBLE
Loading
Loading
Loading
Loading
@@ -3,7 +3,6 @@ package com.commit451.gitlab.viewHolder
import android.graphics.Color
import android.net.Uri
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Loading
Loading
@@ -60,7 +59,7 @@ class ProjectViewHolder(view: View) : RecyclerView.ViewHolder(view) {
}
 
textTitle.text = project.nameWithNamespace
if (!TextUtils.isEmpty(project.description)) {
if (!project.description.isNullOrEmpty()) {
textDescription.visibility = View.VISIBLE
textDescription.text = project.description
} else {
Loading
Loading
Loading
Loading
@@ -2,11 +2,8 @@ package com.commit451.gitlab.widget
 
import android.content.Context
import android.content.SharedPreferences
import android.text.TextUtils
import com.bluelinelabs.logansquare.LoganSquare
import com.commit451.gitlab.model.Account
import java.io.IOException
 
/**
Loading
Loading
@@ -25,14 +22,13 @@ object ProjectFeedWidgetPrefs {
 
fun getAccount(context: Context, widgetId: Int): Account? {
val accountsJson = getSharedPrefs(context).getString(widgetId.toString() + KEY_ACCOUNT, null)
if (!TextUtils.isEmpty(accountsJson)) {
if (!accountsJson.isNullOrEmpty()) {
try {
return LoganSquare.parse(accountsJson, Account::class.java)
} catch (e: IOException) {
//why would this ever happen?!?!?1
getSharedPrefs(context).edit().remove(widgetId.toString() + KEY_ACCOUNT).commit()
}
}
return null
}
Loading
Loading
Loading
Loading
@@ -2,11 +2,8 @@ package com.commit451.gitlab.widget
 
import android.content.Context
import android.content.SharedPreferences
import android.text.TextUtils
import com.bluelinelabs.logansquare.LoganSquare
import com.commit451.gitlab.model.Account
import java.io.IOException
 
/**
Loading
Loading
@@ -24,7 +21,7 @@ object UserFeedWidgetPrefs {
 
fun getAccount(context: Context, widgetId: Int): Account? {
val accountsJson = getSharedPrefs(context).getString(widgetId.toString() + KEY_ACCOUNT, null)
if (!TextUtils.isEmpty(accountsJson)) {
if (!accountsJson.isNullOrEmpty()) {
try {
return LoganSquare.parse(accountsJson, Account::class.java)
} catch (e: IOException) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment