diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index e5a6c5f..a13acaf 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5e88377..7339432 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -46,23 +46,23 @@ android:name=".SignUpActivity" android:exported="true" android:label="@string/title_activity_sign_up"> - - + + - - + + - - + + - - + + - - + + - - + + { - // ShopActivityでどこの店についての投稿かを管理できるように更新する - nemophila.setCurrentShop(shop); - shopsViewModel.setShopAndMarker(shop,null); - - // ShopActivityへ画面遷移する - Intent intent = new Intent(getApplication(), MainActivity.class); - startActivity(intent); - }); + // フィールド + Shop dummyShop = new Shop(); // 店の名前が入力されていればsidを発行し、新しくShopを生成 - Button shopCreateButton = findViewById(R.id.buttonShopCreate); - shopCreateButton.setOnClickListener(v -> { + Button transitionButton = findViewById(R.id.buttonTransitionPostActivity); + transitionButton.setOnClickListener(v -> { EditText nameTextBox = findViewById(R.id.editTextShopCreate); String name = nameTextBox.getText().toString(); // 店の名前を入力されているときのみ処理を行う if (!name.equals("")) { - shopsViewModel.createShop(name, nemophila.getCurrentLongitude(), nemophila.getCurrentLatitude()); - shopCreateButton.setEnabled(false); + dummyShop.setName(name); + dummyShop.setLongitude(nemophila.getCurrentLongitude()); + dummyShop.setLatitude(nemophila.getCurrentLatitude()); + nemophila.setDummyShop(dummyShop); + + // PostActivityへ画面を遷移する + Intent intent = new Intent(getApplication(), PostActivity.class); + startActivity(intent); // 店の名前を入力されていないときToastを発行 } else { Toast ts = Toast.makeText(ShopCreateActivity.this, "名前を入力してください", Toast.LENGTH_SHORT); @@ -56,5 +51,12 @@ ts.show(); } }); + + Button cancelButton = findViewById(R.id.buttonCancel); + cancelButton.setOnClickListener(v -> { + cancelButton.setEnabled(false); + Intent intent = new Intent(getApplication(), MainActivity.class); + startActivity(intent); + }); } } \ No newline at end of file diff --git a/app/src/main/java/com/example/nemophila/TestActivity.java b/app/src/main/java/com/example/nemophila/TestActivity.java index 85f9381..0fe08d0 100644 --- a/app/src/main/java/com/example/nemophila/TestActivity.java +++ b/app/src/main/java/com/example/nemophila/TestActivity.java @@ -60,10 +60,12 @@ // shopsViewModel.start(500, nemophila); break; case 1: - //accountViewModel.getAccount("1111"); + accountViewModel.getAccountPosts("1111"); break; case 2: - postsViewModel.loadShopPost("151347fa-2c90-44d7-ba48-f23f475b910d"); + postsViewModel.createPost("1114", "dbfd3740-8dcc-4b9c-b3b0-42c908da1c65", "151347fa-2c90-44d7-ba48-f23f475b910d", 1, + "和食", "辛いね", "", "", ""); +// postsViewModel.loadShopPost("151347fa-2c90-44d7-ba48-f23f475b910d"); break; } } diff --git a/app/src/main/java/com/example/nemophila/resources/PostsRest.java b/app/src/main/java/com/example/nemophila/resources/PostsRest.java index bf4aa98..a0d2246 100644 --- a/app/src/main/java/com/example/nemophila/resources/PostsRest.java +++ b/app/src/main/java/com/example/nemophila/resources/PostsRest.java @@ -20,7 +20,7 @@ @Path("uid") String uid, @Field("token") String token, @Field("sid") String sid, - @Field("rate") String rate, + @Field("rate") int rate, @Field("genre") String genre, @Field("comment")String comment, @Field("image1") String img1, diff --git a/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java b/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java index 6820651..00577e1 100644 --- a/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java +++ b/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java @@ -42,22 +42,6 @@ public MutableLiveData getAccountLiveData() { return accountLiveData; } public MutableLiveData> getAccountPostsLiveData() { return accountPostsLiveData; } - //AccountJsonからAccountを作成し,対象のライブデータに設定する - private void setAccountLiveDataFromJson(AccountJson accountJson) { - Account account = new Account(accountJson); - accountLiveData.setValue(account); - } - - //PostJsonからPostを作成し,対象のライブデータに設定する - private void setAccountPostLiveDataFromJson(Collection postJson) { - ArrayList posts = new ArrayList<>(); - for(PostJson i: postJson) { - Post post = new Post(i); - posts.add(post); - } - accountPostsLiveData.setValue(posts); - } - // 対象のアカウント情報の取得 public void getAccount(String uid) { Call call = accountsRest.getAccount(uid); @@ -69,16 +53,22 @@ AccountJson accountJson = response.body(); setAccountLiveDataFromJson(accountJson); } else { - System.out.println("response error"); + System.out.println("GetAccount ResponseError"); } } @Override public void onFailure(Call call, Throwable t) { - System.out.println("correspondence error"); + System.out.println("GetAccount NetworkError" + t); } }); } + //AccountJsonからAccountを作成し,対象のライブデータに設定する + private void setAccountLiveDataFromJson(AccountJson aj) { + Account account = new Account(aj); + accountLiveData.setValue(account); + } + // 対象のアカウント情報の削除 public void deleteAccount(String uid) { Call call = accountsRest.deleteAccount(uid); @@ -87,14 +77,14 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - System.out.println("successful"); + System.out.println("DeleteAccount Successful"); } else { - System.out.println("response error"); + System.out.println("DeleteAccount ResponseError"); } } @Override public void onFailure(Call call, Throwable t) { - System.out.println("correspondence error"); + System.out.println("DeleteAccount NetworkError" + t); } }); } @@ -107,15 +97,14 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - AccountJson accountJson = response.body(); - setAccountLiveDataFromJson(accountJson); + System.out.println("Success ChangePW"); } else { System.out.println("response error"); } } @Override public void onFailure(Call call, Throwable t) { - System.out.println("correspondence error"); + System.out.println("correspondence error" + t); } }); } @@ -128,15 +117,14 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - AccountJson accountJson = response.body(); - setAccountLiveDataFromJson(accountJson); + System.out.println("Success ChangeName"); } else { System.out.println("response error"); } } @Override public void onFailure(Call call, Throwable t) { - System.out.println("correspondence error"); + System.out.println("correspondence error" + t); } }); } @@ -151,17 +139,28 @@ if (response.isSuccessful()) { Collection postJson = response.body(); setAccountPostLiveDataFromJson(postJson); + System.out.println("Success" + accountPostsLiveData.getValue().toString()); } else { System.out.println("response error"); } } @Override public void onFailure(Call> call, Throwable t) { - System.out.println("correspondence error"); + System.out.println("correspondence error" + t); } }); } + //PostJsonからPostを作成し,対象のライブデータに設定する + private void setAccountPostLiveDataFromJson(Collection postJson) { + ArrayList posts = new ArrayList<>(); + for(PostJson pj: postJson) { + Post post = new Post(pj); + posts.add(post); + } + accountPostsLiveData.setValue(posts); + } + // 対象のアカウントがした投稿の削除 public void deleteAccountPost(String sid, String uid, String pid, String token) { Call call = accountsRest.deletePost(sid, uid, pid, token); @@ -177,7 +176,7 @@ } @Override public void onFailure(Call call, Throwable t) { - System.out.println("correspondence error"); + System.out.println("correspondence error" + t); } }); } diff --git a/app/src/main/java/com/example/nemophila/viewmodels/PostsViewModel.java b/app/src/main/java/com/example/nemophila/viewmodels/PostsViewModel.java index 51bd9d6..bb4252c 100644 --- a/app/src/main/java/com/example/nemophila/viewmodels/PostsViewModel.java +++ b/app/src/main/java/com/example/nemophila/viewmodels/PostsViewModel.java @@ -109,7 +109,7 @@ //投稿作成 public void createPost(String uid, String token, String sid, - String rate, String genre, String comment, + int rate, String genre, String comment, String image1, String image2, String image3) { Call call = postsRest.postAccountPost(uid ,token, sid, rate, genre, comment, image1, image2, image3); diff --git a/app/src/main/java/com/example/nemophila/viewmodels/ShopsViewModel.java b/app/src/main/java/com/example/nemophila/viewmodels/ShopsViewModel.java index 88282c9..88ea984 100644 --- a/app/src/main/java/com/example/nemophila/viewmodels/ShopsViewModel.java +++ b/app/src/main/java/com/example/nemophila/viewmodels/ShopsViewModel.java @@ -60,15 +60,18 @@ ShopToMarker.put(shop, marker); } + // ShopToMarkerからkeyを指定して、要素を削除する + public void removeShopAndMarker(Shop shop) { ShopToMarker.remove(shop); } + // 店に紐づいたピンを返す public Marker getMarker(Shop shop) { return ShopToMarker.get(shop); } + // TimerViewModelを利用して、定期的にMainActivityに呼び出してもらう @Override public void update() { updateShops(); - // System.out.println("hogehoge"); } // 画面を動かす, 又はGPSが移動する度に呼び出される @@ -119,6 +122,7 @@ }); } + // 新しく店を生成する public void createShop(String name, double longitude, double latitude) { Call call = shopsRest.createShop(name, longitude, latitude); diff --git a/app/src/main/res/layout/activity_post.xml b/app/src/main/res/layout/activity_post.xml index 5e67388..ede9b97 100644 --- a/app/src/main/res/layout/activity_post.xml +++ b/app/src/main/res/layout/activity_post.xml @@ -7,7 +7,7 @@ tools:context=".PostActivity"> + app:layout_constraintVertical_bias="0.195" + tools:ignore="SpeakableTextPresentCheck" /> + + + + + + + + + +