Commit c175f4e3 authored by Ivan Del Pino's avatar Ivan Del Pino Committed by Rafael Jesus Hernández Vasquez

feat: add download file request

Signed-off-by: default avatarIvan Del Pino <idelpino@teclib.com>
parent 257b8e84
......@@ -92,7 +92,6 @@ public class MainActivity extends AppCompatActivity {
progressBar = findViewById(R.id.progressBar);
recyclerView = findViewById(R.id.recyclerViewApi);
resultList.add("Ivans");
activityAdapter = new ActivityAdapter(resultList);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(activityAdapter);
......@@ -103,6 +102,7 @@ public class MainActivity extends AppCompatActivity {
list.add("Full Session");
list.add("Kill session");
list.add("Call Request");
list.add("File Request");
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerTest.setAdapter(adapter);
......@@ -128,6 +128,9 @@ public class MainActivity extends AppCompatActivity {
case "Call Request":
btnCall();
break;
case "File Request":
btnFile();
break;
}
}
});
......@@ -139,7 +142,7 @@ public class MainActivity extends AppCompatActivity {
glpi.killSession(new GLPI.ResponseHandle<String, String>() {
@Override
public void onResponse(String response) {
FlyveLog.i("killSession: %s", response.toString());
FlyveLog.i("killSession: %s", response);
updateAdapter("Success: Kill Session");
progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE);
......@@ -515,6 +518,54 @@ public class MainActivity extends AppCompatActivity {
glpi.resetPassword("youremail@yourdomain.com", "asdfasdfafsASDFd333A", "1234", callback);
}
private void btnFile() {
progressBar.setVisibility(View.VISIBLE);
resultList.clear();
glpi.downloadFileMD(new GLPI.VoidCallback() {
@Override
public void onResponse(String response) {
FlyveLog.i("Download file: %s", response);
updateAdapter("Success: Download file");
}
@Override
public void onFailure(String errorMessage) {
FlyveLog.e("Download file: %s", errorMessage);
updateAdapter("Error: Download file" + errorMessage);
}
});
glpi.getPluginPackage("fileId", new GLPI.VoidCallback() {
@Override
public void onResponse(String response) {
FlyveLog.i("Package plugin: %s", response);
updateAdapter("Success: Package plugin");
}
@Override
public void onFailure(String errorMessage) {
FlyveLog.e("Package plugin: %s", errorMessage);
updateAdapter("Error: Package plugin" + errorMessage);
}
});
glpi.getPluginFile("fileId", new GLPI.VoidCallback() {
@Override
public void onResponse(String response) {
FlyveLog.i("File plugin: %s", response);
updateAdapter("Success: File plugin");
progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE);
}
@Override
public void onFailure(String errorMessage) {
FlyveLog.e("File plugin: %s", errorMessage);
updateAdapter("Error: File plugin" + errorMessage);
progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE);
}
});
}
private void updateAdapter(String message) {
resultList.add(message);
activityAdapter.notifyDataSetChanged();
......
......@@ -51,6 +51,7 @@ import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;
import retrofit2.http.Url;
public interface Routes {
......@@ -144,10 +145,14 @@ public interface Routes {
/*Get File */
@Headers("Content-Type: application/json")
@GET("PluginFlyvemdmFile/{fileId}")
Call<JsonArray> getPluginFile(@HeaderMap Map<String, String> headers, @Path("fileId") String fileId);
Call<JsonObject> getPluginFile(@HeaderMap Map<String, String> headers, @Path("fileId") String fileId);
@Headers("Content-Type: application/json")
@GET("PluginFlyvemdmPackage/{fileId}")
Call<JsonArray> getPluginPackage(@HeaderMap Map<String, String> headers, @Path("fileId") String fileId);
Call<JsonObject> getPluginPackage(@HeaderMap Map<String, String> headers, @Path("fileId") String fileId);
@Headers("Content-Type: application/json")
@GET("CHANGELOG.md")
Call<JsonObject> downloadFileMD(@Url String url, @HeaderMap Map<String, String> headers);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment