{"action":"created","comment":{"url":"https://api.github.com/repos/sarality/appblocks/pulls/comments/24233847","id":24233847,"diff_hunk":"@@ -20,29 +19,64 @@\n  */\n public abstract class DynamicListDialogFragment<T> extends BaseDialogFragment implements DataConsumer<List<T>> {\n \n-  private final DataSource<List<T>> dataSource;\n-  private final ListViewAdapter<T> adapter;\n-\n-  public DynamicListDialogFragment(FragmentActivity activity, ListViewRowRenderer<T> renderer,\n-      DataSource<List<T>> dataSource) {\n-    super(activity);\n-    this.dataSource = dataSource;\n-    this.adapter = new ListViewAdapter<T>(activity, dataSource.getData(), renderer);\n-  }\n+  private ListViewAdapter<T> adapter;\n \n   @Override\n   public void onActivityCreated(Bundle savedInstanceState) {\n     super.onActivityCreated(savedInstanceState);\n-    // Start loading data here.\n-    getFragmentActivity().getSupportLoaderManager()\n-        .initLoader(0, null, new DataLoader<List<T>>(getActivity(), dataSource, this));\n+    DataSource<List<T>> dataSource = getDataSource();\n+    startLoad(dataSource, getLoaderId(), this);\n+    if (dataSource != null) {\n+      this.adapter = new ListViewAdapter<T>(getActivity(), dataSource.getData(), getListViewRowRenderer());\n+    } else {\n+      this.adapter = new ListViewAdapter<T>(getActivity(), null, getListViewRowRenderer());\n+    }\n+  }\n+\n+  /**\n+   * @return Renderer to be used to render each row of the list displayed in the dialog.\n+   */\n+  protected abstract ListViewRowRenderer<T> getListViewRowRenderer();\n+\n+  /**\n+   * Returns a unique Id to be used for the loader.\n+   *\n+   * @return Unique Id for the loader.\n+   */\n+  protected abstract int getLoaderId();\n+\n+  /**\n+   * @return The DataSource used to load data for the fragment.\n+   */\n+  protected abstract DataSource<List<T>> getDataSource();\n+\n+  /**\n+   *\n+   * @param dataSource DataSource to load the data from\n+   * @param loaderId Id to used for the loader\n+   */\n+  protected <D> void startLoad(DataSource<D> dataSource, int loaderId, DataConsumer<D> consumer) {","path":"src/java/com/sarality/app/view/dialog/DynamicListDialogFragment.java","position":60,"original_position":60,"commit_id":"5666ba9385c17f79b37e3c0d318feadfa3d3eaee","original_commit_id":"5666ba9385c17f79b37e3c0d318feadfa3d3eaee","user":{"login":"abhideep","id":5652836,"avatar_url":"https://avatars.githubusercontent.com/u/5652836?v=3","gravatar_id":"","url":"https://api.github.com/users/abhideep","html_url":"https://github.com/abhideep","followers_url":"https://api.github.com/users/abhideep/followers","following_url":"https://api.github.com/users/abhideep/following{/other_user}","gists_url":"https://api.github.com/users/abhideep/gists{/gist_id}","starred_url":"https://api.github.com/users/abhideep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhideep/subscriptions","organizations_url":"https://api.github.com/users/abhideep/orgs","repos_url":"https://api.github.com/users/abhideep/repos","events_url":"https://api.github.com/users/abhideep/events{/privacy}","received_events_url":"https://api.github.com/users/abhideep/received_events","type":"User","site_admin":false},"body":"This is to allow the Fragement to load other data sources asynchronously and then have them impact the view. By default the LoaderId is used, but this leaves the flexibility in the hands of the caller.","created_at":"2015-02-06T10:56:14Z","updated_at":"2015-02-06T10:56:14Z","html_url":"https://github.com/sarality/appblocks/pull/244#discussion_r24233847","pull_request_url":"https://api.github.com/repos/sarality/appblocks/pulls/244","_links":{"self":{"href":"https://api.github.com/repos/sarality/appblocks/pulls/comments/24233847"},"html":{"href":"https://github.com/sarality/appblocks/pull/244#discussion_r24233847"},"pull_request":{"href":"https://api.github.com/repos/sarality/appblocks/pulls/244"}}},"pull_request":{"url":"https://api.github.com/repos/sarality/appblocks/pulls/244","id":28793978,"html_url":"https://github.com/sarality/appblocks/pull/244","diff_url":"https://github.com/sarality/appblocks/pull/244.diff","patch_url":"https://github.com/sarality/appblocks/pull/244.patch","issue_url":"https://api.github.com/repos/sarality/appblocks/issues/244","number":244,"state":"open","locked":false,"title":"Loader id in fragments initializers","user":{"login":"abhideep","id":5652836,"avatar_url":"https://avatars.githubusercontent.com/u/5652836?v=3","gravatar_id":"","url":"https://api.github.com/users/abhideep","html_url":"https://github.com/abhideep","followers_url":"https://api.github.com/users/abhideep/followers","following_url":"https://api.github.com/users/abhideep/following{/other_user}","gists_url":"https://api.github.com/users/abhideep/gists{/gist_id}","starred_url":"https://api.github.com/users/abhideep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhideep/subscriptions","organizations_url":"https://api.github.com/users/abhideep/orgs","repos_url":"https://api.github.com/users/abhideep/repos","events_url":"https://api.github.com/users/abhideep/events{/privacy}","received_events_url":"https://api.github.com/users/abhideep/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-06T09:06:03Z","updated_at":"2015-02-06T10:56:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"47bb8582922a66f8ea69b1df2f74a87622798e8d","assignee":{"login":"sunayna","id":5754536,"avatar_url":"https://avatars.githubusercontent.com/u/5754536?v=3","gravatar_id":"","url":"https://api.github.com/users/sunayna","html_url":"https://github.com/sunayna","followers_url":"https://api.github.com/users/sunayna/followers","following_url":"https://api.github.com/users/sunayna/following{/other_user}","gists_url":"https://api.github.com/users/sunayna/gists{/gist_id}","starred_url":"https://api.github.com/users/sunayna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunayna/subscriptions","organizations_url":"https://api.github.com/users/sunayna/orgs","repos_url":"https://api.github.com/users/sunayna/repos","events_url":"https://api.github.com/users/sunayna/events{/privacy}","received_events_url":"https://api.github.com/users/sunayna/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/sarality/appblocks/pulls/244/commits","review_comments_url":"https://api.github.com/repos/sarality/appblocks/pulls/244/comments","review_comment_url":"https://api.github.com/repos/sarality/appblocks/pulls/comments/{number}","comments_url":"https://api.github.com/repos/sarality/appblocks/issues/244/comments","statuses_url":"https://api.github.com/repos/sarality/appblocks/statuses/5666ba9385c17f79b37e3c0d318feadfa3d3eaee","head":{"label":"sarality:loader_id_in_fragments_initializers","ref":"loader_id_in_fragments_initializers","sha":"5666ba9385c17f79b37e3c0d318feadfa3d3eaee","user":{"login":"sarality","id":5752439,"avatar_url":"https://avatars.githubusercontent.com/u/5752439?v=3","gravatar_id":"","url":"https://api.github.com/users/sarality","html_url":"https://github.com/sarality","followers_url":"https://api.github.com/users/sarality/followers","following_url":"https://api.github.com/users/sarality/following{/other_user}","gists_url":"https://api.github.com/users/sarality/gists{/gist_id}","starred_url":"https://api.github.com/users/sarality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarality/subscriptions","organizations_url":"https://api.github.com/users/sarality/orgs","repos_url":"https://api.github.com/users/sarality/repos","events_url":"https://api.github.com/users/sarality/events{/privacy}","received_events_url":"https://api.github.com/users/sarality/received_events","type":"Organization","site_admin":false},"repo":{"id":16136525,"name":"appblocks","full_name":"sarality/appblocks","owner":{"login":"sarality","id":5752439,"avatar_url":"https://avatars.githubusercontent.com/u/5752439?v=3","gravatar_id":"","url":"https://api.github.com/users/sarality","html_url":"https://github.com/sarality","followers_url":"https://api.github.com/users/sarality/followers","following_url":"https://api.github.com/users/sarality/following{/other_user}","gists_url":"https://api.github.com/users/sarality/gists{/gist_id}","starred_url":"https://api.github.com/users/sarality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarality/subscriptions","organizations_url":"https://api.github.com/users/sarality/orgs","repos_url":"https://api.github.com/users/sarality/repos","events_url":"https://api.github.com/users/sarality/events{/privacy}","received_events_url":"https://api.github.com/users/sarality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sarality/appblocks","description":"The Building Blocks to make it easier to build Android Apps","fork":false,"url":"https://api.github.com/repos/sarality/appblocks","forks_url":"https://api.github.com/repos/sarality/appblocks/forks","keys_url":"https://api.github.com/repos/sarality/appblocks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sarality/appblocks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sarality/appblocks/teams","hooks_url":"https://api.github.com/repos/sarality/appblocks/hooks","issue_events_url":"https://api.github.com/repos/sarality/appblocks/issues/events{/number}","events_url":"https://api.github.com/repos/sarality/appblocks/events","assignees_url":"https://api.github.com/repos/sarality/appblocks/assignees{/user}","branches_url":"https://api.github.com/repos/sarality/appblocks/branches{/branch}","tags_url":"https://api.github.com/repos/sarality/appblocks/tags","blobs_url":"https://api.github.com/repos/sarality/appblocks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sarality/appblocks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sarality/appblocks/git/refs{/sha}","trees_url":"https://api.github.com/repos/sarality/appblocks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sarality/appblocks/statuses/{sha}","languages_url":"https://api.github.com/repos/sarality/appblocks/languages","stargazers_url":"https://api.github.com/repos/sarality/appblocks/stargazers","contributors_url":"https://api.github.com/repos/sarality/appblocks/contributors","subscribers_url":"https://api.github.com/repos/sarality/appblocks/subscribers","subscription_url":"https://api.github.com/repos/sarality/appblocks/subscription","commits_url":"https://api.github.com/repos/sarality/appblocks/commits{/sha}","git_commits_url":"https://api.github.com/repos/sarality/appblocks/git/commits{/sha}","comments_url":"https://api.github.com/repos/sarality/appblocks/comments{/number}","issue_comment_url":"https://api.github.com/repos/sarality/appblocks/issues/comments/{number}","contents_url":"https://api.github.com/repos/sarality/appblocks/contents/{+path}","compare_url":"https://api.github.com/repos/sarality/appblocks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sarality/appblocks/merges","archive_url":"https://api.github.com/repos/sarality/appblocks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sarality/appblocks/downloads","issues_url":"https://api.github.com/repos/sarality/appblocks/issues{/number}","pulls_url":"https://api.github.com/repos/sarality/appblocks/pulls{/number}","milestones_url":"https://api.github.com/repos/sarality/appblocks/milestones{/number}","notifications_url":"https://api.github.com/repos/sarality/appblocks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sarality/appblocks/labels{/name}","releases_url":"https://api.github.com/repos/sarality/appblocks/releases{/id}","created_at":"2014-01-22T10:44:45Z","updated_at":"2015-02-06T05:06:09Z","pushed_at":"2015-02-06T09:05:54Z","git_url":"git://github.com/sarality/appblocks.git","ssh_url":"git@github.com:sarality/appblocks.git","clone_url":"https://github.com/sarality/appblocks.git","svn_url":"https://github.com/sarality/appblocks","homepage":null,"size":18588,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"sarality:master","ref":"master","sha":"974390770eda2c99a5049e39b5c4f8968f83ddf6","user":{"login":"sarality","id":5752439,"avatar_url":"https://avatars.githubusercontent.com/u/5752439?v=3","gravatar_id":"","url":"https://api.github.com/users/sarality","html_url":"https://github.com/sarality","followers_url":"https://api.github.com/users/sarality/followers","following_url":"https://api.github.com/users/sarality/following{/other_user}","gists_url":"https://api.github.com/users/sarality/gists{/gist_id}","starred_url":"https://api.github.com/users/sarality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarality/subscriptions","organizations_url":"https://api.github.com/users/sarality/orgs","repos_url":"https://api.github.com/users/sarality/repos","events_url":"https://api.github.com/users/sarality/events{/privacy}","received_events_url":"https://api.github.com/users/sarality/received_events","type":"Organization","site_admin":false},"repo":{"id":16136525,"name":"appblocks","full_name":"sarality/appblocks","owner":{"login":"sarality","id":5752439,"avatar_url":"https://avatars.githubusercontent.com/u/5752439?v=3","gravatar_id":"","url":"https://api.github.com/users/sarality","html_url":"https://github.com/sarality","followers_url":"https://api.github.com/users/sarality/followers","following_url":"https://api.github.com/users/sarality/following{/other_user}","gists_url":"https://api.github.com/users/sarality/gists{/gist_id}","starred_url":"https://api.github.com/users/sarality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarality/subscriptions","organizations_url":"https://api.github.com/users/sarality/orgs","repos_url":"https://api.github.com/users/sarality/repos","events_url":"https://api.github.com/users/sarality/events{/privacy}","received_events_url":"https://api.github.com/users/sarality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sarality/appblocks","description":"The Building Blocks to make it easier to build Android Apps","fork":false,"url":"https://api.github.com/repos/sarality/appblocks","forks_url":"https://api.github.com/repos/sarality/appblocks/forks","keys_url":"https://api.github.com/repos/sarality/appblocks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sarality/appblocks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sarality/appblocks/teams","hooks_url":"https://api.github.com/repos/sarality/appblocks/hooks","issue_events_url":"https://api.github.com/repos/sarality/appblocks/issues/events{/number}","events_url":"https://api.github.com/repos/sarality/appblocks/events","assignees_url":"https://api.github.com/repos/sarality/appblocks/assignees{/user}","branches_url":"https://api.github.com/repos/sarality/appblocks/branches{/branch}","tags_url":"https://api.github.com/repos/sarality/appblocks/tags","blobs_url":"https://api.github.com/repos/sarality/appblocks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sarality/appblocks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sarality/appblocks/git/refs{/sha}","trees_url":"https://api.github.com/repos/sarality/appblocks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sarality/appblocks/statuses/{sha}","languages_url":"https://api.github.com/repos/sarality/appblocks/languages","stargazers_url":"https://api.github.com/repos/sarality/appblocks/stargazers","contributors_url":"https://api.github.com/repos/sarality/appblocks/contributors","subscribers_url":"https://api.github.com/repos/sarality/appblocks/subscribers","subscription_url":"https://api.github.com/repos/sarality/appblocks/subscription","commits_url":"https://api.github.com/repos/sarality/appblocks/commits{/sha}","git_commits_url":"https://api.github.com/repos/sarality/appblocks/git/commits{/sha}","comments_url":"https://api.github.com/repos/sarality/appblocks/comments{/number}","issue_comment_url":"https://api.github.com/repos/sarality/appblocks/issues/comments/{number}","contents_url":"https://api.github.com/repos/sarality/appblocks/contents/{+path}","compare_url":"https://api.github.com/repos/sarality/appblocks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sarality/appblocks/merges","archive_url":"https://api.github.com/repos/sarality/appblocks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sarality/appblocks/downloads","issues_url":"https://api.github.com/repos/sarality/appblocks/issues{/number}","pulls_url":"https://api.github.com/repos/sarality/appblocks/pulls{/number}","milestones_url":"https://api.github.com/repos/sarality/appblocks/milestones{/number}","notifications_url":"https://api.github.com/repos/sarality/appblocks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sarality/appblocks/labels{/name}","releases_url":"https://api.github.com/repos/sarality/appblocks/releases{/id}","created_at":"2014-01-22T10:44:45Z","updated_at":"2015-02-06T05:06:09Z","pushed_at":"2015-02-06T09:05:54Z","git_url":"git://github.com/sarality/appblocks.git","ssh_url":"git@github.com:sarality/appblocks.git","clone_url":"https://github.com/sarality/appblocks.git","svn_url":"https://github.com/sarality/appblocks","homepage":null,"size":18588,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sarality/appblocks/pulls/244"},"html":{"href":"https://github.com/sarality/appblocks/pull/244"},"issue":{"href":"https://api.github.com/repos/sarality/appblocks/issues/244"},"comments":{"href":"https://api.github.com/repos/sarality/appblocks/issues/244/comments"},"review_comments":{"href":"https://api.github.com/repos/sarality/appblocks/pulls/244/comments"},"review_comment":{"href":"https://api.github.com/repos/sarality/appblocks/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/sarality/appblocks/pulls/244/commits"},"statuses":{"href":"https://api.github.com/repos/sarality/appblocks/statuses/5666ba9385c17f79b37e3c0d318feadfa3d3eaee"}}}}