Browse Source

Fix for uploads courses

develop
Ezerous 3 years ago
parent
commit
40918385d9
  1. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java
  2. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsCourse.java
  3. 28
      app/src/main/res/raw/uploads_courses.json

2
app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java

@ -421,7 +421,7 @@ public class UploadActivity extends BaseActivity {
generateFieldsButton.setEnabled(true); generateFieldsButton.setEnabled(true);
} }
FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
String uploadsCoursesString = firebaseRemoteConfig.getString(firebaseConfigUploadsCoursesKey); String uploadsCoursesString = firebaseRemoteConfig.getValue(firebaseConfigUploadsCoursesKey).asString();
JSONObject uploadsCoursesJSON; JSONObject uploadsCoursesJSON;
try { try {
uploadsCoursesJSON = new JSONObject(uploadsCoursesString); uploadsCoursesJSON = new JSONObject(uploadsCoursesString);

6
app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadsCourse.java

@ -6,6 +6,8 @@ import org.json.JSONObject;
import java.util.HashMap; import java.util.HashMap;
import timber.log.Timber;
public class UploadsCourse { public class UploadsCourse {
private final int id; private final int id;
private final String name, minifiedName, greeklishName; private final String name, minifiedName, greeklishName;
@ -43,7 +45,9 @@ public class UploadsCourse {
String name = course.getString("name"); String name = course.getString("name");
String minifiedName = course.getString("minified"); String minifiedName = course.getString("minified");
String greeklisName = course.getString("greeklish"); String greeklisName = course.getString("greeklish");
coursesHashMap.put(course.getInt("id"), new UploadsCourse(id, name, minifiedName, greeklisName)); if(coursesHashMap.containsKey(id))
Timber.w("Added a duplicate id (%d) in uploads courses!", id);
coursesHashMap.put(id, new UploadsCourse(id, name, minifiedName, greeklisName));
} }
} }

28
app/src/main/res/raw/uploads_courses.json

@ -435,6 +435,10 @@
{ {
"id": "20", "id": "20",
"name": "8ο εξάμηνο", "name": "8ο εξάμηνο",
"categories": [
{
"id": "5526",
"name": "8ο εξάμηνο [ΠΠΣ]",
"categories": [ "categories": [
{ {
"id": "990", "id": "990",
@ -496,6 +500,8 @@
} }
] ]
} }
]
}
], ],
"courses": [ "courses": [
{ {
@ -758,10 +764,6 @@
"id": "15", "id": "15",
"name": "7ο εξάμηνο", "name": "7ο εξάμηνο",
"categories": [ "categories": [
{
"id": "4943",
"name": "7ο εξάμηνο [ΠΠΣ]",
"categories": [
{ {
"id": "4943", "id": "4943",
"name": "7ο εξάμηνο [ΠΠΣ]", "name": "7ο εξάμηνο [ΠΠΣ]",
@ -798,8 +800,6 @@
} }
] ]
} }
]
}
], ],
"courses": [ "courses": [
{ {
@ -1462,12 +1462,6 @@
"minified": "Γεωηλεκτρομαγνητισμός", "minified": "Γεωηλεκτρομαγνητισμός",
"greeklish": "Geoilektromagnitismos" "greeklish": "Geoilektromagnitismos"
}, },
{
"id": "150",
"name": "Μικροκυματική Τηλεπισκόπηση [ΠΠΣ]",
"minified": "Μικροκυματική Τηλεπισκόπηση",
"greeklish": "MRS"
},
{ {
"id": "157", "id": "157",
"name": "Τεχνικές Κωδικοποίησης [ΠΠΣ]", "name": "Τεχνικές Κωδικοποίησης [ΠΠΣ]",
@ -1480,6 +1474,12 @@
"id": "6000", "id": "6000",
"name": "Υποχρεωτικά Μαθήματα [ΠΠΣ]", "name": "Υποχρεωτικά Μαθήματα [ΠΠΣ]",
"courses": [ "courses": [
{
"id": "150",
"name": "Μικροκυματική Τηλεπισκόπηση [ΠΠΣ]",
"minified": "Μικροκυματική Τηλεπισκόπηση",
"greeklish": "MRS"
},
{ {
"id": "149", "id": "149",
"name": "Σύνθεση Τηλεπικοινωνιακών Διατάξεων [ΠΠΣ]", "name": "Σύνθεση Τηλεπικοινωνιακών Διατάξεων [ΠΠΣ]",
@ -1487,6 +1487,8 @@
"greeklish": "Synthesi_Tilepikoinoniakon_Diatakseon" "greeklish": "Synthesi_Tilepikoinoniakon_Diatakseon"
} }
] ]
}
]
}, },
{ {
"id": "2024", "id": "2024",
@ -1563,8 +1565,6 @@
] ]
} }
] ]
}
]
}, },
{ {
"id": "3", "id": "3",

Loading…
Cancel
Save