Tutorial by Examples

public static async Task<ImageSource> FromStorageFile(StorageFile sf) { using (var randomAccessStream = await sf.OpenAsync(FileAccessMode.Read)) { var result = new BitmapImage(); await result.SetSourceAsync(randomAccessStream); return result; } } ...
public static async Task<WriteableBitmap> RenderUIElement(UIElement element) { var bitmap = new RenderTargetBitmap(); await bitmap.RenderAsync(element); var pixelBuffer = await bitmap.GetPixelsAsync(); var pixels = pixelBuffer.ToArray(); var writeableBitmap = new W...
public static async Task<IRandomAccessStream> ConvertWriteableBitmapToRandomAccessStream(WriteableBitmap writeableBitmap) { var stream = new InMemoryRandomAccessStream(); BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream); Stream pixe...
Quick start A rule describes when and how certain files (rule's targets) are created. It can also serve to update a target file if any of the files required for its creation (target's prerequisites) are newer than the target. Rules follow the syntax below: (Note that commands following a rule are ...
In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. Wikipedia reference protocol SenderProtocol { func send(packa...
A while loop is used to execute a piece of code while a condition is true. The while loop is to be used when a block of code is to be executed a variable number of times. For example the code shown gets the user input, as long as the user inserts numbers which are not 0. If the user inserts 0, the ...
The pipe (%>%) operator could be used in combination with dplyr functions. In this example we use the mtcars dataset (see help("mtcars") for more information) to show how to sumarize a data frame, and to add variables to the data with the result of the application of a function. librar...
Writing with roxygen2 roxygen2 is a package created by Hadley Wickham to facilitate documentation. It allows to include the documentation inside the R script, in lines starting by #'. The different parameters passed to the documentation start with an @, for example the creator of a package will by...
In certain cases we need to cancel an image download request in Picasso before the download has completed. This could happen for various reasons, for example if the parent view transitioned to some other view before the image download could be completed. In this case, you can cancel the image down...
Copy and Paste following class in your package: public class MLRoundedImageView extends ImageView { public MLRoundedImageView(Context context) { super(context); } public MLRoundedImageView(Context context, AttributeSet attrs) { super(context, attrs); } ...
nrs = [1, 2, 3, 4, 5, 6, 7, 8, 9] lets = ['a', 'b', 'c', 'd', 'e', 'f'] println GroovyCollections.transpose([nrs, lets]) .collect {le -> [(le[0]):le[1]]}.collectEntries { it } or println [nrs,lets].transpose().collectEntries{[it[0],it[1]]} // [1:a, 2:b, 3:c, 4:d, 5:e, 6:f...
A BroadcastReceiver is basically a mechanism to relay Intents through the OS to perform specific actions. A classic definition being "A Broadcast receiver is an Android component which allows you to register for system or application events." LocalBroadcastManager is a way to send ...
Android allows programmers to place images at all four corners of a TextView. For example, if you are creating a field with a TextView and at same time you want to show that the field is editable, then developers will usually place an edit icon near that field. Android provides us an interesting opt...
ngMessages is used to enhanced the style for displaying validation messages in the view. Traditional approach Before ngMessages, we normally display the validation messages using Angular pre-defined directives ng-class.This approach was litter and a repetitive task. Now, by using ngMessages we ca...
AsyncTask is an abstract Class and does not inherit the Thread class. It has an abstract method doInBackground(Params... params), which is overridden to perform the task. This method is called from AsyncTask.call(). Executor are part of java.util.concurrent package. Moreover, AsyncTask contains 2 ...
A numeric type used to store 16-bit positive integers. ushort is an alias for System.UInt16, and takes up 2 bytes of memory. Valid range is 0 to 65535. ushort a = 50; // 50 ushort b = 65536; // Error, cannot be converted ushort c = unchecked((ushort)65536); // Overflows (wraps around to 0) ...
A numeric type used to store 8-bit signed integers. sbyte is an alias for System.SByte, and takes up 1 byte of memory. For the unsigned equivalent, use byte. Valid range is -127 to 127 (the leftover is used to store the sign). sbyte a = 127; // 127 sbyte b = -127; // -127 sbyte c = 200; // Err...
These are URL schemes supported by native apps on iOS, OS X, and watchOS 2 and later. Opening link in Safari: Objective-C NSString *stringURL = @"http://stackoverflow.com/"; NSURL *url = [NSURL URLWithString:stringURL]; [[UIApplication sharedApplication] openURL:url]; Swift: let s...
To open an app with defined URL scheme todolist://: Objective-C NSURL *myURL = [NSURL URLWithString:@"todolist://there/is/something/to/do"]; [[UIApplication sharedApplication] openURL:myURL]; Swift let stringURL = "todolist://there/is/something/to/do" if let url = NSURL(s...
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo Info = cm.getActiveNetworkInfo(); if (Info == null || !Info.isConnectedOrConnecting()) { Log.i(TAG, "No connection"); } else { ...

Page 712 of 1336