diff --git a/app/build.gradle b/app/build.gradle index 274eb52..8a5b3fa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,7 +33,6 @@ implementation 'com.journeyapps:zxing-android-embedded:3.6.0' implementation 'com.android.support:design:28.0.0' //cropView - implementation 'com.oginotihiro:cropview:1.0.0' api 'com.theartofdev.edmodo:android-image-cropper:2.7.+' implementation project(path: ':dynamicgrid') } diff --git a/app/src/main/java/com/example/cosmosclient/views/CreateGroupActivity.java b/app/src/main/java/com/example/cosmosclient/views/CreateGroupActivity.java index d83bf9e..49e3d17 100644 --- a/app/src/main/java/com/example/cosmosclient/views/CreateGroupActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/CreateGroupActivity.java @@ -1,10 +1,15 @@ package com.example.cosmosclient.views; +import android.media.Image; +import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; import android.view.View; import android.widget.Button; import android.widget.EditText; +import android.widget.ImageButton; import android.widget.Toast; import com.example.cosmosclient.R; @@ -19,6 +24,7 @@ import retrofit2.converter.jackson.JacksonConverterFactory; public class CreateGroupActivity extends AppCompatActivity { + Button createGroupButton; @Override protected void onCreate(Bundle savedInstanceState) { @@ -27,9 +33,14 @@ //各種IDを取得 final EditText groupNameText = findViewById(R.id.groupNameText); - Button createGroupButton = findViewById(R.id.createGroupButton); + createGroupButton = findViewById(R.id.createGroupButton); final String uId,token; + //ボタン有効化&監視 + createGroupButton.setEnabled(false); + createGroupButton.setBackgroundColor(0xaa808080); + groupNameText.addTextChangedListener(new CreateGroupActivity.GenericTextWatcher(groupNameText)); + //グループ作成に必要な情報の取得 Cosmos app = (Cosmos) getApplication(); uId = app.getuId(); @@ -49,15 +60,24 @@ createGroupButton.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view){ - try { - Call createGroup = createGroupService.createGroup(groupNameText.getText().toString(), uId, token); + //ボタン連打防止 + createGroupButton.setEnabled(false); + createGroupButton.setBackgroundColor(0xaa808080); + new Handler().postDelayed(new Runnable() { + public void run() { + createGroupButton.setEnabled(true); + createGroupButton.setBackgroundColor(0xaa009688); + } + }, 1000L); - createGroup.enqueue(new Callback() { - @Override - public void onResponse(Call call, Response response) { - if (response.isSuccessful()) { - //成功時 - Group result = response.body(); + Call createGroup = createGroupService.createGroup(groupNameText.getText().toString(), uId, token); + + createGroup.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()) { + //成功時 + Group result = response.body(); // //確認用 // System.out.println(result.getgId()); @@ -65,29 +85,51 @@ // System.out.println(result.getRequests()); // System.out.println(result.getUri()); - Toast.makeText(CreateGroupActivity.this, - "グループを作成しました", Toast.LENGTH_SHORT).show(); - finish(); - } else { - //onFailureでキャッチできない用のエラー - System.out.println(""); - Toast.makeText(CreateGroupActivity.this, - "通信エラー",Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onFailure(Call call, Throwable t) { - //失敗時 - t.printStackTrace(); Toast.makeText(CreateGroupActivity.this, - "グループ作成失敗",Toast.LENGTH_SHORT); + "グループを作成しました", Toast.LENGTH_SHORT).show(); + finish(); + } else { + //onFailureでキャッチできない用のエラー + System.out.println(""); + Toast.makeText(CreateGroupActivity.this, + "通信エラー",Toast.LENGTH_SHORT).show(); } - }); - }catch(Exception e){ - e.printStackTrace(); - } + } + + @Override + public void onFailure(Call call, Throwable t) { + //失敗時 + t.printStackTrace(); + Toast.makeText(CreateGroupActivity.this, + "グループ作成失敗",Toast.LENGTH_SHORT).show(); + } + }); } }); } -} + //テキスト欄監視 + private class GenericTextWatcher implements TextWatcher { + private View view; + + private GenericTextWatcher(View view){ + this.view = view; + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count,int after){/*記述不要*/}; + @Override + public void onTextChanged(CharSequence s, int start, int before, int count){/*記述不要*/}; + + @Override + public void afterTextChanged(Editable s){ + //ボタン有効&無効 + if(s.length()>0){ + createGroupButton.setEnabled(true); + createGroupButton.setBackgroundColor(0xaa009688); + }else{ + createGroupButton.setEnabled(false); + createGroupButton.setBackgroundColor(0xaa808080); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java b/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java index 7214bb7..799fec0 100644 --- a/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java @@ -1,6 +1,7 @@ package com.example.cosmosclient.views; import android.content.Intent; +import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Editable; @@ -57,6 +58,14 @@ SigninButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + //ボタン連打防止 + SigninButton.setEnabled(false); + new Handler().postDelayed(new Runnable() { + public void run() { + SigninButton.setEnabled(true); + } + }, 1000L); + //APIに値を送信 Call call = signinService.login(UserIdText.getText().toString(), PasswordText.getText().toString()); diff --git a/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java b/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java index fe6d66f..da8b756 100644 --- a/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java @@ -3,6 +3,7 @@ import android.content.Intent; import android.net.Uri; +import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Editable; @@ -68,6 +69,15 @@ MakeAccountButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + //ボタン連打防止 + MakeAccountButton.setEnabled(false); + new Handler().postDelayed(new Runnable() { + public void run() { + MakeAccountButton.setEnabled(true); + } + }, 1000L); + + //パスワード文字列比較のための変数宣言 String pw = PasswordText.getText().toString(); String confirmPw = ConfirmPasswordText.getText().toString();