This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object PreferencesUtil { | |
fun putIntValue(context: Context, key: String, value: Int) { | |
val prefs = PreferenceManager.getDefaultSharedPreferences(context) | |
val editor = prefs.edit() | |
editor.putInt(key, value) | |
editor.commit() | |
} | |
fun putStringValue(context: Context, key: String, value: String) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PermissionsApp{ | |
companion object { | |
val PERMISSIONS = arrayOf<String>(Manifest.permission.CAMERA, | |
Manifest.permission.READ_EXTERNAL_STORAGE, | |
Manifest.permission.WRITE_EXTERNAL_STORAGE, | |
Manifest.permission.ACCESS_NETWORK_STATE, | |
Manifest.permission.RECORD_AUDIO, | |
Manifest.permission.INTERNET, | |
Manifest.permission.WRITE_SETTINGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<intent-filter> | |
<action android:name="android.intent.action.VIEW" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
<category android:name="android.intent.category.BROWSABLE" /> | |
<!-- myapp://content --> | |
<data android:host="content" android:scheme="myapp" /> | |
<!-- https://myapp.example.com/content --> | |
<data android:host="myapp.example.com" android:scheme="https" android:pathPrefix="/content" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void callAlert(Activity activity, String msg, DialogInterface.OnClickListener listener) { | |
if(!activity.isFinishing()){ | |
new AlertDialog.Builder(activity) | |
.setTitle("Atenção") | |
.setIcon(R.drawable.ic_alert) | |
.setMessage(msg) | |
.setPositiveButton("Ok", listener) | |
.create() | |
.show(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val wm = getSystemService(WIFI_SERVICE); | |
val ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Util{ | |
fun modifyStatusBar(window : Window, applicationContext : Context, @ColorRes colorId : Int){ | |
// clear FLAG_TRANSLUCENT_STATUS flag: | |
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) | |
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window | |
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) | |
// finally change the color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object isOnline{ | |
@SuppressLint("MissingPermission") | |
fun isOnline(context : Context) : Boolean { | |
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val networkInfo = connectivityManager.activeNetworkInfo | |
return networkInfo != null && networkInfo.isConnected | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Pipe({name: 'cnpj'}) | |
export class CNPJPipe implements PipeTransform { | |
transform(value) { | |
return value.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/g,"\$1.\$2.\$3\/\$4\-\$5") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
util.saveAndPush = function(arrayModel , objectModel , idArrayObject , objectToSave , arrayToPush , keyRequired , keyNotFound , keySavedSuccess , next){ | |
if(!idArrayObject){ | |
next({ | |
'message' : keyRequired, | |
'status' : 400 | |
}) | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker exec -it mongo mongo |