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
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget | |
plugins { | |
kotlin("native.cocoapods") | |
kotlin("multiplatform") | |
} | |
version = "1.0.0" | |
kotlin { |
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 void connect(String ssid, String password) { | |
NetworkSpecifier networkSpecifier = new WifiNetworkSpecifier.Builder() | |
.setSsid(ssid) | |
.setWpa2Passphrase(password) | |
.setIsHiddenSsid(true) //specify if the network does not broadcast itself and OS must perform a forced scan in order to connect | |
.build(); | |
NetworkRequest networkRequest = new NetworkRequest.Builder() | |
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI) | |
.setNetworkSpecifier(networkSpecifier) | |
.build(); |
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 abstract class SampleReactActivity extends Activity implements DefaultHardwareBackBtnHandler, | |
PermissionAwareActivity { | |
private final SampleReactActivityDelegate mDelegate; | |
protected SampleReactActivity() { | |
mDelegate = createReactActivityDelegate(); | |
} | |
/** |
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
func calculateAge(dob : String) -> (year :Int, month : Int, day : Int){ | |
let df = NSDateFormatter() | |
df.dateFormat = "yyyy-MM-dd" | |
let date = df.dateFromString(dob) | |
guard let val = date else{ | |
return (0, 0, 0) | |
} | |
var years = 0 | |
var months = 0 | |
var days = 0 |
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
/*The trick is to adopt the protocol UICollectionViewDelegateFlowLayout | |
and implement the following method*/ | |
//UICollectionViewDelegateFlowLayout method | |
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, | |
sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize{ | |
//specify height as per your requirement | |
return CGSize(width: collectionView.bounds.width, height: 120) | |
} |
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
/*code snippet shows how we can delete items from collection view without reloading it | |
the below function is attcahed as selector to a button embedded in collection view cell*/ | |
func removeItem(sender : UIButton){ | |
if let collectionViewCell = sender.superview?.superview as? UICollectionViewCell{ | |
if let indexPath = self.docsCollectionView.indexPathForCell(collectionViewCell){ | |
self.items.removeAtIndex(indexPath.row) | |
self.collectionView.deleteItemsAtIndexPaths([indexPath]) | |
} | |
} | |
} |
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
let items = [String]() | |
items.append("Swift") | |
self.collectionView.insertItemsAtIndexPaths([NSIndexPath(forRow: self.items.count - 1, inSection: 0)]) |