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
package com.t2r2.volleyexample | |
import android.app.Activity | |
import android.content.Intent | |
import android.net.Uri | |
import android.os.Bundle | |
import android.widget.Button | |
import android.widget.ImageView | |
import androidx.appcompat.app.AppCompatActivity | |
import com.android.volley.Response |
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
<?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"> | |
<ImageView | |
android:id="@+id/imageView" |
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
package com.t2r2.volleyexample | |
import com.android.volley.* | |
import com.android.volley.toolbox.HttpHeaderParser | |
import java.io.* | |
import kotlin.math.min | |
open class VolleyFileUploadRequest( | |
method: Int, |
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
// label.frame = CGRect(x: 150, y: 200, width: 200, height: 20) | |
// label.text = "Hello World!" | |
// label.textColor = .black | |
label.numberOfLines = 0 | |
label.lineBreakMode = .byWordWrapping | |
label.translatesAutoresizingMaskIntoConstraints = false | |
label.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true | |
label.topAnchor.constraint(equalTo: view.topAnchor).isActive = true | |
label.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true | |
label.isUserInteractionEnabled = true |
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
extension String { | |
func convertToAttributedFromHTML() -> NSAttributedString? { | |
var attributedText: NSAttributedString? | |
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue] | |
if let data = data(using: .unicode, allowLossyConversion: true), let attrStr = try? NSAttributedString(data: data, options: options, documentAttributes: nil) { | |
attributedText = attrStr | |
} | |
return attributedText | |
} | |
} |
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
@objc func didTapLabel(sender: UITapGestureRecognizer) { | |
var tappedImage = false | |
if let index = label.characterIndexTapped(tap: sender), let _ = label.attributedText?.attribute(NSAttributedString.Key.attachment, at: index, effectiveRange: nil) as? NSTextAttachment { | |
tappedImage = true | |
} | |
let alertTitle = tappedImage ? "Tapped Image":"Random Taps" | |
let alertMessage = tappedImage ? "You just tapped the image.":"You just tapped outside the image." | |
let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .actionSheet) | |
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)) | |
present(alertController, animated: true, completion: nil) |
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
extension UILabel { | |
func characterIndexTapped(tap: UITapGestureRecognizer) -> Int? { | |
guard attributedText != nil else { return nil } | |
// Create instances for NSLayoutManager, NSTextContainer, and NSTextStorage | |
let layoutManager = NSLayoutManager() | |
let textContainer = NSTextContainer(size: .zero) | |
let textStorage = NSTextStorage(attributedString: attributedText!) | |
layoutManager.addTextContainer(textContainer) | |
textStorage.addLayoutManager(layoutManager) |
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
// instantiate a dictionary | |
var personalInfo = ["firstName": "John", "address": "1100 Main St."] | |
// data retrieval | |
let firstName = personalInfo["firstName"] | |
let middleName = personalInfo["middleName"] | |
// data insertion | |
personalInfo["lastName"] = "Smith" | |
personalInfo["firstName"] = "Mike" | |
// data deletion | |
let deletedAddress = personalInfo.removeValue(forKey: "address") |
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
<?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"> | |
<Button |
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
<key>UIApplicationShortcutItems</key> | |
<array> | |
<dict> | |
<key>UIApplicationShortcutItemType</key> | |
<string>SearchAction</string> | |
<key>UIApplicationShortcutItemIconType</key> | |
<string>UIApplicationShortcutIconTypeSearch</string> | |
<key>UIApplicationShortcutItemTitle</key> | |
<string>Search</string> | |
<key>UIApplicationShortcutItemSubtitle</key> |
OlderNewer