SyncAdapter without ContentObserver - android-contentresolver

I recently learned that when using a ContentProvider with CursorLoaders, there is no need to create your own ContentObserver, you just call cursor#setNotificationUri() or getContext().getResolver().notifyChange. Now i want to use a SyncAdapter to perform syncs on data change, and a requirement for this is having a ContentObserver for the respective URIs, my question is, what effect will this have on the aforementioned way of listening for data changes?

You don't need a ContentObserver to trigger a sync when using a SyncAdapter. Just make sure you set syncToNetwork to true when you call notifyChange (Uri uri, ContentObserver observer, boolean syncToNetwork).
Android will automatically call all SyncAdapters for this authority that have supportsUploading set to true and that are configured to sync automatically.

Related

Why does the Google Tag Manager automaticalls has a Trigger event for gtm.load for my custom variables?

So I want to Trigger my Tags when the user accept cookies, obviously.
I tried different approaches, JSVariable, Custom JS, First party cookie and datalayer variable.
Now I have them all set in Triggers, for example if the JSVariable is true or if the first party cookie contains the cookie value I set, or the datalayer variable contains filled.
Now in Debug mode these Triggers actually seem to work. They all get Ticks under firing triggers, but the Tags don't seem to Trigger because I get another Trigger for some reason which states
gtm.load equals [variableName] (for example: gtm.load equals myJSVariable) and it always has this red X.
I just don't seem to find an answer to this problem.
Thank you all very much
So if anyone experienceses something similar (in case I am not the only dummy):
When you type in the eventname, it is about WHEN to look for your variable basically.
So for example you would enter gtm.load, when the site has been completely loaded. Then GTM would look for your CustomVariable

Stable ID's in fiori launchpad

I am using a FlexColumnLayout for my app.
In the mid column I need to access a controll of the begin column of the FlexColumnLayout. Here is the problem:
Since it is a different view I cannot use
this.getView().byId("myId")
My first solution was to use stable ID's, by giving the views (XML) IDs.
Like that I could use:
sap.ui.getCore().byId("application---viewId--myId")
At first it worked just fine, but now that I integrated my app into the fiori launchpad the first part of the stable ID (the part before "viewId") changed and when I transport into productive it will change again.
Is there a way to access the mid column controls without sap.ui.getCore().byId?
Or is there a way to load the first part dynamically so I don't need to change my IDs when tranporting?
Sadly I don't know how to reproduce a Launchpad for testing purposes, but for those who want to test their ideas about my problem, my FlexColumnLayout is build just like in the DemoApp: https://sapui5.hana.ondemand.com/#/entity/sap.f.FlexibleColumnLayout
Ok guys i found a solution:
this.getView().getParent().getParent()
returns the FlexColumnLayout. This has a method called "getBeginColumnPages", which returns an array of the views representing the begin column. Now that i can access the view in which my control is found, i can access it with the sap.ui.core.mvc.View.byId() method.
Now I have
this.getView().getParent().getParent().getMidColumnPages()[0].byId("myId")
Since the doulbe .getParent() doesn't seem to be ideal, please post a better solution if you know one : D
You have to use createId() function, this will return the complete ID of your control.
this.byId(this.createId("myid"));

How to use ApplyAction

I've been trying to search for information on how use the copyCard trello action, it looks like I should use Card.ApplyAction, but I am not sure if thats the correct way. I have not found how to set the needed data on the action to copy the card.
Is there a method in Manatee.Trello to copy a card or do I just do it all myself? If there is how do you use it?
To copy a card, you'll need the destination list. If you're just trying to put it in the same list, that's card.List.
Then you can just add a new card using the existing card as a source:
var card = new Card("<card ID>");
var copy = Card.List.Cards.Add(card);
Done!
Edit for completeness
The ActionTypes enum serves two purposes:
Identify the type of action when you get the list of actions (card.Actions) for objects that expose them (boards, lists, cards, etc.)
Filter actions that are included in the Filter() extension method.
You can find out more on the Manatee.Trello wiki
Another edit for more completeness
The card.ApplyAction() method is for web hooks. When a request is received, the content is deserialized as a string and passed to this method. It is an alternative updating mechanism from the default on-demand polling.

How to remove all entries (delete data) from root / in Firebase?

I'm trying to reset the database programatically from Swift. I want to achieve the same result as in the Firebase console, clicking the red X on the name of the database (root path)
The Firebase API reference for Objective-C has two methods that seem to be relevant:
Firebase.removeValue
Firebase.removeValueWithCompletionBlock:block
The latter allows you to supply a callback to call after the removal has been completed.

How does one programmatically delete a preference from the NSGlobalDomain?

This is a simple task from the terminal:
defaults delete -g <key>
I'd like to do this in Swift using NSUserDefaults. The documentation says:
If you want to change the value of a preference in the global domain, write that same preference to the application domain with the new value.
This simply sets a new value for the same key in the application domain so that when NSUserDefaults retrieves the value for the key in the future, it will find the new value in the application domain before it searches the global domain.
Is there some way to either:
delete the key from the NSGlobalDomain, or
set a new value for the key in NSGlobalDomain
using NSUserDefaults?
I know I can use NSTask, for example, to run defaults delete -g <key>, but I consider that a workaround (a valid one).
You can try this, but it's not really a good idea:
var defaults = NSUserDefaults.standardUserDefaults()
var globalDomain = defaults.persistentDomainForName(NSGlobalDomain)
globalDomain.removeObjectForKey(someKey)
defaults.setPersistentDomain(globalDomain, forName:NSGlobalDomain)
The main problem is a race condition with other processes or threads. If something changes the global domain between the time you read it and when you write it back, you undo those changes, even if they didn't involve the key you were manipulating. Also, you're potentially reading and writing a large dictionary, doing a lot more work than actually necessary.
Probably better to drop down to the CFPreferences API:
CFPreferencesSetValue(someKey, nil, kCFPreferencesAnyApplication,
kCFPreferencesCurrentUser, kCFPreferencesCurrentHost)