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 / validation_functions.kt
Created December 8, 2019 10:13
Validation functions
fun emptyTextBox(context: Context, txt: EditText, toggleFlag: Boolean = true): Boolean
fun emptyTextView(context: Context, txt: TextView, toggleFlag: Boolean = true): Boolean
fun emptyCustomTextBox(context: Context, txt: TextView, msg: String, toggleFlag: Boolean = true): Boolean
fun emptyEditTextPicker(context: Context, txt: EditText, toggleFlag: Boolean = true): Boolean
fun rangeTextBox(context: Context, txt: EditText, min: Int, max: Int, type: String, toggleFlag: Boolean = true): Boolean
@AliAzaz
AliAzaz / clearing_functions.kt
Created December 8, 2019 10:17
Clear functions
fun clearCheckBoxes(container: ViewGroup, flag: Boolean? = null)
fun clearRadioGroup(view: RadioGroup, flag: Boolean? = null)
fun clearAllFields(view: View, flag: Boolean? = null)
@AliAzaz
AliAzaz / old_validation.java
Created December 8, 2019 14:59
Old validating method
//Empty edittext checking
if (txtbox1.getText().toString().isEmpty()) {
txtbox1.setError("This data is Required!");
return false;
} else {
txtbox1.setError(null);
}
//Equal/Pattern edittext checking
if (!txtBoxDefault.isTextEqualToPattern())
@AliAzaz
AliAzaz / old_clearing.java
Created December 8, 2019 15:40
Old clearing views method
//Clearing edittext
txtbox1.setText(null);
txtbox1.clearFocus();
txtbox1.setError(null);
//Clearing Radiogroup
mnc2.clearCheck()
mnc2.clearFocus();
mnc2.setError(null);
@AliAzaz
AliAzaz / new_clear_method.java
Last active December 9, 2019 07:04
New clear method with the help of AndroidValidatorCrawler
//fldGrpSecA01: is the view group in which whole layout is defined in xml
Clear.clearAllFields(fldGrpSecA01);
@AliAzaz
AliAzaz / new_validation_method.java
Last active December 9, 2019 07:04
New validation method with the help of AndroidValidatorCrawler
//fldGrpSecA01: is the view group in which whole layout is defined in xml
Validator.emptyCheckingContainer(this, fldGrpSecA01);
@AliAzaz
AliAzaz / Comparison.txt
Created December 30, 2019 07:29 — forked from tomaszpolanski/Comparison.txt
Kotlin Standard comparison
╔══════════╦═════════════════╦═══════════════╦═══════════════╗
║ Function ║ Receiver (this) ║ Argument (it) ║ Result ║
╠══════════╬═════════════════╬═══════════════╬═══════════════╣
║ let ║ this@MyClass ║ String("...") ║ Int(42) ║
║ run ║ String("...") ║ N\A ║ Int(42) ║
║ run* ║ this@MyClass ║ N\A ║ Int(42) ║
║ with* ║ String("...") ║ N\A ║ Int(42) ║
║ apply ║ String("...") ║ N\A ║ String("...") ║
║ also ║ this@MyClass ║ String("...") ║ String("...") ║
╚══════════╩═════════════════╩═══════════════╩═══════════════╝
@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;
@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 / 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