Skip to content

Commit

Permalink
Automatic update when closing a post & improvements for better User E…
Browse files Browse the repository at this point in the history
…xperience
  • Loading branch information
AlexGiulioBerton-UNIVE committed Jan 15, 2023
1 parent 2d7b43b commit a0e485e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand All @@ -23,6 +24,7 @@

public class CustomDialogManagePost extends AppCompatDialogFragment {
private EditText txtUsername;
public Context c;

@NonNull
@Override
Expand All @@ -44,8 +46,9 @@ public void onClick(DialogInterface dialogInterface, int i) {
@Override
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
if(response.body().get("status").toString().equals("\"SUCCESS\"")) {
//getActivity().finish();
System.out.println("FATTO");
Toast.makeText(c, "POST chiuso con successo!", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(c, "Chiusura POST non avvenuta! Riprovare più tardi!", Toast.LENGTH_LONG).show();
}
}

Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/com/example/fitems/ManagePost.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void onClick(View view) {
@Override
public void onClick(View view) {
CustomDialogManagePost dialog = new CustomDialogManagePost();
dialog.c = getApplicationContext();
dialog.show(getSupportFragmentManager(), "");
}
});
Expand All @@ -88,12 +89,14 @@ private void confermaRitrovamento() {
call.enqueue(new Callback<JsonObject>() {
@Override
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
Toast.makeText(ManagePost.this, "Status: " + response.body().get("status"), Toast.LENGTH_LONG).show();

btnRestituzione.setVisibility(View.INVISIBLE);
btnTrovatoIo.setVisibility(View.INVISIBLE);
if(response.body().get("status").toString().equals("\"SUCCESS\"")) {
btnRestituzione.setVisibility(View.INVISIBLE);
btnTrovatoIo.setVisibility(View.INVISIBLE);
Toast.makeText(getApplicationContext(), "Post chiuso con successo", Toast.LENGTH_LONG).show();
finish();
} else {
txtInfo.setText("Si è verificato un errore riprova più tardi!");
txtInfo.setVisibility(View.VISIBLE);
}
}

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/example/fitems/MyPosts.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,10 @@ public void onFailure(Call<JsonObject> call, Throwable t) {
}
});
}

@Override
protected void onRestart() {
super.onRestart();
downloadMyPosts();
}
}

0 comments on commit a0e485e

Please sign in to comment.