Tutorial by Examples: cycle

Add the dependency as described in the Remark section, then add a RecyclerView to your layout: <android.support.v7.widget.RecyclerView android:id="@+id/my_recycler_view" android:layout_width="match_parent" android:layout_height="wrap_content"/> ...
class MyClass { func sayHi() { print("Hello") } deinit { print("Goodbye") } } When a closure captures a reference type (a class instance), it holds a strong reference by default: let closure: () -> Void do { let obj = MyClass() // Captures a strong re...
A reference cycle (or retain cycle) is so named because it indicates a cycle in the object graph: Each arrow indicates one object retaining another (a strong reference). Unless the cycle is broken, the memory for these objects will never be freed. A retain cycle is created when two instances of ...
The services lifecycle has the following callbacks onCreate() : Executed when the service is first created in order to set up the initial configurations you might need. This method is executed only if the service is not already running. onStartCommand() : Executed every time startService...
What’s a component? A component is basically a directive that uses a simpler configuration and that is suitable for a component-based architecture, which is what Angular 2 is all about. Think of a component as a widget: A piece of HTML code that you can reuse in several different places in y...
To add a header to a recyclerview with a gridlayout, first the adapter needs to be told that the header view is the first position - rather than the standard cell used for the content. Next, the layout manager must be told that the first position should have a span equal to the *span count of the e...
The only time the garbage collector is needed is if you have a reference cycle. The simples example of a reference cycle is one in which A refers to B and B refers to A, while nothing else refers to either A or B. Neither A or B are accessible from anywhere in the program, so they can safely be dest...
package { import flash.display.Sprite; import flash.events.Event; public class Viewport extends Sprite { /** Constructor */ public function Viewport() { super(); // Listen for added to stage event addEventListener(Event.ADDED_TO_STAGE, addedToStageHandle...
You can implement the swipe-to-dismiss and drag-and-drop features with the RecyclerView without using 3rd party libraries. Just use the ItemTouchHelper class included in the RecyclerView support library. Instantiate the ItemTouchHelper with the SimpleCallback callback and depending on which functi...
Life-cycle hooks are also exposed as DSL elements, where later invocations of the methods shown below will replace the contents of the respective hooks: val a = actor(new Act { whenStarting { testActor ! "started" } whenStopping { testActor ! "stopped" } }) The above i...
First of all you need to create a class which extends RecyclerView.ItemDecoration : public class SimpleBlueDivider extends RecyclerView.ItemDecoration { private Drawable mDivider; public SimpleBlueDivider(Context context) { mDivider = context.getResources().getDrawable(R.drawable.divider_b...
This is a sample adapter code. public class SampleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int FOOTER_VIEW = 1; // Define a view holder for Footer view public class FooterViewHolder extends ViewHolder { public FooterViewHolder(View ite...
CREATE TRIGGER BooksDeleteTrigger ON MyBooksDB.Books AFTER DELETE AS INSERT INTO BooksRecycleBin SELECT * FROM deleted; GO
It's also possible to use data binding within your RecyclerView Adapter. Data model public class Item { private String name; public String getName() { return name; } } XML Layout <TextView android:layout_width="wrap_content" android:layou...
This is an example of using Android Support Library V7 RecyclerView. Support libraries are generally recommended because they provide backward-compatible versions of new features, provide useful UI elements that are not included in the framework, and provide a range of utilities that apps can draw o...
add filter method in RecyclerView.Adapter: public void filter(String text) { if(text.isEmpty()){ items.clear(); items.addAll(itemsCopy); } else{ ArrayList<PhoneBookItem> result = new ArrayList<>(); text = text.toLower...
Assume an application with a MainActivity which can call the Next Activity using a button click. public class MainActivity extends AppCompatActivity { private final String LOG_TAG = MainActivity.class.getSimpleName(); @Override protected void onCreate(Bundle savedInstanceState) { ...
This example shows how a function can accept pipelined input, and iterate efficiently. Note, that the begin and end structures of the function are optional when pipelining, but that process is required when using ValueFromPipeline or ValueFromPipelineByPropertyName. function Write-FromPipeline{ ...
cycle is an infinite iterator. >>> import itertools as it >>> it.cycle('ABCD') A B C D A B C D A B C D ... Therefore, take care to give boundaries when using this to avoid an infinite loop. Example: >>> # Iterate over each element in cycle for a fixed range >&g...
put this code inside your ViewHolder note: In this code I am using btnExpand click-event, for whole recyclerview click event you can set listener to itemView object. public class MyViewHolder extends RecyclerView.ViewHolder{ CardView cv; TextView recordName, visibleFile, date, t...

Page 1 of 3