mirror of
				https://github.com/SimpleMobileTools/Simple-App-Launcher.git
				synced 2025-06-05 21:49:21 +02:00 
			
		
		
		
	couple style edits to the recycler adapter
This commit is contained in:
		| @@ -29,19 +29,19 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i | |||||||
|         var actMode: ActionMode? = null |         var actMode: ActionMode? = null | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     val deleteMode = object : ModalMultiSelectorCallback(multiSelector) { |     val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { | ||||||
|         override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean { |         override fun onActionItemClicked(mode: ActionMode?, item: MenuItem): Boolean { | ||||||
|             when (item?.itemId) { |             return when (item.itemId) { | ||||||
|                 R.id.cab_edit -> { |                 R.id.cab_edit -> { | ||||||
|                     showEditDialog() |                     showEditDialog() | ||||||
|                     return true |                     true | ||||||
|                 } |                 } | ||||||
|                 R.id.cab_delete -> { |                 R.id.cab_delete -> { | ||||||
|                     deleteSelectedItems() |                     deleteSelectedItems() | ||||||
|                     return true |                     true | ||||||
|                 } |                 } | ||||||
|  |                 else -> false | ||||||
|             } |             } | ||||||
|             return false |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         override fun onCreateActionMode(actionMode: ActionMode?, menu: Menu?): Boolean { |         override fun onCreateActionMode(actionMode: ActionMode?, menu: Menu?): Boolean { | ||||||
| @@ -64,7 +64,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onBindViewHolder(holder: ViewHolder, position: Int) { |     override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||||||
|         holder.bindView(act, deleteMode, multiSelector, launchers[position]) |         holder.bindView(act, multiSelectorMode, multiSelector, launchers[position]) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { |     override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { | ||||||
| @@ -81,23 +81,21 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i | |||||||
|         val editView = act.layoutInflater.inflate(R.layout.edit_launcher, null) |         val editView = act.layoutInflater.inflate(R.layout.edit_launcher, null) | ||||||
|         editView.edit_launcher_edittext.setText(selectedLauncher.name) |         editView.edit_launcher_edittext.setText(selectedLauncher.name) | ||||||
|  |  | ||||||
|         val builder = AlertDialog.Builder(act) |         AlertDialog.Builder(act).apply { | ||||||
|         builder.setTitle(act.getString(R.string.rename_launcher)) |             setTitle(act.getString(R.string.rename_launcher)) | ||||||
|         builder.setView(editView) |             setView(editView) | ||||||
|  |             setPositiveButton(R.string.ok, null) | ||||||
|         builder.setPositiveButton(R.string.ok, null) |             setNegativeButton(R.string.cancel, null) | ||||||
|         builder.setNegativeButton(R.string.cancel, null) |             create().apply { | ||||||
|  |                 window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) | ||||||
|         val alertDialog = builder.create() |                 show() | ||||||
|         alertDialog.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) |                 getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { | ||||||
|         alertDialog.show() |  | ||||||
|         alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { |  | ||||||
|                     val newName = editView.edit_launcher_edittext.text.toString().trim() |                     val newName = editView.edit_launcher_edittext.text.toString().trim() | ||||||
|                     if (!newName.isEmpty()) { |                     if (!newName.isEmpty()) { | ||||||
|                         if (DbHelper(act).updateLauncherName(selectedLauncher.id, newName) > 0) { |                         if (DbHelper(act).updateLauncherName(selectedLauncher.id, newName) > 0) { | ||||||
|                             (act as RecyclerInterface).launcherRenamed() |                             (act as RecyclerInterface).launcherRenamed() | ||||||
|                             finishActionMode() |                             finishActionMode() | ||||||
|                     alertDialog.dismiss() |                             dismiss() | ||||||
|                         } else { |                         } else { | ||||||
|                             act.toast(R.string.unknown_error) |                             act.toast(R.string.unknown_error) | ||||||
|                         } |                         } | ||||||
| @@ -106,6 +104,8 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     fun finishActionMode() { |     fun finishActionMode() { | ||||||
|         actMode?.finish() |         actMode?.finish() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user