Tutorial by Examples: o

public static async Task<IRandomAccessStream> ConvertWriteableBitmapToRandomAccessStream(WriteableBitmap writeableBitmap) { var stream = new InMemoryRandomAccessStream(); BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream); Stream pixe...
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 ...
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) ...
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 { ...
To check exact strength in decibels use this- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo Info = cm.getActiveNetworkInfo(); if (Info == null || !Info.isConnectedOrConnecting()) { Log.i(TAG, "No connection");...
A trapezoid can be made by a block element with zero height (height of 0px), a width greater than zero and a border, that is transparent except for one side: HTML: <div class="trapezoid"></div> CSS: .trapezoid { width: 50px; height: 0; border-left: 50px ...
By default the ArrayAdapter class creates a view for each array item by calling toString() on each item and placing the contents in a TextView. To create a complex view for each item (for example, if you want an ImageView for each array item), extend the ArrayAdapter class and override the getView(...
Using Picasso as ImageGetter for Html.fromHtml public class PicassoImageGetter implements Html.ImageGetter { private TextView textView; private Picasso picasso; public PicassoImageGetter(@NonNull Picasso picasso, @NonNull TextView textView) { this.picasso = picasso; this.textView...
You can communicate two activities so that Activity A can be notified of an event happening in Activity B. Activity A final String eventName = "your.package.goes.here.EVENT"; @Override protected void onCreate(Bundle savedInstanceState) { registerEventReceiver(); super.onCre...
Unlike for and while loops, do-while loops check the truth of the condition at the end of the loop, which means the do block will execute once, and then check the condition of the while at the bottom of the block. Meaning that a do-while loop will always run at least once. For example this do-while...
A use case that comes across frequently, is creating a String from a stream, where the stream-items are separated by a certain character. The Collectors.joining() method can be used for this, like in the following example: Stream<String> fruitStream = Stream.of("apple", "banana...

Page 543 of 1038