ajay-prabhakar / Codeforces

Codeforces is Android version of Codeforces web. This app is made to integrate all the available Codeforces API into this app. :rocket:
Apache License 2.0
15 stars 7 forks source link

Landscape Orientation Not Supported #44

Open parjanyaacoder opened 4 years ago

parjanyaacoder commented 4 years ago

The bug is that the app does not support Landscape mode. The app only supports Portrait Mode.On Switching from portrait to landscape mode or vice versa the app crashes.

To Reproduce Steps to reproduce the behavior:

  1. Go to RUN
  2. Wait till the app is ready to run in emulator or in device.
  3. Search a CodeForce handle.
  4. Rotate the app.
  5. I hope you can see what the bug is.

Expected behavior As Expected the app should have supported the Layout Orientation of the phone as well.

Screenshots Screenshot_20191217-163723_Codeforces

Would you like to work on the issue? Yes

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.70. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

parjanyaacoder commented 4 years ago

I need help in resolving this issue.

krharsh17 commented 4 years ago

I went through it. You need to implement two-way callback for setting the visibility of menu item. The issue here is that when the screen is rotated, the activity restarts as part of normal lifecycle. But since no parameters are changed on this restart, so the API request is resent and response is received in an instant (probably from a cached version of the API response). But the UI elements are not initialized so fast, so a NPE is observed. To fix this, you can maintain a flag which checks whether the visibility related task has been completed or not. You have to set this flag true only when the task is complete. Now, you need to check for null in the onLoadFinished callback, and if null is not found, set the visibility as needed and set flag to true. If a null is found, set flag to false. Now you need to implement the same code related to the visibility check in onCreate, which should run only if the flag was false. This way I think this issue will be resolved.