Skip to content

Instantly share code, notes, and snippets.

View AliAzaz's full-sized avatar
🇵🇰
Passion to help others 😊

Ali Azaz Alam AliAzaz

🇵🇰
Passion to help others 😊
View GitHub Profile
@AliAzaz
AliAzaz / CMakesList.txt
Created July 7, 2021 09:20
CMakesList file used in NDK process to secure key
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
@AliAzaz
AliAzaz / JetpackMutableStateOf.kt
Created August 9, 2020 16:07
mutableStateOf approach using
//--------------Utils Class start--------------------
sealed class MenuOptions {
object TaskList : MenuOptions()
object AddTask : MenuOptions()
data class ModifyTask(val task: Task) : MenuOptions()
}
object AppMain {
private var current_screen: MenuOptions = MenuOptions.TaskList
var route_screen by mutableStateOf(current_screen)
@AliAzaz
AliAzaz / JetpackState.kt
Last active August 26, 2020 17:10
state approach using
@Composable
fun AddTask() {
val title = remember { mutableStateOf("") }
val titleExist = remember { mutableStateOf(false) }
if (titleExist.value) Text(
modifier = Modifier.padding(5.dp),
text = "Title already exist",
style = TextStyle(color = Color(0xFFF50B0B)) + MaterialTheme.typography.body1
)
@AliAzaz
AliAzaz / load.kt
Created July 12, 2020 16:16 — forked from mootoh/load.kt
Load remote image with Coil into Jetpack Compose Image
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
Column {
ItemCell(item = Item("cat 1", "https://thumbs-prod.si-cdn.com/s-rtW1rEAQTIGcmUVNFSSPC4s3I=/800x600/filters:no_upscale()/https://public-media.si-cdn.com/filer/56/4a/564a542d-5c37-4be7-8892-98201ab13180/cat-2083492_1280.jpg"))
ItemCell(item = Item("cat 2", "https://images.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260"))
}
@AliAzaz
AliAzaz / expandablelistview_oncreate.java
Created March 13, 2020 07:50 — forked from moltak/expandablelistview_oncreate.java
ExpandableListView in Scrollview
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.expandable, container, false);
ExpandableAdapter adapter = new ExpandableAdapter();
expandableListView.setAdapter(adapter);
setExpandableListViewHeight(expandableListView, -1);
expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int position, long id) {
@AliAzaz
AliAzaz / FullscreenFragment.java
Created March 3, 2020 11:01 — forked from gelldur/FullscreenFragment.java
FullscreenFragment - simple android fragment that will make fullscreen for you. Remember to: "You must manually call onKeyDown and onWindowFocusChanged."
package com.dexode.fragment;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
@AliAzaz
AliAzaz / RegistrationFragment.kt
Created February 22, 2020 20:08
Defines both the navigation and receiving arguments
class RegistrationFragment : Fragment() {
private lateinit var bi: FragmentRegistrationBinding
lateinit var vModel: MainViewModel
private val flag: RegistrationFragmentArgs by navArgs()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
vModel = activity?.run {
@AliAzaz
AliAzaz / activity_main.xml
Created February 20, 2020 20:40
Defining NavHostFragment in host activity
<?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"
tools:context=".MainActivity">
<fragment
@AliAzaz
AliAzaz / LocalBroadcastReceiver.java
Created February 4, 2020 06:09 — forked from shawnthye/LocalBroadcastReceiver.java
Push Notification - Local Broadcast Receiver and Result Receiver
public class LocalBroadcastReceiver extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
Log.d("LocalBroadcastReceiver", "onReceive()");
// Tell the result receiver to CANCEL some specific action.
// eg. do not display System Notification
setResultCode(Activity.RESULT_CANCELED);
}
}
@AliAzaz
AliAzaz / LocationListener.java
Last active January 10, 2020 06:07
Location listener service
public class LocationService extends Service {
public static final String BROADCAST_ACTION = "GettingLoc";
private static final int TWO_MINUTES = 1000 * 60 * 2;
private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 2000; // in Milliseconds
public LocationManager locationManager;
public GPSLocationListener listener;
public Location previousBestLocation = null;
Intent intent;