-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeremy Silver
authored and
Asser
committed
Oct 2, 2017
1 parent
c47de01
commit 95f7929
Showing
39 changed files
with
671 additions
and
32 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...-GitHub-Repo-Search/T02.01-Exercise-CreateLayout/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-GitHub-Repo-Search/T02.01-Solution-CreateLayout/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Lesson02-GitHub-Repo-Search/T02.02-Exercise-AddMenu/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.DS_Store | ||
|
||
# built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# files for the dex VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# generated files | ||
bin/ | ||
out/ | ||
gen/ | ||
|
||
# Libraries used by the app | ||
# Can explicitly add if we want, but shouldn't do so blindly. Licenses, bloat, etc. | ||
/libs | ||
|
||
|
||
# Build stuff (auto-generated by android update project ...) | ||
build.xml | ||
ant.properties | ||
local.properties | ||
project.properties | ||
|
||
# Eclipse project files | ||
.classpath | ||
.project | ||
|
||
# idea project files | ||
.idea/ | ||
*.iml | ||
*.ipr | ||
*.iws | ||
|
||
# Gradle-based build | ||
.gradle | ||
build/ |
1 change: 1 addition & 0 deletions
1
Lesson02-GitHub-Repo-Search/T02.02-Exercise-AddMenu/app/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
24 changes: 24 additions & 0 deletions
24
Lesson02-GitHub-Repo-Search/T02.02-Exercise-AddMenu/app/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.1" | ||
|
||
defaultConfig { | ||
applicationId "com.example.android.datafrominternet" | ||
minSdkVersion 10 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:25.0.1' | ||
} |
20 changes: 20 additions & 0 deletions
20
Lesson02-GitHub-Repo-Search/T02.02-Exercise-AddMenu/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.android.datafrominternet"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name="com.example.android.datafrominternet.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
60 changes: 60 additions & 0 deletions
60
...Exercise-AddMenu/app/src/main/java/com/example/android/datafrominternet/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (C) 2016 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.example.android.datafrominternet; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.widget.EditText; | ||
import android.widget.TextView; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private EditText mSearchBoxEditText; | ||
|
||
private TextView mUrlDisplayTextView; | ||
private TextView mSearchResultsTextView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
mSearchBoxEditText = (EditText) findViewById(R.id.et_search_box); | ||
|
||
mUrlDisplayTextView = (TextView) findViewById(R.id.tv_url_display); | ||
mSearchResultsTextView = (TextView) findViewById(R.id.tv_github_search_results_json); | ||
} | ||
|
||
// Do 2 - 7 in menu.xml /////////////////////////////////////////////////////////////////////// | ||
// TODO (2) Create a menu in xml called main.xml | ||
// TODO (3) Add one menu item to your menu | ||
// TODO (4) Give the menu item an id of @+id/action_search | ||
// TODO (5) Set the orderInCategory to 1 | ||
// TODO (6) Show this item if there is room (use app:showAsAction, not android:showAsAction) | ||
// TODO (7) Set the title to the search string ("Search") from strings.xml | ||
// Do 2 - 7 in menu.xml /////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
// TODO (8) Override onCreateOptionsMenu | ||
// TODO (9) Within onCreateOptionsMenu, use getMenuInflater().inflate to inflate the menu | ||
// TODO (10) Return true to display your menu | ||
|
||
// TODO (11) Override onOptionsItemSelected | ||
// TODO (12) Within onOptionsItemSelected, get the ID of the item that was selected | ||
// TODO (13) If the item's ID is R.id.action_search, show a Toast and return true to tell Android that you've handled this menu click | ||
// TODO (14) Don't forgot to call .show() on your Toast | ||
// TODO (15) If you do NOT handle the menu click, return super.onOptionsItemSelected to let Android handle the menu click | ||
} |
76 changes: 76 additions & 0 deletions
76
...ddMenu/app/src/main/java/com/example/android/datafrominternet/utilities/NetworkUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2016 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.example.android.datafrominternet.utilities; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.util.Scanner; | ||
|
||
/** | ||
* These utilities will be used to communicate with the network. | ||
*/ | ||
public class NetworkUtils { | ||
|
||
final static String GITHUB_BASE_URL = | ||
"https://api.github.com/search/repositories"; | ||
|
||
final static String PARAM_QUERY = "q"; | ||
|
||
/* | ||
* The sort field. One of stars, forks, or updated. | ||
* Default: results are sorted by best match if no field is specified. | ||
*/ | ||
final static String PARAM_SORT = "sort"; | ||
final static String sortBy = "stars"; | ||
|
||
/** | ||
* Builds the URL used to query Github. | ||
* | ||
* @param githubSearchQuery The keyword that will be queried for. | ||
* @return The URL to use to query the weather server. | ||
*/ | ||
public static URL buildUrl(String githubSearchQuery) { | ||
return null; | ||
} | ||
|
||
/** | ||
* This method returns the entire result from the HTTP response. | ||
* | ||
* @param url The URL to fetch the HTTP response from. | ||
* @return The contents of the HTTP response. | ||
* @throws IOException Related to network and stream reading | ||
*/ | ||
public static String getResponseFromHttpUrl(URL url) throws IOException { | ||
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); | ||
try { | ||
InputStream in = urlConnection.getInputStream(); | ||
|
||
Scanner scanner = new Scanner(in); | ||
scanner.useDelimiter("\\A"); | ||
|
||
boolean hasInput = scanner.hasNext(); | ||
if (hasInput) { | ||
return scanner.next(); | ||
} else { | ||
return null; | ||
} | ||
} finally { | ||
urlConnection.disconnect(); | ||
} | ||
} | ||
} |
Oops, something went wrong.