Skip to content

Instantly share code, notes, and snippets.

View virendersran01's full-sized avatar
💻
Working from home

Virender Srxn virendersran01

💻
Working from home
  • India
View GitHub Profile
class ClickDrawable(layers: Array<out Drawable> = arrayOf()) : LayerDrawable(layers) {
private val mask: Drawable =
ColorDrawable(0xFF00FFFF.toInt()).apply { alpha = 0 }
init {
addLayer(mask)
}
class ClickDrawable(layers: Array<out Drawable> = arrayOf()) : LayerDrawable(layers) {
private var wasPressed = false
private var mActive = false
private var canStart = true
private var mBounds = bounds
override fun isStateful(): Boolean {
return true
}
@Override
protected boolean onStateChange(int[] stateSet) {
final boolean changed = super.onStateChange(stateSet);
boolean enabled = false;
boolean pressed = false;
boolean focused = false;
boolean hovered = false;
@virendersran01
virendersran01 / DisplayCandidates.kt
Created July 8, 2020 07:23 — forked from macieknajbar/DisplayCandidates.kt
CandidateAssessment - use cases
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 })
}
enum class Assessment {
A, B, C, D, E, F
}
@virendersran01
virendersran01 / Webview.java
Created July 9, 2020 12:05 — forked from GitEliteNovice/Webview.java
Get Authentication code for LinkedN
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";
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;
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()));
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) {
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