Snackbar error - None of the following functions can be called with the arguments supplied - android-studio

I've created a simple app to show a toast message which I'm trying to replace with Snackbar. Gettin the error message for the below code.
Snackbar.make(
this#MainActivity,
R.string.true_snack,
Snackbar.LENGTH_LONG
).show()
I tried looking for similar issues but are mostly related to toasts. One suggestion was to make the view nullable but that didn't work.

Related

mdToast cannot resolve a promise with itself error

I keep running into an error in the console when my $mdToast fires. It says: TypeError: [$q:qcycle] Expected promise to be resolved with value other than itself '{}' The toast works fine, but I would prefer not to have that error whenever it pops up. Here is the function:
let showSuccess = this.mdToast.show({
template: '<md-toast>User added successfully!</md-toast>',
hideDelay: 33000,
position: 'top'
});
this.mdToast.hide(showSuccess);
Does anyone know what might be causing this? Thanks
You don't need to pass toast itself to hide function. Just use it without any parameters:
this.mdToast.hide();
According to the reference it hides an existing toast. Optional response parameter is actually used for another purpose (promises).
$mdToast.hide([response]);
Hide an existing toast and resolve the promise returned from $mdToast.show().

Swift UIWebView Optional is nil

In the below example, infoScroller is a UIWebView and println(HTMLDescription) prints a lovely string of HTML. However, the attempt to loadHTMLString gets the runtime error: fatal error: Can't unwrap Optional.None
if let HTMLDescription = self.myData?.content? {
println(HTMLDescription)
infoScroller.loadHTMLString(HTMLDescription, baseURL: nil)
}
I've tried every combination of ! and ? in both the assignment and use of the string but I get this same error every time, though the variable never fails to print out perfectly to the console.
There is another value that I set using the same method and it works fine. Both are strings, but the other one is more simple in that HTMLDescription is multiline and the working one is not.
Edit: The discussion in the comments prompted me to check the infoScroller and it's description as printed in the console is: (#sil_weak UIWebView!) infoScroller =
I'm thinking that's the issue, but I'm not sure what it means or how to fix it.
Edit 2: This has to be the issue. println(infoScroller.description) yields the exact same error.
Got it! This question put me on the path. I was trying to load the content before the view was fully loaded. Moved loadHTMLString() into viewDidLoad(). Stupid simple.

Derbyjs TEMPLATE ERROR

I just started trying out Derbyjs, and I already ran into a problem. I can't find any support for this error, and most likely is some dumb mistake i'm making.
I'm trying to render a view, following the example from the www.derbyjs.com documentation.
My app is as simple as this:
var app = require('derby').createApp(module);
app.get('/', function (page, model) {
page.render('home');
});
My views are composed by two files.
"index.html"
<import: src="home">
<Body:>
Default page content
"home.html"
<Body:>
Welcome to the home page
I get the following error whenever the page is rendered:
TEMPLATE ERROR
Error: Template import of 'home'... ...can't contain content
As you can see, it is a very simple example. What am I missing?
I get that error even if I have the "home.html" file empty.
Well, I got the answer from one of the developers.
It seems like there was a subtle bug in the Template Parser that probably has already been fixed.
Having a whitespace or linebreak in front of
<import: src="home">
was causing the parser to raise the error. Writing
<import: src="home"><Body:>
solved the issue.

FormatMessage gets Error 317 while trying to read EventLog

I had nearly similar problem with this.
FormatMessage Fails with error code 317
The difference is it is said as an answer that this is caused by "FORMAT_MESSAGE_FROM_SYSTEM" but when I remove it it happens again.
I am trying to read from EventLog in Windows Server 2003. But when I try to use FormatMessage function I get 317 error.
Interestingly same code works for Windows Server 2008. How can I fix this or what can I use instead of FormatMessage?
My code:
FormatMessage(FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ALLOCATE_BUFFER,
g_hResources, // handles DLL containing message table
MessageId,
0, // Default language
(LPWSTR) &pMessage,
0,
(va_list*)pArgs )
Good day to you..
Error 317 is "The system cannot find message text for message number 0x%1 in the message file for %2.". That means the MessageId is not an error number known to the system.
You are combining FORMAT_MESSAGE_FROM_HMODULE and FORMAT_MESSAGE_FROM_SYSTEM, which doesn't make sense. Where do you want to get the message from? Do you want to get it from g_hResources or from the system error message table? From the comment, it sounds like you want to get it from g_hResources, in which case you should remove FORMAT_MESSAGE_FROM_SYSTEM. If you still get error 317, then it means that the message number you passed doesn't exist in g_hResources.

Appending document in response function

Not sure why, but I'm getting an unexpected identifier error when trying to append an element to the document in a response function. I've found that doing anything with the document seems to give me this error. Here's a sample code:
chrome.extension.sendRequest({send:data},function(response) {
document.body.innerHTML='test'
})
It looks to me like it should work, but evidently it does now. This piece of code is located in the contentscript, and messing with the document outside of this function seems to work just fine, but I always get "unexpected identifier" when trying this. Unfortunately I cannot do it outside of the function because the response determines whether or not an element is added to the body.
The code you shared should work. Try restarting your browser to see if that fixes it.

Resources