SuperNotCalledExeption onPause() - fragment

I am using this example: http://android-er.blogspot.com/2012/07/implement-gallery-like.html but in a fragment and I am getting a SuperNotCalledException for onPause() I used the debugger and it is failing when adding the images to the linear view not really sure why though if someone could help me I will greatly appreciate it :
File[] files = targetDirector.listFiles();
for (File file : files){
myGallery.addView(insertPhoto(file.getAbsolutePath()));
}

Make sure you call super.onPause() in your onPause() method.

Related

Cant use TappedEventArgs in OnTapped Event

In all examples regarding Tapping Eventhandling in MAUI I have seen the Handlerfunction gets TappedEventArgs.
-> void OnTapGestureRecognizerTapped(object sender, TappedEventArgs args)
-> XAML: ...
If I try to do so, Visual Studio says "CS0123 - No overload for "OnTapGestureRecognizerTapped" matches the delegate EventHandler".
I have to change it from TappedEventArgs to EventArgs.
No matter if in XAML or C# I always get this result.
What am I doing wrong?
Did I miss any Using xyz?
I need TappedEventArgs or how else can I detect the tapped position?
Please help me.
I need an Eventhandler with TappedEventArgs instead of EventArgs.
I tried casting, but does not work.

Unity problem with call api and set data after it

I have a call to my Firebase database that retrieves data from a player, and then it sends this data to an object. (In this object there is a list containing the weapons).
Except that in another file, I call the function to retrieve the weapons in the list. This one is empty when the game starts, because the then is not passed yet.
I solved the problem by setting an isReady variable to true when the then is passed, and I put in a void Update() the call of the function on the list.
I don't think this is the right solution, and there must be a better one, do you have an idea ? I start on unity
Here is the code :
This method will search in the list.
public void DisplayIfOwned()
{
if (GameObject.Find("PlayerManager").GetComponent<GetDataSoldier>().soldier.weaponsList.Contains(id)) weapon.SetActive(true);
else weapon.SetActive(false);
}
This method calls api to retrieve the player.
public void FillSoldierData()
{
RestClient.Get<Soldier>("https://minisoldiers-fdd66.firebaseio.com/Soldiers/" + SoldierCreation.soldierName + ".json")
.Then(response =>
{
soldier = response;
UpdateSoldier();
isReady = true;
});
}
You really should provide more clear information, I needed to make assumptions of how exactly you did things. Don't hesitate to add more code snippets, it's very helpful :)
If my assumptions are correct though, then why not just call DisplayIfOwned method directly inside Then(...? You said you're doing that in Update, so you surely have class level reference that has access to that method.
If it's done in some other way, then this might be what you want: Action

Eclipse removing white spaces when saving

I have a big issue. I develop in eclipse ide environment, mostly on windows but also on linux. This seems to be a general issue.
Before I save my project on eclipse I have certain spaces between functions or in the code somewhere. I don't want to reformat the code that is in place.
However, every single time I try to save my project. Those spaces disappear, and I cannot find the place where I should change this auto-formatting in my eclipse properties.
Please see example bellow:
First of all I don't touch the code but I receive it as bellow and have to make modifications elsewhere. So at the initial state of my file I have somewhere in the code two functions [functionOne, functionTwo]. Those two functions are separated by a new line [NL] and 6 spaces. The problem appears when I save my project and as you can see the two functions are not separated anymore by the same number of spaces.
Before saving my project:
public void functionOne(){
int i = 0;
while(i<150)
{
//blabla...
}
}
NL:123456
public void functionTwo(){
int i = 0;
while(i<150)
{
//blabla...
}
}
After saving my project:
public void functionOne(){
int i = 0;
while(i<150)
{
//blabla...
}
}
NL:1
public void functionTwo(){
int i = 0;
while(i<150)
{
//blabla...
}
}
I'm starting to be sick of this issue and really need help to solve this.
Not forgetting to mention that absolutely no "Save actions" is enabled!
I don't see anything on my format options neither, but I could be wrong.
Could someone please help me to find a solutions to this problem?
Best regards,
Greg
So that wasn't the "Save actions" but some plugin that I was using. Didn't had the time to check which one it is I just uninstalled the rarely/unused once. And for the moment it seems to work. I'll check later if the problem remains/reappears.
Thanks for your help.
Best regards,
Gregory

silverstripe dopublish function for ModelAdmin managed Pages

in the silverstripe backend I´m managing certain PageTypes via a ModelAdmin. That works fine so far, the only thing i can´t figure out is how to make a Page being "Published" when saving it.
Thats my code:
class ProjectPage extends Page {
public function onAfterWrite() {
$this->doPublish();
parent::onAfterWrite();
}
}
At the moment I can still see the ModelAdmin-created Pages in the Sitetree and I can see they are in Draft Mode. If I use the code above I get this error:
Maximum execution time of 30 seconds exceeded in
.../framework/model/DataList.php
Many thx,
Florian
the reason why you get "Maximum execution time exceeded" is because $this->doPublish(); calls $this->write(); which then calls $this->onAfterWrite();. And there you have your endless loop.
So doing this in onAfterWrite() or write() doesn't really work
you should just display the save & publish button instead of the save button
But I guess its easier said than done.
Well adding a button is actually just a few lines, but we also need a provide the functions that do what the button says it does.
This sounds like the perfect call for creating a new Module that allows proper handling of Pages in model admin. I have done this in SS2.4, and I have a pretty good idea of how to do it in SS3, but no time this week, poke me on the silverstripe irc channel on the weekend, maybe I have time on the weekend.
I found the same need/lack and I built a workaround that seems to work for me, maybe it can be useful.
public function onAfterWrite()
{
if(!$this->isPublished() || $this->getIsModifiedOnStage())
{
$this->publish('Stage', 'Live');
Controller::curr()->redirectBack();
}
parent::onAfterWrite();
}
Create a class that extends ModelAdmin and define an updateEditForm function to add a publish button to the actions in the GridFieldDetailForm component of the GridField.
public function updateEditForm($form) {
if ( ! singleton($this->owner->modelClass)->hasExtension('Versioned') ) return;
$gridField = $form->Fields()->fieldByName($this->owner->modelClass);
$gridField->getConfig()->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function ($form) {
$form->Actions()->push(FormAction::create('doPublish', 'Save & Publish'));
});
}
Then create a class that extends GridFieldDetailForm_ItemRequest to provide an action handler for your publish button.
public function doPublish($data, $form) {
$return = $this->owner->doSave($data, $form);
$this->owner->record->publish('Stage', 'Live');
return $return;
}
Make sure the extensions are applied and you're done.
Or, you could just grab all the code you need from GitHub.

How do I know when user minimizes / maximizes Eclipse?

I need to respond to the events of minimizing / maximizing Eclipse window. How do I do that?
I can suggest a way: you can write a plugin for it.
For example see this improvized "tutorial", I made it, tried it works on Ganymede. A bit ugly at the final Shell variable, but working. If you know nicer solution just shoot :)
((actually there is a way: to extend your own ControlListener class, but that needs more coding :))
Create a new Plug-in Project, name it as you want, create it from a template named: Hello World Command
Open the SampleHandler class, and then replace the execute() function with this code.
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil
.getActiveWorkbenchWindowChecked(event);
final Shell s = window.getShell();
window.getShell().addControlListener(new ControlListener() {
#Override
public void controlMoved(ControlEvent e) {
// TODO Auto-generated method stub
}
#Override
public void controlResized(ControlEvent e) {
MessageDialog.openInformation(s,
"WindowEventHandler Plug-in", "RESIZED: "
+ e.toString() + "\nHello, Eclipse world");
}
});
MessageDialog.openInformation(window.getShell(),
"WindowEventHandler Plug-in",
"Hello, Eclipse world, resize will be taken care of.");
return null;
}
now. Start the project (Run As-> Eclipse application), and you'll se an Eclipse button on the toolbar. Click on it! It triggers the running of the above code where the essence is that the window.getShell() returns with the main window component so you can add listeners to it.
If you want it to run automatically, not just for a button, you have to find out a plugin where the entry point is connected to the starting of the application.
Hope this helps.
b
Found a way to do it easily: you have to create a ShellListener or ShellAdapter, which have methods that are called when the shell is iconified, deiconified, activated, deactivated and closed.
After creating it, add it as a listener with the following line:
int i;
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().addShellListener( yourListenerHere);
If you ever remove it from the shell's listeners list, be sure that Workbench, ActiveWorkbnchWindow and Shell are not null.