Skip to content

Droplist and current location added#2

Open
TomasJank wants to merge 2 commits into
HoutanProject:masterfrom
TomasJank:TomasJ
Open

Droplist and current location added#2
TomasJank wants to merge 2 commits into
HoutanProject:masterfrom
TomasJank:TomasJ

Conversation

@TomasJank

@TomasJank TomasJank commented Jan 3, 2019

Copy link
Copy Markdown

I have added a dropdown list for location selections and a textview for a current location

}
/* Toast.makeText(mContext, objectString, Toast.LENGTH_SHORT).show();*/
br.close();
} catch (IOException e) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

at least a printStackTrace here?

Ideally should wrap and rethrow in a custom exception so the UI can notify the frontend

Toast.makeText(MainContext.INSTANCE.getContext(), "Saved", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(context, "Not saved", Toast.LENGTH_SHORT).show();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

seems like your code is not properly layered, both doing I/O and interacting with the frontend. This makes your code hard to reuse and test

String content = FileUtils.readFile(MainContext.INSTANCE.getResources(), R.raw.shanghai);
wiFiLocations = new JSONObject(content);
Toast.makeText(MainContext.INSTANCE.getContext(), "Loaded locations with " + wiFiLocations.length() + " MAC -> location mappings", Toast.LENGTH_LONG).show();
} catch (Exception e) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

catchall exceptions are generally bad. you want to be specific

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants