|
1 | 1 | package me.blog.korn123.easydiary.fragments
|
2 | 2 |
|
3 | 3 | import android.app.Activity
|
| 4 | +import android.content.Context |
4 | 5 | import android.content.DialogInterface
|
5 | 6 | import android.content.Intent
|
6 | 7 | import android.os.Bundle
|
@@ -41,15 +42,17 @@ class SettingsGMSBackupFragment() : androidx.fragment.app.Fragment() {
|
41 | 42 | ***************************************************************************************************/
|
42 | 43 | private lateinit var progressContainer: ConstraintLayout
|
43 | 44 | private lateinit var mRootView: ViewGroup
|
| 45 | + private lateinit var mContext: Context |
44 | 46 | private var mTaskFlag = 0
|
45 | 47 | private val mActivity: Activity
|
46 | 48 | get() = activity!!
|
47 | 49 |
|
48 | 50 |
|
49 |
| - /*************************************************************************************************** |
50 |
| - * override functions |
51 |
| - * |
52 |
| - ***************************************************************************************************/ |
| 51 | + override fun onAttach(context: Context) { |
| 52 | + super.onAttach(context) |
| 53 | + this.mContext = context |
| 54 | + } |
| 55 | + |
53 | 56 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
54 | 57 | mRootView = inflater.inflate(R.layout.layout_settings_backup_gms, container, false) as ViewGroup
|
55 | 58 | return mRootView
|
@@ -133,7 +136,7 @@ class SettingsGMSBackupFragment() : androidx.fragment.app.Fragment() {
|
133 | 136 | progressContainer.visibility = View.VISIBLE
|
134 | 137 | val realmPath = EasyDiaryDbHelper.getRealmPath()
|
135 | 138 | initGoogleSignAccount(this) { account ->
|
136 |
| - DriveServiceHelper(mActivity, account).run { |
| 139 | + DriveServiceHelper(mContext, account).run { |
137 | 140 | initDriveWorkingDirectory(DriveServiceHelper.AAF_EASY_DIARY_REALM_FOLDER_NAME) {
|
138 | 141 | createFile(
|
139 | 142 | it!!, realmPath,
|
@@ -162,7 +165,7 @@ class SettingsGMSBackupFragment() : androidx.fragment.app.Fragment() {
|
162 | 165 |
|
163 | 166 | private fun openRealmFilePickerDialog() {
|
164 | 167 | initGoogleSignAccount(this) { account ->
|
165 |
| - val driveServiceHelper = DriveServiceHelper(mActivity, account) |
| 168 | + val driveServiceHelper = DriveServiceHelper(mContext, account) |
166 | 169 |
|
167 | 170 | // driveServiceHelper.queryFiles("mimeType contains 'text/aaf_v' and name contains '$DIARY_DB_NAME'", 1000)
|
168 | 171 |
|
@@ -231,7 +234,7 @@ class SettingsGMSBackupFragment() : androidx.fragment.app.Fragment() {
|
231 | 234 | mActivity.setScreenOrientationSensor(false)
|
232 | 235 | progressContainer.visibility = View.VISIBLE
|
233 | 236 | initGoogleSignAccount(this) { account ->
|
234 |
| - DriveServiceHelper(mActivity, account).run { |
| 237 | + DriveServiceHelper(mContext, account).run { |
235 | 238 | initDriveWorkingDirectory(DriveServiceHelper.AAF_EASY_DIARY_PHOTO_FOLDER_NAME) { photoFolderId ->
|
236 | 239 | progressContainer.visibility = View.GONE
|
237 | 240 | mActivity.run {
|
|
0 commit comments