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 / 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",
@yunusemredilber
yunusemredilber / MyModalBottomSheet.java
Created February 15, 2020 12:58
Android - Material Modal Bottom Sheets
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class LocationPermissionBottomSheet extends BottomSheetDialogFragment {
@Override
public View onCreateView (LayoutInflater inflater,
@yunusemredilber
yunusemredilber / dashed_border_in.xml
Last active February 25, 2020 10:42
A container with dashed border and rounded corners in android
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<corners android:radius="10dp" />
<solid android:color="#ffffff" />
<stroke
android:dashGap="5dp"
android:dashWidth="5dp"
android:width="3dp"
android:color="#0000FF" />
@yunusemredilber
yunusemredilber / postgresql_for_rails.sh
Created March 17, 2020 20:23
Potgresql installation for Rails [Ubuntu based distros]
$ sudo apt update
$ sudo apt install postgresql postgresql-contrib libpq-dev
$ sudo -u postgres createuser --interactive
> Enter name of role to add: yunus # Current OS Username
> Shall the new role be a superuser? (y/n) y
## This should work :)
## If any error comes up, the link at the bottom might help
@yunusemredilber
yunusemredilber / elementary_starter.sh
Last active April 5, 2020 15:29
Elementary OS commands for creating a development environment [Mostly for Android & Rails]
# Update and Upgrade System
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
# Install Tweaks (To enable dark mode and more)
sudo apt install software-properties-common
sudo add-apt-repository ppa:philip.scott/elementary-tweaks
sudo apt install elementary-tweaks
@yunusemredilber
yunusemredilber / QrActivity.java
Created April 21, 2020 11:43
Android QR Reading
public class QrActivity extends AppCompatActivity implements QRCodeReaderView.OnQRCodeReadListener {
private QRCodeReaderView qrCodeReaderView;
private static final int MY_CAMERA_REQUEST_CODE = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_qr);
if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
@yunusemredilber
yunusemredilber / RxBus.java
Created May 7, 2020 13:29
Asynchronous and event-based data passing in Android with RxJava
public final class RxBus {
// String can be replaced with any kind of Object.
private static final BehaviorSubject<String> behaviorSubject
= BehaviorSubject.create();
public static Disposable subscribe(@NonNull Consumer<String> action) {
return behaviorSubject.subscribe(action);
}
public static void publish(@NonNull String value) {
@yunusemredilber
yunusemredilber / text_horizontal_scrollable.xml
Created May 12, 2020 12:53
Android horizontal scrollable text
<androidx.appcompat.widget.AppCompatEditText
android:background="@null"
android:inputType="none"
android:textIsSelectable="false"
android:cursorVisible="false"
android:focusable="false"
android:layout_width="200dp"
app:layout_constrainedWidth="true"
android:scrollHorizontally="true"
android:singleLine="true"
@yunusemredilber
yunusemredilber / AndroidManifest.xml
Last active May 20, 2020 07:24
Android Firebase Cloud Messaging Skeleton
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.example">
<!-- ... -->
<application
<!-- ... --> >
<!-- ... -->
@yunusemredilber
yunusemredilber / local_to_android.md
Last active May 20, 2020 07:53
Connecting to a local rails project from android

Connecting to a local rails project from android

Find your public ip

ifconfig |grep inet

or