質問編集履歴
1
LoginActivity、BudgetTrackerUserDaoそれぞれ変更
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -11,22 +11,24 @@ | |
| 11 11 |  | 
| 12 12 | 
             
            ```LoginActivity.kt
         | 
| 13 13 | 
             
            try {
         | 
| 14 | 
            -
                             | 
| 14 | 
            +
                            budgetTrackerUserDao.logIn(budgetTrackerUserDto) { result ->
         | 
| 15 | 
            -
             | 
| 15 | 
            +
                                if (result == 1) {
         | 
| 16 | 
            -
             | 
| 16 | 
            +
                                    Toast.makeText(this@LoginActivity, "Login successful!", Toast.LENGTH_SHORT).show()
         | 
| 17 | 
            -
             | 
| 17 | 
            +
                                    val intent = Intent(this, MainActivity::class.java)
         | 
| 18 | 
            -
             | 
| 18 | 
            +
                                    startActivity(intent)
         | 
| 19 | 
            -
             | 
| 19 | 
            +
                                } else {
         | 
| 20 | 
            -
             | 
| 20 | 
            +
                                    Toast.makeText(this@LoginActivity, "Login failed!", Toast.LENGTH_SHORT).show()
         | 
| 21 | 
            +
                                }
         | 
| 21 22 | 
             
                            }
         | 
| 22 23 | 
             
                        } catch (e: IOException) {
         | 
| 23 24 | 
             
                            Toast.makeText(this@LoginActivity, "Error in logging in!", Toast.LENGTH_SHORT).show()
         | 
| 24 25 | 
             
                            e.printStackTrace()
         | 
| 26 | 
            +
             | 
| 25 27 | 
             
                        }
         | 
| 26 28 | 
             
            ```
         | 
| 27 29 |  | 
| 28 30 | 
             
            ```BudgetTrackerUserDao.kt
         | 
| 29 | 
            -
            fun logIn(budgetTrackerUserDto: BudgetTrackerUserDto | 
| 31 | 
            +
            fun logIn(budgetTrackerUserDto: BudgetTrackerUserDto, callback: (result: Int) -> Unit) {
         | 
| 30 32 | 
             
                    var result = 0
         | 
| 31 33 | 
             
                    try {
         | 
| 32 34 | 
             
                        val properties = Properties()
         | 
| @@ -49,18 +51,20 @@ | |
| 49 51 | 
             
                                        Log.e("JSONException", e.toString())
         | 
| 50 52 | 
             
                                    }
         | 
| 51 53 | 
             
                                }
         | 
| 54 | 
            +
                                callback(result)
         | 
| 52 55 | 
             
                            },
         | 
| 53 56 | 
             
                            Response.ErrorListener { error ->
         | 
| 54 57 | 
             
                                if (context != null) {
         | 
| 55 58 | 
             
                                    Toast.makeText(context, "Unable to send data $error", Toast.LENGTH_SHORT).show()
         | 
| 56 59 | 
             
                                }
         | 
| 57 60 | 
             
                                Log.e("VolleyError", error.toString())
         | 
| 61 | 
            +
                                callback(result)
         | 
| 58 62 | 
             
                            }) {
         | 
| 59 63 | 
             
                            @Throws(AuthFailureError::class)
         | 
| 60 64 | 
             
                            override fun getParams(): Map<String, String> {
         | 
| 61 65 | 
             
                                val params = HashMap<String, String>()
         | 
| 62 66 | 
             
                                params["user_name"] = budgetTrackerUserDto.getId()
         | 
| 63 | 
            -
                                params["password"] = budgetTrackerUserDto. | 
| 67 | 
            +
                                params["password"] = budgetTrackerUserDto.getPassword()
         | 
| 64 68 | 
             
                                return params
         | 
| 65 69 | 
             
                            }
         | 
| 66 70 | 
             
                        }
         | 
| @@ -69,8 +73,8 @@ | |
| 69 73 | 
             
                    } catch (e: IOException) {
         | 
| 70 74 | 
             
                        e.printStackTrace()
         | 
| 71 75 | 
             
                    }
         | 
| 72 | 
            -
                    return result
         | 
| 73 76 | 
             
                }
         | 
| 77 | 
            +
             | 
| 74 78 | 
             
            ```
         | 
| 75 79 |  | 
| 76 80 | 
             
            バックエンドサーバの開発環境は以下の通りです。
         | 
