Skip to content

Instantly share code, notes, and snippets.

View MomenZaq's full-sized avatar

Momen Zaqout MomenZaq

View GitHub Profile
@MomenZaq
MomenZaq / AndroidDrawableImporter.md
Created September 13, 2021 18:52 — forked from delacrixmorgan/AndroidDrawableImporter.md
Android Drawable Importer - Change Logs

Android Drawable Importer by Marc Prengemann

This plugin consists of three main features. You can access them by a right-click anywhere, but not on a file, inside an Android module under New.

  1. AndroidIcons and Material Icons Drawable Import You are able to select the asset, specify your color, change the target resource name and select all the resolutions you want to import. All the missing folders will be created automatically. If there are already drawables with the same name, you will be warned. You can even search for your desired asset by just start typing when the first spinner has focus. Since Material Icons provide also Vector Drawables, those can be imported now as well!

  2. Batch Drawable Import Select assets (or a whole folder) and specify the source resolutions. You can change the source size of every image as well. Specify all resolutions, to which it should be resized to.

@MomenZaq
MomenZaq / ConnectivityStatus
Last active May 19, 2021 19:55
ConnectivityStatus is a class to check the internet connection, it gives you the true status about the connection, not just if the device connects to a network.
/*
ConnectivityStatus is a class to check the internet connection,
it gives you the true status about the connection,
not just if the device connects to a network.
It also check the internet connection each 2 seconds.
The class uses flow with liveData to be lifecycle aware
@MomenZaq
MomenZaq / ConnectivityStatus
Created May 19, 2021 19:40
ConnectivityStatus is a class to check the internet connection, it gives you the true status about the connection, not just if the device connects to network.
@Singleton
class ConnectivityStatus @Inject constructor(private val context: Context) {
private var connectionFlow: Flow<ConnectionModel>? = null
fun followConnection(): LiveData<ConnectionModel> {
return hostAvailable()
@MomenZaq
MomenZaq / MainAdapter.java
Created January 9, 2021 20:44
RecyclerViewWithFragmentTypeExample
package com.android.recyclerviewwithfragmenttypeexample;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
@MomenZaq
MomenZaq / MainActivity.java
Created January 9, 2021 20:40
RecyclerViewWithFragmentTypeExample
package com.android.recyclerviewwithfragmenttypeexample;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import java.util.ArrayList;
@MomenZaq
MomenZaq / MainActivity.java
Created January 9, 2021 14:13
RecyclerViewWithNestedScrollViewExample
package com.android.recyclerviewwithnestedscrollviewexample;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.List;
@MomenZaq
MomenZaq / activity_main.xml
Last active January 16, 2021 04:00
RecyclerViewWithNestedScrollViewExample
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
@MomenZaq
MomenZaq / RecyclerviewFullScreenshot.java
Last active October 10, 2022 03:44
Take a screenshot of RecyclerView in FULL length
/*
1. create a new NestedScrollView
2. add it to recyclerview's parent
3. remove recyclerview from its parent "it's important to add it to a new parent"
4. add recyclerview to nestedscrollview
5. take screenshot of nestedscrollview
6. add recyclerview to its main parent.
*/
@MomenZaq
MomenZaq / ConnectivityAndInternetAccess.kt
Created January 27, 2020 19:32
Class to check the Connectivity and Internet Access of an Android device.
/*
* Copyright (c) 2020 Rodrigo Sambade
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions: