Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Hanging out at localhost

Yunus Emre Dilber yunusemredilber

:shipit:
Hanging out at localhost
View GitHub Profile
@yunusemredilber
yunusemredilber / AndroidManifest.xml
Created Sep 3, 2019
Android Turbolinks Geolocation Handling
View AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@yunusemredilber
yunusemredilber / _form.html.erb
Created Sep 10, 2019
One by one multiple file (image) upload [Ruby on Rails] [StimulusJS]
View _form.html.erb
<%= 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 Aug 12, 2019
turbolinks-android fix unnecessary runtime crash
View build.gradle
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 Sep 27, 2019
Android Translucent Status Bar
View MainActivity.java
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 Oct 1, 2019
Turbolinks Android - Fix Session Issues
View JsBridge.java
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 Oct 9, 2019
Bootstrap grid of images responsive [Rails] [Stimulus]
View _grid.html.erb
<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 Dec 3, 2019
Using Turbolinks Android with tabs.
View MainActivity.java
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 Feb 5, 2020
Android Material FAB With Badge Attached
View activity_fab_with_badge.xml
<?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 Feb 8, 2020
Webview In Navigation View (Drawer) [ Android ]
View SomeActivity.java
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 Feb 15, 2020
Android circular image view downloaded from the internet with AsyncTask
View MainActivity.java
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",