{"action":"created","comment":{"url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/comments/23720183","id":23720183,"diff_hunk":"@@ -0,0 +1,348 @@\n+package com.alex700.AWeather;\n+\n+\n+import android.app.Activity;\n+import android.app.ActionBar;\n+import android.app.Fragment;\n+import android.app.LoaderManager;\n+import android.content.CursorLoader;\n+import android.content.Loader;\n+import android.database.Cursor;\n+import android.support.v4.app.ActionBarDrawerToggle;\n+import android.support.v4.view.GravityCompat;\n+import android.support.v4.widget.DrawerLayout;\n+import android.content.SharedPreferences;\n+import android.content.res.Configuration;\n+import android.os.Bundle;\n+import android.preference.PreferenceManager;\n+import android.util.Log;\n+import android.view.LayoutInflater;\n+import android.view.Menu;\n+import android.view.MenuInflater;\n+import android.view.MenuItem;\n+import android.view.View;\n+import android.view.ViewGroup;\n+import android.widget.AdapterView;\n+import android.widget.ArrayAdapter;\n+import android.widget.Button;\n+import android.widget.LinearLayout;\n+import android.widget.ListView;\n+import android.widget.Toast;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+\n+public class NavigationDrawerFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>,\n+        View.OnClickListener {\n+\n+    private static final String STATE_SELECTED_POSITION = \"selected_navigation_drawer_position\";\n+\n+    private static final String PREF_USER_LEARNED_DRAWER = \"navigation_drawer_learned\";\n+\n+    private NavigationDrawerCallbacks mCallbacks;\n+\n+    private ActionBarDrawerToggle mDrawerToggle;\n+\n+    private DrawerLayout mDrawerLayout;\n+    private LinearLayout mDrawerListView;\n+    private View mFragmentContainerView;\n+\n+    private int mCurrentSelectedPosition = 0;\n+    private boolean mFromSavedInstanceState;\n+    private boolean mUserLearnedDrawer;\n+    private List<String> elements;\n+    private List<City> cities;\n+    private boolean firstStart = true;\n+    private String lastSelected = null;\n+\n+    public List<City> getCities() {\n+        return cities;\n+    }\n+\n+    public List<String> getElements() {\n+        return elements;\n+    }\n+\n+    public void selectItemAfterLoading(String x) {\n+        lastSelected = x;\n+        Log.d(\"Choose\", \"start\");\n+    }\n+\n+    public NavigationDrawerFragment() {\n+    }\n+\n+    @Override\n+    public void onCreate(Bundle savedInstanceState) {\n+        super.onCreate(savedInstanceState);\n+\n+        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());\n+        mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);\n+\n+        if (savedInstanceState != null) {\n+            mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);\n+            mFromSavedInstanceState = true;\n+        }\n+\n+    }\n+\n+    @Override\n+    public void onActivityCreated(Bundle savedInstanceState) {\n+        super.onActivityCreated(savedInstanceState);\n+        setHasOptionsMenu(true);\n+    }\n+\n+    @Override\n+    public View onCreateView(LayoutInflater inflater, ViewGroup container,\n+                             Bundle savedInstanceState) {\n+\n+        Log.d(\"NAVIG\", \"onCreateView\");\n+        mDrawerListView = (LinearLayout) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);\n+        ((ListView) mDrawerListView.findViewById(R.id.city_list)).setOnItemClickListener(new AdapterView.OnItemClickListener() {\n+            @Override\n+            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {\n+                selectItem(position);\n+            }\n+        });\n+\n+        elements = new ArrayList<>();\n+        cities = new ArrayList<>();\n+        ((ListView) mDrawerListView.findViewById(R.id.city_list)).setAdapter(new ArrayAdapter<>(\n+                getActionBar().getThemedContext(),\n+                android.R.layout.simple_list_item_activated_1,\n+                android.R.id.text1,\n+                elements));\n+\n+        ((ListView) mDrawerListView.findViewById(R.id.city_list)).setItemChecked(mCurrentSelectedPosition, true);\n+        ((ListView) mDrawerListView.findViewById(R.id.city_list)).setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {\n+            @Override\n+            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {\n+                if (elements.size() != 1) {\n+                    City delCity = cities.get(position);\n+                    getActivity().getContentResolver().delete(WeatherContentProvider.WEATHER_CONTENT_URI,\n+                            WeatherDatabaseHelper.WEATHER_CITY_ID + \"=\" + delCity.getId(), null);\n+                    getActivity().getContentResolver().delete(WeatherContentProvider.CITY_CONTENT_URI,\n+                            WeatherDatabaseHelper.CITY_ID + \"=\" + delCity.getId(), null);\n+                    cities.remove(position);\n+                    elements.remove(position);\n+                    ((ArrayAdapter) ((ListView) getActivity().findViewById(R.id.city_list)).getAdapter()).notifyDataSetChanged();\n+                    selectItem(0);\n+                } else {\n+                    Toast.makeText(getActivity(), \"Don't delete last town !\", Toast.LENGTH_SHORT).show();\n+                }\n+                return true;\n+            }\n+        });\n+        ((Button) mDrawerListView.findViewById(R.id.add_city_button)).setOnClickListener(this);\n+        getLoaderManager().restartLoader(2222, null, this);","path":"app/src/main/java/com/alex700/AWeather/NavigationDrawerFragment.java","position":137,"original_position":137,"commit_id":"a37dae6940ceef371749b2ea30508bbd66caa9b1","original_commit_id":"a37dae6940ceef371749b2ea30508bbd66caa9b1","user":{"login":"thevery","id":99576,"avatar_url":"https://avatars.githubusercontent.com/u/99576?v=3","gravatar_id":"","url":"https://api.github.com/users/thevery","html_url":"https://github.com/thevery","followers_url":"https://api.github.com/users/thevery/followers","following_url":"https://api.github.com/users/thevery/following{/other_user}","gists_url":"https://api.github.com/users/thevery/gists{/gist_id}","starred_url":"https://api.github.com/users/thevery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thevery/subscriptions","organizations_url":"https://api.github.com/users/thevery/orgs","repos_url":"https://api.github.com/users/thevery/repos","events_url":"https://api.github.com/users/thevery/events{/privacy}","received_events_url":"https://api.github.com/users/thevery/received_events","type":"User","site_admin":false},"body":"const!","created_at":"2015-01-28T20:25:11Z","updated_at":"2015-01-28T20:25:11Z","html_url":"https://github.com/IFMO-MobDev-2014/lesson8/pull/43#discussion_r23720183","pull_request_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/43","_links":{"self":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/comments/23720183"},"html":{"href":"https://github.com/IFMO-MobDev-2014/lesson8/pull/43#discussion_r23720183"},"pull_request":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/43","id":27110818,"html_url":"https://github.com/IFMO-MobDev-2014/lesson8/pull/43","diff_url":"https://github.com/IFMO-MobDev-2014/lesson8/pull/43.diff","patch_url":"https://github.com/IFMO-MobDev-2014/lesson8/pull/43.patch","issue_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/issues/43","number":43,"state":"open","locked":false,"title":"Латышев Алексей Сергеевич, группа 2539","user":{"login":"alex-700","id":8705888,"avatar_url":"https://avatars.githubusercontent.com/u/8705888?v=3","gravatar_id":"","url":"https://api.github.com/users/alex-700","html_url":"https://github.com/alex-700","followers_url":"https://api.github.com/users/alex-700/followers","following_url":"https://api.github.com/users/alex-700/following{/other_user}","gists_url":"https://api.github.com/users/alex-700/gists{/gist_id}","starred_url":"https://api.github.com/users/alex-700/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex-700/subscriptions","organizations_url":"https://api.github.com/users/alex-700/orgs","repos_url":"https://api.github.com/users/alex-700/repos","events_url":"https://api.github.com/users/alex-700/events{/privacy}","received_events_url":"https://api.github.com/users/alex-700/received_events","type":"User","site_admin":false},"body":"Все части.\r\n","created_at":"2015-01-09T16:26:32Z","updated_at":"2015-01-28T20:25:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c658acdd539e31c92bd8b2e871bde8b70e399c9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/43/commits","review_comments_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/43/comments","review_comment_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/comments/{number}","comments_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/issues/43/comments","statuses_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/statuses/a37dae6940ceef371749b2ea30508bbd66caa9b1","head":{"label":"alex-700:master","ref":"master","sha":"a37dae6940ceef371749b2ea30508bbd66caa9b1","user":{"login":"alex-700","id":8705888,"avatar_url":"https://avatars.githubusercontent.com/u/8705888?v=3","gravatar_id":"","url":"https://api.github.com/users/alex-700","html_url":"https://github.com/alex-700","followers_url":"https://api.github.com/users/alex-700/followers","following_url":"https://api.github.com/users/alex-700/following{/other_user}","gists_url":"https://api.github.com/users/alex-700/gists{/gist_id}","starred_url":"https://api.github.com/users/alex-700/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex-700/subscriptions","organizations_url":"https://api.github.com/users/alex-700/orgs","repos_url":"https://api.github.com/users/alex-700/repos","events_url":"https://api.github.com/users/alex-700/events{/privacy}","received_events_url":"https://api.github.com/users/alex-700/received_events","type":"User","site_admin":false},"repo":{"id":27308895,"name":"lesson8","full_name":"alex-700/lesson8","owner":{"login":"alex-700","id":8705888,"avatar_url":"https://avatars.githubusercontent.com/u/8705888?v=3","gravatar_id":"","url":"https://api.github.com/users/alex-700","html_url":"https://github.com/alex-700","followers_url":"https://api.github.com/users/alex-700/followers","following_url":"https://api.github.com/users/alex-700/following{/other_user}","gists_url":"https://api.github.com/users/alex-700/gists{/gist_id}","starred_url":"https://api.github.com/users/alex-700/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex-700/subscriptions","organizations_url":"https://api.github.com/users/alex-700/orgs","repos_url":"https://api.github.com/users/alex-700/repos","events_url":"https://api.github.com/users/alex-700/events{/privacy}","received_events_url":"https://api.github.com/users/alex-700/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alex-700/lesson8","description":"","fork":true,"url":"https://api.github.com/repos/alex-700/lesson8","forks_url":"https://api.github.com/repos/alex-700/lesson8/forks","keys_url":"https://api.github.com/repos/alex-700/lesson8/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alex-700/lesson8/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alex-700/lesson8/teams","hooks_url":"https://api.github.com/repos/alex-700/lesson8/hooks","issue_events_url":"https://api.github.com/repos/alex-700/lesson8/issues/events{/number}","events_url":"https://api.github.com/repos/alex-700/lesson8/events","assignees_url":"https://api.github.com/repos/alex-700/lesson8/assignees{/user}","branches_url":"https://api.github.com/repos/alex-700/lesson8/branches{/branch}","tags_url":"https://api.github.com/repos/alex-700/lesson8/tags","blobs_url":"https://api.github.com/repos/alex-700/lesson8/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alex-700/lesson8/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alex-700/lesson8/git/refs{/sha}","trees_url":"https://api.github.com/repos/alex-700/lesson8/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alex-700/lesson8/statuses/{sha}","languages_url":"https://api.github.com/repos/alex-700/lesson8/languages","stargazers_url":"https://api.github.com/repos/alex-700/lesson8/stargazers","contributors_url":"https://api.github.com/repos/alex-700/lesson8/contributors","subscribers_url":"https://api.github.com/repos/alex-700/lesson8/subscribers","subscription_url":"https://api.github.com/repos/alex-700/lesson8/subscription","commits_url":"https://api.github.com/repos/alex-700/lesson8/commits{/sha}","git_commits_url":"https://api.github.com/repos/alex-700/lesson8/git/commits{/sha}","comments_url":"https://api.github.com/repos/alex-700/lesson8/comments{/number}","issue_comment_url":"https://api.github.com/repos/alex-700/lesson8/issues/comments/{number}","contents_url":"https://api.github.com/repos/alex-700/lesson8/contents/{+path}","compare_url":"https://api.github.com/repos/alex-700/lesson8/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alex-700/lesson8/merges","archive_url":"https://api.github.com/repos/alex-700/lesson8/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alex-700/lesson8/downloads","issues_url":"https://api.github.com/repos/alex-700/lesson8/issues{/number}","pulls_url":"https://api.github.com/repos/alex-700/lesson8/pulls{/number}","milestones_url":"https://api.github.com/repos/alex-700/lesson8/milestones{/number}","notifications_url":"https://api.github.com/repos/alex-700/lesson8/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alex-700/lesson8/labels{/name}","releases_url":"https://api.github.com/repos/alex-700/lesson8/releases{/id}","created_at":"2014-11-29T17:03:54Z","updated_at":"2015-01-09T16:24:29Z","pushed_at":"2015-01-09T16:24:29Z","git_url":"git://github.com/alex-700/lesson8.git","ssh_url":"git@github.com:alex-700/lesson8.git","clone_url":"https://github.com/alex-700/lesson8.git","svn_url":"https://github.com/alex-700/lesson8","homepage":null,"size":3118,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"IFMO-MobDev-2014:master","ref":"master","sha":"108a0745cc1f02a3198b6ddf0adfba6962a24a26","user":{"login":"IFMO-MobDev-2014","id":8738407,"avatar_url":"https://avatars.githubusercontent.com/u/8738407?v=3","gravatar_id":"","url":"https://api.github.com/users/IFMO-MobDev-2014","html_url":"https://github.com/IFMO-MobDev-2014","followers_url":"https://api.github.com/users/IFMO-MobDev-2014/followers","following_url":"https://api.github.com/users/IFMO-MobDev-2014/following{/other_user}","gists_url":"https://api.github.com/users/IFMO-MobDev-2014/gists{/gist_id}","starred_url":"https://api.github.com/users/IFMO-MobDev-2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IFMO-MobDev-2014/subscriptions","organizations_url":"https://api.github.com/users/IFMO-MobDev-2014/orgs","repos_url":"https://api.github.com/users/IFMO-MobDev-2014/repos","events_url":"https://api.github.com/users/IFMO-MobDev-2014/events{/privacy}","received_events_url":"https://api.github.com/users/IFMO-MobDev-2014/received_events","type":"Organization","site_admin":false},"repo":{"id":27033654,"name":"lesson8","full_name":"IFMO-MobDev-2014/lesson8","owner":{"login":"IFMO-MobDev-2014","id":8738407,"avatar_url":"https://avatars.githubusercontent.com/u/8738407?v=3","gravatar_id":"","url":"https://api.github.com/users/IFMO-MobDev-2014","html_url":"https://github.com/IFMO-MobDev-2014","followers_url":"https://api.github.com/users/IFMO-MobDev-2014/followers","following_url":"https://api.github.com/users/IFMO-MobDev-2014/following{/other_user}","gists_url":"https://api.github.com/users/IFMO-MobDev-2014/gists{/gist_id}","starred_url":"https://api.github.com/users/IFMO-MobDev-2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IFMO-MobDev-2014/subscriptions","organizations_url":"https://api.github.com/users/IFMO-MobDev-2014/orgs","repos_url":"https://api.github.com/users/IFMO-MobDev-2014/repos","events_url":"https://api.github.com/users/IFMO-MobDev-2014/events{/privacy}","received_events_url":"https://api.github.com/users/IFMO-MobDev-2014/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/IFMO-MobDev-2014/lesson8","description":"","fork":false,"url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8","forks_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/forks","keys_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/teams","hooks_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/hooks","issue_events_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/issues/events{/number}","events_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/events","assignees_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/assignees{/user}","branches_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/branches{/branch}","tags_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/tags","blobs_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/git/refs{/sha}","trees_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/statuses/{sha}","languages_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/languages","stargazers_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/stargazers","contributors_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/contributors","subscribers_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/subscribers","subscription_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/subscription","commits_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/commits{/sha}","git_commits_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/git/commits{/sha}","comments_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/comments{/number}","issue_comment_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/issues/comments/{number}","contents_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/contents/{+path}","compare_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/merges","archive_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/downloads","issues_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/issues{/number}","pulls_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls{/number}","milestones_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/milestones{/number}","notifications_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/labels{/name}","releases_url":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/releases{/id}","created_at":"2014-11-23T13:42:50Z","updated_at":"2014-11-23T14:07:36Z","pushed_at":"2014-11-23T14:07:36Z","git_url":"git://github.com/IFMO-MobDev-2014/lesson8.git","ssh_url":"git@github.com:IFMO-MobDev-2014/lesson8.git","clone_url":"https://github.com/IFMO-MobDev-2014/lesson8.git","svn_url":"https://github.com/IFMO-MobDev-2014/lesson8","homepage":null,"size":4923,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"open_issues_count":12,"forks":56,"open_issues":12,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/43"},"html":{"href":"https://github.com/IFMO-MobDev-2014/lesson8/pull/43"},"issue":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/issues/43"},"comments":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/IFMO-MobDev-2014/lesson8/statuses/a37dae6940ceef371749b2ea30508bbd66caa9b1"}}}}