Skip to content

Instantly share code, notes, and snippets.

View mo7amd89's full-sized avatar

Mohammed Imam mo7amd89

View GitHub Profile
import 'package:flutter/material.dart';
//-----GLOBAL VARIABLES-----
final Color mainColor = Color(0xFFFF5656);
final List<MountModel> mountItems = [
MountModel(
path:
'https://sa.kapamilya.com/absnews/abscbnnews/media/2021/afp/01/17/20210116-mt-semeru-indonesia-ash-afp-s.jpg',
name: 'Mount Semeru',
@mo7amd89
mo7amd89 / ConnectivityListener.kt
Created March 8, 2022 08:40 — forked from andrewsafwatsamuel/ConnectivityListener.kt
Android connectivity listener
import android.annotation.TargetApi
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.*
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.lifecycle.LiveData
@mo7amd89
mo7amd89 / EmailValidator.java
Created March 21, 2022 10:22 — forked from Eldius/EmailValidator.java
Email validation with regex.
package net.eldiosantos.testes.controller;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class EmailValidator {
private final String emailValidationPattern = "[a-z0-9!#$%&\'*+/=?^_\'{|}~-]+(?:.[a-z0-9!#$%&\'*+/=?^_\'{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
public static void main(String[] args) {
@mo7amd89
mo7amd89 / Down.java
Last active March 29, 2022 10:29
Android Download file with DownloadManager
@SuppressLint("Range")
private boolean downloadUpdate() {
boolean flag = false;
try {
final File apk_file_path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), fileName);
if (apk_file_path.exists()) apk_file_path.delete();
Log.v(TAG, "Downloading request on url :" + BaseUrl);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(BaseUrl));
request.setDescription("Update the App تحديث التطبيق");
@mo7amd89
mo7amd89 / SendStringOverSocket.java
Created July 7, 2022 08:36 — forked from chatton/SendStringOverSocket.java
Example of sending a String through a Socket in Java.
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
public class Client {
public static void main(String[] args) throws IOException {
// need host and port, we want to connect to the ServerSocket at port 7777
Socket socket = new Socket("localhost", 7777);
System.out.println("Connected!");
@mo7amd89
mo7amd89 / CountDownTimer.java
Created August 18, 2022 08:47 — forked from bverc/CountDownTimer.java
Drop-in alternative for the Android CountDownTimer class, but which you can cancel from within onTick. Modified to include pause and resume functionality.
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@mo7amd89
mo7amd89 / ToastUtils.kt
Created August 23, 2022 10:38
inline function koltin
import android.content.Context
import android.widget.Toast
import androidx.fragment.app.Fragment
inline fun Context.toast(message:()->String){
Toast.makeText(this, message() , Toast.LENGTH_LONG).show()
}
inline fun Fragment.toast(message:()->String){
Toast.makeText(this.context, message() , Toast.LENGTH_LONG).show()
@mo7amd89
mo7amd89 / FileLogger.java
Created October 30, 2022 08:52
store Logs in a txt file using the android.util.log
import android.os.Environment;
import android.util.Log;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@mo7amd89
mo7amd89 / SaveLogcatApp.java
Created January 3, 2023 11:03
Saving Logcat to a text file in Android Device
public class MyPersonalApp extends Application {
/**
* Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created.
*/
public void onCreate() {
super.onCreate();
if ( isExternalStorageWritable() ) {
@mo7amd89
mo7amd89 / DownloadRequest.kt
Created February 25, 2023 12:43 — forked from PrashamTrivedi/DownloadRequest.kt
Download File with progress indicator, written in Kotlin with Co-routines
suspend fun downloadFile(url: String,
downloadFile: File,
downloadProgressFun: (bytesRead: Long, contentLength: Long, isDone: Boolean) -> Unit) {
async(CommonPool) {
val request = with(Request.Builder()) {
url(url)
}.build()
val client = with(OkHttpClient.Builder()) {
addNetworkInterceptor { chain ->