Skip to content

Commit b37652d

Browse files
committed
Profile: Minor fixes
1 parent c49088b commit b37652d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/src/main/java/com/lithium/leona/openstud/activities/ProfileActivity.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ private void refresh(Openstud os) {
124124
try {
125125
student = InfoManager.getInfoStudent(getApplication(), os);
126126
isee = InfoManager.getIsee(getApplication(), os);
127+
runOnUiThread(() -> applyInfos(student, isee));
127128
} catch (OpenstudConnectionException e) {
128129
h.sendEmptyMessage(ClientHelper.Status.CONNECTION_ERROR.getValue());
129130
e.printStackTrace();
@@ -141,6 +142,7 @@ private void refresh(Openstud os) {
141142
}
142143

143144
private void applyInfos(Student st, Isee isee) {
145+
if (st == null) return;
144146
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/uuuu");
145147
TextView navTitle = headerLayout.findViewById(R.id.nav_title);
146148
navTitle.setText(getString(R.string.fullname, student.getFirstName(), student.getLastName()));
@@ -270,9 +272,7 @@ public void handleMessage(Message msg) {
270272
ProfileActivity activity = mActivity.get();
271273
if (activity != null) {
272274
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()) {
276276
LayoutHelper.createActionSnackBar(activity.mDrawerLayout, R.string.connection_error, R.string.retry, Snackbar.LENGTH_LONG, listener);
277277
} else if (msg.what == ClientHelper.Status.INVALID_RESPONSE.getValue()) {
278278
LayoutHelper.createActionSnackBar(activity.mDrawerLayout, R.string.invalid_response_error, R.string.retry, Snackbar.LENGTH_LONG, listener);

0 commit comments

Comments
 (0)