Skip to content

Instantly share code, notes, and snippets.

View Ikhiloya's full-sized avatar

Ikhiloya Ikhiloya

View GitHub Profile
@Ikhiloya
Ikhiloya / currentThread.java
Created January 31, 2019 10:02
code to get the current thread id in android
Thread.currentThread().getId();
@Ikhiloya
Ikhiloya / HttpsRequestPoster.java
Created March 18, 2019 15:05 — forked from xSAVIKx/HttpsRequestPoster.java
Simple HTTPS POST request using raw JAVA for quering web-form
import javax.net.ssl.*;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;
@Ikhiloya
Ikhiloya / GetRequestHeader,..java
Created April 23, 2019 13:03
Get Request Headers in Spring Boot
@GetMapping(value = "/test")
public void test(@RequestHeader HttpHeaders httpHeaders){
System.out.println("ALL headers -- "+ httpHeaders);
System.out.println(httpHeaders.get("DEVICE-ID"));
System.out.println(httpHeaders.get("DEVICE-ID").get(0));
// System.out.println("'Accept' header -- "+ headers.("Accept"));
// System.out.println("'TestCookie' value -- "+ headers.getCookies().get("TestCookie").getValue());
}
mRecycler = findViewById(R.id.home_recycler);
mRecycler.setHasFixedSize(true);
mRecycler.setLayoutManager(new GridLayoutManager(this, 2));
mPager = findViewById(R.id.mainViewPager);
WormDotsIndicator wormDotsIndicator = findViewById(R.id.worm_dots_indicator);
categories = new ArrayList<>();
categories.add(new Category(R.drawable.cam, PHOTOGRAPHY));
categories.add(new Category(R.drawable.eve, EVENT));
@Ikhiloya
Ikhiloya / GooglePlacesInitialization.java
Created June 1, 2019 22:44
Google Places Initialization in android
String apiKey = getString(R.string.api_key);
/**
* Initialize Places. For simplicity, the API key is hard-coded. In a production
* environment we recommend using a secure mechanism to manage API keys.
*/
if (!Places.isInitialized()) {
Places.initialize(getApplicationContext(), apiKey);
}
@Ikhiloya
Ikhiloya / GooglePlacesInitialization.java
Created June 1, 2019 22:44
Google Places Initialization in android
String apiKey = getString(R.string.api_key);
/**
* Initialize Places. For simplicity, the API key is hard-coded. In a production
* environment we recommend using a secure mechanism to manage API keys.
*/
if (!Places.isInitialized()) {
Places.initialize(getApplicationContext(), apiKey);
}
@Ikhiloya
Ikhiloya / AutocompleteSupportFragment.xml
Last active June 1, 2019 22:54
Google Places Autocomplete Support Fragment
<fragment android:id="@+id/autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment"
/>
@Ikhiloya
Ikhiloya / AutocompleteSupportFragmentInit.java
Created June 1, 2019 22:58
AutocompleteSupportFragment Initialization
// Initialize the AutocompleteSupportFragment.
AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)
getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment);
autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
@Ikhiloya
Ikhiloya / SearchOptionsMenu.xml
Created June 1, 2019 23:02
Options menu for Search
<?xml version="1.0" encoding="utf-8"?><!-- Options Menu for Search-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/search"
android:icon="@drawable/ic_search_24dp"
android:title="@string/menu_search"
app:showAsAction="always|collapseActionView" />
</menu>
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.search:
onSearchCalled();
return true;
case android.R.id.home:
finish();
return true;
default: