Skip to content

Instantly share code, notes, and snippets.

View yunusemredilber's full-sized avatar
:shipit:
Hanging out at localhost

Yunus Emre Dilber yunusemredilber

:shipit:
Hanging out at localhost
View GitHub Profile
@yunusemredilber
yunusemredilber / AndroidManifest.xml
Created September 3, 2019 13:54
Android Turbolinks Geolocation Handling
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@yunusemredilber
yunusemredilber / _form.html.erb
Created September 10, 2019 11:21
One by one multiple file (image) upload [Ruby on Rails] [StimulusJS]
<%= form_with(model: content, id: 'content_form',
data: {controller: 'image-upload',
target: 'image-upload.form',
action: 'ajax:beforeSend->image-upload#submit'}) do |form| %>
<div data-target="image-upload.imagePreviews"></div>
<%= form.file_field :photos, multiple: true,
accept: "image/*;capture=camera|library",
data: { action: "image-upload#multiImageDisplay" } %>
@yunusemredilber
yunusemredilber / build.gradle
Created August 12, 2019 21:46
turbolinks-android fix unnecessary runtime crash
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.example.groupath"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
@yunusemredilber
yunusemredilber / MainActivity.java
Created September 27, 2019 11:24
Android Translucent Status Bar
import androidx.appcompat.app.AppCompatActivity;
import android.os.Build;
import android.os.Bundle;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
// -----------------------------------------------------------------------
// Activity overrides
// -----------------------------------------------------------------------
@yunusemredilber
yunusemredilber / JsBridge.java
Created October 1, 2019 12:32
Turbolinks Android - Fix Session Issues
public class JsBridge {
private Context context;
public static android.webkit.CookieManager cookieManager = CookieManager.getInstance();
public JsBridge(Context context){
this.context = context;
}
@JavascriptInterface
@yunusemredilber
yunusemredilber / _grid.html.erb
Created October 9, 2019 11:12
Bootstrap grid of images responsive [Rails] [Stimulus]
<div class="row">
<% photos.each_with_index do |photo, i| %>
<% if i == 0 %>
<%= render partial: 'image', locals: { image: image, col_length: 12, square: false }, cached: true %>
<% else %>
<%= render partial: 'image', locals: { image: image, col_length: 4, square: true }, cached: true %>
<% end %>
<% end %>
</div>
@yunusemredilber
yunusemredilber / MainActivity.java
Created December 3, 2019 12:21
Using Turbolinks Android with tabs.
public class MainActivity extends AppCompatActivity implements TurbolinksAdapter {
// Change the BASE_URL to an address that your VM or device can hit.
private static final String BASE_URL = "http://10.0.1.100:9292";
private static final String INTENT_URL = "intentUrl";
String tab1_path = "/tab1";
String tab2_path = "/tab2";
boolean tab1_is_visited = false;
boolean tab2_is_visited = false;
@yunusemredilber
yunusemredilber / activity_fab_with_badge.xml
Created February 5, 2020 11:23
Android Material FAB With Badge Attached
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_view">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/notifications_button"
@yunusemredilber
yunusemredilber / SomeActivity.java
Last active February 8, 2020 06:39
Webview In Navigation View (Drawer) [ Android ]
public class SomeActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview_in_drawer_layout);
// ...
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawerLayout, null, R.string.app_name, R.string.app_name);
@yunusemredilber
yunusemredilber / MainActivity.java
Created February 15, 2020 11:53
Android circular image view downloaded from the internet with AsyncTask
public class MapActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Download and set image of profile button. (async)
new DownloadButtonImageTask().execute(
new DownloadButtonImageTaskParams("https://images.unsplash.com/photo-1555436169-f998ad1259fd?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80",