Here’s the source of the data … just hard coded. [Note: I’ve refactored the name ListAttributes to ListTheme. The data structure has not changed.]
private void uploadTestAttributes() {
if (!CommonMethods.isNetworkAvailable()) {
showOkDialog(this, “Network Not Available”, “Unable to upload attributes”);
return;
}
long startTime = System.currentTimeMillis();
ArrayList<ListTheme> listOfAttributes = new ArrayList<>();
ListThemeRepositoryImpl listAttributesRepositoryImpl = new ListThemeRepositoryImpl(this);
ListTheme attributes;
attributes = ListTheme.newInstance("Genoa",
Color.parseColor("#4c898e"), Color.parseColor("#125156"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, true);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Opal",
Color.parseColor("#cbdcd4"), Color.parseColor("#91a69d"),
ContextCompat.getColor(this, R.color.black),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Shades of Blue",
-5777934, -10841921,
ContextCompat.getColor(this, R.color.black),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Off White",
ContextCompat.getColor(this, R.color.white), -2436147,
ContextCompat.getColor(this, R.color.black),
17f, 10f, 10f, false, true, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Whiskey",
Color.parseColor("#e9ac6d"), Color.parseColor("#ad7940"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Shakespeare",
Color.parseColor("#73c5d3"), Color.parseColor("#308d9e"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Sorbus",
Color.parseColor("#f0725b"), Color.parseColor("#bc3c21"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Dark Khaki",
Color.parseColor("#ced285"), Color.parseColor("#9b9f55"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Lemon Chiffon",
Color.parseColor("#fdfcdd"), Color.parseColor("#e3e2ac"),
ContextCompat.getColor(this, R.color.black),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Paprika",
Color.parseColor("#994552"), Color.parseColor("#5f0c16"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Medium Wood",
Color.parseColor("#bfaa75"), Color.parseColor("#8a7246"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Breaker Bay",
Color.parseColor("#6d8b93"), Color.parseColor("#31535c"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Sandrift",
Color.parseColor("#cbb59d"), Color.parseColor("#92806c"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Pale Brown",
Color.parseColor("#ac956c"), Color.parseColor("#705c39"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Seagull",
Color.parseColor("#94dcea"), Color.parseColor("#4ea0ab"),
ContextCompat.getColor(this, R.color.black),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Beige",
Color.parseColor("#fefefe"), Color.parseColor("#d3d8c2"),
ContextCompat.getColor(this, R.color.black),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Orange",
Color.parseColor("#ff6c52"), Color.parseColor("#e0341e"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Arsenic",
Color.parseColor("#545c67"), Color.parseColor("#1d242c"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
attributes = ListTheme.newInstance("Acapulco",
Color.parseColor("#8dbab3"), Color.parseColor("#58857e"),
ContextCompat.getColor(this, R.color.white),
17f, 10f, 10f, false, false, false);
listOfAttributes.add(attributes);
// ListTheme.saveToBackendlessAsync(attributes);
int count = 0;
//Server.Processing: java.lang.RuntimeException: java.lang.NullPointerException
for (ListTheme attribute : listOfAttributes) {
listAttributesRepositoryImpl.insert(attribute);;
count++;
}
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
String resultMessage = "Requested " + listOfAttributes.size() + " Attributes asyncSave to Backendless.";
MyLog.i("uploadTestAttributes", resultMessage);
showOkDialog(this, "Saved Attributes", resultMessage);
}