Code refactor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Umberto Furno 2020-01-05 19:58:35 +01:00
parent 99b0690e20
commit fdd558a613

View File

@ -17,6 +17,8 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -73,8 +75,9 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
service.getCardService().getAllCards(sp.getBoardId(), current.getId()).enqueue( service.getCardService().getAllCards(sp.getBoardId(), current.getId()).enqueue(
new Callback<List<Card>>() { new Callback<List<Card>>() {
@Override @Override
public void onResponse(Call<List<Card>> call, Response<List<Card>> response) { public void onResponse(@NotNull Call<List<Card>> call, @NotNull Response<List<Card>> response) {
for(int i=0; i<response.body().size(); i++){ assert response.body() != null;
for(int i = 0; i<response.body().size(); i++){
cardTitle.add(response.body().get(i).getTitle()); cardTitle.add(response.body().get(i).getTitle());
} }
ArrayAdapter<String> adapter = new ArrayAdapter<>(mContext, ArrayAdapter<String> adapter = new ArrayAdapter<>(mContext,
@ -90,7 +93,7 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
}); });
} }
@Override @Override
public void onFailure(Call<List<Card>> call, Throwable t) { public void onFailure(@NotNull Call<List<Card>> call, @NotNull Throwable t) {
} }
}); });
@ -116,7 +119,7 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
private void showInputDialog(final String current) { private void showInputDialog(final String current) {
LayoutInflater layoutInflater = LayoutInflater.from(mContext); LayoutInflater layoutInflater = LayoutInflater.from(mContext);
View promptView = layoutInflater.inflate(R.layout.alert_new_card, null); @SuppressLint("InflateParams") View promptView = layoutInflater.inflate(R.layout.alert_new_card, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
alertDialogBuilder.setView(promptView); alertDialogBuilder.setView(promptView);
@ -129,8 +132,9 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
if(!editText.getText().toString().matches("")) { if(!editText.getText().toString().matches("")) {
service.getSwimlanesService().getAllSwimlanes(sp.getBoardId()).enqueue(new Callback<List<Swimlane>>() { service.getSwimlanesService().getAllSwimlanes(sp.getBoardId()).enqueue(new Callback<List<Swimlane>>() {
@Override @Override
public void onResponse(Call<List<Swimlane>> call, Response<List<Swimlane>> response) { public void onResponse(@NotNull Call<List<Swimlane>> call, @NotNull Response<List<Swimlane>> response) {
String idDefaultSwimlane = null; String idDefaultSwimlane = null;
assert response.body() != null;
for(Swimlane swim: response.body()){ for(Swimlane swim: response.body()){
if(swim.getTitle().equalsIgnoreCase("default")) if(swim.getTitle().equalsIgnoreCase("default"))
idDefaultSwimlane=swim.getTitle(); idDefaultSwimlane=swim.getTitle();
@ -139,15 +143,14 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
card.setTitle(editText.getText().toString()); card.setTitle(editText.getText().toString());
card.setAuthorId(sp.getUserId()); card.setAuthorId(sp.getUserId());
card.setSwimlaneId(idDefaultSwimlane); card.setSwimlaneId(idDefaultSwimlane);
System.out.println("****************" + idDefaultSwimlane);
//card.setDescription("new card from app"); //card.setDescription("new card from app");
service.getListService().getList(sp.getBoardId(), current).enqueue(new Callback<it.unisannio.ding.ids.wedroid.wrapper.entity.WList>() { service.getListService().getList(sp.getBoardId(), current).enqueue(new Callback<it.unisannio.ding.ids.wedroid.wrapper.entity.WList>() {
@Override @Override
public void onResponse(Call<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> call, Response<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> response) { public void onResponse(@NotNull Call<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> call, @NotNull Response<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> response) {
service.getCardService().newCard(sp.getBoardId(), current, card).enqueue(new Callback<Card>() { service.getCardService().newCard(sp.getBoardId(), current, card).enqueue(new Callback<Card>() {
@Override @Override
public void onResponse(Call<Card> call, Response<Card> response){ public void onResponse(@NotNull Call<Card> call, @NotNull Response<Card> response){
if(response.isSuccessful()) if(response.isSuccessful())
Toast.makeText(mContext, "card posted" , Toast.makeText(mContext, "card posted" ,
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
@ -156,21 +159,21 @@ public class WListsAdapter extends RecyclerView.Adapter<WListsAdapter.WListViewH
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} }
@Override @Override
public void onFailure(Call<Card> call, Throwable t) { public void onFailure(@NotNull Call<Card> call, @NotNull Throwable t) {
} }
}); });
} }
@Override @Override
public void onFailure(Call<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> call, Throwable t) { public void onFailure(@NotNull Call<it.unisannio.ding.ids.wedroid.wrapper.entity.WList> call, @NotNull Throwable t) {
} }
}); });
} }
@Override @Override
public void onFailure(Call<List<Swimlane>> call, Throwable t) { public void onFailure(@NotNull Call<List<Swimlane>> call, @NotNull Throwable t) {
} }
}); });