Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank screen#240 fix #241

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions app/src/main/java/ai/elimu/appstore/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ protected void onStart() {
finish();
} else {
// Redirect to Activity for downloading list of Applications from REST API
Intent intent = new Intent(getApplicationContext(), InitialSyncActivity.class);
startActivity(intent);
finish();


runOnUiThread(new Runnable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was runOnUiThread added?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While running application on local i faced an issue where after coming back to app it was running on different thread while loading data on to Screen. So i used runOnUiThread to in UI thread.

Copy link
Member

@nya-elimu nya-elimu Aug 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While running application on local i faced an issue where after coming back to app it was running on different thread while loading data on to Screen. So i used runOnUiThread to in UI thread.

@arvind-1 Are you saying that the application was already downloading content from the REST API when you came back to the app after having opened it previously? If that's the case, maybe it would be better if we implement code that will cancel the download if the user leaves the activity (onStop()) before the download completes?

CC @gscdev

@Override
public void run() {
Intent intent = new Intent(getApplicationContext(), InitialSyncActivity.class);
startActivity(intent);
finish();
}
});


}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,21 @@ protected void onStart() {
RoomDb.databaseWriteExecutor.execute(() -> {
List<Application> applications = applicationDao.loadAll();
Log.d(getClass().getName(), "applications.size(): " + applications.size());
applicationListAdapter.setApplications(applications);

if(null!=applications) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to if (applications != null) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i will update it.

applicationListAdapter.setApplications(applications);
nya-elimu marked this conversation as resolved.
Show resolved Hide resolved
}
List<ApplicationVersion> applicationVersions = applicationVersionDao.loadAll();
Log.d(getClass().getName(), "applicationVersions.size(): " + applicationVersions.size());
applicationListAdapter.setApplicationVersions(applicationVersions);

applicationListAdapter.notifyDataSetChanged();

recyclerView.post(new Runnable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid the dependence on recyclerView, use runOnUiThread instead?:

Suggested change
recyclerView.post(new Runnable() {
runOnUiThread(new Runnable() {

@Override
public void run() {
applicationListAdapter.notifyDataSetChanged();
nya-elimu marked this conversation as resolved.
Show resolved Hide resolved
}
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

});
}
}
}