code cleanup

pull/4/head
Felix Prahl-Kamps 2019-08-23 14:05:07 +02:00
parent f59778872b
commit 41ab6c18ce
6 changed files with 5 additions and 113 deletions

View File

@ -12,7 +12,6 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".activities.NetworkTestActivity"></activity>
<activity android:name=".activities.UploadActivity" />
<activity android:name=".activities.LauncherActivity">
<intent-filter>

View File

@ -144,7 +144,7 @@ public class HomeActivity extends AppCompatActivity {
@Override
public void failure(String error) {
Snackbar.make(recyclerView, error, Snackbar.LENGTH_LONG).show();
}
});
@ -161,14 +161,14 @@ public class HomeActivity extends AppCompatActivity {
}
@Override
public void failure(String error) {
Snackbar.make(recyclerView, error, Snackbar.LENGTH_LONG).show();
}
});
}
@Override
public void failure(String error) {
Snackbar.make(recyclerView, error, Snackbar.LENGTH_LONG).show();
}
});
}

View File

@ -1,99 +0,0 @@
package lu.circl.mispbump.activities;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.util.Pair;
import java.util.List;
import lu.circl.mispbump.R;
import lu.circl.mispbump.auxiliary.MispRestClient;
import lu.circl.mispbump.auxiliary.PreferenceManager;
import lu.circl.mispbump.interfaces.MispService;
import lu.circl.mispbump.models.SyncInformation;
import lu.circl.mispbump.models.restModels.MispOrganisation;
import lu.circl.mispbump.models.restModels.MispServer;
import lu.circl.mispbump.models.restModels.Organisation;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class NetworkTestActivity extends AppCompatActivity {
private PreferenceManager preferenceManager;
private MispService service;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_network_test);
preferenceManager = PreferenceManager.getInstance(NetworkTestActivity.this);
Pair<String, String> credentials = preferenceManager.getUserCredentials();
MispRestClient restClient = MispRestClient.getInstance(credentials.first, credentials.second);
service = restClient.getService();
loadAllSyncs();
}
private void boundSyncInfoToServer() {
List<SyncInformation> syncInformationList = preferenceManager.getSyncInformationList();
for (SyncInformation syncInfo : syncInformationList) {
String authkey = syncInfo.getRemote().getServer().getAuthkey();
String localUUID = syncInfo.getLocal().getOrganisation().getUuid();
String foreignUUID = syncInfo.getRemote().getOrganisation().getUuid();
}
}
private void loadAllSyncs() {
Call<List<MispServer>> allServersCall = service.getAllServers();
allServersCall.enqueue(new Callback<List<MispServer>>() {
@Override
public void onResponse(Call<List<MispServer>> call, Response<List<MispServer>> response) {
if (!response.isSuccessful()) {
return;
}
List<MispServer> allServers = response.body();
assert allServers != null;
for (MispServer mispServer : allServers) {
loadOrganisation(mispServer.getRemoteOrganisation().getId());
}
}
@Override
public void onFailure(Call<List<MispServer>> call, Throwable t) {
}
});
}
private void loadOrganisation(int id) {
Call<MispOrganisation> organisationCall = service.getOrganisation(id);
organisationCall.enqueue(new Callback<MispOrganisation>() {
@Override
public void onResponse(Call<MispOrganisation> call, Response<MispOrganisation> response) {
if (!response.isSuccessful()) {
return;
}
Organisation org = response.body().organisation;
Log.d("DEBUG", org.toString());
}
@Override
public void onFailure(Call<MispOrganisation> call, Throwable t) {
}
});
}
}

View File

@ -51,7 +51,7 @@ public class PreferenceActivity extends AppCompatActivity {
public static class PreferencesFragment extends PreferenceFragmentCompat {
Preference.OnPreferenceClickListener onDeleteAllSyncsListener;
private Preference.OnPreferenceClickListener onDeleteAllSyncsListener;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.NetworkTestActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -13,7 +13,7 @@ import static org.junit.Assert.assertEquals;
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
public void additionIsCorrect() {
assertEquals(4, 2 + 2);
}
}