diff --git a/app/src/main/java/com/example/cosmosclient/entities/Request.java b/app/src/main/java/com/example/cosmosclient/entities/Request.java index 999dcb9..a323c01 100644 --- a/app/src/main/java/com/example/cosmosclient/entities/Request.java +++ b/app/src/main/java/com/example/cosmosclient/entities/Request.java @@ -15,9 +15,7 @@ private Date deadline; // private String location; private int location; - @JsonIgnore - private String name; //消 - private boolean done = false; + private boolean done; public Request() { } @@ -30,7 +28,6 @@ this.date = date; this.deadline = deadline; this.location = location; - this.name = name; this.done = done; } @@ -90,14 +87,6 @@ this.location = location; } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - public boolean isDone() { return done; } diff --git a/app/src/main/java/com/example/cosmosclient/resources/GroupsRest.java b/app/src/main/java/com/example/cosmosclient/resources/GroupsRest.java index 70aa7a3..34ebcfc 100644 --- a/app/src/main/java/com/example/cosmosclient/resources/GroupsRest.java +++ b/app/src/main/java/com/example/cosmosclient/resources/GroupsRest.java @@ -29,7 +29,7 @@ @POST("groups/{gId}/requests") @FormUrlEncoded - Call addRequests(@Path("gId") String gId, @Field("uId") String uId, @Field("product") String product, /*@Field("deadline") Date deadline,*/ @Field("location") int location, @Field("token") String token); + Call addRequests(@Path("gId") String gId, @Field("uId") String uId, @Field("product") String product, @Field("deadline") String deadline, @Field("location") int location, @Field("token") String token); // @GET("{gId}/requests/{rId}") // Call getRequestsDetailByGidAndRid(@Path("gid") String gid, @Path("rid") String rid, @Query("token") String token); diff --git a/app/src/main/java/com/example/cosmosclient/views/AddRequestActivity.java b/app/src/main/java/com/example/cosmosclient/views/AddRequestActivity.java index fceaa7b..b0a300f 100644 --- a/app/src/main/java/com/example/cosmosclient/views/AddRequestActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/AddRequestActivity.java @@ -3,6 +3,7 @@ import android.app.DatePickerDialog; import android.content.Context; import android.os.Bundle; +import android.os.Handler; import android.support.v7.app.AppCompatActivity; import android.view.KeyEvent; import android.view.View; @@ -19,12 +20,10 @@ import com.example.cosmosclient.R; import com.example.cosmosclient.app.Cosmos; import com.example.cosmosclient.entities.AddRequestsResponse; -import com.example.cosmosclient.entities.Request; import com.example.cosmosclient.resources.GroupsRest; import com.example.cosmosclient.yolp.Yolp; import java.io.IOException; -import java.sql.Date; import java.util.Calendar; import retrofit2.Call; @@ -39,9 +38,9 @@ private ImageButton calenderButton; - private int curYear; - private int curMonth; - private int curDayOfMonth; + private Integer deadlineYear; + private Integer deadlineMonth; + private Integer deadlineDayOfMonth; private EditText editTextProduct; private EditText editTextDeadline; @@ -87,9 +86,9 @@ @Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { - curYear = year; - curMonth = month; - curDayOfMonth = dayOfMonth; + deadlineYear = year; + deadlineMonth = month; + deadlineDayOfMonth = dayOfMonth; //setした日付を取得して表示 editTextDeadline.setText(String.format("%d / %02d / %02d", year, month+1, dayOfMonth)); @@ -125,15 +124,21 @@ addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + //ボタン連打防止 + addButton.setEnabled(false); + new Handler().postDelayed(new Runnable() { + public void run() { + addButton.setEnabled(true); + } + }, 3000L); + // エディットテキストのテキストを取得 String inputProduct = editTextProduct.getText().toString(); - // 取得したテキストを TextView に張り付ける - RequestListActivity.requestlist.add(0, (new Request("d", "d", inputProduct, new Date(curYear, curMonth, curDayOfMonth), new Date(curYear, curMonth, curDayOfMonth), Yolp.getInstance().getCodeBySubcategory(selectedSubCategory), "a-hongo", false))); - //retrofitの処理 final Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/cosmos/") +// .baseUrl("http://10.0.2.2:8080/") .addConverterFactory(JacksonConverterFactory.create()) .build(); @@ -142,16 +147,18 @@ //RequestList取得するための必要な情報 Cosmos app = (Cosmos) getApplication(); -// final String uId = app.getuId(); -// final String gid = app.getgId(); - final String uId = "cbc24743-643b-4a8b-bbac-8bedb77f8ae5"; - final String gId = "8f924678-e489-4640-b827-dddc0246b30c"; -// final String token = app.getToken(); - final String token = "hoge"; + final String uId = app.getuId(); + final String gId = app.getCurentGroup().getgId(); + final String token = app.getToken(); final boolean detail = true; + String deadline = null; -// Call call = addRequestsService.addRequests(gId, uId, inputProduct, new Date(curYear, curMonth, curDayOfMonth), Yolp.getInstance().getCodeBySubcategory(selectedSubCategory), token); - Call call = addRequestsService.addRequests(gId, uId, inputProduct, Yolp.getInstance().getCodeBySubcategory(selectedSubCategory), token); + if(deadlineYear != null && deadlineMonth != null && deadlineDayOfMonth != null) { + deadline = String.format("%d-%02d-%02d %02d:%02d:%02d", deadlineYear, deadlineMonth +1, deadlineDayOfMonth, 23, 59, 59); + } + Call call = addRequestsService.addRequests(gId, uId, inputProduct, deadline, Yolp.getInstance().getCodeBySubcategory(selectedSubCategory), token); +// Call call = addRequestsService.addRequests(gId, uId, inputProduct, new Date(deadlineYear, deadlineMonth, deadlineDayOfMonth), Yolp.getInstance().getCodeBySubcategory(selectedSubCategory), token); +// Call call = addRequestsService.addRequests(gId, uId, inputProduct, Yolp.getInstance().getCodeBySubcategory(selectedSubCategory), token); //サーバからのレスポンス call.enqueue(new Callback() { diff --git a/app/src/main/java/com/example/cosmosclient/views/RequestListActivity.java b/app/src/main/java/com/example/cosmosclient/views/RequestListActivity.java index fe76016..1a223bd 100644 --- a/app/src/main/java/com/example/cosmosclient/views/RequestListActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/RequestListActivity.java @@ -32,12 +32,12 @@ import java.io.IOException; import java.text.Collator; -import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.TimeZone; import retrofit2.Call; import retrofit2.Callback; @@ -53,9 +53,8 @@ Toast toast; //動作テスト用 //Request List - public static ArrayList requestlist = new ArrayList<>(); - Requests requests; + //Color制御 boolean productColorFlag = true; //買うもの (true:白, false:黒) boolean deadlineColorFlag = true; //購入期限 @@ -72,6 +71,9 @@ Collator collator = Collator.getInstance(Locale.JAPANESE); +// TableLayout requesttable = (TableLayout)findViewById(R.id.RequestList); +// TableLayout accomplishedRequesttable = (TableLayout)findViewById(R.id.RequestList); + //productOnClick public View.OnClickListener productOnClick = new View.OnClickListener() { @Override @@ -215,11 +217,19 @@ } }; + //requestListRowOnClick +// public View.OnClickListener requestListRowOnClick = new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// requesttable.removeView(view); +// } +// }; + //productSortComparator public Comparator productSortComparator = new Comparator() { @Override public int compare(Request r1, Request r2) { - return collator.compare(r1.getProduct().toString(), r2.getProduct().toString()); + return collator.compare(r1.getProduct(), r2.getProduct()); } }; @@ -257,7 +267,7 @@ public Comparator nameSortComparator = new Comparator() { @Override public int compare(Request r1, Request r2) { - return collator.compare(r1.getName().toString(), r2.getName().toString()); + return collator.compare(r1.getIssuer().getName(), r2.getIssuer().getName()); } }; @@ -280,13 +290,6 @@ } }); -// requestlist.clear(); -// -// //Add Request -// requestlist.add(new Request("a", "a", "わさび", new Date(2019, 6, 7), new Date(2019, 6, 7), 205002, "a-hongo", false)); -// requestlist.add(new Request("b", "b","ケーキ" , new Date(2019, 6, 6), new Date(2019, 6, 6), 205001, "t-sugisawa", false)); -// requestlist.add(new Request("c", "c", "からし", new Date(2018, 6, 4), new Date(2018, 6, 4), 205002, "n-kande", false)); - //LEFT hamburger button DrawerLayout requestlistDrawer = (DrawerLayout) findViewById(R.id.request_list_drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( @@ -308,7 +311,6 @@ nameView = (LinearLayout)findViewById(R.id.name); nameView.setOnClickListener(nameOnClick); - } @Override @@ -318,6 +320,7 @@ //retrofitの処理 final Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/cosmos/") +// .baseUrl("http://10.0.2.2:8080/") .addConverterFactory(JacksonConverterFactory.create()) .build(); @@ -326,10 +329,8 @@ //RequestList取得するための必要な情報 Cosmos app = (Cosmos) getApplication(); -// final String gId = app.getCurentGroup().getgId(); - final String gId = "8f924678-e489-4640-b827-dddc0246b30c"; -// final String token = app.getToken(); - final String token = "hoge"; + final String gId = app.getCurentGroup().getgId(); + final String token = app.getToken(); final boolean detail = true; int quantity = 20; @@ -341,6 +342,7 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Tokyo")); requests = response.body(); //Add RequestList Table @@ -450,23 +452,26 @@ if(Yolp.getInstance().getSubCategoryByCode(requests.getRequest(i).getLocation()) != null) { textLocation.setText(Yolp.getInstance().getSubCategoryByCode(requests.getRequest(i).getLocation()).getSubName()); } + textLocation.setTextSize(20); textLocation.setHeight(150); textLocation.setGravity(Gravity.CENTER); tableRow.addView(textLocation, new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT)); TextView textName = new TextView(this); -// requestList.get(i).getIssuer().getName(); textName.setText(requests.getRequest(i).getIssuer().getName()); textName.setTextSize(20); textName.setHeight(150); textName.setGravity(Gravity.CENTER); tableRow.addView(textName, new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT)); +// tableRow.setOnClickListener(requestListRowOnClick); + requesttable.addView(tableRow); } } + // Can not to reset! private void ResetRequestListTable() { TableLayout requesttable = (TableLayout)findViewById(R.id.RequestList); int childCount = requesttable.getChildCount();