Is there any way to get firebaesevisionimagelabel data in oncreate? - firebase

Im trying to make copy of firebasevisionimagelabel, but only it works in function after then i can't get any of label in oncreate
This is firebase,written in kotlin. i've put string in wordpilec but i can't load it in oncreate
private fun runDetector (bitmap : Bitmap?){
val image = FirebaseVisionImage.fromBitmap(bitmap!!)
val options = FirebaseVisionCloudImageLabelerOptions.Builder()
.setConfidenceThreshold(0.7f)
.build()
val labeler = FirebaseVision.getInstance().getCloudImageLabeler(options)
labeler.processImage(image)
.addOnSuccessListener { labels -> processResultfromcloud(labels)
}
private fun processResultfromcloud(labels: List<FirebaseVisionImageLabel>) {
for (label in labels) {
builder.append(label.text).append(",")
}
wordpilec = builder.toString()
stringtoArray(wordpilec)
}
I expect strings should be same but one is null the other is perfect . I can not get perfect one

The detector runs asynchronously, and I'm guessing you are trying to access wordpilec in onCreate before the detector has assigned a value assigned to it. You could try and move the operation you are trying to do with the string to the success listener instead.

Related

Unable to recieve value of getquery parameter in Firebase Dynamic Links

I have to add an extra parameter as "meetingToken" in firebase deeplink .
But On adding an extra parameter "meetingtoken" as queryparameter im not recieving the value and getting error in joinmeeting(it) : No value passed for parameter meetingToken.
While the same works fine on passing a single parameter, What changes do i need to recieve both the parameters value.
Currently its giving me error at:
deepLink?.getQueryParameter("meetingCode")?.let { joinMeeting(it) }
No value passed for parameter 'meetingToken'
Link = https://example.in/?meetingCode=myuser?meetingToken=rtgdhh.tywufgsioqpp
private fun handleDynamicLink() {
Firebase.dynamicLinks
.getDynamicLink(intent)
.addOnSuccessListener { pendingDynamicLinkData ->
val deepLink: Uri?
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.link
on android debugging its generating the following firebase Link = https://example.in/?meetingCode=userroom?meetingToken%3DeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Ni
deepLink?.getQueryParameter("meetingToken")
deepLink?.getQueryParameter("meetingCode")?.let { joinMeeting(it) }
}
}
.addOnFailureListener { _ ->
toast(getString(R.string.main_error_fetch_dynamic_link))
}
}
private fun joinMeeting (meetingCode:String, meetingToken:String) {
MeetingUtils.startMeeting(
this, meetingCode,
meetingToken)
}
meeting Utils.kt file to start meeting
object MeetingUtils {
fun startMeeting(context: Context, meetingCode: String, meetingToken: String)
app deep link url string
<string name="app_deep_link_url">https://example.in/?meetingCode=%1$s?meetingToken=%2$s</string>
this is the share code
private fun onShareMeetingCodeClick() {
tilCodeCreateMeeting.setEndIconOnClickListener {
binding.tilCodeCreateMeeting.error = null
toast(getString(R.string.main_creating_dynamic_link))
Firebase.dynamicLinks.shortLinkAsync {
link = Uri.parse(getString(R.string.app_deep_link_url, getCreateMeetingCode(), getCreateMeetingToken() ))
domainUriPrefix = getString(R.string.app_dynamic_link_url_prefix)
androidParameters {}
navigationInfoParameters {
forcedRedirectEnabled = true // Directly open the link in the app
}
}.addOnSuccessListener { result ->
val shortDynamicLink = result.shortLink.toString()
startShareTextIntent(
getString(R.string.main_share_meeting_code_title),
getString(R.string.main_share_meeting_code_desc, shortDynamicLink)
)
}.addOnFailureListener {
toast(getString(R.string.main_error_create_dynamic_link))
}
Can Someone guide me how to recieve value of getQueryparameter for more than 1 parameter. Thanks in Advance
You should use & instead of ? on appending the second parameter on your deep link. Also, the deep link configured should be URL-encoded since multiple parameters are configured in the deep link. Your sample deep link should look like this.
link=https%3A%2F%2Fexample.in%2F%3FmeetingCode%3Dmyuser%26meetingToken%3Drtgdhh.tywufgsioqpp
By URL-encoding the deep link, FDL will able to distinguish which parameters belongs to the deep link.
Uri.parse(getString(R.string.app_deep_link_url, getCreateMeetingCode(), getCreateMeetingToken()))
I'm not sure on what you're trying to achieve passing multiple parameters on getString for the deep link value.
Won't it make sense to create a StringBuilder or append it manually?
val deepLink = getString(R.string.app_deep_link_url)+ "%2F%3FmeetingCode%3D$meetingCode%26meetingToken%3D$meetingToken";
link = Uri.parse(deepLink);
where "app_deep_link_url" in strings.xml is
<string name="app_deep_link_url">https%3A%2F%2Fexample.in</string>

Xamarin Form passing parameters between page keep a hard link to it

I try the new Shell of Xamarin Form 4 for a small project.
I have a list of order, then someone chooses an order and start picking some inventory for this order with barcode. To be simple, I use 2 views and 2 viewmodel.
The process is:
1. User select an order the click a button "pickup"
2. I use ViewModelLocator (TinyIoc) to resolve the correct ViewModel of the pickup view
3. I call Initialize on the new ViewModel and pass some parameters needed. Like a list of items needed to be pickup.
4. Open the view in modal state.
I don't understand that if I change some qty in the list I pass on the second viewmodel, then hit the back button (modal view close). The quantity changed is now in the original viewmodel. How this is possible? I was thinking that passing parameter to a function do not share the same variable but just copy it??
Viewmodel of the first view (look at the Initialize function the List passed and the JobEnCours object)
private async Task GoPickup()
{
Device.BeginInvokeOnMainThread(async () =>
{
if (this.CodeJob != null && this.CodeJob != "")
{
this.IsBusy = true;
PrepChariotSP3ViewModel vm = ViewModelLocator.Resolve<PrepChariotSP3ViewModel>();
await vm.InitializeAsync(this._jobEnCours, this.ComposantesPick.ToList()) ;
await Shell.Current.Navigation.PushAsync(new PrepChariotSP3Page(vm));
this.IsBusy = false;
}
});
}
the the Initialize code on the second Viewmodel (look I set the JobEnCours.Description=Test)
public async Task InitialiseAsync(Job jobEnCours, List<ComposantePick> composantePick)
{
Title = "Ceuillette: " + jobEnCours.CodeProd;
this._jobEnCours = jobEnCours;
this.ComposantesPick = new ItemsChangeObservableCollection<ComposantePick>();
foreach(ComposantePick c in composantePick)
{
this.ComposantesPick.Add(c);
}
jobEnCours.Description = "test";
So, If I do the back button, then in the first VM the JobEnCours.Description is now set to "test" how this is possible?!
Any idea?

Cannot implicitly convert type 'System.Linq.IQueryable to System.Data.Entity.DbSet<>

I receive the following error when I try to run my code. I haven't managed to solve it yet, please Help:
edit: Marked with * where it fails.
>
public IQueryable<Video> GetVideos([QueryString("id")] int? categorieId)
{
var _db = new TeleviziuneAcademicaAspSilverlight.Models.VideoContext();
IQueryable<Video> query = *_db.Videos;*
if (categorieId.HasValue && categorieId > 0)
{
query = query.Where(v => v.CategorieID == categorieId);
}
return query;
Change
IQueryable<Video> query =
to
IQueryable<Appname.Models.Video> query =
The reason for your error is that you have the type Video defined twice and because of using a short type name you accidentally reference not the one Video you should.
Also change it in the method's return value
public IQueryable<Appname.Models.Video> GetVideos( ... )
You seem to have two classes called Video. If you need both, you'll need to project from one to the other before your return statement:
return query.Select(dbVideo => new Appname.Video()
{
Prop1 = dbVideo.Prop1,
Prop2 = dbVideo.Prop2,
// etc.
});
Though you'll probably need to change the return type to an IEnumerable<> if you do that.
If you can just work with Appname.Models.Video, change IQueryable<Video> to IQueryable<Appname.Models.Video> in the method signature and the method body.

Factory Method implementation in actionscript

Hey folks, i ve got this issue implementing the Factory method.
Following is the snippet of the the main chart class which calls ChartFactory's method to attain the proper object. I Type Cast chartobject so as to be able to call the Show method;i m apprehensive about that as well.
container = new VBox();
container.percentWidth = 100;
container.percentHeight = 100;
super.media.addChild(container);
chartObject = new ChartBase();
chartObject = ChartFactory.CreateChartObject(chartType);
IChart(chartObject).Show(o);
container.addChild(chartObject);
legend = new Legend();
legend.dataProvider = IChart(chartObject);
container.addChild(legend);
Following is the snippet of ChartFactory's method:
public static function CreateChartObject(subType:String):ChartBase
{
switch(subType)
{
case ChartFactory.AREA_CHART:
return new AreaCharts();
break;
case ChartFactory.COLUMN_CHART:
return new ColumnCharts();
break;
case ChartFactory.PIE_CHART:
return new PieCharts();
break;
default:
throw new ArgumentError(subType + ": Chart type is not recognized.");
}
}
And following is Show method of one of the several Charts type classes: AreaCharts, PieCharts etc. All of which implements IChart Interface.
public function Show(o:ObjectProxy):void
{
var grids:GridLines;
var stroke:SolidColorStroke;
var horizontalAxis:CategoryAxis;
var verticalAxis:LinearAxis;
var horizontalAxisRenderer:AxisRenderer;
var verticalAxisRenderer:AxisRenderer;
grids = new GridLines();
if(WidgetStylesheet.instance.LineChart_ShowGrid)
grids.setStyle("gridDirection", "both");
else
grids.setStyle("gridDirection", "");
stroke = new SolidColorStroke(WidgetStylesheet.instance.LineChart_GridLineColor, WidgetStylesheet.instance.LineChart_GridLineThickness);
grids.setStyle("horizontalStroke", stroke);
grids.setStyle("verticalStroke", stroke);
horizontalAxis = new CategoryAxis();
horizontalAxis.categoryField = o.LargeUrl.Chart.xField;
horizontalAxis.title = o.LargeUrl.Chart.xAxisTitle.toString();
verticalAxis = new LinearAxis();
verticalAxis.title = o.LargeUrl.Chart.yAxisTitle.toString();
horizontalAxisRenderer = new AxisRenderer();
horizontalAxisRenderer.axis = horizontalAxis;
horizontalAxisRenderer.setStyle("tickLength", 0);
horizontalAxisRenderer.setStyle("showLine", false);
horizontalAxisRenderer.setStyle("showLabels", true);
horizontalAxisRenderer.setStyle("fontSize", WidgetStylesheet.instance.ComputeChartAxisFontSize(o.HeadlineFontSize));
verticalAxisRenderer = new AxisRenderer();
verticalAxisRenderer.axis = verticalAxis;
verticalAxisRenderer.setStyle("tickLength", 0);
verticalAxisRenderer.setStyle("showLine", false);
verticalAxisRenderer.setStyle("fontSize", WidgetStylesheet.instance.ComputeChartAxisFontSize(o.HeadlineFontSize));
this.series = this.m_createSeries(o);
this.horizontalAxis = horizontalAxis;
this.horizontalAxisRenderers = [horizontalAxisRenderer];
this.verticalAxis = verticalAxis;
this.verticalAxisRenderers = [verticalAxisRenderer];
this.backgroundElements = [grids];
}
I'm afraid that there is more than one issue with this code. Unfortunately it is not obvious why your chart doesn't show up so you may apply some of advices below and use debugger to analyse the issue.
There is no point in creating ChartBase instance if you are going to change value of chartObject reference in the next line
chartObject = new ChartBase();
chartObject = ChartFactory.CreateChartObject(chartType);
If the API of your charts is IChart your factory should return IChart instead of casting.
public static function CreateChartObject(subType:String):IChart
Make sure that you are returning instances of the correct class from the factory. i.e. that you are returning your subclass of standard PieChart. Generally it's not the best idea to extend the class keeping the same name and just changing the package.
Once again, if you are not sure if the program enters some function use the Flash Builder debugger to check this. I can't imagine development without debugger.
Some thoughts:
you call the Show method, pass it some object but nowhere in that method is any child added to a displayObject. What exactly is Show supposed to do?
a lot of member variables in your classes start with UpperCase. The compiler can easily confuse those with class names, in case your classes are named the same. Bad practice to start variable and function names with capitals.
If your casting an instance to another class or interface fails, you will get a runtime error. Those are easy to debug using the Flash Builder debugger.
Hey ppl..
i found out wat wnt wrng..as olwys it wa "I".
I ve a habit of mkin mock ups secluded from the main project n dn integrate it. So in mock up i hd used an xml whch hd a format slightly diff dn d one being used in the main project.
N i hd a conditional chk to return from the prog if certain value doesnt match, n due to faulty xml i did'nt.
So this more a lexical error than a logical one.
Sorry n Thanx evryone for responding.

Problems with remote shared objects Fms Flex 4

I'm trying to develop an application where simultaneous users can interact and i need to have a persistent remote shared object with the list of users currently in session.
When a new user enter in the session he get the server's object with the list. That list was supose to have all the others users in session but is undefined.
I'm doing this first:
users_so = SharedObject.getRemote("users_so", nc.uri, true);
users_so.connect( nc );
users_so.addEventListener( SyncEvent.SYNC, usersSyncHandler );
then i set property to shared object
remoteUsers = new ArrayCollection();
remoteUsers.addItem(displayName);
users_so.setProperty("usersID", remoteUsers);
and finaly i put users in the list.
Thanks!
I would say, that you need to use sharedObject.setDirty("usersID");
SharedObject can't know, that you changed content of ArrayCollection, because the reference to it didn't change. You can use setDirty() to force synch.
Note: The SharedObject.setProperty()
method implements the setDirty()
method. In most cases, such as when
the value of a property is a primitive
type like String or Number, you would
use setProperty() instead of setDirty.
However, when the value of a property
is an object that contains its own
properties, use setDirty() to indicate
when a value within the object has
changed. In general, it is a good idea
to call setProperty() rather than
setDirty(), because setProperty()
updates a property value only when
that value has changed, whereas
setDirty() forces synchronization on
all subscribed clients.
I am using simple dynamic object for this. Client has read-only SharedObject and server decides when to add/remove client from this SharedObject.
m_so is SharedObject (remote), m_userList is Object (local)
if(m_so.data.userList != null) {
for (var key:String in m_so.data.userList) {
if(m_userList[key] == null) {
_addUser(m_so.data.userList[key]);
}
}
for(var clientId:String in m_userList) {
if(m_so.data.userList[clientId] == null) {
_removeUser(clientId);
}
}
}
application.onAppStart = function () {
userList = {};
so = SharedObject.get("roster", false);
so.setProperty("userList", userList);
}
application.onConnect = function (client /*Client*/, userId /*string*/) {
application.acceptConnection(client);
client.userId = userId;
userList[userId] = userId;
so.setProperty("userList", userList);
}
application.onDisconnect = function (client /*Client*/) {
var userId = client.userId;
delete userList[userId];
so.setProperty("userList", userList);
}
I found one solution that works better for me:
It consists in calling remote funcions on server and then broadcast to all clients. The clientes then apply the necessery changes making the solution a lot more stable.

Resources