This file contains hidden or 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
| import androidx.appcompat.app.AppCompatActivity | |
| import android.os.Bundle | |
| import androidx.fragment.app.Fragment | |
| import dagger.hilt.android.AndroidEntryPoint | |
| import javax.inject.Inject | |
| @AndroidEntryPoint | |
| class MainActivity : AppCompatActivity() { | |
| @Inject |
This file contains hidden or 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
| request_permission.setOnClickListener { | |
| requestPermission.launch(permission.BLUETOOTH) | |
| } | |
| request_multiple_permission.setOnClickListener { | |
| requestMultiplePermissions.launch( | |
| arrayOf( | |
| permission.BLUETOOTH, | |
| permission.NFC, | |
| permission.ACCESS_FINE_LOCATION |
This file contains hidden or 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
| // General activity result contract | |
| private val openPostActivity = | |
| registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> | |
| if (result.resultCode == Activity.RESULT_OK) { | |
| // Do something here | |
| toast("Result OK from PostActivity") | |
| } | |
| } | |
| btn_post.setOnClickListener { |
This file contains hidden or 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
| // Requesting Location Permission | |
| bi.btnRequestPermission.setOnClickListener { | |
| askLocationPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) | |
| } | |
| // Single Permission Contract | |
| private val askLocationPermission = registerForActivityResult(ActivityResultContracts.RequestPermission()) { result -> | |
| if(result){ | |
| Log.e("TAG", "Location permnission granted") | |
| }else{ |
This file contains hidden or 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
| import android.content.Context | |
| import android.net.ConnectivityManager | |
| import android.net.NetworkCapabilities | |
| import android.os.Build | |
| val Context.isConnected: Boolean | |
| get() { | |
| val connectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| return when { | |
| Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> { |
This file contains hidden or 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
| import styled, { createGlobalStyle } from 'styled-components'; | |
| export const theme = { | |
| emoji: 'emoji', | |
| emojiSuggestions: 'emojiSuggestions', | |
| emojiSuggestionsEntry: 'emojiSuggestionsEntry', | |
| emojiSuggestionsEntryFocused: 'emojiSuggestionsEntryFocused', | |
| emojiSuggestionsEntryText: 'emojiSuggestionsEntryText', | |
| emojiSuggestionsEntryIcon: 'emojiSuggestionsEntryIcon', | |
| emojiSelect: 'emojiSelect', |
This file contains hidden or 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
| /* | |
| MIT License | |
| Copyright (c) 2018 Fayaz Bin Salam | |
| 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 |
This file contains hidden or 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
| import React from 'react'; | |
| import PropTypes from 'prop-types'; | |
| import { CompositeDecorator, convertFromRaw, Editor, EditorState } from 'draft-js'; | |
| // Following code based on: | |
| // https://github.com/facebook/draft-js/blob/master/examples/draft-0-10-0/link/link.html | |
| const Link = (props) => { | |
| const {url} = props.contentState.getEntity(props.entityKey).getData(); | |
| return ( | |
| <a rel="nofollow noreferrer" href={url} target="_blank"> |
This file contains hidden or 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
| var zip = new JSZip(); | |
| var count = 0; | |
| var zipFilename = "zipFilename.zip"; | |
| var urls = [ | |
| 'http://image-url-1', | |
| 'http://image-url-2', | |
| 'http://image-url-3' | |
| ]; | |
| urls.forEach(function(url){ |
This file contains hidden or 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
| import android.support.annotation.NonNull; | |
| import android.support.annotation.Nullable; | |
| import android.support.v4.util.ArrayMap; | |
| import java.io.IOException; | |
| import java.util.Collections; | |
| import java.util.Map; | |
| import java.util.regex.Matcher; | |
| import java.util.regex.Pattern; |
NewerOlder