{"action":"created","comment":{"url":"https://api.github.com/repos/mapsme/omim/pulls/comments/57731193","id":57731193,"diff_hunk":"@@ -89,51 +89,40 @@ public boolean onBackPressed()\n \n   private void switchMode()\n   {\n-    if (mIsAdvancedMode)\n-      simpleMode();\n+    if (!mIsAdvancedMode)\n+    {\n+      final String filledTimetables = mSimpleModeFragment != null ? mSimpleModeFragment.getTimetables()\n+                                                                  : OpeningHours.nativeTimetablesToString(OpeningHours.nativeGetDefaultTimetables());\n+      if (!OpeningHours.nativeIsTimetableStringValid(filledTimetables))\n+      {\n+        new AlertDialog.Builder(getActivity())\n+            .setMessage(R.string.editor_correct_mistake)\n+            .setPositiveButton(android.R.string.ok, null)\n+            .show();\n+        return;\n+      }\n+      mIsAdvancedMode = true;\n+      mSwitchMode.setText(R.string.editor_time_advanced);\n+      mAdvancedModeFragment = (AdvancedTimetableFragment) attachFragment(mAdvancedModeFragment, AdvancedTimetableFragment.class.getName());\n+      mAdvancedModeFragment.setTimetables(filledTimetables);\n+    }\n     else\n-      advancedMode();\n-  }\n-\n-  private void simpleMode()\n-  {\n-    mIsAdvancedMode = false;\n-    mSwitchMode.setText(R.string.editor_time_advanced);\n-    final Timetable[] filledTimetables = getFilledTimetables(mAdvancedModeFragment, mAdvancedModeFragment);\n-    mSimpleModeFragment = (SimpleTimetableFragment) attachFragment(mSimpleModeFragment, SimpleTimetableFragment.class.getName());\n-    mSimpleModeFragment.setTimetables(filledTimetables);\n-  }\n-\n-  private void advancedMode()\n-  {\n-    mIsAdvancedMode = true;\n-    mSwitchMode.setText(R.string.editor_time_simple);\n-    final Timetable[] filledTimetables = getFilledTimetables(mSimpleModeFragment, mSimpleModeFragment);\n-    mAdvancedModeFragment = (AdvancedTimetableFragment) attachFragment(mAdvancedModeFragment, AdvancedTimetableFragment.class.getName());\n-    mAdvancedModeFragment.setTimetables(filledTimetables);\n-  }\n-\n-  private boolean hasFilledTimetables(Fragment fragment)\n-  {\n-    return fragment != null && fragment.isAdded();\n-  }\n-\n-  @Nullable\n-  private Timetable[] getFilledTimetables(Fragment fragment, TimetableProvider provider)\n-  {\n-    if (!hasFilledTimetables(fragment))\n-      return null;\n-\n-    final Timetable[] timetables = provider.getTimetables();\n-    if (timetables == null)\n     {\n-      new AlertDialog.Builder(getActivity())\n-          .setMessage(R.string.editor_correct_mistake)\n-          .create();\n-      return null;\n+      final String filledTimetables = mAdvancedModeFragment != null ? mAdvancedModeFragment.getTimetables()\n+                                                                    : OpeningHours.nativeTimetablesToString(OpeningHours.nativeGetDefaultTimetables());\n+      if (!OpeningHours.nativeIsTimetableStringValid(filledTimetables))\n+      {\n+        new AlertDialog.Builder(getActivity())\n+            .setMessage(R.string.editor_correct_mistake)\n+            .setPositiveButton(android.R.string.ok, null)\n+            .show();\n+        return;\n+      }\n+      mIsAdvancedMode = false;\n+      mSwitchMode.setText(R.string.editor_time_simple);\n+      mSimpleModeFragment = (SimpleTimetableFragment) attachFragment(mSimpleModeFragment, SimpleTimetableFragment.class.getName());\n+      mSimpleModeFragment.setTimetables(filledTimetables);","path":"android/src/com/mapswithme/maps/editor/TimetableFragment.java","position":116,"original_position":118,"commit_id":"d11a0ea72f21a96058629f61f0747be129d297ad","original_commit_id":"4a195bbeebe113d84b7c9fa4c3c254dcbfbbbe3c","user":{"login":"yunikkk","id":2265924,"avatar_url":"https://avatars.githubusercontent.com/u/2265924?v=3","gravatar_id":"","url":"https://api.github.com/users/yunikkk","html_url":"https://github.com/yunikkk","followers_url":"https://api.github.com/users/yunikkk/followers","following_url":"https://api.github.com/users/yunikkk/following{/other_user}","gists_url":"https://api.github.com/users/yunikkk/gists{/gist_id}","starred_url":"https://api.github.com/users/yunikkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yunikkk/subscriptions","organizations_url":"https://api.github.com/users/yunikkk/orgs","repos_url":"https://api.github.com/users/yunikkk/repos","events_url":"https://api.github.com/users/yunikkk/events{/privacy}","received_events_url":"https://api.github.com/users/yunikkk/received_events","type":"User","site_admin":false},"body":"Остаются эти две строчки - тоже выходит уродливо и с проверками в двух местах.\n\n> On Mar 29, 2016, at 5:21 PM, Alexander Marchuk <notifications@github.com> wrote:\n> \n> In android/src/com/mapswithme/maps/editor/TimetableFragment.java <https://github.com/mapsme/omim/pull/2614#discussion_r57731049>:\n> \n> > -          .create();\n> > -      return null;\n> > +      final String filledTimetables = mAdvancedModeFragment != null ? mAdvancedModeFragment.getTimetables()\n> > +                                                                    : OpeningHours.nativeTimetablesToString(OpeningHours.nativeGetDefaultTimetables());\n> > +      if (!OpeningHours.nativeIsTimetableStringValid(filledTimetables))\n> > +      {\n> > +        new AlertDialog.Builder(getActivity())\n> > +            .setMessage(R.string.editor_correct_mistake)\n> > +            .setPositiveButton(android.R.string.ok, null)\n> > +            .show();\n> > +        return;\n> > +      }\n> > +      mIsAdvancedMode = false;\n> > +      mSwitchMode.setText(R.string.editor_time_simple);\n> > +      mSimpleModeFragment = (SimpleTimetableFragment) attachFragment(mSimpleModeFragment, SimpleTimetableFragment.class.getName());\n> > +      mSimpleModeFragment.setTimetables(filledTimetables);\n> Например, всё, что выше последних двух строчек вроде бы легко выносится.\n> \n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly or view it on GitHub <https://github.com/mapsme/omim/pull/2614/files/b9b7a07ccb512adcfc1a190ee9bc7bde65172a54..4a195bbeebe113d84b7c9fa4c3c254dcbfbbbe3c#r57731049>\n\n","created_at":"2016-03-29T14:21:59Z","updated_at":"2016-03-29T14:21:59Z","html_url":"https://github.com/mapsme/omim/pull/2614#discussion_r57731193","pull_request_url":"https://api.github.com/repos/mapsme/omim/pulls/2614","_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments/57731193"},"html":{"href":"https://github.com/mapsme/omim/pull/2614#discussion_r57731193"},"pull_request":{"href":"https://api.github.com/repos/mapsme/omim/pulls/2614"}}},"pull_request":{"url":"https://api.github.com/repos/mapsme/omim/pulls/2614","id":64470347,"html_url":"https://github.com/mapsme/omim/pull/2614","diff_url":"https://github.com/mapsme/omim/pull/2614.diff","patch_url":"https://github.com/mapsme/omim/pull/2614.patch","issue_url":"https://api.github.com/repos/mapsme/omim/issues/2614","number":2614,"state":"open","locked":false,"title":"[android] Timetable editor fixes.","user":{"login":"yunikkk","id":2265924,"avatar_url":"https://avatars.githubusercontent.com/u/2265924?v=3","gravatar_id":"","url":"https://api.github.com/users/yunikkk","html_url":"https://github.com/yunikkk","followers_url":"https://api.github.com/users/yunikkk/followers","following_url":"https://api.github.com/users/yunikkk/following{/other_user}","gists_url":"https://api.github.com/users/yunikkk/gists{/gist_id}","starred_url":"https://api.github.com/users/yunikkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yunikkk/subscriptions","organizations_url":"https://api.github.com/users/yunikkk/orgs","repos_url":"https://api.github.com/users/yunikkk/repos","events_url":"https://api.github.com/users/yunikkk/events{/privacy}","received_events_url":"https://api.github.com/users/yunikkk/received_events","type":"User","site_admin":false},"body":"https://trello.com/c/lmqNWwd2/147-android-opening-hours-advanced-mode","created_at":"2016-03-29T14:03:50Z","updated_at":"2016-03-29T14:21:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b674cb49afbb1e6304fda8f4c9d6a950de95b714","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mapsme/omim/pulls/2614/commits","review_comments_url":"https://api.github.com/repos/mapsme/omim/pulls/2614/comments","review_comment_url":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapsme/omim/issues/2614/comments","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/d11a0ea72f21a96058629f61f0747be129d297ad","head":{"label":"yunikkk:crashfix","ref":"crashfix","sha":"d11a0ea72f21a96058629f61f0747be129d297ad","user":{"login":"yunikkk","id":2265924,"avatar_url":"https://avatars.githubusercontent.com/u/2265924?v=3","gravatar_id":"","url":"https://api.github.com/users/yunikkk","html_url":"https://github.com/yunikkk","followers_url":"https://api.github.com/users/yunikkk/followers","following_url":"https://api.github.com/users/yunikkk/following{/other_user}","gists_url":"https://api.github.com/users/yunikkk/gists{/gist_id}","starred_url":"https://api.github.com/users/yunikkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yunikkk/subscriptions","organizations_url":"https://api.github.com/users/yunikkk/orgs","repos_url":"https://api.github.com/users/yunikkk/repos","events_url":"https://api.github.com/users/yunikkk/events{/privacy}","received_events_url":"https://api.github.com/users/yunikkk/received_events","type":"User","site_admin":false},"repo":{"id":44106681,"name":"omim","full_name":"yunikkk/omim","owner":{"login":"yunikkk","id":2265924,"avatar_url":"https://avatars.githubusercontent.com/u/2265924?v=3","gravatar_id":"","url":"https://api.github.com/users/yunikkk","html_url":"https://github.com/yunikkk","followers_url":"https://api.github.com/users/yunikkk/followers","following_url":"https://api.github.com/users/yunikkk/following{/other_user}","gists_url":"https://api.github.com/users/yunikkk/gists{/gist_id}","starred_url":"https://api.github.com/users/yunikkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yunikkk/subscriptions","organizations_url":"https://api.github.com/users/yunikkk/orgs","repos_url":"https://api.github.com/users/yunikkk/repos","events_url":"https://api.github.com/users/yunikkk/events{/privacy}","received_events_url":"https://api.github.com/users/yunikkk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yunikkk/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":true,"url":"https://api.github.com/repos/yunikkk/omim","forks_url":"https://api.github.com/repos/yunikkk/omim/forks","keys_url":"https://api.github.com/repos/yunikkk/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yunikkk/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yunikkk/omim/teams","hooks_url":"https://api.github.com/repos/yunikkk/omim/hooks","issue_events_url":"https://api.github.com/repos/yunikkk/omim/issues/events{/number}","events_url":"https://api.github.com/repos/yunikkk/omim/events","assignees_url":"https://api.github.com/repos/yunikkk/omim/assignees{/user}","branches_url":"https://api.github.com/repos/yunikkk/omim/branches{/branch}","tags_url":"https://api.github.com/repos/yunikkk/omim/tags","blobs_url":"https://api.github.com/repos/yunikkk/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yunikkk/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yunikkk/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/yunikkk/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yunikkk/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/yunikkk/omim/languages","stargazers_url":"https://api.github.com/repos/yunikkk/omim/stargazers","contributors_url":"https://api.github.com/repos/yunikkk/omim/contributors","subscribers_url":"https://api.github.com/repos/yunikkk/omim/subscribers","subscription_url":"https://api.github.com/repos/yunikkk/omim/subscription","commits_url":"https://api.github.com/repos/yunikkk/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/yunikkk/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/yunikkk/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/yunikkk/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/yunikkk/omim/contents/{+path}","compare_url":"https://api.github.com/repos/yunikkk/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yunikkk/omim/merges","archive_url":"https://api.github.com/repos/yunikkk/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yunikkk/omim/downloads","issues_url":"https://api.github.com/repos/yunikkk/omim/issues{/number}","pulls_url":"https://api.github.com/repos/yunikkk/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/yunikkk/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/yunikkk/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yunikkk/omim/labels{/name}","releases_url":"https://api.github.com/repos/yunikkk/omim/releases{/id}","deployments_url":"https://api.github.com/repos/yunikkk/omim/deployments","created_at":"2015-10-12T12:41:54Z","updated_at":"2016-02-05T12:51:47Z","pushed_at":"2016-03-29T14:18:25Z","git_url":"git://github.com/yunikkk/omim.git","ssh_url":"git@github.com:yunikkk/omim.git","clone_url":"https://github.com/yunikkk/omim.git","svn_url":"https://github.com/yunikkk/omim","homepage":null,"size":2301591,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mapsme:release-60","ref":"release-60","sha":"55f8ace635fb907e9353a855191e5a2f702c7ef4","user":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"repo":{"id":42798033,"name":"omim","full_name":"mapsme/omim","owner":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapsme/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":false,"url":"https://api.github.com/repos/mapsme/omim","forks_url":"https://api.github.com/repos/mapsme/omim/forks","keys_url":"https://api.github.com/repos/mapsme/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapsme/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapsme/omim/teams","hooks_url":"https://api.github.com/repos/mapsme/omim/hooks","issue_events_url":"https://api.github.com/repos/mapsme/omim/issues/events{/number}","events_url":"https://api.github.com/repos/mapsme/omim/events","assignees_url":"https://api.github.com/repos/mapsme/omim/assignees{/user}","branches_url":"https://api.github.com/repos/mapsme/omim/branches{/branch}","tags_url":"https://api.github.com/repos/mapsme/omim/tags","blobs_url":"https://api.github.com/repos/mapsme/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapsme/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapsme/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapsme/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/mapsme/omim/languages","stargazers_url":"https://api.github.com/repos/mapsme/omim/stargazers","contributors_url":"https://api.github.com/repos/mapsme/omim/contributors","subscribers_url":"https://api.github.com/repos/mapsme/omim/subscribers","subscription_url":"https://api.github.com/repos/mapsme/omim/subscription","commits_url":"https://api.github.com/repos/mapsme/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapsme/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapsme/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapsme/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapsme/omim/contents/{+path}","compare_url":"https://api.github.com/repos/mapsme/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapsme/omim/merges","archive_url":"https://api.github.com/repos/mapsme/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapsme/omim/downloads","issues_url":"https://api.github.com/repos/mapsme/omim/issues{/number}","pulls_url":"https://api.github.com/repos/mapsme/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/mapsme/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/mapsme/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapsme/omim/labels{/name}","releases_url":"https://api.github.com/repos/mapsme/omim/releases{/id}","deployments_url":"https://api.github.com/repos/mapsme/omim/deployments","created_at":"2015-09-20T02:57:13Z","updated_at":"2016-03-29T12:33:26Z","pushed_at":"2016-03-29T14:20:11Z","git_url":"git://github.com/mapsme/omim.git","ssh_url":"git@github.com:mapsme/omim.git","clone_url":"https://github.com/mapsme/omim.git","svn_url":"https://github.com/mapsme/omim","homepage":null,"size":2328801,"stargazers_count":1679,"watchers_count":1679,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":245,"mirror_url":null,"open_issues_count":115,"forks":245,"open_issues":115,"watchers":1679,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/2614"},"html":{"href":"https://github.com/mapsme/omim/pull/2614"},"issue":{"href":"https://api.github.com/repos/mapsme/omim/issues/2614"},"comments":{"href":"https://api.github.com/repos/mapsme/omim/issues/2614/comments"},"review_comments":{"href":"https://api.github.com/repos/mapsme/omim/pulls/2614/comments"},"review_comment":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapsme/omim/pulls/2614/commits"},"statuses":{"href":"https://api.github.com/repos/mapsme/omim/statuses/d11a0ea72f21a96058629f61f0747be129d297ad"}}}}