OSDN Git Service

namespaceを少し整理。
[gokigen/mangle.git] / app / src / main / java / jp / osdn / gokigen / gokigenassets / camera / vendor / pixpro / operation / CameraPowerOffPixpro.kt
1 package jp.osdn.gokigen.gokigenassets.camera.vendor.pixpro.operation
2
3 import android.content.Context
4 import androidx.preference.Preference
5 import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert
6 import jp.osdn.gokigen.gokigenassets.scene.IChangeSceneBasic
7 import jp.osdn.gokigen.gokigenassets.utils.ConfirmationDialog
8
9 class CameraPowerOffPixpro(private val context: Context, private val changeScene: IChangeSceneBasic) : Preference.OnPreferenceClickListener, ConfirmationDialog.ConfirmationCallback
10 {
11     private var preferenceKey: String? = null
12
13     /**
14      * クラスの準備
15      *
16      */
17     fun prepare()
18     {
19         // 何もしない
20     }
21
22     /**
23      *
24      *
25      * @param preference クリックしたpreference
26      * @return false : ハンドルしない / true : ハンドルした
27      */
28     override fun onPreferenceClick(preference: Preference): Boolean
29     {
30         if (!preference.hasKey())
31         {
32             return false
33         }
34         preferenceKey = preference.key
35         val isContain = preferenceKey?.contains(IApplicationConstantConvert.ID_PREFERENCE_LABEL_EXIT_APPLICATION)
36         if ((isContain != null)&&(isContain))
37         {
38
39             // 確認ダイアログの生成と表示
40             val dialog: ConfirmationDialog = ConfirmationDialog.newInstance(context)
41             dialog.show(IApplicationConstantConvert.ID_DIALOG_TITLE_CONFIRMATION, IApplicationConstantConvert.ID_DIALOG_EXIT_POWER_OFF, this)
42             return true
43         }
44         return false
45     }
46
47     /**
48      *
49      *
50      */
51     override fun confirm()
52     {
53         val isContain = preferenceKey?.contains(IApplicationConstantConvert.ID_PREFERENCE_LABEL_EXIT_APPLICATION)
54         if ((isContain != null)&&(isContain))
55         {
56             // カメラの電源をOFFにしたうえで、アプリケーションを終了する。
57             changeScene.exitApplication()
58         }
59     }
60 }