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: 's avatarIvan Del Pino <idelpino@teclib.com>
parent 257b8e84
...@@ -92,7 +92,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -92,7 +92,6 @@ public class MainActivity extends AppCompatActivity {
progressBar = findViewById(R.id.progressBar); progressBar = findViewById(R.id.progressBar);
recyclerView = findViewById(R.id.recyclerViewApi); recyclerView = findViewById(R.id.recyclerViewApi);
resultList.add("Ivans");
activityAdapter = new ActivityAdapter(resultList); activityAdapter = new ActivityAdapter(resultList);
recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(activityAdapter); recyclerView.setAdapter(activityAdapter);
...@@ -103,6 +102,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -103,6 +102,7 @@ public class MainActivity extends AppCompatActivity {
list.add("Full Session"); list.add("Full Session");
list.add("Kill session"); list.add("Kill session");
list.add("Call Request"); list.add("Call Request");
list.add("File Request");
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.spinner_item, list); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerTest.setAdapter(adapter); spinnerTest.setAdapter(adapter);
...@@ -128,6 +128,9 @@ public class MainActivity extends AppCompatActivity { ...@@ -128,6 +128,9 @@ public class MainActivity extends AppCompatActivity {
case "Call Request": case "Call Request":
btnCall(); btnCall();
break; break;
case "File Request":
btnFile();
break;
} }
} }
}); });
...@@ -139,7 +142,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -139,7 +142,7 @@ public class MainActivity extends AppCompatActivity {
glpi.killSession(new GLPI.ResponseHandle<String, String>() { glpi.killSession(new GLPI.ResponseHandle<String, String>() {
@Override @Override
public void onResponse(String response) { public void onResponse(String response) {
FlyveLog.i("killSession: %s", response.toString()); FlyveLog.i("killSession: %s", response);
updateAdapter("Success: Kill Session"); updateAdapter("Success: Kill Session");
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
recyclerView.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.VISIBLE);
...@@ -515,6 +518,54 @@ public class MainActivity extends AppCompatActivity { ...@@ -515,6 +518,54 @@ public class MainActivity extends AppCompatActivity {
glpi.resetPassword("youremail@yourdomain.com", "asdfasdfafsASDFd333A", "1234", callback); 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) { private void updateAdapter(String message) {
resultList.add(message); resultList.add(message);
activityAdapter.notifyDataSetChanged(); activityAdapter.notifyDataSetChanged();
......
...@@ -51,6 +51,7 @@ import retrofit2.http.PUT; ...@@ -51,6 +51,7 @@ import retrofit2.http.PUT;
import retrofit2.http.Path; import retrofit2.http.Path;
import retrofit2.http.Query; import retrofit2.http.Query;
import retrofit2.http.QueryMap; import retrofit2.http.QueryMap;
import retrofit2.http.Url;
public interface Routes { public interface Routes {
...@@ -144,10 +145,14 @@ public interface Routes { ...@@ -144,10 +145,14 @@ public interface Routes {
/*Get File */ /*Get File */
@Headers("Content-Type: application/json") @Headers("Content-Type: application/json")
@GET("PluginFlyvemdmFile/{fileId}") @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") @Headers("Content-Type: application/json")
@GET("PluginFlyvemdmPackage/{fileId}") @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