@@ -124,6 +124,7 @@ private void refresh(Openstud os) {
124
124
try {
125
125
student = InfoManager .getInfoStudent (getApplication (), os );
126
126
isee = InfoManager .getIsee (getApplication (), os );
127
+ runOnUiThread (() -> applyInfos (student , isee ));
127
128
} catch (OpenstudConnectionException e ) {
128
129
h .sendEmptyMessage (ClientHelper .Status .CONNECTION_ERROR .getValue ());
129
130
e .printStackTrace ();
@@ -141,6 +142,7 @@ private void refresh(Openstud os) {
141
142
}
142
143
143
144
private void applyInfos (Student st , Isee isee ) {
145
+ if (st == null ) return ;
144
146
DateTimeFormatter formatter = DateTimeFormatter .ofPattern ("dd/MM/uuuu" );
145
147
TextView navTitle = headerLayout .findViewById (R .id .nav_title );
146
148
navTitle .setText (getString (R .string .fullname , student .getFirstName (), student .getLastName ()));
@@ -270,9 +272,7 @@ public void handleMessage(Message msg) {
270
272
ProfileActivity activity = mActivity .get ();
271
273
if (activity != null ) {
272
274
View .OnClickListener listener = v -> new Thread (() -> activity .refresh (activity .os )).start ();
273
- if (msg .what == ClientHelper .Status .OK .getValue ()) {
274
- activity .applyInfos (activity .student , activity .isee );
275
- } else if (msg .what == ClientHelper .Status .CONNECTION_ERROR .getValue ()) {
275
+ if (msg .what == ClientHelper .Status .CONNECTION_ERROR .getValue ()) {
276
276
LayoutHelper .createActionSnackBar (activity .mDrawerLayout , R .string .connection_error , R .string .retry , Snackbar .LENGTH_LONG , listener );
277
277
} else if (msg .what == ClientHelper .Status .INVALID_RESPONSE .getValue ()) {
278
278
LayoutHelper .createActionSnackBar (activity .mDrawerLayout , R .string .invalid_response_error , R .string .retry , Snackbar .LENGTH_LONG , listener );
0 commit comments