Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sdex committed Sep 5, 2023
1 parent f5971fa commit c812b15
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.widget.PopupMenu
import android.widget.Toast
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia
import androidx.appcompat.app.AppCompatActivity
import androidx.core.graphics.drawable.toBitmap
import androidx.core.widget.doOnTextChanged
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
Expand Down Expand Up @@ -63,24 +62,17 @@ class AddShortcutDialogActivity : AppCompatActivity(), IconDialog.Callback {
val activityModel = intent?.serializable<ActivityModel>(ARG_ACTIVITY_MODEL)
val historyModel = intent?.serializable<HistoryModel>(ARG_HISTORY_MODEL)

binding.label.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
binding.label.doOnTextChanged { _, _, _, count ->
binding.valueLayout.endIconMode = if (count == 0) {
TextInputLayout.END_ICON_DROPDOWN_MENU
} else {
TextInputLayout.END_ICON_CLEAR_TEXT
}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
binding.valueLayout.endIconMode =
if (count != 0) TextInputLayout.END_ICON_CLEAR_TEXT
else TextInputLayout.END_ICON_DROPDOWN_MENU
}

override fun afterTextChanged(s: Editable?) {
}
})
}
binding.label.setText(activityModel?.label)
binding.label.text?.let { binding.label.setSelection(it.length) }
binding.label.setSimpleItems(arrayOf(activityModel?.label, activityModel?.name))


val loader = IconPackLoader(applicationContext)
iconPack = createMaterialDesignIconPack(loader)
iconPack?.loadDrawables(loader.drawableLoader)
Expand Down

0 comments on commit c812b15

Please sign in to comment.