Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Mohamed Elshiekh m7mdra

🏠
Working from home
View GitHub Profile
View style.json
{"version":8,"name":"THTC Maps Style default","sources":{"thtcmaps":{"type":"vector","url":"https://ksamaps.com/api/tilejson"}},"sprite":"https://ksamaps.com/assets/sprite","glyphs":"https://ksamaps.com/fonts/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"#aadaff"}},{"id":"land_fine","type":"fill","source":"thtcmaps","source-layer":"land_fine","layout":{"visibility":"visible"},"paint":{"fill-color":"#eeece6"}},{"id":"terrain","minzoom":4,"maxzoom":13,"type":"line","source":"thtcmaps","source-layer":"gcc_terrain","paint":{"line-color":"#dbc688","line-opacity":{"base":1,"stops":[[4,0.5],[18,0.1]]},"line-width":{"base":1,"stops":[[4,0.25],[18,0.75]]}}},{"id":"countryborder","type":"line","source":"thtcmaps","source-layer":"land","maxzoom":7,"layout":{"visibility":"visible"},"paint":{"line-color":"#bdbec2","line-width":0.5}},{"id":"provinces","type":"line","source":"thtcmaps","source-layer":"provinces","layout":{"visibility":"visible"},"paint":{"line-color":
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.m7mdra.copythat">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
View BaseActivity.java
public class BaseActivity extends AppCompatActivity {
private ProgressDialog progressDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Title here");
@m7mdra
m7mdra / Example.kt
Last active Aug 18, 2021 — forked from radoyankov/Example.kt
Easy Spannable on Kotlin
View Example.kt
val spanned = spannable{ bold("some") + italic(" formatted") + color(Color.RED, " text") }
val nested = spannable { italic(underline(bold(size(2f, color(Color.RED, "Red Bold Color"))))) }
val noWrapping = bold("no ") + sub("wrapping ) + sup("also ") + "works"
text_view.text = spanned + nested + noWrapping
View MainActivity.kt
import android.app.Activity
import android.graphics.Color
import android.graphics.Paint
import android.os.Bundle
import android.support.v7.widget.SearchView
import android.text.SpannableString
import android.text.style.BackgroundColorSpan
import android.util.Log
import kotlinx.android.synthetic.main.activity_main.*
View vector.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:autoMirrored="true"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#fff"
android:pathData="M10,16.5l6,-4.5 -6,-4.5v9zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z" />
</vector>
@m7mdra
m7mdra / Uri.java
Created Apr 25, 2018
create image file in internal application cache directory and returns the newly created file uri
View Uri.java
private String saveImageByUri(Uri uri) {
File parent = new File(getCacheDir(), "temp_images");
try {
final InputStream inputStream = getContentResolver().openInputStream(uri);
if (inputStream == null)
return "";
final BufferedSource source = Okio.buffer(Okio.source(inputStream));
//create file named with same format temp24734194048114480959349.png
final File file = File.createTempFile(String.format(Locale.ENGLISH, "temp%d", SystemClock.currentThreadTimeMillis()), ".png", parent);
final Sink sink = Okio.sink(file);
@m7mdra
m7mdra / Resource.java
Last active Apr 7, 2018
Retrofit callback wrapper with extra method to indicate the state of the request
View Resource.java
package comtas.com.zoolvibs.network;
import javax.annotation.Nullable;
/**
* Created by m7mdra on 23/12/17.
*/
public interface Resource<T> {
@m7mdra
m7mdra / SpringAnimator.java
Last active Dec 19, 2017
Applies Spring animation to a given view using physics animation API
View SpringAnimator.java
package comtas.com.zoolvibs.helper;
import android.support.animation.DynamicAnimation;
import android.support.animation.SpringAnimation;
import android.view.View;
/**
* Created by m7mdra on 08/10/17.
*/
View StorageLowState.java
package comtas.com.zoolvibs.helper;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
/**