Commit 79ef15f8 authored by Loris's avatar Loris
Browse files

it works

parent a7b9eec0
......@@ -4,16 +4,17 @@ import java.util.List;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
public
interface ApiConfig {
public interface ApiConfig {
@Multipart
@POST("/")
Call uploadFile(@Part MultipartBody.Part file, @Part RequestBody name);
@POST("/foo")
Call<ServerResponse> uploadFile(@Part MultipartBody.Part file, @Part("foo") RequestBody name);
}
......@@ -5,7 +5,7 @@ import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class AppConfig {
private static String BASE_URL = "http://192.168.1.18:8080";
private static String BASE_URL = "http://192.168.1.33:8080";
public static Retrofit getRetrofit() {
return new Retrofit.Builder()
.baseUrl(AppConfig.BASE_URL)
......
......@@ -6,15 +6,7 @@ import android.util.Log;
import android.widget.Toast;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import de.tonifetzer.sensorrecorder.MainActivity;
import de.tonifetzer.sensorrecorder.sender.ApiConfig;
import de.tonifetzer.sensorrecorder.sender.AppConfig;
import de.tonifetzer.sensorrecorder.sender.ServerResponse;
import de.tonifetzer.sensorrecorder.sensors.Logger;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
......@@ -41,7 +33,7 @@ public final class Sender {
// Uploading Image/Video
public void upload(File file, ProgressDialog progressDialog) {
progressDialog.show();
// progressDialog.show();
// Map is used to multipart the file using okhttp3.RequestBody
// Parsing any Media type file
......@@ -57,16 +49,12 @@ public final class Sender {
public void onResponse(Call<ServerResponse> call, Response<ServerResponse> response) {
ServerResponse serverResponse = response.body();
if (serverResponse != null) {
if (serverResponse.getSuccess()) {
Toast.makeText(context, serverResponse.getMessage(), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context, serverResponse.getMessage(), Toast.LENGTH_SHORT).show();
}
Toast.makeText(context, serverResponse.getMessage(), Toast.LENGTH_SHORT).show();
} else {
assert serverResponse != null;
Log.v("Response", serverResponse.toString());
}
progressDialog.dismiss();
// progressDialog.dismiss();
}
@Override
......
......@@ -39,7 +39,7 @@ public class PhoneSensors extends MySensor implements SensorEventListener{
all = sensorManager.getSensorList(Sensor.TYPE_ALL);
// dump sensor-vendor info to file
dumpVendors(act);
// dumpVendors(act);
}
private final char NL = '\n';
......
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