diff --git a/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java b/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java index a93c50f..5347c0a 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java @@ -287,7 +287,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { final int n = 5; - toastMessage = "ああああ"; + //toastMessage = "タイトルが入力されていません"; final Dialog dialog = new Dialog(getActivity()); @@ -302,83 +302,83 @@ //checkbox1のIDを取得 final CheckBox check = dialog.findViewById(R.id.checkbox_1); + final EditText editText = ((Dialog) dialog).findViewById(R.id.editTitle); + //final EditText editText2 = ((Dialog) dialog).findViewById(R.id.editOverview); + // OK ボタンのリスナ dialog.findViewById(R.id.positive_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - //タイトルの入力 - EditText editText = ((Dialog)dialog).findViewById(R.id.editTitle); - String editTitle = editText.getText().toString(); - TextView Title = (TextView)getActivity().findViewById(R.id.VoiceTitle); - Title.setText(editTitle); + if(editText.getText().toString().equals("") == false) { + //タイトルの入力 + EditText editText = ((Dialog) dialog).findViewById(R.id.editTitle); + String editTitle = editText.getText().toString(); + TextView Title = (TextView) getActivity().findViewById(R.id.VoiceTitle); + Title.setText(editTitle); - //概要の入力 - EditText editText2 = ((Dialog)dialog).findViewById(R.id.editOverview); - String editOverview = editText2.getText().toString(); - TextView Overview = (TextView)getActivity().findViewById(R.id.VoiceOverview); - Overview.setText(editOverview); + //概要の入力 + EditText editText2 = ((Dialog) dialog).findViewById(R.id.editOverview); + String editOverview = editText2.getText().toString(); + TextView Overview = (TextView) getActivity().findViewById(R.id.VoiceOverview); + Overview.setText(editOverview); - //for(int i = 0;i list = new ArrayList<>(); //ViewGroup layout = check; //int count = layout.getChildCount(); //for(int j = 0;j< count;j++){ - //v = layout.getChildAt(j); - //if(v instanceof CheckBox){ - //CheckBox box = (CheckBox) v; - //if(box.isChecked())list.add(box.getText().toString()); + //v = layout.getChildAt(j); + //if(v instanceof CheckBox){ + //CheckBox box = (CheckBox) v; + //if(box.isChecked())list.add(box.getText().toString()); - //} //} - //} + //} + //} - //checkbox1がチェックされた状態だった - if(check.isChecked() == true){ - Title.setText("1"); - }else{//checkbox1がチェックされていない状態だった - Title.setText("ダメです。"); + //checkbox1がチェックされた状態だった + if (check.isChecked() == true) { + Title.setText("1"); + } else {//checkbox1がチェックされていない状態だった + Title.setText("ダメです。"); + } + + + //aaaa = new MapsFragment(); + + + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/amaryllis/") + .addConverterFactory(JacksonConverterFactory.create()) + .build(); + voicememosService = retrofit.create(VoicememosRest.class); + Amaryllis amaryllis = (Amaryllis) getActivity().getApplication(); + data = amaryllis.getData(); + String str = data.replace("\n", ""); + + Call call = voicememosService.postVoicememos(amaryllis.getUid(), amaryllis.getToken(), 10, str, 35, 135, "untitled", "abcde"); + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + Voicememo voicememo = response.body(); + System.out.println("Success!!!!!!!"); + } + + @Override + public void onFailure(Call call, Throwable t) { + System.out.println("failed!!!!!!!!!!!!!"); + } + }); + + + + + dismiss(); + }else{ + Toast toast = Toast.makeText(v.getContext(), "タイトルが入力されていません", Toast.LENGTH_LONG); + toast.show(); } - - - - - //aaaa = new MapsFragment(); - - - Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/amaryllis/") - .addConverterFactory(JacksonConverterFactory.create()) - .build(); - voicememosService = retrofit.create(VoicememosRest.class); - Amaryllis amaryllis = (Amaryllis) getActivity().getApplication(); - data = amaryllis.getData(); - String str = data.replace("\n",""); - - Call call = voicememosService.postVoicememos(amaryllis.getUid(),amaryllis.getToken(),10,str,35,135,"untitled","abcde"); - call.enqueue(new Callback() { - @Override - public void onResponse(Call call, Response response) { - Voicememo voicememo = response.body(); - System.out.println("Success!!!!!!!"); - } - - @Override - public void onFailure(Call call, Throwable t) { - System.out.println("failed!!!!!!!!!!!!!"); - } - }); - - - Toast toast = Toast.makeText(v.getContext(), toastMessage, Toast.LENGTH_LONG); - toast.show(); - - - - - - - dismiss(); } }); // Close ボタンのリスナ