Tutorial by Examples: am

Executing code after 1.5 seconds: Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { //The code you want to run after the time is up } }, 1500); //the time you want to delay in milliseconds Executing code repeatedly every...
It is possible to create a function that accepts objects that implement a specific trait. Static Dispatch fn generic_speak<T: Speak>(speaker: &T) { println!("{0}", speaker.speak()); } fn main() { let person = Person {}; let dog = Dog {}; generic_speak(...
An algorithmic problem is specified by describing the complete set of instances it must work on and of its output after running on one of these instances. This distinction, between a problem and an instance of a problem, is fundamental. The algorithmic problem known as sorting is defined as follows:...
This filter is very useful. One of the common problems for developers is how to include templates in plugins they develop. The filter is applied immediately after wordpress locates the appropriate template in the active child/parent theme using the wp hierarchy. Be careful to define when you want ...
add_filter('template_include', 'custom_function'); function custom_function($template){ /* * This example is a little more advanced. * It will check to see if $template contains our post-type in the path. * If it does, the theme contains a high level templat...
Destructuring allows us to refer to one key in an object, but declare it as a variable with a different name. The syntax looks like the key-value syntax for a normal JavaScript object. let user = { name: 'John Smith', id: 10, email: '[email protected]', }; let {user: userName, id: us...
One way to create a macro is to record it. Start recording a macro and save it to a register (in this example, we'll use a, but it can be any register you could normally yank text to): qa Then run the commands you want to record in the macro (here, we'll surround the contents of a line with &lt...
If you want to pass in values to a method when it is called, you use parameters: - (int)addInt:(int)intOne toInt:(int)intTwo { return intOne + intTwo; } The colon (:) separates the parameter from the method name. The parameter type goes in the parentheses (int). The parameter name goes aft...
Abstract classes are classes that are meant to be inherited but avoid implementing specific methods, leaving behind only method signatures that subclasses must implement. Abstract classes are useful for defining and enforcing class abstractions at a high level, similar to the concept of interfaces ...
To add a method to a button, first create an action method: Objective-C -(void)someButtonAction:(id)sender { // sender is the object that was tapped, in this case its the button. NSLog(@"Button is tapped"); } Swift func someButtonAction() { print("Button is tapped...
public class Dog : RealmObject { public string Name { get; set; } public int Age { get; set; } } var realm = Realm.GetInstance(); realm.Write(() => { var mydog = realm.CreateObject<Dog>(); mydog.Name = "Rex"; mydog.Age = 1; }); var pups = real...
Example is the main part of Documentation, it is thus important to provide clear and useful examples. Good examples are self-contained and succinct. Examples usually would have code for users to understand the topic better. Refer to the Help Center for more information.
SRXMPPDemo Download the example and all the classes here - https://github.com/SahebRoy92/SRXMPPDemo A demo on XMPP in Objective C, with various simple and complex features implemented in it. All the features of XMPP is done by "in band" xmpp functions. Few features this project contains...
When creating a recyclerview with a gridlayout layout manager you have to specify the span count in the constructor. Span count refers to the number of columns. This is fairly clunky and doesn't take into account larger screen sizes or screen orientation. One approach is to create multiple layouts f...
An unnamed namespace can be used to ensure names have internal linkage (can only be referred to by the current translation unit). Such a namespace is defined in the same way as any other namespace, but without the name: namespace { int foo = 42; } foo is only visible in the translation uni...
Functions can either be named or unnamed (anonymous functions): var namedSum = function sum (a, b) { // named return a + b; } var anonSum = function (a, b) { // anonymous return a + b; } namedSum(1, 3); anonSum(1, 3); 4 4 But their names are private to their own scope: ...
The NameOf operator resolves namespaces, types, variables and member names at compile time and replaces them with the string equivalent. One of the use cases: Sub MySub(variable As String) If variable Is Nothing Then Throw New ArgumentNullException("variable") End Sub The old sy...
To get the timestamp in seconds Math.floor((new Date().getTime()) / 1000)
Prerequisites Installation
If you have a type definition file (d.ts) for the module, you can use an import statement. import _ = require('lodash'); If you don't have a definition file for the module, TypeScript will throw an error on compilation because it cannot find the module you are trying to import. In this case, yo...

Page 16 of 129