This file contains hidden or 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
| interface DisplayCandidates { | |
| fun all() | |
| fun withName(name: String) | |
| data class Candidate(val id: String, val name: String, val phoneNumbers: Collection<String>) { | |
| internal companion object { | |
| fun from(candidate: CandidateEntity) = Candidate(candidate.id, candidate.fullName, candidate.contactNumbers.map { it.phoneNumber }) | |
| } |
This file contains hidden or 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
| enum class Assessment { | |
| A, B, C, D, E, F | |
| } |
This file contains hidden or 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
| public class NewLinkedInIntegration extends Activity { | |
| /*CONSTANT FOR THE AUTHORIZATION PROCESS*/ | |
| /****FILL THIS WITH YOUR INFORMATION*********/ | |
| //This is the public api key of our application | |
| private static final String API_KEY = "your client id"; | |
| //This is the private api key of our application | |
| private static final String SECRET_KEY = "your secret key"; |
This file contains hidden or 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
| private void sendGetRequestForEmail(String urlString, String accessToken) throws Exception { | |
| URL url = new URL(urlString); | |
| HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); | |
| con.setRequestMethod("GET"); | |
| con.setRequestProperty("Authorization", "Bearer " + accessToken); | |
| con.setRequestProperty("cache-control", "no-cache"); | |
| con.setRequestProperty("X-Restli-Protocol-Version", "2.0.0"); | |
| BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); | |
| StringBuilder jsonString = new StringBuilder(); | |
| String line; |
This file contains hidden or 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
| public void sendGetRequest(String urlString, String accessToken) throws Exception { | |
| URL url = new URL(urlString); | |
| HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); | |
| con.setRequestMethod("GET"); | |
| con.setRequestProperty("Authorization", "Bearer " + accessToken); | |
| con.setRequestProperty("cache-control", "no-cache"); | |
| con.setRequestProperty("X-Restli-Protocol-Version", "2.0.0"); | |
| BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); |
This file contains hidden or 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
| private class PostRequestAsyncTask extends AsyncTask<String, Void, Boolean> { | |
| @Override | |
| protected void onPreExecute() { | |
| pd = ProgressDialog.show(NewLinkedInIntegration.this, "", "Loading", true); | |
| } | |
| @Override | |
| protected Boolean doInBackground(String... urls) { | |
| if (urls.length > 0) { |
This file contains hidden or 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
| private static String getAccessTokenUrl(String authorizationToken) { | |
| return ACCESS_TOKEN_URL | |
| + QUESTION_MARK | |
| + GRANT_TYPE_PARAM + EQUALS + GRANT_TYPE | |
| + AMPERSAND | |
| + RESPONSE_TYPE_VALUE + EQUALS + authorizationToken | |
| + AMPERSAND | |
| + CLIENT_ID_PARAM + EQUALS + API_KEY | |
| + AMPERSAND | |
| + REDIRECT_URI_PARAM + EQUALS + REDIRECT_URI |
This file contains hidden or 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
| @Override | |
| public boolean shouldOverrideUrlLoading(WebView view, String authorizationUrl) { | |
| //This method will be called when the Auth proccess redirect to our RedirectUri. | |
| //We will check the url looking for our RedirectUri. | |
| if (authorizationUrl.startsWith(REDIRECT_URI)) { | |
| Log.i("Authorize", ""); | |
| Uri uri = Uri.parse(authorizationUrl); | |
| //We take from the url the authorizationToken and the state token. We have to check that the state token returned by the Service is the same we sent. | |
| //If not, that means the request may be a result of CSRF and must be rejected. | |
| String stateToken = uri.getQueryParameter(STATE_PARAM); |
This file contains hidden or 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
| ... | |
| bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { | |
| @Override | |
| public void onStateChanged(View view, int i) { | |
| // .. | |
| // your code is here | |
| } | |
| @Override |
This file contains hidden or 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
| LinearLayout bottomSheet = findViewById(R.id.bottom_sheet_behavior_id); | |
| BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); | |
| // .. | |
| // here you could find all the UI views inside your bottom sheet and initialize them | |
| // .. | |
| // .. | |
| // setting the bottom sheet callback for interacting with state changes and sliding | |
| bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { |