質問編集履歴
5
LoginFragmentのコードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -180,89 +180,39 @@
|
|
180
180
|
|
181
181
|
|
182
182
|
|
183
|
-
```
|
183
|
+
```LoginFragment
|
184
|
-
|
184
|
+
|
185
|
-
package com.example.a
|
185
|
+
package com.example.a.Security.Login
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
186
|
+
|
190
|
-
|
191
|
-
|
187
|
+
|
192
188
|
|
193
189
|
import android.content.ContentValues.TAG
|
194
190
|
|
195
|
-
import android.c
|
191
|
+
import androidx.lifecycle.ViewModelProvider
|
196
192
|
|
197
193
|
import android.os.Bundle
|
198
194
|
|
199
195
|
import android.util.Log
|
200
196
|
|
201
|
-
import androidx.fragment.app.
|
197
|
+
import androidx.fragment.app.Fragment
|
198
|
+
|
202
|
-
|
199
|
+
import android.view.LayoutInflater
|
200
|
+
|
201
|
+
import android.view.View
|
202
|
+
|
203
|
+
import android.view.ViewGroup
|
204
|
+
|
203
|
-
import androidx.navigation.Nav
|
205
|
+
import androidx.navigation.fragment.NavHostFragment
|
204
206
|
|
205
207
|
import androidx.navigation.fragment.findNavController
|
206
208
|
|
207
|
-
|
209
|
+
import com.example.a.R
|
208
|
-
|
210
|
+
|
209
|
-
cla
|
211
|
+
import com.example.a.databinding.LoginFragmentBinding
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
212
|
+
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
return activity?.let {
|
218
|
-
|
219
|
-
val builder = AlertDialog.Builder(it)
|
220
|
-
|
221
|
-
builder.setTitle("この機能を利用するには\nユーザー登録が必要です")
|
222
|
-
|
223
|
-
.setItems(
|
224
|
-
|
225
|
-
R.array.aiueo,
|
226
|
-
|
227
|
-
|
213
|
+
import com.google.firebase.auth.FirebaseAuth
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
214
|
+
|
232
|
-
|
233
|
-
|
215
|
+
|
234
|
-
|
235
|
-
findNavController().navigate(R.id.action_profFragment_to_loginFragment)
|
236
|
-
|
237
|
-
Log.d(TAG, "登録する")
|
238
|
-
|
239
|
-
}
|
240
|
-
|
241
|
-
1 -> {
|
242
|
-
|
243
|
-
Log.d(TAG, "今はしない")
|
244
|
-
|
245
|
-
}
|
246
|
-
|
247
|
-
}
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
})
|
252
|
-
|
253
|
-
builder.create()
|
254
|
-
|
255
|
-
} ?: throw IllegalStateException("Activity cannot be null")
|
256
|
-
|
257
|
-
}
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
```
|
264
|
-
|
265
|
-
```LoginFragment
|
266
216
|
|
267
217
|
class LoginFragment : Fragment() {
|
268
218
|
|
@@ -288,12 +238,6 @@
|
|
288
238
|
|
289
239
|
|
290
240
|
|
291
|
-
private val email = binding.email.toString()
|
292
|
-
|
293
|
-
private val password = binding.password.toString()
|
294
|
-
|
295
|
-
|
296
|
-
|
297
241
|
override fun onCreate(savedInstanceState: Bundle?) {
|
298
242
|
|
299
243
|
super.onCreate(savedInstanceState)
|
@@ -306,7 +250,7 @@
|
|
306
250
|
|
307
251
|
binding.forgotpassword.setOnClickListener {
|
308
252
|
|
309
|
-
forg
|
253
|
+
pw_forget()
|
310
254
|
|
311
255
|
}
|
312
256
|
|
@@ -314,6 +258,86 @@
|
|
314
258
|
|
315
259
|
|
316
260
|
|
261
|
+
override fun onCreateView(
|
262
|
+
|
263
|
+
inflater: LayoutInflater, container: ViewGroup?,
|
264
|
+
|
265
|
+
savedInstanceState: Bundle?
|
266
|
+
|
267
|
+
): View? {
|
268
|
+
|
269
|
+
_binding = LoginFragmentBinding.inflate(inflater, container, false)
|
270
|
+
|
271
|
+
return binding.root
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
278
|
+
|
279
|
+
super.onActivityCreated(savedInstanceState)
|
280
|
+
|
281
|
+
viewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
private fun login() {
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
var email = binding.email.text.toString()
|
292
|
+
|
293
|
+
var password = binding.password.text.toString()
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
if (email.isNotEmpty() && password.isNotEmpty()) {
|
298
|
+
|
299
|
+
auth.signInWithEmailAndPassword(email, password)
|
300
|
+
|
301
|
+
.addOnCompleteListener { task ->
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
if (task.isSuccessful) {
|
306
|
+
|
307
|
+
Log.d(TAG, "ログインに成功しました。")
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
private fun pw_forget() {
|
320
|
+
|
321
|
+
val navController = findNavController()
|
322
|
+
|
323
|
+
navController.navigate(R.id.action_loginFragment_to_signinFragment)
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
override fun onDestroyView() {
|
330
|
+
|
331
|
+
super.onDestroyView()
|
332
|
+
|
333
|
+
_binding = null
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
317
341
|
```
|
318
342
|
|
319
343
|
|
4
ファイル名
test
CHANGED
File without changes
|
test
CHANGED
@@ -262,7 +262,7 @@
|
|
262
262
|
|
263
263
|
```
|
264
264
|
|
265
|
-
```
|
265
|
+
```LoginFragment
|
266
266
|
|
267
267
|
class LoginFragment : Fragment() {
|
268
268
|
|
3
コードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -262,6 +262,62 @@
|
|
262
262
|
|
263
263
|
```
|
264
264
|
|
265
|
+
```
|
266
|
+
|
267
|
+
class LoginFragment : Fragment() {
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
companion object {
|
272
|
+
|
273
|
+
fun newInstance() = LoginFragment()
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
private lateinit var viewModel: LoginViewModel
|
280
|
+
|
281
|
+
private lateinit var auth: FirebaseAuth
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
private var _binding: LoginFragmentBinding? = null
|
286
|
+
|
287
|
+
private val binding get() = _binding!!
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
private val email = binding.email.toString()
|
292
|
+
|
293
|
+
private val password = binding.password.toString()
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
298
|
+
|
299
|
+
super.onCreate(savedInstanceState)
|
300
|
+
|
301
|
+
binding.login.setOnClickListener {
|
302
|
+
|
303
|
+
login()
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
binding.forgotpassword.setOnClickListener {
|
308
|
+
|
309
|
+
forgotpw()
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
```
|
318
|
+
|
319
|
+
|
320
|
+
|
265
321
|
### 自分でやったこと
|
266
322
|
|
267
323
|
|
2
自分でやったことを追加(編集)
test
CHANGED
File without changes
|
test
CHANGED
@@ -272,4 +272,4 @@
|
|
272
272
|
|
273
273
|
「 Unable to instantiate fragment」
|
274
274
|
|
275
|
-
で検索しましたが分かりませんでした。
|
275
|
+
などで検索しましたが分かりませんでした。
|
1
自分でやったことを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -261,3 +261,15 @@
|
|
261
261
|
|
262
262
|
|
263
263
|
```
|
264
|
+
|
265
|
+
### 自分でやったこと
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
「calling Fragment constructor caused an exception」
|
270
|
+
|
271
|
+
や
|
272
|
+
|
273
|
+
「 Unable to instantiate fragment」
|
274
|
+
|
275
|
+
で検索しましたが分かりませんでした。
|