This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 21 - Pages: 2 [ Previous | 1 2 ] - Last Post: 23 Mar 22, 00:04 Last Post By: RobM Threads: [ Previous | Next ]
RobM

Posts: 4,383
Registered: 4-Aug-2006
Re: AlbumObjects and isIncluded()
Posted: 21 Mar 22, 17:00   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
JeffTucker wrote:
But if he wants to exclude sparky.jpg, is there really any harm in not excluding extras/sparky.jpg? The core will generate an unused slide image, but beyond that....
No harm, but for someone with zillions of images, it could amount to significant uploading of orphaned images. Hypothetical I know, but I have to have something to do to keep the few remaining grey cells active.
RobM

Posts: 4,383
Registered: 4-Aug-2006
Re: AlbumObjects and isIncluded()
Posted: 21 Mar 22, 21:29   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
David. Another big thank you due, so thank you!

For posterity the much reduced code is
//Synchronise any extra objects with their primary object
//extraProps are custom gui settings to override skin sync settings
syncExtras(AlbumObject folder) {
	for(AlbumObject ao: folder.getChildren()) {
		//Only check primary folders, not the extras
		if(ao.isFolder() && !ao.getName().equals(extraDirName)) {
				syncExtras(ao);
		}
		else if(ao.isFolder() && ao.getName().equals(extraDirName)){
			//This is an extras folder, so hide it
			ao.setHidden(true);
			//Ensure changes are reflected in the object tree
			ao.invalidate();
			//Now process its contents
			for(AlbumObject extra: ao.getChildren()) {	
				//Get this extras primary object
				AlbumObject primaryObj = folder.getChild(extra.getName());
				//Ensure there is a primary object to work with
				if(primaryObj != null) {
					//Get the extra object's properties
					extraProps = extra.getProperties();
					//Synchronise the extra object's properties to the primary
					if(extraProps.get("override")) {
						if(syncIncluded) extra.setIncluded(extraProps.get("overrideSyncIncluded"));
						if(syncIncOriginal) extra.setIncludeOriginal(extraProps.get("overrideSyncIncOriginal"));
						if(syncUseOriginal) extra.setUseOriginal(extraProps.get("overrideSyncUseOriginal"));
					}
					else {
						if(syncIncluded) extra.setIncluded(primaryObj.isIncluded());
						if(syncIncOriginal) extra.setIncludeOriginal(primaryObj.isIncludeOriginal());
						if(syncUseOriginal) extra.setUseOriginal(primaryObj.isUseOriginal());
					}
				}
				else {
					//No primary object, so exclude this extra
					extra.setIncluded(false);
				}
			}
		}
	}
}
 
 
//Start the synchronisation process of objects and extras
if(!extraDirName.equals("")) syncExtras(context.getExplorer().getRootFolder());

Of course, this may soon become obsolete if your attach object idea is implemented.
JeffTucker

Posts: 8,467
Registered: 31-Jan-2006
Re: AlbumObjects and isIncluded()
Posted: 21 Mar 22, 21:32   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
For posterity the much reduced code is....

Ah, but what if I want jAlbum to use the original for sparky.jpg, but scale extras/sparky.jpg? Answer me that one, smart guy!
RobM

Posts: 4,383
Registered: 4-Aug-2006
Re: AlbumObjects and isIncluded()
Posted: 21 Mar 22, 22:05   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
JeffTucker wrote:
RobM wrote:
For posterity the much reduced code is....

Ah, but what if I want jAlbum to use the original for sparky.jpg, but scale extras/sparky.jpg? Answer me that one, smart guy!

Simple, use another skin that supports alternative images ;)
I could offer skin settings, asking if those properties should be synchronised, but we both know that then users will ask for an override per image. I think I'll wait for an actual user request, shouldn't be anytime soon.
JeffTucker

Posts: 8,467
Registered: 31-Jan-2006
Re: AlbumObjects and isIncluded()
Posted: 21 Mar 22, 22:16   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
Simple, use another skin that supports alternative images ;)

That's the spirit! :)
davidekholm

Posts: 4,407
Registered: 18-Oct-2002
Re: AlbumObjects and isIncluded()
Posted: 22 Mar 22, 10:53   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
That code looks far more readable Rob, and is faster too. Nested loops are high risk candidates for CPU hogs, so it's good you got rid of those too. Just make a null check after calling getChild in case there is no "primary" object with the same name as the secondary object.
RobM

Posts: 4,383
Registered: 4-Aug-2006
Re: AlbumObjects and isIncluded()
Posted: 22 Mar 22, 10:58   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
That code looks far more readable Rob, and is faster too. Nested loops are high risk candidates for CPU hogs, so it's good you got rid of those too. Just make a null check after calling getChild in case there is no "primary" object with the same name as the secondary object.
Thanks. I’ll add a null check and if null set the extra to not included, that might be safer than deleting it as the user might add a replacement later.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums