1 package jp.osdn.gokigen.gokigenassets.camera.vendor.ricohpentax.operation
3 import android.content.Context
4 import androidx.preference.Preference
5 import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_DIALOG_EXIT_POWER_OFF
6 import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_DIALOG_TITLE_CONFIRMATION
7 import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Companion.ID_PREFERENCE_LABEL_EXIT_APPLICATION
8 import jp.osdn.gokigen.gokigenassets.scene.IChangeSceneBasic
9 import jp.osdn.gokigen.gokigenassets.utils.ConfirmationDialog
11 class RicohGr2CameraPowerOff(private val context: Context, private val changeScene: IChangeSceneBasic) : Preference.OnPreferenceClickListener, ConfirmationDialog.ConfirmationCallback
13 private var preferenceKey: String? = null
26 * @param preference クリックしたpreference
27 * @return false : ハンドルしない / true : ハンドルした
29 override fun onPreferenceClick(preference: Preference): Boolean {
30 if (!preference.hasKey()) {
33 preferenceKey = preference.key
34 val isContain = preferenceKey?.contains(ID_PREFERENCE_LABEL_EXIT_APPLICATION)
35 if ((isContain != null)&&(isContain))
39 val dialog: ConfirmationDialog = ConfirmationDialog.newInstance(context)
40 dialog.show(ID_DIALOG_TITLE_CONFIRMATION, ID_DIALOG_EXIT_POWER_OFF, this)
50 override fun confirm()
52 val isContain = preferenceKey?.contains(ID_PREFERENCE_LABEL_EXIT_APPLICATION)
53 if ((isContain != null)&&(isContain))
55 // カメラの電源をOFFにしたうえで、アプリケーションを終了する。
56 changeScene.exitApplication()