samedi 27 juin 2015

how to make a uitableview know about where to scroll for uncreated views yet

I have a UITableView which has up to 600 items in it. They are split between headers and items (like 30 headers of 15-20 items each). It is a catalog and has to mimick the printed catalog.

There is also a navigation pop-up view that shows only the headers that a user can overlay to the main table view. It is represented like this:

header
 \subheader
header2
\subheader
  \subheader

And our code for navigating is like this:

  func tapOnMenuHeaderView(recognizer: UITapGestureRecognizer)
  {
    self.hideModalNavigation()
    self.mainTV.reloadData()
    self.mainTV.scrollToRowAtIndexPath(NSIndexPath(forRow: self.menuHeaderPositions[recognizer.view!.tag]!, inSection: 0), atScrollPosition: UITableViewScrollPosition.Top, animated: true)
  }

However, it doesn't go to the right place many times. It seems to always be short and gets less accurate the further down you go. Is this a limitation to scrollRowAtIndexPath and is there a way I could force a full reload or something? The only way I could get this to work was to remove using a tableview and do everything as UIViews and just increment it in a scroll view. How would I make it so that our overlay navigation scrolls to the correct place?

Add Selfie Stick Support To iOS App

I am looking to add support for a "Selfie Stick Remote" to my upcoming iOS app. This question was already asked in the form of How to detect click event of connected Bluetooth peripheral device (Selfie stick)? but for Android, not iOS.

Specifically I am looking for it to work with the bluetooth devices (like this one http://ift.tt/1NnSiqf).

randomly change image of buttons and decelerate changing

i have 2 buttons.

they are called _rightButtonPressed and _leftButtonPressed. They have an background image named "blackBackground". When they are clicked, the background image is changed to "whiteBackground".

Ok. Now i want to make a third button, that changes the background image at first _rightButtonPressed to "white", then "black", then _leftButtonPressed to "white", then "black" and so on. This change have to decelerate to the end. At least, it should be randomly stops at a button with "white" background image and click the button. I hope its comprehensible.

I have no idea, how i can do this...

How to set the title text color of UIButton?

I tried changing the colors of the text for a button, but it's still staying white.

isbeauty = UIButton()
isbeauty.setTitle("Buy", forState: UIControlState.Normal)
isbeauty.titleLabel?.textColor = UIColorFromRGB("F21B3F")
isbeauty.titleLabel!.font = UIFont(name: "AppleSDGothicNeo-Thin" , size: 25)
isbeauty.backgroundColor = UIColor.clearColor()
isbeauty.layer.cornerRadius = 5
isbeauty.layer.borderWidth = 1
isbeauty.layer.borderColor = UIColorFromRGB("F21B3F").CGColor
isbeauty.frame = CGRectMake(300, 134, 55, 26)
isbeauty.addTarget(self,action: "first:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(isbeauty)

I also tried changing it the red, black, blue, but nothing is happening.

Days countdown iOS swift

My app requires that I start countdown of days from first launch. If someone launch my app for the first time I want to count day 1 after 12 midnight (using the device clock of course) and then day2 ... and perform an action after the 21st day. It shouldn't matter if the person close the app or switch off phone. When the app come back up, it should automatically detect how many days have passed.

Does anyone have an idea how to realise that ? . I am thinking of NStimer but kind of confuse.

MagicalRecord findByAttribute returning inverse relationship documents issue

I'm having an issue figuring out how to model/fetch items with Core Data and MagicalRecord. I have two entities, User and Message, which both have inverse relationships to each other:

User Entity

Relationship    Destination    Inverse    Type
-------------------------------------------------
messages        Message        user       To Many

Message Entity

Relationship    Destination    Inverse    Type
-------------------------------------------------
user            User           messages   To One

Issue

When fetching messages by a given user, MagicalRecord is returning 2x the number of records since it's matching attributes at the user and user.messages.user keyPaths:

- (NSArray *)fetchMessagesByUser:(NSString *)identifier {

    // returning 2x the records it should
    return [Message MR_findByAttribute:@"user.identifier" withValue:identifier];
}

Should I change the way I'm using MagicalRecord or is there a fundamental issue with my Core Data model?

When programatically creating a ViewController, how can I set its view to be of type SKVIew?

I am developing a game in iOS on XCode. I have several SKScenes each associated with a UIViewController class. So in each of the view controller's viewDidLoad, I create

SKView *skView = (SKView *)self.view
SKScene * scene = [whateverSKScene sceneWithSize:skView.bounds.size]
[skView present scene]

I want to avoid the storyboard. However, when I presentViewController from the first view controller to the next, the app crashes at the line "[skView present scene]" because it thinks the new view controller's view is still UIView ('-[UIView presentScene:]: unrecognized selector sent to instance).

How can I fix this? Specifically, when creating the 2nd view controller (programatically), how can I change its view to be of type SKview not UIview? (I should note I want the scenes to be 1:1 with view controllers because almost all of them are popups like a pause-menu pop up over game play or settings pop up etc)

libssh2 iOS Error 31

I have tried several projects based on libssh2 for iOS and I consistently get error -31 when trying to upload files. The file is created on the server, but no data is uploaded. I suspect that it maybe that something is unsupported on the server as -31 is defined as LIBSSH2_ERROR_SFTP_PROTOCOL. I only have access to the server via sftp and I cannot get in touch with the admins. I can do sftp from the command line on my mac. My code is based on NMSSH. However, I have tried the demo app on DLSFTPClient with the same result.

Anyone else have a similar problem. If so, how did you correct it?

Add and save item to favorites

I have a tableview with many words and I want to add the favorites feature so each detail view can have a button to save as a Favorite. This is my code, but doesn't work, after pressing the button I get this error (property lists cannot contain objects of type 'CFType'), but if I use slovoItem.slovo or slovoItem.definice, value is saved correctly. slovoItem has values slovoItem.slovo and slovoItem.definice and I need to save completely slovoItem.

Code in my DetailViewController:

- (IBAction) addToFavorites:(id)sender
{
    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];


    NSMutableArray *tempArray = [[prefs objectForKey:@"favorite"] mutableCopy];
    favorite = tempArray;

    [favorite addObject:self.slovoItem];

    [prefs setObject:favorite forKey:@"favorite"];

    for (id obj in favorite)
    {
        NSLog(@"%@", obj);
    }
}

iOS Design Pattern Implementation

I'm struggling with design patterns and would like to follow best practices while rewriting my current app from Objective-C to Swift.

I have a game where a player gets extra scores/or special prizes for, let's say, solving a certain amount of levels. There are several milestones to be reached (such as 10 levels completed/50 levels completed). I have different game modes, so I have several subclasses of a Gameplay class. After each player's turn -checkSolution is being invoked to check whether the player solved the level. In case of success I increment the player's games score and send him to a new level . And here I also call -checkForMilestone of ScoreManager class to check whether any of the milestones has been reached.

I'm not sure whether it is ok to call -checkForMilestone inside -checkSolution. Or it might be better to create a callback using blocks or use KVO to observe (from ScoreManager class) whether the player's score was changed and then react appropriately.

***RESOLVED: searchDisplayController not updating UITableVIew

I have a UITableView with a Searchbar & Search Display Controller. My code appears to be correct but when I type in the searchbar, I get no results. The UITableView remains the same.

My segue is correct as it is still passing data correctly as well to the next VC just fine.

A push in the right direction would be appreciated.

**Note: I realize that searchDisplayController is deprecated starting with iOS8 but I want to figure this out for the sake of knowing.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.searchDisplayController.searchResultsTableView) {
    return [searchResults count];

} else {
    return [bands count];

}
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"BandCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}

if (tableView == self.searchDisplayController.searchResultsTableView) {
    cell.textLabel.text = [searchResults objectAtIndex:indexPath.row];
} else {
    cell.textLabel.text = [bands objectAtIndex:indexPath.row];
}

return cell;
}

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope {
NSPredicate *resultPredicate = [NSPredicate
                                predicateWithFormat:@"SELF contains[cd] %@",
                                searchText];

searchResults = [bands filteredArrayUsingPredicate:resultPredicate];
}

-(BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchString:(NSString *)searchString {
[self filterContentForSearchText:searchString
                           scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
                                  objectAtIndex:[self.searchDisplayController.searchBar
                                                 selectedScopeButtonIndex]]];

return YES;
}

EDIT

connections

I noticed that searchBar wasnt connected. When I connected this, I noticed that the searchbar would dissapear whenever I would tap inside it. It looks like the searchbar is dissapearing behind the navigation bar. Thats another issue for later.

I am still unable to get the table to update correctly.

Source: Source

EDIT

On a side note, I figured out why my searchbar was dissapearing. I had my tab bar embedded in a navigation controller when I should have had my navigation bar embedded in the tab bar.

So: Tab bar --> Navigation controller

Adding the following code stopped my searchbar from moving up and overlapping the status bar

self.definesPresentationContext = YES;

EDIT

Not sure why but I noticed that my searchbar / search controller was not wired correctly. I removed it and added it back and everything wired up correctly. Specifically:

missing connection

searchDisplayController was not wired up to Band list.

İOS how to make LINE to share image view [on hold]

I would like to share your photos via the application . How basıca of a button and the image line applications.please help me

UIAlertView in superclass and subclass

I have a superclass where I sometimes show an UIAlertView and handles the delegation (clickedButtonAtIndex). When I then have a subclass that also handles the "clickedButtonAtIndex" only the subclass delegation is called.

In both cases the UIAlertView is show like this:

[[[UIAlertView alloc] initWithTitle:@"" message:@"message" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"Open", nil]show];

Am I doing something wrong or is it bad design to have the same delegation in both the superclass and subclass. I thought the "delegate:self" separated them.

Tableview word wrap works in Simulator, but not on device

The following code wraps to multiple lines, as expected, on the 8.3 Simulator; but truncates the line when running on 8.3 iPhone 6. ????

Here is the code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{


    static NSString *simpleTableIdentifier = @"Active Playlist";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }

     cell.textLabel.numberOfLines = 0;
     cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;

    cell.textLabel.text = [playList objectAtIndex:indexPath.row];
    return cell;
}

WatchKit get data from closed App in iPhone

There are some application (example Runtastic) where is possible from the Watch to activate some function of the companion App even if the App is not running in the iPhone (never opened or closed). How is possible to make the same with my Apps? Thanks

Using MPMediaItem with simpleaudioengine

I've been making a project in cocos-2dx, but needed to create a .mm to select music from the iOS library to play in the background. I got it working by playing the music in the .mm file, but for various reasons, it needs to play in cocos-2dx using SimpleAudioEngine. I've tried converting the url's absoluteString to an NSString to an id to a const char* to move it back to the cocos-2dx files, but it still didn't run.

This is what it gave me for the absoluteString(ipod-library://item/item.m4a?id=456458322781804615)

.cc-

-(void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)collection{
if(collection){
    MPMusicPlayerController* appMusicPlayer = [MPMusicPlayerController applicationMusicPlayer];
    [appMusicPlayer setQueueWithItemCollection:collection];
    [appMusicPlayer play];
    MPMusicPlayerController *iPodMusicPlayerController = [MPMusicPlayerController iPodMusicPlayer];
    MPMediaItem *nowPlayingItem = [iPodMusicPlayerController nowPlayingItem];

    NSURL *url = [nowPlayingItem valueForProperty:MPMediaItemPropertyAssetURL];
    NSString *filePath= [url absoluteString];
    NSString *filePath2 = [url path];
    _songUrl = filePath;
 }
 -(id)returnsongUrl{
     return _songUrl;
 }

Second .mm

 const char* MediaPicker::songUrl(){
     id na1 = [[MediaPickerWrapper sharedIntance] returnsongUrl];
    const char *cString =  [na1 cStringUsingEncoding:NSASCIIStringEncoding];
    return  cString;
 }

Cocos-2dx file

  CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(media->songUrl());
  CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(media->songUrl(),false);

How to convert UPC-A to UPC-E?

We would like to convert the 12 digit UPC-A to 8 digit UPC-E. Can you tell me which is the best way to do this without having to use my own code to convert?

I got many formula for convert the 8 digit UCC-E to 12 digit UPC-A but not reverse.

IOS: keyword search in a list of passages only returns the last match, instead of all matches

i have one passage list and from that i want to find out keyword search from user, passage ID getting over ride in array and because of that only last passage showing the result.

i want search keyword from all passage and show the result .

- (UIViewController*) showContentWithQuery:(NSDictionary*)query
{
ContentViewController * viewController = nil;
if (query)
{

    NSNumber * sectionId = query[@"sectionId"];
    NSNumber * passageId = query[@"passageId"];

    if (sectionId)
    {
        viewController = [[[ContentViewController alloc] initWithSectionId:sectionId] autorelease];

        if (passageId)
        {

            viewController.tempHighlightPassageArray = @[passageId];
        }
    }
}

return viewController;     }

Change the colour of tab bar icons and table background under the "More" tab?

I have around 7 tab bar items and hence have been given a 'more' tab bar item. All the other tab bar items are using the 'Original' mode instead of 'Template' but when i select the 'more' tab, the remaining icons are back to 'Template' until they're dragged to the tab bar after pressing edit. As well as this, my other views are tableviews with a coloured background, when i select the 'more' tab, the tableview presented has a white background. I managed to fix this for the tableview but the cells within are white, with the empty cells having the correct colour. Any idea how i'd fix these issues?

iOS and unicode characters: \u+2605 not solid star in UILabel

I'm trying to make a UILabel that says "★ FEATURED". However, when it renders it, the star isn't solid! Here's the code I'm using:

    _sponsoredLabel = [UILabel new];
    _sponsoredLabel.numberOfLines = 1;
    _sponsoredLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    _sponsoredLabel.textColor = [UIColor yellowColor];
    _sponsoredLabel.backgroundColor = [UIColor clearColor];
    _sponsoredLabel.textAlignment = NSTextAlignmentLeft;
    _sponsoredLabel.text = @"✭ FEATURED";
    _sponsoredLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:14.0f];
    _sponsoredLabel.hidden = YES;

In the text itself it looks solid, but here's what it looks like when it renders:

Any advice is much appreciated!

cocos2dx - Alignment with LabelBMFont

I am trying and struggling to align the BMFontLabel with a sprite side by side. I am using code below to show score of the game with a coin on the left, and score on the right side..

Sprite *coin=Sprite::create("coinimg.png");
Label *scoreLbl=Label::createWithBMFont(GameConfig::scoreBigFont, strScore);
scoreLbl->setScale(.5);

MenuItemSprite *itemCoin=MenuItemSprite::create(coin);
MenuItemLabel *itemScore=MenuItemLabel::create(scoreLbl);

Menu *mainMenu=Menu::create(itemCoin,itemScore, NULL);

mainMenu->alignItemsHorizontallyWithPadding(0.0);

mainMenu->setPosition(Vec2(winsize.width*.1,winsize.height*.8));

The problem is I am getting is different alignments with different values I input like in image.

Thanks for help.

Transparent navigation bar in Ionic

My Ionic application have a detail view with transparent header. Applying CSS class "bar-clear" to my element is doing the job just fine in desktop browsers and when running the app on Android (see result here).

But when running on iOS 8 the header is white and opaque (see here).
Any idea why?

Delay in Corelocation

I've created a helper class for my location needs so i don't violate the DRY principle. The class looks like this:
Location.h

@interface Location : NSObject <CLLocationManagerDelegate>{
CLLocationManager *manager;
CLGeocoder *geocoder;
CLPlacemark *placemark;
}

-(float)latitude;
-(float)longitude;
-(NSString *)postalcode;

Location.m

@implementation Location{
    float latitude;
    float longitude;
    NSString *postalcode;
}
-(id)init{
    NSLog(@"Hallo");
    [self setupLocationManager];
    return self;
}

-(float)latitude{

    return latitude;
}

-(float)longitude{

    return longitude;
}

-(NSString *)postalcode{

    return postalcode;
}

-(void)setupLocationManager{
    manager = [[CLLocationManager alloc] init];
    [manager requestWhenInUseAuthorization];
    manager.delegate = self;
    manager.desiredAccuracy = kCLLocationAccuracyBest;
    manager.distanceFilter = 100;
    [manager startUpdatingLocation];
    geocoder = [[CLGeocoder alloc] init];
 }

 #pragma mark - CLLocationManagerDelegate Methods

 - (void)locationManager:(CLLocationManager *)manager didFailWithError:          (NSError *)error
{

     NSLog(@"Error: %@", error);
     NSLog(@"Failed to get location! :(");

}

 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{

NSLog(@"Location: %@", newLocation);
CLLocation *currentLocation = newLocation;

if (currentLocation != nil) {

    latitude = currentLocation.coordinate.latitude;
    longitude = currentLocation.coordinate.longitude;


}

[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {

    if (error == nil && [placemarks count] > 0) {

        placemark = [placemarks lastObject];
        postalcode = [NSString stringWithFormat:@"%@",placemark.postalCode];
        /*
         self.address.text = [NSString stringWithFormat:@"%@ %@\n%@ %@\n%@\n%@",
         placemark.subThoroughfare, placemark.thoroughfare,
         placemark.postalCode, placemark.locality,
         placemark.administrativeArea,
         placemark.country];
         */
    } else {

        NSLog(@"%@", error.debugDescription);

    }

} ];

}


 @end

When i in my ViewController tries to create an instance of Location and set latitude and longitude labels, in the viewDidLoad method, the labels are sat to 0.00000. Apparently it takes around half a second for Location to get the coordinates. I've tried using

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
        [self setCoordinateLabels];
    });

But that just seems very hacky and can't possibly be the best practise? So is there any way i could do this a better way?

Failing to install SwiftyJSON

I want to include SwiftyJSON into my Xcode 6.3 project.

When I try to build it get about 40 compiler errors. Most of them are similar to 'AnyObject' is not convertible to 'String'. Did you mean as! to enforce downcast?

I followed the tutorial steps:

  1. Download SwiftyJSON (http://ift.tt/Z2t6lA)
  2. Drag and drop the SwiftyJSON.swift to my Xcode project.
  3. Accepting the "copy if necessary".
  4. Re-build project.

My best guess is that since I'm so new I'm missing some very "obvious" step.

Tutorial used: http://ift.tt/1tkN0Ql

Get the end of a string in a uitextview

I want to create a message box just like Telegram and others chats, that have a time in the down side of the box.

But if the text ends in the end of the line, the time label should be in the next line, otherwise, should stay in the same line.

So, I want something like this: new line for date when content is goes until the end

How to accomplish this in my xib, or programatically ?

Thanks in regards,

Make an object appear in frame N and not frame 0 in SpriteBuilder

In SpriteBuilder, every object starts at frame 0.

I have some objects that will fall from the sky, but I want their falling animation (physics with gravity) to begin later in the scene, and not at 0.

Can I either have the objects exist at a certain frame? (i.e. insert empty frames before the object's first keyframe), or can I have the objects queue the physics gravity after a certain frame?

tia

AVAssetExportSession export fails non-deterministically with error: "Operation Stopped, NSLocalizedFailureReason=The video could not be composed."

We add subtitles to a video recorded by the user, but the export by our AVAssetExportSession object fails non-deterministically: sometimes it works, and sometimes it doesn't. It's unclear even how to reproduce the error.

Error:

Error Domain=AVFoundationErrorDomain Code=-11841 "Operation Stopped" UserInfo=0x170676e80 {NSLocalizedDescription=Operation Stopped, NSLocalizedFailureReason=The video could not be composed.}

Code:

    let videoAsset = AVURLAsset(URL: fileUrl, options: nil)
    let mixComposition = AVMutableComposition()
    let videoTrack = mixComposition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID(kCMPersistentTrackID_Invalid))
    let audioTrack = mixComposition.addMutableTrackWithMediaType(AVMediaTypeAudio, preferredTrackID: CMPersistentTrackID(kCMPersistentTrackID_Invalid))

    let sourceVideoTrack = videoAsset.tracksWithMediaType(AVMediaTypeVideo)[0] as! AVAssetTrack
    let sourceAudioTrack = videoAsset.tracksWithMediaType(AVMediaTypeAudio)[0] as! AVAssetTrack
    videoTrack.insertTimeRange(CMTimeRangeMake(kCMTimeZero, videoAsset.duration), ofTrack: sourceVideoTrack, atTime: kCMTimeZero, error: nil)
    audioTrack.insertTimeRange(CMTimeRangeMake(kCMTimeZero, videoAsset.duration), ofTrack: sourceAudioTrack, atTime: kCMTimeZero, error: nil)

    // Create something mutable???
    // -- Create instruction
    let instruction = AVMutableVideoCompositionInstruction()
    instruction.timeRange = CMTimeRangeMake(kCMTimeZero, videoAsset.duration)
    let videoLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: sourceVideoTrack)
    instruction.layerInstructions = [videoLayerInstruction]

    let mutableComposition = AVMutableVideoComposition()
    //mutableComposition.renderSize = videoTrack.naturalSize
    mutableComposition.renderSize = CGSize(width: 320, height: 320)
    mutableComposition.frameDuration = CMTimeMake(1, 60)
    mutableComposition.instructions = [instruction]

    // Animate
    mutableComposition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videoLayer, inLayer: parentLayer)

    // -- Get path
    let fileName = "/editedVideo-\(arc4random() % 10000).mp4"
    let allPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
    let docsPath = allPaths[0] as! NSString
    let exportPath = docsPath.stringByAppendingFormat(fileName)
    let exportUrl = NSURL.fileURLWithPath(exportPath as String)!

    println("Num of tracks \(mixComposition.tracks.count)")

    // -- Remove old video?
    if NSFileManager.defaultManager().fileExistsAtPath(exportPath as String) {
        println("Deleting existing file\n")
        NSFileManager.defaultManager().removeItemAtPath(exportPath as String, error: nil)
    }

    // -- Create exporter
    let exporter = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetHighestQuality)
    exporter.videoComposition = mutableComposition
    exporter.outputFileType = AVFileTypeMPEG4
    exporter.outputURL = exportUrl
    exporter.shouldOptimizeForNetworkUse = true

    // -- Export video
    exporter.exportAsynchronouslyWithCompletionHandler({
        self.exportDidFinish(exporter)
    })

Questions:

1) What's causing the problem, and what's the solution?

2) Suggestions on how to reproduce the error consistently, which hopefully helps debug the problem?

Libgdx/RoboVM write UIImage/bytes to file

I need to write an image from the IOS gallery to a file to be used in my app. I dont speak Obj-C, neither can I translate Obj-C to RoboVM´s Java library. What I think would be the easiest for me to understand is to use InputStream to write the image to a file. So this is what I got going so far:

@Override
public void iosPickImage(final InputStream stream) {
    // Gallery
    MyDelegatePicker delegate = new MyDelegatePicker() {
        @Override
        public void didFinishPickingMedia(UIImagePickerController picker, UIImagePickerControllerEditingInfo info) {
            UIImage selectedImage = info.getOriginalImage();
            File file = new File(Gdx.files.getExternalStoragePath() + "selectedPhoto1.bin");
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                FileInputStream fileStream = new FileInputStream(file);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }


            try {
                stream.read(selectedImage.toPNGData().getBytes());

            } catch (IOException e) {
                e.printStackTrace();
            }
            picker.dismissViewController(true, null);
        }

        @Override
        public void didCancel(UIImagePickerController picker) {

        }
    };
   UIViewController controller = ((IOSApplication) Gdx.app).getUIViewController();
    MyImagePickerController imagePicker = new MyImagePickerController();
    controller.addChildViewController(imagePicker);
    controller.getView().addSubview(imagePicker.getView());
    imagePicker.getView().setBounds(controller.getView().getBounds());
    imagePicker.setSourceType(UIImagePickerControllerSourceType.PhotoLibrary);
    imagePicker.setDelegate(delegate);
    imagePicker.addStrongRef((ObjCObject) delegate);


    //Gdx.app.exit();

}

And then by passing that method through my interface :

public void iosGallery(final InputStream stream) {
    gallery.iosPickImage(stream);


}

This as you can see is far from finished. I would like to use Callback and AsyncExecutor to finish this off, but the RoboVM library dont support those classes. So anyone got an idea on how to finish this method or rewrite it to work?

Unexpectedly found nil while unwrapping an Optional value (UIButton)

I'm trying to create a button programmatically and add it to a UIScrollView in Swift. The code below is what I am using and throws the infamous "unwrapping optional error" where I add the button as a subview. Why is it doing this? I have checked and compared my code to others' and all seems to look fine.

let button = UIButton.buttonWithType(UIButtonType.System) as UIButton
button.frame = CGRectMake(8, 2, 200, 300)
button.backgroundColor = UIColor.grayColor()
button.setTitle(productName, forState: UIControlState.Normal)
self.productButtonView.addSubview(button) //This line throws error

Thank you in advance.

UIActionSheet crashes on iPad swift

I have the following button action in a toolbar:

  @IBAction func share(sender: AnyObject) {
        let modifiedURL1 = "http://ift.tt/1GDOWdL"
        let modifiedURL = modifiedURL1.stringByReplacingOccurrencesOfString(" ", withString: "%20", options: NSStringCompareOptions.LiteralSearch, range: nil)

        let alert = UIAlertController(title: "Share", message: "Share your findings", preferredStyle: UIAlertControllerStyle.ActionSheet)
        let twBtn = UIAlertAction(title: "Twitter", style: UIAlertActionStyle.Default) { (alert) -> Void in
            if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter){
                var twitterSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
                twitterSheet.setInitialText("Look what I found on Declassified and Ratified: \(modifiedURL)")
                self.presentViewController(twitterSheet, animated: true, completion: nil)
            } else {
                var alert = UIAlertController(title: "Accounts", message: "Please login to a Twitter account to share.", preferredStyle: UIAlertControllerStyle.Alert)
                alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
                self.presentViewController(alert, animated: true, completion: nil)
            }
        }

        let fbBtn = UIAlertAction(title: "Facebook", style: UIAlertActionStyle.Default) { (alert) -> Void in
            if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook){
                var facebookSheet:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
                facebookSheet.setInitialText("Look what I found on Declassified and Ratified: \(modifiedURL)")
                self.presentViewController(facebookSheet, animated: true, completion: nil)
            } else {
                var alert = UIAlertController(title: "Accounts", message: "Please login to a Facebook account to share.", preferredStyle: UIAlertControllerStyle.Alert)
                alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
                self.presentViewController(alert, animated: true, completion: nil)
            }
        }
        let safariBtn = UIAlertAction(title: "Open in Safari", style: UIAlertActionStyle.Default) { (alert) -> Void in
            let URL = NSURL(string: modifiedURL)
            UIApplication.sharedApplication().openURL(URL!)
        }
        let cancelButton = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) { (alert) -> Void in
            println("Cancel Pressed")
        }

        let textBtn = UIAlertAction(title: "Message", style: UIAlertActionStyle.Default) { (alert) -> Void in
            if (MFMessageComposeViewController.canSendText()) {
                let controller = MFMessageComposeViewController()
                controller.body = "Look what I found on Declassified and Ratified: \(modifiedURL)"
                controller.messageComposeDelegate = self
                self.presentViewController(controller, animated: true, completion: nil)
            }
        }


        alert.addAction(twBtn)
        alert.addAction(fbBtn)
        alert.addAction(safariBtn)
        alert.addAction(textBtn)
        alert.addAction(cancelButton)
        self.presentViewController(alert, animated: true, completion: nil)
    }

However, this code crashes when called on an iPad with a sigbart crash (that is all I can see in the console). I see this is a common problem but the other solutions have not worked for me. I even set the version to the latest iOS and that didn't fix it. Can someone explain?

Swift - Starting a game with out pressing the screen

I am making a game that, when the game loads in, doesn't require the user to tap the screen to start, but starts straight away.

My code with the "tap to start":

import Foundation
import SpriteKit

class GameScene: SKScene, SKPhysicsContactDelegate {

    var isStarted = false

    override func didMoveToView(view: SKView) {
        //backgroundColor = UIColor.greenColor()

        addTapToStartLabel()

    func addTapToStartLabel() {
        let tapToStartLabel = SKLabelNode(text: "Tap to start!")
        tapToStartLabel.name = "tapToStartLabel"
        tapToStartLabel.position.x = view!.center.x
        tapToStartLabel.position.y = view!.center.y + 40
        tapToStartLabel.fontColor = UIColor.whiteColor()
        tapToStartLabel.fontName = "Helvetica"
        tapToStartLabel.fontSize = 22.0
        addChild(tapToStartLabel)
    }

    func start() {
        isStarted = true

        let tapToStartLabel = childNodeWithName("tapToStartLabel")
        tapToStartLabel?.removeFromParent()

        square1.stop()
        movingGround.start()
        wallGen.startGenWallsEvery(1)
        diamondGen.startGenDiamondsEvery(1)
    }

    override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {

        if isGameOver {
            restart()
        } else if !isStarted {
            start()
        } else {
            square1.flip()
        }
    }

I have tried a couple of things and I can't seem to figure it out.

How can I recieve messages in my app IOS

I am creating an app and I want to receive messages in my own app. How can I do it? I have searched around a bit and I was unable to find any resource on the web. I hope I can get solution from this community.

UISegmentedControl unselect segment by pressing it again

How can one unselect a given segment in a UISegmented control, by pressing the same segment again?

E.g. Press segment 0, it becomes selected and remains highlighted. Press segment 0 again and it becomes unselected and unhighlighted.

The control only fires UIControlEventValueChanged events. Other events don't seem to work with it.

There is a property 'momentary' which when set to YES almost allows the above behavior, excepting that highlighting is only momentary. When momentary=YES pressing the same segment twice results in two UIControlEventValueChanged events, but when momentary=NO only the first press of a given segment results in a UIControlEventValueChanged event being fired. I.e. subsequent presses on the same segment will not fire the UIControlEventValueChanged event.

ReactiveCocoa takeUntil 2 possible signals ?

So I am trying to get the timer to stop upon a completed signal from my updated table and it appears not to be working.

I have gotten the signal to stop when the button is pressed the second time that works well.

However I tried to created a second signal to allow the scheduler to stop, and it does not appear to stop in both options 1 and 2 in the update table view.

Am I writing this correctly, is there a concept I am not understanding?

-(RACSignal*) startTimer {
    return [[[[RACSignal interval:1.0
            onScheduler:[RACScheduler mainThreadScheduler]]
             startWith:[NSDate date]]
             takeUntil:[self.start rac_signalForControlEvents:UIControlEventTouchUpInside]]
             takeUntil:self.completeSignal];
}

-(void) viewDidLoad {


    self.tableView.delegate = self;
    self.tableView.dataSource = self;

    RACSignal* pressedStart = [self.start rac_signalForControlEvents:UIControlEventTouchUpInside];

    @weakify(self);
    RACSignal* textChangeSignal = [[pressedStart map:^id(id value) {
        @strongify(self);
        return [self.start.titleLabel.text isEqualToString:@"Start"] ? @"Stop" : @"Start";
    }] startWith:@"Start"];

    [textChangeSignal subscribeNext:^(NSString* text) {
        @strongify(self);
        [self.start setTitle:text forState:UIControlStateNormal];
    }];


    static NSInteger t = 0;
    [[pressedStart flattenMap:^RACStream *(id value) {
        return [self startTimer];
    }] subscribeNext:^(id x) {
            t = t + 1;
            NSLog(@"%ld",t);
        [self updateTable];
    }];





}

-(void) updateTable {

    // option 1 Doesn't work
        [self.start    sendActionsForControlEvents:UIControlEventTouchUpInside];
// Option 2 doesn't work 
self.completeSignal = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
        [subscriber sendCompleted];
        return nil;
    }];
    if ([self.excercises count] > 0 || self.excercises !=nil) {

    }else {
        // stop everything
        // using button signal
    }




}

OpenEars in Swift?

I just created an empty swift project and imported the OpenEars framework.

I followed the method mentioned here for bridging: How to call Objective C code from Swift

In the bridge file it says all header (.h) files are missing. Where did I go wrong?

Here's my project: http://ift.tt/1CAlogg

UI_APPEARANCE_SELECTOR required or not?

For below code to work we should generally define a aFont property in TestView.h with UI_APPEARANCE_SELECTOR. But, it seems it is not required. I tried with and without the UI_APPEARANCE_SELECTOR, results are the same.

I don't know if this is right or wrong?

[[TestView appearance] setAFont:[UIFont boldSystemFontOfSize:20.0f]];

#import "ViewController.h"
#import "TestView.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
     [[TestView appearance] setAFont:[UIFont boldSystemFontOfSize:20.0f]];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

TestView.h

#import <UIKit/UIKit.h>

@interface TestView : UIView
@property (strong,nonatomic) UIFont *aFont  ;
@end

TestView.m

#import "TestView.h"

@implementation TestView
{
    UILabel *aTestLabel;
}
@synthesize aFont=_aFont;

- (void)drawRect:(CGRect)rect {
    // Drawing code
    NSLog(@"A Font= %@ ",_aFont);
}


-(id) init{
    self=[super init];
    if(self){
        [self addLabel];
    }
    return self;
}

-(id) initWithCoder:(NSCoder *)aDecoder{
    self=[super initWithCoder:aDecoder];
    if(self){
        [self addLabel];
    }
    return self;
}

-(void)addLabel{
    aTestLabel=[[UILabel alloc] initWithFrame:self.bounds];
    aTestLabel.text=@"Hello";
    _aFont=[UIFont systemFontOfSize:10.0];

    [self addSubview:aTestLabel];
}

-(void)setAFont:(UIFont *)aFont{
    _aFont=aFont;
    aTestLabel.font=_aFont;    
}

How to process words one by one?

how can I pick words from a paragraph and process one by one. I want to switch places of letters except first and last letter. How can I? Thanks

Sharing of Image and text with Deep linking on facebook in ios8

Have anyone worked on deep linking in ios 8? I tried to follow facebook.developer tutorial to implement deep linking but is not so much clear. please suggest me any blog and tutorial or sample code. Any help will be appriceate. Thanks in advance!

How to cast to generic type in Swift

I am about to learn Swift. I want to write a class, that handles Cora Data tasks for me. In this case, it should be possible to pass an entity name and and array of tuples to a function, which then interprets the tuples as key value pairs for NSPredicates to retrieve ManagedObjects matching them. Because of NSPredicate needing values with specific types, I tried to pass the types of the values, too. But I can't get around that "'t' is not a type" compile error (last line of code). How can I cast the value to an passed type? Or would you create the NSPredicate in a totally different way?

class func getManagedObjectsWithEntityName<T>(entityName: String, keysAndValues: [(key: String, value: AnyObject, type: T.Type)]) -> [NSManagedObject] {

    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
    let managedContext = appDelegate.managedObjectContext

    let fetchRequest = NSFetchRequest(entityName: entityName)
    var predicates: [NSPredicate] = []

    for tuple in keysAndValues {
        let t = tuple.type
        predicates.append( NSPredicate(format: tuple.key + " = %@", tuple.value as t)!)
    }

    ...
}

PickerView bug with selectedRowInComponent()

I'm having a weird bug with PickerView - I have three components in a PickerView, where the first component selects the main category, the second component selects the sub category, etc.

So, in my pickerView(..., numberOfRowsInComponent) function, I detect which row is selected in the first component using selectedRowInComponent(0), and then feed in the correct count of rows for the second component.

Some strange bug is occuring though... I've coded it so that if the first row (row 0) is selected on component 0, then the second and third components both have only 1 row each. But if component 0's second row is selected (row 1), there should be 5 rows in the second and third component.

In the viewOnLoad function of this corresponding view, I have it so I automatically select the second row of the pickerView's first component (using picker.selectRow()). This should mean that my second component will automatically appear with five rows. But instead, when I run my app, the second row is selected in component 0, but the second and third components only have 1 row each. It seems like it's bugging out and thinking that the first row is selected. Weird thing is that if I change the first component's row to something else and then back to row 1, it suddenly has the correct number of rows in components 1 and 2.

Hopefully this makes sense, hard to describe. Happy to post pictures if need be. Anyone know what I might be doing wrong?? Thanks!

Cannot find libcocos2d ios.a library in Xcode

I have downloaded the cocos2d-x 3.6 yesterday. And I do follow the steps in this tutorial page: http://ift.tt/1v5QE5a.

I build and run my new project in Xcode successfully. But I notice that there is no "libcocos2d ios.a" library existed when I click my project setting. I try to search the answer from internet, but it seems doesn't have correct one.

One more thing, if I clean the whole project and rebuild it. It will compiling 621 source files to come out(I think it's cocos2d source files), it takes too long time! I don't want to wait so long every time when I clean and rebuild project. Is there a way to make it don't rebuild cocos2d-x source files every time?

the screenshot: enter image description here

--------------- environment ---------------
Xcode 6.3.2
Mac OS 10.10.3
cocos2d-x 3.6


I find a possible solution here: http://ift.tt/1HnZmVF

After trying, the Xcode project failed to link those two generated "libcocos2d ios.a" files(one for arm7, the other for arm64). I still don't know why this happened. I am building project for iPhone 6(arm64), why it says require i386 architecture.

here is the error (build for iPhone 6 simulator): enter image description here

Storing images from [UIImage] array to Parse

I have an UIImage array, images, which is declared as

var images = [UIImage]()

I currently have pictures stored in there, and when I output it using the println() function, I get

[<UIImage: 0x195dc810>, <UIImage: 0x195da3e0>, <UIImage: 0x1950ab50>]

I was wondering how I could upload these images to Parse as one row.

Here is my full code of what I have now(not working):

@IBAction func saveToParse(sender: AnyObject) {

    for var i = 0; i < images.count; i++
    {
        var objectForSave:PFObject = PFObject(className: "NewLog")
        //error on this line below:  [(UIImage)] does not have a member variable named 'objectAtIndex'
        let imageData:NSData = NSData(data: UIImagePNGRepresentation(images.objectAtIndex(i) as! UIImage))

        var imageFile:PFFile = PFFile(data: imageData)
        imageFile.saveInBackgroundWithBlock({ (success:Bool, error:NSError?) -> Void in
            if success{
                objectForSave.setObject(imageFile, forKey: "Image")

                objectForSave.saveInBackgroundWithBlock({ (success:Bool, error:NSError?) -> Void in
                    if success{
                        //do smth
                    }else{
                        println(error)
                    }
                })

            }else{
                println(error)
            }

            }, progressBlock: { (progress:Int32) -> Void in

        })


    }     
    } 

Thank you.

Assigning a delegate to a background job for dropbox upload

I am using Dropbox's SDK API V1 to upload files from my iOS app. The files aren't loading in real time, but rather I push them into a queue, and they get uploaded in the background.

I can't figure out for the life of me how to take DB RestClient delegate and make it respond to a completion/failure event that happens in the background. Is that even possible?

It seems (and I am new here), that delegates are meant to respond to live events on screen. Is that even an option to assign them to anything other than a UI element/view?

UITableView cell gives different widths. How to solve this?

I have the function heightForRowAtIndexPath to calculate the height of the cell having two textfields of dynamic text

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
    let cell = tableView.dequeueReusableCellWithIdentifier(self.kkCellIdentifier) as! NibTableViewCell
    cell.updateConstraints()
    let width = cell.contentView.frame.width
    //use width to calculate the height
}

I am running this on iPhone 6 simulator.

In portrait:

I get cell width sometimes as 375 (wrong- it is actually tableView's frame width) and sometimes as 320 (Correct one)

In Landscape:

I get cell width sometimes as 320 and sometimes as 659 (Correct one)

Why is it like this? Is this a bug?

How to solve this?

How to retrieve part of JSON file?

it's possible by using IF to retrieve some parts of JSON not all of it in Objective-C. like i want to retrieve just those data when Gender equals Male

[
  {
    "name":"A",
    "gender":"Male",
    "age":20
  },
  {
    "name":"B",
    "gender":"Female",
    "age":12
  },
 {
    "name":"C",
    "gender":"Male",
    "age":20
  }
]

any idea would be appreciated.

How to change duration of ImageView in Objective-C

I am creating a simple camera app for a photobooth. This code below is a sample of the whole project, I am using AVFoundation because I needed my own custom requirements.

When the user presses a button, it takes a photo and instantly shows the preview in the imageView. This is my first major coding project and am new to Objective-C. Is there a way to add a timer or duration to the imageView so that it then removes the image from it, or a way to cycle to a second black image after some time, ready for the next user to take their photo?

Many thanks for any help suggested!

- (IBAction)takephoto:(id)sender {

    AVCaptureConnection *videoConnection = nil;

    for (AVCaptureConnection *connection in StillImageOutput.connections) {
        for (AVCaptureInputPort *port in [connection inputPorts ]) {
            if ([[port mediaType] isEqual:AVMediaTypeVideo]) {
                videoConnection = connection;
                break;
            }
        }
    }
    [StillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
        if (imageDataSampleBuffer != NULL) {
            NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
            UIImage *image = [UIImage imageWithData:imageData];
            imageView.image = image;
        }
    }];
}

Swift code completion not working with Cocoapods

I have an demo app that uses various internal development pods written in swift. All of the swift code in the development pods has trouble code completing. For example, when holding command and clicking on import UIKit, Xcode complains of a Symbol Not Found when tapping on UIKit. There's no compiler errors, everything builds and runs just fine.

If I have swift code outside of the pod in the demo project itself, that code completes just fine, but when I put it in a pod and run pod install, it either stops code completing immediately, or works for a few hours / pod update commands, and then randomly stops working. I have other development pods in my project, and those written in Objective-C have no trouble code completing ever.

I have tried multiple different solutions, namely the solutions listed here: Xcode 6 Swift code completion not working. None of these worked for me.

I tried various combinations of these solutions from the post above multiple times:

  • deleting Xcode's derived data
  • selecting a different simulator device to force a re-index
  • deleting Cocoapod's cache (both in the library and the Podfile.lock and Pods directory)
  • running pod deintegrate and then pod install
  • restarting Xcode and computer
  • using different versions of Xcode (6.3.2, 6.4, 7.0-beta2)
  • on a completely different machine

None of which seem to work.

Any help would be greatly appreciated!

How to add collection view programmatically in iOS

i want to add UICollectionview when i click on a button.. The default screen has table view already. I am adding grid option button and want to arrange data in grid by collection view when user click on grid button

How can I program hundred eighty barcode scanner?

I am in a need to develop an app for iOS. I want to connect that app with the hundred eighty barcode scanner. My client wants to use only this scanner as he feels it is cheaper than other scanners. I don't know how to program it. Does socketmobile SDKs help to program this scanner? Or is there any other way to program the hundred eighty scanner? Please, someone help me out.

Sprite-Kit Swift: How can I drag a SpriteNode across the screen

I have a SpriteNode which is a ball. It drops down the screen and I want to drag and release so that it can move by itself towards the top of the screen where a laser will destroy it. The ball itself is affected by gravity. What code do I need to write in touches began so that I can specify that when I touch the ball the above description starts.

lundi 11 mai 2015

IResourceChangeListener rename and set EditorPart name dynamically

IResourceChangeListener listens to changes in project workspace for example if the editor part file name has changed.

I want to know how to access that particular EditorPart and change its title name accordingly (e.g. with .setPartName), or maybe the refresh the editor so that it shows the new name automatically.

Ideal would be if the IResourceChangeListener has a Rename event type but does not seem to be the case.

Eclipse Android Game - Crashes when I hit Play

I've been following some tutorials online to try to get a grasp of basic android development, and I seem to be stuck. There are no errors in my code, but a few warnings and whenever I press play from the main menu, it crashes. If anyone could help out that'd be greatly appreciated!!

This is my MainActivity.java

package com.example.shadowassassinstu3;

import com.example.shadowassassinstu3.Game;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;


public class MainActivity extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void play(View v)
    {
        Intent i=new Intent(this,Game.class);
        startActivity(i);
    }

    public void exit(View v)
    {
        System.exit(0);
    }
}

This is my Game.java

package com.example.shadowassassinstu3;

import com.example.shadowassassinstu3.gameloop;
import com.example.shadowassassinstu3.Game.GameView;
import com.example.shadowassassinstu3.Game.TeleListener;
import com.example.shadowassassinstu3.R;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.view.Display;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;
import android.view.WindowManager;

public class Game extends Activity {
    gameloop gameLoopThread;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //phone state
        TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        TelephonyMgr.listen(new TeleListener(),PhoneStateListener.LISTEN_CALL_STATE);
        //for no title
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(new GameView(this));     
    }

    public class GameView extends SurfaceView {
        Bitmap bmp,pause;
        Bitmap background;
        Bitmap run1;
        Bitmap run2;
        Bitmap run3;
        Bitmap exit;

        private SurfaceHolder holder;
        private int x = 0,y=0,z=0,delay=0,getx,gety;
        int show=0,sx,sy;
        int cspeed=0,kspeed=0,gameover=0;
        int score=0,health=100,reset=0;
        int pausecount=0,volume,power=0,powerrun=0,shieldrun=0;

        @SuppressWarnings("deprecation")
        @SuppressLint("NewApi")
        public GameView(Context context) 
          {
              super(context);

              gameLoopThread = new gameloop(this);
              holder = getHolder();

                 holder.addCallback(new SurfaceHolder.Callback() {
                @SuppressWarnings("deprecation")
                @Override
                public void surfaceDestroyed(SurfaceHolder holder) 
                {
                    gameLoopThread.setRunning(false);
                    gameLoopThread.getThreadGroup().interrupt();
                }

                @SuppressLint("WrongCall")
                @Override
                public void surfaceCreated(SurfaceHolder holder) 
                {
                      gameLoopThread.setRunning(true);
                      gameLoopThread.start();

                }
                @Override
                public void surfaceChanged(SurfaceHolder holder, int format,int width, int height) 
                        {

                        }
                });



                Display display = getWindowManager().getDefaultDisplay();

                sx = display.getWidth();
                sy = display.getHeight();;
                background = BitmapFactory.decodeResource(getResources(), R.drawable.back);
                run1=BitmapFactory.decodeResource(getResources(), R.drawable.run1);
                run2=BitmapFactory.decodeResource(getResources(), R.drawable.run2);
                run3=BitmapFactory.decodeResource(getResources(), R.drawable.run3);
                exit=BitmapFactory.decodeResource(getResources(), R.drawable.exit);
                pause=BitmapFactory.decodeResource(getResources(), R.drawable.pause);

                exit=Bitmap.createScaledBitmap(exit, 25,25, true);
                pause=Bitmap.createScaledBitmap(pause, 25,25, true);
                run1=Bitmap.createScaledBitmap(run1, sx/9,sy/7, true);
                run2=Bitmap.createScaledBitmap(run2, sx/9,sy/7, true);
                run3=Bitmap.createScaledBitmap(run3, sx/9,sy/7, true);
                background=Bitmap.createScaledBitmap(background, 2*sx,sy, true);

    }


     // on touch method

          @Override
            public boolean onTouchEvent(MotionEvent event) {

                if(event.getAction()==MotionEvent.ACTION_DOWN)
                {
                    show=1;

                    getx=(int) event.getX();
                    gety=(int) event.getY();

                // restart game
                if(getx>91&&gety<25)
                {
                    if(health<=0)
                    {
                        gameLoopThread.setPause(0);
                        health=100;
                        score=0;

                    }
                }
                //pause game
                if((getx>(sx-25)&&gety<25&&pausecount==0))
                {

                    gameLoopThread.setPause(1);
                    pausecount=1;
                }
                else if(getx>(sx-25)&&gety<25&&pausecount==1)
                {
                    gameLoopThread.setPause(0);
                    pausecount=0;
                }
            }

            return true;
        }


        @SuppressLint("WrongCall")
        @Override
        protected void onDraw(Canvas canvas) 
        {
            //background moving
            z=z-10;
            if(z==-sx)
            {
                z=0;
                canvas.drawBitmap(background, z, 0, null);

            }
            else
            {
                canvas.drawBitmap(background, z, 0, null);  
            }

            //running player 

         x+=5;
         if(x==20)
         {
             x=5;
         }

          if(show==0)
          {
              if(x%2==0)
              {
                  canvas.drawBitmap(run3, sx/16, 15*sy/18, null);

              }
              else 
              {
                  canvas.drawBitmap(run1, sx/16, 15*sy/18, null);

              }
          }

          canvas.drawBitmap(exit, 0, 0, null);
          canvas.drawBitmap(pause, (sx-25), 0, null);
        }
    }

    //phone state
    public class TeleListener extends PhoneStateListener 
    {
        public void onCallStateChanged(int state,String incomingNumber)
        {
            if(state==TelephonyManager.CALL_STATE_RINGING)
                {
                    System.exit(0);  
                }
        } 

    }
}

and this is my gameloop.java

package com.example.shadowassassinstu3;

import com.example.shadowassassinstu3.Game.GameView;
import android.annotation.SuppressLint;
import android.graphics.Canvas;

public class gameloop extends Thread {

    private GameView view;
    static final long FPS = 10;
    private boolean running = false;
       boolean isPaused;

    public gameloop(GameView view) {
          this.view = view;
    }

    public void setRunning(boolean run) {

          running = run;
    }

    public void setPause(int i)
    {
        synchronized (view.getHolder()) 
        {


            if(i==0)
            {
                isPaused=false;
            }
            if(i==1)
            {
                isPaused = true;
            }
         }
    }

    public void run() {
           long ticksPS = 100;
           long startTime = 0;
           long sleepTime;
              while (running) {
                  //pause and resume

                if (isPaused) 
                {
                      try 
                      {
                          this.sleep(50);
                      } 
                      catch (InterruptedException e) 
                      {
                        e.printStackTrace();
                      }
                }
                else
                {
                     Canvas c = null;
                     startTime = System.currentTimeMillis();
                     try {

                            c = view.getHolder().lockCanvas();

                            synchronized (view.getHolder()) 
                            {
                                view.onDraw(c);
                            }

                          } 
                     finally 
                     {
                         if (c != null) 
                            {
                                view.getHolder().unlockCanvasAndPost(c);
                            }
                     }
                   }
                     sleepTime = ticksPS-(System.currentTimeMillis() - startTime); 

                     try {

                            if (sleepTime > 0)
                               sleep(sleepTime);
                            else
                               sleep(10);
                        } 
                catch (Exception e) {}

              }

        }
}

A lot of the code I've gotten through watching tutorials and I really can't figure out what's wrong, if anyone could help I'd really appreciate it!

I think this is what you guys asked for:

05-11 10:23:51.966: D/AndroidRuntime(1894): Shutting down VM 05-11 10:23:51.966: D/AndroidRuntime(1894): --------- beginning of crash 05-11 10:23:51.966: E/AndroidRuntime(1894): FATAL EXCEPTION: main 05-11 10:23:51.966: E/AndroidRuntime(1894): Process: com.example.shadowassassinstu3, PID: 1894 05-11 10:23:51.966: E/AndroidRuntime(1894): java.lang.IllegalStateException: Could not execute method of the activity 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.view.View$1.onClick(View.java:4007) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.view.View.performClick(View.java:4756) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.view.View$PerformClick.run(View.java:19749) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.os.Handler.handleCallback(Handler.java:739) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.os.Handler.dispatchMessage(Handler.java:95) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.os.Looper.loop(Looper.java:135) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.app.ActivityThread.main(ActivityThread.java:5221) 05-11 10:23:51.966: E/AndroidRuntime(1894): at java.lang.reflect.Method.invoke(Native Method) 05-11 10:23:51.966: E/AndroidRuntime(1894): at java.lang.reflect.Method.invoke(Method.java:372) 05-11 10:23:51.966: E/AndroidRuntime(1894): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 05-11 10:23:51.966: E/AndroidRuntime(1894): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 05-11 10:23:51.966: E/AndroidRuntime(1894): Caused by: java.lang.reflect.InvocationTargetException 05-11 10:23:51.966: E/AndroidRuntime(1894): at java.lang.reflect.Method.invoke(Native Method) 05-11 10:23:51.966: E/AndroidRuntime(1894): at java.lang.reflect.Method.invoke(Method.java:372) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.view.View$1.onClick(View.java:4002) 05-11 10:23:51.966: E/AndroidRuntime(1894): ... 10 more 05-11 10:23:51.966: E/AndroidRuntime(1894): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.shadowassassinstu3/com.example.shadowassassinstu3.Game}; have you declared this activity in your AndroidManifest.xml? 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1761) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1485) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.app.Activity.startActivityForResult(Activity.java:3736) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.app.Activity.startActivityForResult(Activity.java:3697) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.app.Activity.startActivity(Activity.java:4007) 05-11 10:23:51.966: E/AndroidRuntime(1894): at android.app.Activity.startActivity(Activity.java:3975) 05-11 10:23:51.966: E/AndroidRuntime(1894): at com.example.shadowassassinstu3.MainActivity.play(MainActivity.java:25) 05-11 10:23:51.966: E/AndroidRuntime(1894): ... 13 more 05-11 10:23:55.283: I/Process(1894): Sending signal. PID: 1894 SIG: 9

Is it ok to declare an object to be equal to itself in Javascript for the sake of refactoring a large project

I'm working on a very large javascript web app that doesn't really have a method to it. There seems to be an attempt to declare everything as part of a master object called "app". The original program existed as a single app.js file over 300k lines of code where the following was declared:

var app = {};

Beyond that everything in the app is written as such.

app.somefunction = function(args, callback) { 
    some code
};

This apparently allowed for the author to handily use Eclipse IDE "outline", which I confess I have started to enjoy having, never previously having been an IDE user I'm becoming a convert to the niceties they provide.

My question is, as I work on a phased refactor of this huge codebase, potentially trying to merge it into some sort of more established framework perhaps using something like require.js, is it OK to split the "app.js" up into smaller files and for the sake of sanity to be able to use the IDE outline declare app to be equal to itself in each one.

app = app;

I've tested this, it works from what I can tell and it allows the IDE to add all the subsequent functions to the outline window while making the project a little more manageable while I learn what it is actually doing. Are there any drawbacks to doing this? I imagine some async loading issues might occur; this could possibly add to client side overhead; or is this perfectly acceptable?

I realize that this is sort of a code philosophy question, but the simple Q&A would be, what effect would app=app; have?

Upgrade to JUnit 4 in Eclipse

I tried switching to JUnit 4 in Eclipse using the instructions in this answer: http://ift.tt/1IwEE3T.

It basically says to remove any JUnit 3 library in the build path (I removed a JUnit 3.7 jar) and add the JUnit 4 library, which I did.

However, when I run the following code in my test class:

import junit.runner.Version;
System.out.println("JUnit version is: " + Version.id());

I get:

JUnit version is: 3.8.1

I don't have any other JUnit libraries in my buildpath.

If it's relevant, the exact Eclipse version is "Indigo Service Release 1, Build id: 20110916-0149".

How can I fix this and run JUnit 4?

Android Application run in a real Mobile but not in Eclipse

My application run in my real mobile phone but not in Eclipse+Android Studio Enviroment. I check class and Android Manifest and are same. Whats wrong ?

My codes are:

1) MainActivity.java

package com.example.homework2;

import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;


public class MainActivity extends ActionBarActivity 
{
    EditText firstnameText;
    Button goButton, aboutButton;

    @Override
    protected void onCreate( Bundle savedInstanceState ) 
    {
        super.onCreate( savedInstanceState );       
        setContentView( R.layout.activity_main );       

        //firstnameText = ( EditText ) findViewById( R.id.editText1 );
        //String name = firstnameText.getText().toString();
/*      
        goButton =  ( Button ) findViewById( R.id.letsgo_button );
        goButton.setOnClickListener( new OnClickListener() 
        {
            @Override
            public void onClick( View v ) 
            {
                // TODO Auto-generated method stub
            }
        }); 
*/      
        aboutButton = ( Button ) findViewById( R.id.about_button );
        aboutButton.setOnClickListener( new OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                // TODO Auto-generated method stub
                Intent about = new Intent( MainActivity.this, About.class );
                startActivity( about );
            }           
        });
    }
}

2) activity_main.xml

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.homework2.MainActivity" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:scaleType="centerCrop"
        android:src="@drawable/wallpaper1" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="35dp"
        android:paddingTop="16px"
        android:paddingBottom="16px"
        android:background="#2B3856"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="Enter your Name: "
        android:textColor="#E8E8E8"
        android:textStyle="bold" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/about_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:background="#101010"
        android:text="About"
        android:textColor="#F8F8F8"
        android:textStyle="bold" />

    <Button
        android:id="@+id/letsgo_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/about_button"
        android:layout_alignLeft="@+id/imageView1"
        android:layout_marginBottom="16dp"
        android:background="#3B0B0B"
        android:text="Let&apos;s GO !!!"
        android:textColor="#E8E8E8"
        android:textStyle="bold" />

</RelativeLayout>

3) About.java

package com.example.homework2;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;

public class About extends ActionBarActivity 
{   
    @Override
    protected void onCreate( Bundle savedInstanceState ) 
    {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.about );
    }
}

4) about.xml

   <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://ift.tt/nIICcg"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >


        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="463dp"
            android:layout_x="1dp"
            android:layout_y="-8dp"
            android:scaleType="centerCrop"
            android:src="@drawable/wallpaper2" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="209dp"
            android:layout_x="-1dp"
            android:layout_y="101dp"
            android:textColor="#FFFFFF"
            android:textStyle="bold|italic"   
            android:ems="10"
            android:gravity="center"
            android:text="Πριν δυο χρόνια ο Σερ Άλεξ Φέργκιουσον σταμάτησε την προπονητική. Η συγκεκριμένη εφαρμογή βάζει ένα κουίζ στους οπαδούς της ομάδας, για τα πεπραγμένα του Σκωτσέζου κόουτς στον πάγκο της Μάντσεστερ Γιουνάιτεντ." >

            <requestFocus />
        </EditText>
    </RelativeLayout>

5) AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
    package="com.example.homework2"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".About"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.homework2.ABOUT" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Java - JSON and Parent Shells

I'm kind of new to Java and programming some first programs using SWT GUI with Eclipse.

I got a few things I don't understand and will appreciate some explanations, preferably expanded to me the easiest way possible.

Can someone please tell me what is the best way for me to save a String ArrayList of properties after the program is shut down?

I was told to save it to a text file, and use JSON to read and write, but I could not understand how to do it. I need to be able to get this information from the user and save it for future use.

Is JSON the best way for my needs?

For example, I will need to save these information arrays:

folder: D:\Videos
buttonsPerLine: 7
labelLength: 75
menuButtonLength: 60
spaceFromLeft: 20
spaceFromTop: 20
Shows:
    brooklyn nine nine
    community
    the big bang theory
    the blacklist

and these:

linkArray1:
    www.youtube.com/1
    www.youtube.com/2
    www.youtube.com/3
linkArray2:
    www.youtube.com/1
    www.youtube.com/2
    www.youtube.com/3
linkArray3:
    www.youtube.com/1
    www.youtube.com/1

Thank you very much!

Can't launch the java program

I found this code on the site oracle but I can't launch with Eclipse it's saying me "Unable to launch". I have installed JDK 8 but it doesn't work...

Anybody have a solution please ? :p

public class SwingFX extends Application {

@Override
public void start (Stage stage) {
    final SwingNode swingNode = new SwingNode();

    createSwingContent(swingNode);

    StackPane pane = new StackPane();
    pane.getChildren().add(swingNode);

    stage.setTitle("Swing in JavaFX");
    stage.setScene(new Scene(pane, 250, 150));
    stage.show();
    }

private void createSwingContent(final SwingNode swingNode) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            swingNode.setContent(new JButton("Click me!"));
        }
    });
}
}

link to the website where I found the code : http://ift.tt/1Ffsv46

eclipse errors after java update [on hold]

I have just updated Java from a notification that came into my taskbar tray. Since the update Eclipse has brought up a variety of errors. Every line now has an error, I think it could be something to do with with Eclipse being unable to use the new update but I'm stumped as to what I can do to correct this.

I'm fairly new to Eclipse and Java so any help would be greatly appreciated.

The main error states "The error states the path was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project" I don't think Eclipse can locate the Java libraries, it states it can't resolve System or Scanner. All my classes have the same errors. I was using Java v1.8.42 previously then I did the update

Is it worth reinstalling it?

Hibernate production use warning

This warning comes up evertime i use hibernate.

Mai 11, 2015 3:42:20 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)

Do i have to be worried about this? The tables are created without problem, but this warning makes me unsure about my hibernate.cfg.xml configuration file.

Thx in advance for your support.

Making a list of all combinations of 2 letters and 4 numbers

I have been trying to create a code that can make a list of all combinations of 2 letters and 4 numbers

EX: aa1111, ab1111

the only thing that i can come up with are programs that print combinations that are against my outline

EX: aatc9e, gj3ru7

What can I do that makes it so it stops at two letters and goes to the four numbers?

Playframework create eclipse project

I am use play version i can not create eclipse project playframework via command line, i get next errors. I am use activator version 1.3.2; java -version 1.8 and javac -version 1.6. How solved my problem?

[myProject] $ eclipse
[info] About to create Eclipse project files for your project(s).
[info] Updating {http://file:/D:/activator-1.3.2-minimal/myProject/}root...
[info] Resolving org.scala-lang#scala-library;2.11.1 ...

[myProject] $ eclipse
[info] About to create Eclipse project files for your project(s).
[info] Updating {http://file:/D:/activator-1.3.2-minimal/myProject/}root...
[info] Resolving org.scala-lang#scala-library;2.11.1 ...
[error] D:\activator-1.3.2-minimal\myProject\app\controllers\Application.java:3: error: package play does not exist
[error] import play.*;
[error] ^
[error] D:\activator-1.3.2-minimal\myProject\app\controllers\Application.java:4: error: package play.mvc does not exist
[error] import play.mvc.*;
[error] ^
[error] D:\activator-1.3.2-minimal\myProject\app\controllers\Application.java:8: error: cannot find symbol
[error] public class Application extends Controller {
[error]                                  ^
[error]   symbol: class Controller
[error] D:\activator-1.3.2-minimal\myProject\app\controllers\Application.java:10: error: cannot find symbol
[error]     public static Result index() {
[error]                   ^
[error]   symbol:   class Result
[error]   location: class Application
[error] D:\activator-1.3.2-minimal\myProject\target\scala-2.11\classes\controllers\ReverseAssets.class: warning: Cannot find annotation method 'bytes(
)' in type 'ScalaSignature': class file for scala.reflect.ScalaSignature not found
[error] D:\activator-1.3.2-minimal\myProject\target\scala-2.11\classes\controllers\ReverseApplication.class: warning: Cannot find annotation method 'b
ytes()' in type 'ScalaSignature'
[error] D:\activator-1.3.2-minimal\myProject\target\scala-2.11\classes\controllers\javascript\ReverseAssets.class: warning: Cannot find annotation met
hod 'bytes()' in type 'ScalaSignature'
[error] D:\activator-1.3.2-minimal\myProject\target\scala-2.11\classes\controllers\javascript\ReverseApplication.class: warning: Cannot find annotatio
n method 'bytes()' in type 'ScalaSignature'
[error] D:\activator-1.3.2-minimal\myProject\target\scala-2.11\classes\controllers\ref\ReverseAssets.class: warning: Cannot find annotation method 'by
tes()' in type 'ScalaSignature'
[error] D:\activator-1.3.2-minimal\myProject\target\scala-2.11\classes\controllers\ref\ReverseApplication.class: warning: Cannot find annotation metho
d 'bytes()' in type 'ScalaSignature'
[error] D:\activator-1.3.2-minimal\myProject\target\scala-2.11\classes\views\html\index.class: warning: Cannot find annotation method 'bytes()' in typ
e 'ScalaSignature'
[error] D:\activator-1.3.2-minimal\myProject\app\controllers\Application.java:11: error: cannot access Html
[error]         return ok(index.render("Your new application is ready."));
[error]                               ^
[error]   class file for play.twirl.api.Html not found
[error] 5 errors
[error] 7 warnings
[error] (compile:compile) javac returned nonzero exit code
[error] Could not create Eclipse project files:
[error] Error evaluating task 'dependencyClasspath': error

Is there a way that IntelliJ generates GUI designer code that is usable in Eclipse?

I already tried the option to generate the designer code into the *.java files but this is not the complete code. Is there any other way to do that? Thank you for your help.

Google Play Services running on Emulator

Adding Google Play Services lib (v.7327000) to my app, it works well on real devices but Activity crashes and I get error on running emulator (Google API 21/22, tried Nexus4/5/10) like this:

"E/OpenGLRenderer(2560): Could not allocate texture for layer (fbo=1 2560x1326)"

Tried with Android Studio (selective lib) and Eclipse (library project). Does anyone know a solution ?

Advice defined has not been applied

I have a AspectJ - Project with a aspect to making some System.out.println's to learning a little bit about aspects etc.

The Problem is, that the advices which i define to the cuts doesn't work. The warning which is shown is: advice defined in ShapeAspect has not been applied [Xlint:adviceDidNotMatch]

I'm working with a Mac OS X 10.10 Yosemite, Eclipse Luna Service Release 2 (4.4.2) and AspectJ Runtime: org.aspectj.runtime_1.8.5.20150128171000.jar, for the LTW classes etc.: org.aspectj.weaver_1.8.5.20150128171000.jar and additionally org.aspectj.ajde_1.8.5.20150128171000.jar.

My simple defined aspect:

public aspect ShapeAspect {
   // pointcuts
   pointcut myPointcut2() : execution(oldshape.Point.new(..));

  // advices
  before() : myPointcut2(){
    System.out.println("Before init.");
  }
}

But at the line of before().. is the Warning: advice defined in ShapeAspect has not been applied [Xlint:adviceDidNotMatch]

What is the Problem here? On my PC with Windows it works correctly?

Titan IllegalArgumentException:Could not instantiate implementation:com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager

I'm a beginner with Titan Graph Database and I'm just trying to create a simple titan graph in a particular path using eclipse.Initially , setting the titan configurations followed by creating two vertices and an edge. This is the code i had given :

public class TitanGraphDemo {
        private static final String TITAN_DB = "target/tmp/titan";
        private static final Logger logger = LoggerFactory.getLogger(TitanGraphDemo.class);
        public static void init() {
            Configuration  conf = new BaseConfiguration();
            conf.setProperty("storage.directory", TITAN_DB);
            conf.setProperty("storage.backend","cassandra");
            conf.setProperty("storage.hostname","127.0.0.1");
            conf.setProperty("storage.port","9160");
            TitanGraph graph = TitanFactory.open(conf);

            Vertex rash = graph.addVertex(null);
            rash.setProperty("userId", 1);
            rash.setProperty("username", "rash");
            rash.setProperty("firstName", "Rahul");
            rash.setProperty("lastName", "Chaudhary");
            rash.setProperty("birthday", 101);

            Vertex honey = graph.addVertex(null);
            honey.setProperty("userId", 2);
            honey.setProperty("username", "honey");
            honey.setProperty("firstName", "Honey");
            honey.setProperty("lastName", "Anant");
            honey.setProperty("birthday", 201);

            Edge frnd = graph.addEdge(null, rash, honey, "FRIEND");
            frnd.setProperty("since", 2011);
            graph.commit();
            logger.info("Titan graph loaded successfully.");
        }
    }

But when i run the java, i am getting IllegalArgumentException as below.

Exception in thread "main" java.lang.IllegalArgumentException: Could not instantiate implementation: com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager
    at com.thinkaurelius.titan.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:55)
    at com.thinkaurelius.titan.diskstorage.Backend.getImplementationClass(Backend.java:421)
    at com.thinkaurelius.titan.diskstorage.Backend.getStorageManager(Backend.java:361)
    at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.<init>(GraphDatabaseConfiguration.java:1275)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:93)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:73)
    at titan.TitanGraphDemo.init(TitanGraphDemo.java:37)
    at titan.TitanGraphDemo.main(TitanGraphDemo.java:113)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.thinkaurelius.titan.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:44)
    ... 7 more
Caused by: java.lang.NoSuchMethodError: com.netflix.astyanax.impl.AstyanaxConfigurationImpl.setTargetCassandraVersion(Ljava/lang/String;)Lcom/netflix/astyanax/impl/AstyanaxConfigurationImpl;
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager.getContextBuilder(AstyanaxStoreManager.java:474)
    at com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager.<init>(AstyanaxStoreManager.java:267)
    ... 12 more

I have added the dependencies for titan, cassandra. Please anyone guide me with this issue.

Details of dependencies added in pom.xml is as below :

<!-- Libraries -->
    <dependencies>
        <!-- TinkerPop -->
        <dependency>
            <groupId>com.tinkerpop.blueprints</groupId>
            <artifactId>blueprints-core</artifactId>
            <version>2.6.0</version>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.blueprints</groupId>
            <artifactId>blueprints-test</artifactId>
            <version>2.6.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.gremlin</groupId>
            <artifactId>gremlin-groovy</artifactId>
            <version>2.1.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>gossip</artifactId>
                    <groupId>org.sonatype.gossip</groupId>
                </exclusion>
            </exclusions>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.rexster</groupId>
            <artifactId>rexster-core</artifactId>
            <version>2.1.0</version>
        </dependency>
        <!-- Utility -->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>12.0</version>
        </dependency>
        <dependency>
            <groupId>colt</groupId>
            <artifactId>colt</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode</groupId>
            <artifactId>kryo</artifactId>
            <version>1.04</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cassandra</groupId>
            <artifactId>cassandra-all</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
          <groupId>org.objenesis</groupId>
          <artifactId>objenesis</artifactId>
          <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>com.netflix.astyanax</groupId>
            <artifactId>astyanax</artifactId>
            <version>1.0.6</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.6</version>
        </dependency>
       <!--  <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency> -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>


        <!-- Storage backends -->
        <!-- HBase -->
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase</artifactId>
            <!-- Update the hadoop-core artifact version when you update this -->
            <version>0.94.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>avro</artifactId>
                    <groupId>org.apache.avro</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>jruby-complete</artifactId>
                    <groupId>org.jruby</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <!-- Update the hbase artifact version when you update this -->
            <version>1.0.3</version>
        </dependency>
        <!-- Cassandra -->
       <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.5.5</version>
        </dependency>
        <!-- BerkeleyDB -->
        <dependency>
            <groupId>com.sleepycat</groupId>
            <artifactId>je</artifactId>
            <version>5.0.58</version>
        </dependency>


        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.thinkaurelius.titan</groupId>
            <artifactId>titan-core</artifactId>
            <version>0.5.4</version>
        </dependency>
        <dependency>
            <groupId>com.thinkaurelius.titan</groupId>
            <artifactId>titan-cassandra</artifactId>
            <version>0.5.0</version>
        </dependency>
         <dependency>
            <groupId>com.thinkaurelius.titan</groupId>
            <artifactId>titan-all</artifactId>
            <version>0.5.0-M1</version>
        </dependency> 

        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-core</artifactId>
            <version>2.0.0-beta2</version>
        </dependency>
    </dependencies>

Wrong .classpath generated for multimodule project by maven-eclipse-plugin

My project has the following structure:

/ProjectRoot
/ProjectRoot/A
/ProjectRoot/B
/ProjectRoot/C

ProjectRoot is a multimodule project. Project A should create war and it has dependencies to projects B and C delared in its pom. When I run maven eclipse:eclipse on ProjectRoot it results in incorrect .classpath file created for project A.

<classpath>
  <classpathentry kind="src" path="/B"/>
  <classpathentry kind="src" path="/C"/>
</classpath>

This stops the build in eclipse. Problems tabs displays:

Project 'A' is missing required Java project: 'B'
Project 'A' is missing required Java project: 'C'
The project cannot be built until build path errors are resolved

I know I can fix this problem manually(Properties/Build path/Projects remove the missing ones and then add them once again) but I would like to have the correct settings generated automatically by maven-eclipse-plugin.

Details of Nebula Nattable filtering

It looks as though implementing filter function in Nebula Nattable is difficult. Even the example given is hard to understand. would someone point to an explanation on the various classes used in implementing the filter function ?

Checkstyle validation fail when needs multiple lines

I need to perform a validation rule on eclipse checkstyle, after a key { of method and before end key } should have a empty line, example:

public void wrongMethod() {
    System.out.println("wrong method");
}

correct

public void correctMethod() {

    System.out.println("correct method");

}    

I try to use a RegexpMultiline in checkstyle rules xml file, doing some like this:

<module name="RegexpMultiline">
    <property name="format" value=".+\{\n.+[;]"/>
    <property name="message" value="should have empty line"/>
</module>  

sure, this Regex expression can be better, the issue is, the multiline behavior works in a regex simulator site with the examples above, but in checkstyle dont. I search on a checkstyle documentation and not found a ready reature for this.

Anyone know a solution for this issue?

thanks.

Rename resource file does not change editor part title

In my plugin project, I have a project explorer view where I can rename a config file which in shown in another editor part. The file can be renamed in the explorer with the rename resource dialog but the corresponding the editor tab title does not change. The same problem is described here and also here. Is there a standard way to get the rename functionality working without the creating a custom listener?

Can install RadRails on Eclipse Luna 4.4.2

I am trying to install the RadRails plug-in on a fresh Eclipse Luna instance (4.4.2), using the following update site: http://ift.tt/KNKjIh

But it always fails with the error below:

Cannot complete the install because one or more required items could not be found. Software being installed: Aptana RadRails 2.0.5.1278709071-79-7D7BFZcLCUQRF2NWAQhRBC1qP (com.aptana.radrails.feature.feature.group 2.0.5.1278709071-79-7D7BFZcLCUQRF2NWAQhRBC1qP) Missing requirement: Aptana Editor Infrastructure 2.0.5.1278523018-8o57z9icbz-hWlJZG (com.aptana.ide.feature.editors.feature.group 2.0.5.1278523018-8o57z9icbz-hWlJZG) requires 'org.eclipse.update.ui 0.0.0' but it could not be found

Cannot satisfy dependency: From: Aptana Web Development Tools 2.0.5.1278614541-7D-7O7iRJci-jVhz-KFyoijH (com.aptana.ide.feature.feature.group 2.0.5.1278614541-7D-7O7iRJci-jVhz-KFyoijH) To: com.aptana.ide.feature.editors.feature.group [2.0.5.1278523018-8o57z9icbz-hWlJZG] Cannot satisfy dependency: From: Aptana RadRails 2.0.5.1278709071-79-7D7BFZcLCUQRF2NWAQhRBC1qP (com.aptana.radrails.feature.feature.group 2.0.5.1278709071-79-7D7BFZcLCUQRF2NWAQhRBC1qP) To: com.aptana.ide.feature.feature.group [2.0.5.1278614541-7D-7O7iRJci-jVhz-KFyoijH]

What should I do to install RadRails?