Image Lazy Loading Ionic 3 not working in my project [closed] - ionic-framework

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
link
link2
i follow both link but image lazy load not working in my project ,please suggestion

Here is working Example
image list api
https://picsum.photos/list
constructor(public navCtrl: NavController, public imageloader: Lorem) {
this.loadMyImages();
}
loadMyImages()
{
this.loadingLoremPicsList = true;
this.loremList = [];
this.albumList = [];
this.imageloader.getMyPics().subscribe(
data => {
this.loremList = data;
this.albumList = this.loremList.splice(this.getRandomInt(0, 700), 12);
console.dirxml(this.loremList);
this.loadingLoremPicsList = false;
},
err =>
{
}
)
}
in provider .ts
private my_lorem_pics: string = "https://picsum.photos/list";
constructor(public http: HttpClient) {
}
getMyPics()
{
return this.http.get(this.my_lorem_pics);
}

Related

How to detect what app is opened currently in Flutter

I'm building a Flutter app which simply gives notification while we enter into Instagram.
Is there any way to check if Instagram is opened or not in Flutter?
Any answers will be appreciated. Thank you!
You can use this plugin usage_stats
List<UsageInfo> list = await UsageStats.queryUsageStats(startDate, endDate);
and check if
List<UsageInfo> appList = [];
for (var i in list) {
if (listOfApps.contains(i.packageName)) {
if (!appList.contains(i)) {
appList.add(i);
}
}
}
for (var usageStats in appList) {
if(DateTime.now().millisecondsSinceEpoch) >= int.parse(usageStats.lastTimeUsed!) + 1000)
{
//Instagram is opened
}
}
const List<String> listOfApps = [
'com.instagram.android', // android package name of instagram
];
Hope its helpfull

Call method onSubmit of another button [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have 1 ajax button and 1 link:
AjaxButton buttonA = new AjaxButton("buttonA") {
private static final long serialVersionUID = 1L;
#Override
protected void onSubmit(AjaxRequestTarget target) {
info("buttonA");
}
}
Link<void> buttonB = new Link<void>("buttonB") {
...
}
I want to when I click buttonB is equivalent to buttonA click
Please help me.
Extract the body of ButtonA#onSubmit() to a separate method and just call this method in ButtonB#onClick()
private void doWork() {...}
AjaxButton buttonA = new AjaxButton("buttonA") {
#Override
protected void onSubmit(AjaxRequestTarget target) {
doWork();
}
}
Link<void> buttonB = new Link<void>("buttonB") {
#Override public void onClick() {
doWork();
}
}

cordova-plugin-antplus not work with ionic 3 [duplicate]

This question already has answers here:
When should I use arrow functions in ECMAScript 6?
(9 answers)
Closed 4 years ago.
This is my code:
public antplus: any;
public SelectId: any;
constructor(public navCtrl: NavController) {
this.antplus = (<any>window).antplus;
this.antplus.searchDevices('HEARTRATE', function(device) {
console.log(JSON.stringify(device));
console.log("Ant ID=" + device.antDeviceNumber);
this.SelectId = device.antDeviceNumber;
},(error)=>{console.log("Error Search="+error);});
}
At the console will show [INFO:CONSOLE(64)] "Ant ID=4077".
But also get Error message : in Success callbackId: Antplus1239198979 : TypeError: Cannot set property 'SelectId' of null.
Anyone get this problem before?
public antplus: any;
public SelectId: any;
constructor(public navCtrl: NavController) {
this.antplus = (<any>window).antplus;
this.antplus.searchDevices('HEARTRATE', (device) => {
console.log(JSON.stringify(device));
console.log("Ant ID=" + device.antDeviceNumber);
this.SelectId = device.antDeviceNumber;
},(error) => {
console.log("Error Search="+error);
});
}

Watson keyword spotting unity

I have downloaded the Watson unity SDK and set it up like show in the picture and it works.
My question is how do I add keyword spotting?
I have read this question For Watson's Speech-To-Text Unity SDK, how can you specify keywords?
But I cant for example locate the SendStart function.
The Speech to Text service does not find keywords. To find keywords you would need to take the final text output and send it to the Alchemy Language service. Natural Language Understanding service is still being abstracted into the Watson Unity SDK but will eventually replace Alchemy Language.
private AlchemyAPI m_AlchemyAPI = new AlchemyAPI();
private void FindKeywords(string speechToTextFinalResponse)
{
if (!m_AlchemyAPI.ExtractKeywords(OnExtractKeywords, speechToTextFinalResponse))
Log.Debug("ExampleAlchemyLanguage", "Failed to get keywords.");
}
void OnExtractKeywords(KeywordData keywordData, string data)
{
Log.Debug("ExampleAlchemyLanguage", "GetKeywordsResult: {0}", JsonUtility.ToJson(resp));
}
EDIT 1
Natural Language Understanding has been abstracted in tot he Watson Unity SDK.
NaturalLanguageUnderstanding m_NaturalLanguageUnderstanding = new NaturalLanguageUnderstanding();
private static fsSerializer sm_Serializer = new fsSerializer();
private void FindKeywords(string speechToTextFinalResponse)
{
Parameters parameters = new Parameters()
{
text = speechToTextFinalResponse,
return_analyzed_text = true,
language = "en",
features = new Features()
{
entities = new EntitiesOptions()
{
limit = 50,
sentiment = true,
emotion = true,
},
keywords = new KeywordsOptions()
{
limit = 50,
sentiment = true,
emotion = true
}
}
if (!m_NaturalLanguageUnderstanding.Analyze(OnAnalyze, parameters))
Log.Debug("ExampleNaturalLanguageUnderstanding", "Failed to analyze.");
}
private void OnAnalyze(AnalysisResults resp, string customData)
{
fsData data = null;
sm_Serializer.TrySerialize(resp, out data).AssertSuccess();
Log.Debug("ExampleNaturalLanguageUnderstanding", "AnalysisResults: {0}", data.ToString());
}
EDIT 2
Sorry, I didn't realize Speech To Text had the ability to do keyword spotting. Thanks to Nathan for pointing that out to me! I added this functionality into a future release of Speech to Text in the Unity SDK. It will look like this for the Watson Unity SDK 1.0.0:
void Start()
{
// Create credential and instantiate service
Credentials credentials = new Credentials(_username, _password, _url);
_speechToText = new SpeechToText(credentials);
// Add keywords
List<string> keywords = new List<string>();
keywords.Add("speech");
_speechToText.KeywordsThreshold = 0.5f;
_speechToText.Keywords = keywords.ToArray();
_speechToText.Recognize(_audioClip, HandleOnRecognize);
}
private void HandleOnRecognize(SpeechRecognitionEvent result)
{
if (result != null && result.results.Length > 0)
{
foreach (var res in result.results)
{
foreach (var alt in res.alternatives)
{
string text = alt.transcript;
Log.Debug("ExampleSpeechToText", string.Format("{0} ({1}, {2:0.00})\n", text, res.final ? "Final" : "Interim", alt.confidence));
if (res.final)
_recognizeTested = true;
}
if (res.keywords_result != null && res.keywords_result.keyword != null)
{
foreach (var keyword in res.keywords_result.keyword)
{
Log.Debug("ExampleSpeechToText", "keyword: {0}, confidence: {1}, start time: {2}, end time: {3}", keyword.normalized_text, keyword.confidence, keyword.start_time, keyword.end_time);
}
}
}
}
}
Currently you can find the refactor branch here. This release is a breaking change and has all of the higher level (widgets, config, etc) functionality removed.

ASP.NET MVC 2 - Handling files in an edit action; Or, is it possible to create an 'Optional' data annotation which would skip over other attributes?

I've run into a bit of a design issue, and I'm curious if anyone else has run into something similar.
I have a fairly complex model which I have an Edit action method for. Each individual entity has two images associated with it, along with other, more mundane data. These images are [Required] upon creation. When editing an entity, however, these images already exist, since, again, they were required upon creation. Thus, I don't need to mark them as required.
Adding a bit of a monkey wrench to the whole thing is my custom image validation attribute:
public class ValidateFileAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
var file = value as HttpPostedFileBase;
if (file == null)
{
return false;
}
string[] validExtensions = { "jpg", "jpeg", "gif", "png" };
string[] validMimeTypes = { "image/jpeg", "image/pjepeg", "image/gif", "image/png" };
string[] potentialFileExtensions = file.FileName.Split('.');
string lastExtension = potentialFileExtensions[(potentialFileExtensions.Length - 1)];
string mimeType = file.ContentType;
bool extensionFlag = false;
bool mimeFlag = false;
foreach (string extension in validExtensions)
{
if (extension == lastExtension)
{
extensionFlag = true;
}
}
foreach (string mt in validMimeTypes)
{
if (mt == mimeType)
{
mimeFlag = true;
}
}
if (extensionFlag && mimeFlag)
{
return true;
}
else
{
return false;
}
}
}
What I'd ideally like to do would be to create some kind of [Optional] attribute which would bypass the image validator altogether if new files aren't POSTed along with the rest of the form data.
Is something like this possible? If not, how would the collective wisdom of Stack Overflow address the problem?
you might be interested in following article...
but i have to say i do agree with most in the article.
mainly the part : conditional validation
http://andrewtwest.com/2011/01/10/conditional-validation-with-data-annotations-in-asp-net-mvc/
hope this will helps.