Skip to content

Commit 343f9cc

Browse files
committed
Fix #757
1 parent bdcc5ce commit 343f9cc

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

FCL/src/main/java/com/tungsten/fcl/ui/manage/LocalModListAdapter.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ public LocalModListAdapter(Context context, ModListPage modListPage) {
6868
selectedItemsProperty.clear();
6969
fromSelf = false;
7070
notifyDataSetChanged();
71+
Task.runAsync(() -> {
72+
listProperty().get().forEach(modInfoObject -> {
73+
for (RemoteMod.Type type : RemoteMod.Type.values()) {
74+
try {
75+
if (modInfoObject.getRemoteMod() == null) {
76+
Optional<RemoteMod.Version> remoteVersion = type.getRemoteModRepository().getRemoteVersionByLocalFile(modInfoObject.getModInfo(), modInfoObject.getModInfo().getFile());
77+
if (remoteVersion.isPresent()) {
78+
RemoteMod remoteMod = type.getRemoteModRepository().getModById(remoteVersion.get().getModid());
79+
modInfoObject.getModInfo().setRemoteVersion(remoteVersion.get());
80+
modInfoObject.setRemoteMod(remoteMod);
81+
Schedulers.androidUIThread().execute(LocalModListAdapter.this::notifyDataSetChanged);
82+
break;
83+
}
84+
}
85+
} catch (Throwable ignore) {
86+
}
87+
}
88+
});
89+
notifyDataSetChanged();
90+
}).start();
7191
});
7292
selectedItemsProperty.addListener((InvalidationListener) observable -> {
7393
if (!fromSelf) {
@@ -174,30 +194,12 @@ public View getView(int i, View view, ViewGroup viewGroup) {
174194
ModInfoDialog dialog = new ModInfoDialog(getContext(), modInfoObject);
175195
dialog.show();
176196
});
177-
Task.runAsync(() -> {
178-
for (RemoteMod.Type type : RemoteMod.Type.values()) {
179-
try {
180-
if (modInfoObject.getRemoteMod() == null) {
181-
Optional<RemoteMod.Version> remoteVersion = type.getRemoteModRepository().getRemoteVersionByLocalFile(modInfoObject.getModInfo(), modInfoObject.getModInfo().getFile());
182-
if (remoteVersion.isPresent()) {
183-
RemoteMod remoteMod = type.getRemoteModRepository().getModById(remoteVersion.get().getModid());
184-
modInfoObject.getModInfo().setRemoteVersion(remoteVersion.get());
185-
modInfoObject.setRemoteMod(remoteMod);
186-
} else {
187-
continue;
188-
}
189-
}
190-
RemoteMod remoteMod = modInfoObject.getRemoteMod();
191-
Schedulers.androidUIThread().execute(() -> {
192-
viewHolder.icon.setVisibility(View.VISIBLE);
193-
Glide.with(getContext()).load(remoteMod.getIconUrl()).into(viewHolder.icon);
194-
viewHolder.name.setText(remoteMod.getTitle());
195-
});
196-
break;
197-
} catch (Throwable ignore) {
198-
}
199-
}
200-
}).start();
197+
RemoteMod remoteMod = modInfoObject.getRemoteMod();
198+
if (remoteMod != null) {
199+
viewHolder.icon.setVisibility(View.VISIBLE);
200+
Glide.with(getContext()).load(remoteMod.getIconUrl()).into(viewHolder.icon);
201+
viewHolder.name.setText(remoteMod.getTitle());
202+
}
201203
return view;
202204
}
203205

0 commit comments

Comments
 (0)