signature:
public class FileObservable { /** * If file does not exist at subscribe time then is assumed to not be a
 * directory . If the file is not a directory ( bearing in mind the aforesaid
 * assumption ) then a { @ link WatchService } is set up on its parent and
 * { @ link WatchEvent } s of the given kinds are filtered to concern the file
 * in question . If the file is a directory then a { @ link WatchService } is
 * set up on the directory and all events are passed through of the given
 * kinds .
 * @ param file
 * file to watch
 * @ param kinds
 * event kinds to watch for and emit
 * @ return observable of watch events */
@ SafeVarargs public final static Observable < WatchEvent < ? > > from ( final File file , Kind < ? > ... kinds ) { } }

implementation: return from ( file , null , kinds ) ;


signature:
public class FileObservable { /** * If file does not exist at subscribe time then is assumed to not be a
 * directory . If the file is not a directory ( bearing in mind the aforesaid
 * assumption ) then a { @ link WatchService } is set up on its parent and
 * { @ link WatchEvent } s of the given kinds are filtered to concern the file
 * in question . If the file is a directory then a { @ link WatchService } is
 * set up on the directory and all events are passed through of the given
 * kinds .
 * @ param file
 * file to watch
 * @ param kinds
 * event kinds to watch for and emit
 * @ return observable of watch events */
public final static Observable < WatchEvent < ? > > from ( final File file , List < Kind < ? > > kinds ) { } }

implementation: return from ( file , null , kinds . toArray ( new Kind < ? > [ ] { } ) ) ;


signature:
public class FileObservable { /** * If file does not exist at subscribe time then is assumed to not be a
 * directory . If the file is not a directory ( bearing in mind the aforesaid
 * assumption ) then a { @ link WatchService } is set up on its parent and
 * { @ link WatchEvent } s of the given kinds are filtered to concern the file
 * in question . If the file is a directory then a { @ link WatchService } is
 * set up on the directory and all events are passed through of the given
 * kinds .
 * @ param file
 * file to generate watch events from
 * @ param onWatchStarted
 * called when WatchService is created
 * @ param kinds
 * kinds of watch events to register for
 * @ return observable of watch events */
public final static Observable < WatchEvent < ? > > from ( final File file , final Action0 onWatchStarted , Kind < ? > ... kinds ) { } }

implementation:
return watchService ( file , kinds ) // when watch service created call onWatchStarted
. doOnNext ( new Action1 < WatchService > ( ) { @ Override public void call ( WatchService w ) { if ( onWatchStarted != null ) onWatchStarted . call ( ) ; } } ) // emit events from the WatchService
. flatMap ( TO_WATCH_EVENTS ) // restrict to events related to the file
. filter ( onlyRelatedTo ( file ) ) ;


signature:
public class FileObservable { /** * Creates a { @ link WatchService } on subscribe for the given file and event
 * kinds .
 * @ param file
 * the file to watch
 * @ param kinds
 * event kinds to watch for
 * @ return observable of watch events */
@ SafeVarargs public final static Observable < WatchService > watchService ( final File file , final Kind < ? > ... kinds ) { } }

implementation: return Observable . defer ( new Func0 < Observable < WatchService > > ( ) { @ Override public Observable < WatchService > call ( ) { try { final Path path = getBasePath ( file ) ; WatchService watchService = path . getFileSystem ( ) . newWatchService ( ) ; path . register ( watchService , kinds ) ; return Observable . just ( watchService ) ; } catch ( Exception e ) { return Observable . error ( e ) ; } } } ) ;


signature:
public class FileObservable { /** * Returns true if and only if the path corresponding to a WatchEvent
 * represents the given file . This will be the case for Create , Modify ,
 * Delete events .
 * @ param file
 * the file to restrict events to
 * @ return predicate */
private final static Func1 < WatchEvent < ? > , Boolean > onlyRelatedTo ( final File file ) { } }

implementation: return new Func1 < WatchEvent < ? > , Boolean > ( ) { @ Override public Boolean call ( WatchEvent < ? > event ) { final boolean ok ; if ( file . isDirectory ( ) ) ok = true ; else if ( StandardWatchEventKinds . OVERFLOW . equals ( event . kind ( ) ) ) ok = true ; else { Object context = event . context ( ) ; if ( context != null && context instanceof Path ) { Path p = ( Path ) context ; Path basePath = getBasePath ( file ) ; File pFile = new File ( basePath . toFile ( ) , p . toString ( ) ) ; ok = pFile . getAbsolutePath ( ) . equals ( file . getAbsolutePath ( ) ) ; } else ok = false ; } return ok ; } } ;


signature:
public class OnSubscribeWatchServiceEvents { /** * returns true if and only there may be more events */
private static boolean emitEvents ( WatchService watchService , Subscriber < ? super WatchEvent < ? > > subscriber , long pollDurationMs , long pollIntervalMs ) { } }

implementation:
// get the first event
WatchKey key = nextKey ( watchService , subscriber , pollDurationMs ) ; if ( key != null ) { if ( subscriber . isUnsubscribed ( ) ) return false ; // we have a polled event , now we traverse it and
// receive all the states from it
for ( WatchEvent < ? > event : key . pollEvents ( ) ) { if ( subscriber . isUnsubscribed ( ) ) return false ; else subscriber . onNext ( event ) ; } boolean valid = key . reset ( ) ; if ( ! valid && ! subscriber . isUnsubscribed ( ) ) { subscriber . onCompleted ( ) ; return false ; } else if ( ! valid ) return false ; } return true ;


signature:
public class ViewPagerIndicator { /** * Create a StateListDrawable for the pager indicator
 * @ return a proper StateListDrawable */
private StateListDrawable getSelectorDrawable ( ) { } }

implementation: StateListDrawable d = null ; try { d = new StateListDrawable ( ) ; ShapeDrawable selectedDrawable = new ShapeDrawable ( new OvalShape ( ) ) ; selectedDrawable . getPaint ( ) . setColor ( mItemSelectedColor ) ; selectedDrawable . setIntrinsicHeight ( mItemRadius * 2 ) ; selectedDrawable . setIntrinsicWidth ( mItemRadius * 2 ) ; ShapeDrawable unselectedDrawable = new ShapeDrawable ( new OvalShape ( ) ) ; unselectedDrawable . getPaint ( ) . setColor ( mItemUnselectedColor ) ; unselectedDrawable . setIntrinsicHeight ( mItemRadius * 2 ) ; unselectedDrawable . setIntrinsicWidth ( mItemRadius * 2 ) ; d . addState ( new int [ ] { android . R . attr . state_checked } , selectedDrawable ) ; d . addState ( new int [ ] { } , unselectedDrawable ) ; } catch ( Exception e ) { Log . e ( TAG , getMessageFor ( e ) ) ; } return d ;


signature:
public class ViewPagerIndicator { /** * Initialize ViewPagerIndicator with a properly set up ViewPager
 * @ param viewPager an instance of android . support . v4 . view . ViewPager
 * @ throws IllegalStateException if no adapter has been provided to the viewPager */
public void initWithViewPager ( ViewPager viewPager ) throws IllegalStateException { } }

implementation: if ( viewPager == null ) return ; if ( viewPager . getAdapter ( ) == null ) throw new IllegalStateException ( "ViewPager has no adapter set." ) ; try { mViewPager = viewPager ; mViewPager . addOnPageChangeListener ( mOnPageChangeListener ) ; addViews ( ) ; } catch ( Exception e ) { Log . e ( TAG , getMessageFor ( e ) ) ; }


signature:
public class ViewPagerIndicator { /** * Add page indicators based on the attached ViewPager */
private void addViews ( ) { } }

implementation: try { if ( mViewPager == null || mViewPager . getAdapter ( ) == null || mViewPager . getAdapter ( ) . getCount ( ) == 0 ) return ; removeAllViews ( ) ; AppCompatRadioButton firstItem = new AppCompatRadioButton ( getContext ( ) ) ; firstItem . setText ( "" ) ; firstItem . setButtonDrawable ( mButtonDrawable . getConstantState ( ) . newDrawable ( ) ) ; ViewPagerIndicator . LayoutParams params = new LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . WRAP_CONTENT ) ; firstItem . setLayoutParams ( params ) ; firstItem . setClickable ( false ) ; addView ( firstItem ) ; for ( int i = 1 ; i < mViewPager . getAdapter ( ) . getCount ( ) ; i ++ ) { AppCompatRadioButton item = new AppCompatRadioButton ( getContext ( ) ) ; item . setText ( "" ) ; item . setButtonDrawable ( mButtonDrawable . getConstantState ( ) . newDrawable ( ) ) ; params = new LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . WRAP_CONTENT ) ; params . setMargins ( mItemDividerWidth , 0 , 0 , 0 ) ; item . setLayoutParams ( params ) ; item . setClickable ( false ) ; addView ( item ) ; } check ( firstItem . getId ( ) ) ; } catch ( Exception e ) { Log . e ( TAG , getMessageFor ( e ) ) ; }


signature:
public class ViewPagerIndicator { /** * Always get a message for an exception
 * @ param e an Exception
 * @ return a String describing the Exception */
private String getMessageFor ( Exception e ) { } }

implementation: if ( e == null ) return TAG + ": No Message." ; return e != null && e . getMessage ( ) != null ? e . getMessage ( ) : e . getClass ( ) . getName ( ) + ": No Message." ;


signature:
public class UUID { /** * This method sets the content based on the values of two longs representing the first and second half of the UUID .
 * This method is called from the UUID ( java . util . UUID ) and UUID ( long , long ) constructors .
 * @ param hi Long value representing the first half of the UUID .
 * @ param lo Long value representing the second half of the UUID . */
private void constructFromLongs ( long hi , long lo ) { } }

implementation: content [ 0 ] = ( byte ) ( hi >> 56 ) ; content [ 1 ] = ( byte ) ( hi >> 48 ) ; content [ 2 ] = ( byte ) ( hi >> 40 ) ; content [ 3 ] = ( byte ) ( hi >> 32 ) ; content [ 4 ] = ( byte ) ( hi >> 24 ) ; content [ 5 ] = ( byte ) ( hi >> 16 ) ; content [ 6 ] = ( byte ) ( hi >> 8 ) ; content [ 7 ] = ( byte ) ( hi ) ; content [ 8 ] = ( byte ) ( lo >> 56 ) ; content [ 9 ] = ( byte ) ( lo >> 48 ) ; content [ 10 ] = ( byte ) ( lo >> 40 ) ; content [ 11 ] = ( byte ) ( lo >> 32 ) ; content [ 12 ] = ( byte ) ( lo >> 24 ) ; content [ 13 ] = ( byte ) ( lo >> 16 ) ; content [ 14 ] = ( byte ) ( lo >> 8 ) ; content [ 15 ] = ( byte ) ( lo ) ;


signature:
public class UUID { /** * This method validates a character array as the expected format for a printed representation of a UUID . The
 * expected format is 36 characters long , with ' - ' at the 8th , 13th , 18th , and 23rd characters . The remaining
 * characters are expected to be valid hex , meaning in the range ( ' 0 ' - ' 9 ' , ' a ' - ' f ' , ' A ' - ' F ' ) inclusive .
 * If a character array is valid , then it can be used to construct a UUID . This method has been written unrolled
 * and verbosely , with the theory that this is simpler and faster than using loops or a regex .
 * @ param ch A character array of a UUID ' s printed representation .
 * @ return True or false based on whether the UUID is valid , no exceptions are thrown . */
public static boolean isValidUUID ( char [ ] ch ) { } }

implementation: return ch != null && ch . length == 36 && validHex ( ch [ 0 ] ) && validHex ( ch [ 1 ] ) && validHex ( ch [ 2 ] ) && validHex ( ch [ 3 ] ) && validHex ( ch [ 4 ] ) && validHex ( ch [ 5 ] ) && validHex ( ch [ 6 ] ) && validHex ( ch [ 7 ] ) && ch [ 8 ] == '-' && validHex ( ch [ 9 ] ) && validHex ( ch [ 10 ] ) && validHex ( ch [ 11 ] ) && validHex ( ch [ 12 ] ) && ch [ 13 ] == '-' && validHex ( ch [ 14 ] ) && validHex ( ch [ 15 ] ) && validHex ( ch [ 16 ] ) && validHex ( ch [ 17 ] ) && ch [ 18 ] == '-' && validHex ( ch [ 19 ] ) && validHex ( ch [ 20 ] ) && validHex ( ch [ 21 ] ) && validHex ( ch [ 22 ] ) && ch [ 23 ] == '-' && validHex ( ch [ 24 ] ) && validHex ( ch [ 25 ] ) && validHex ( ch [ 26 ] ) && validHex ( ch [ 27 ] ) && validHex ( ch [ 28 ] ) && validHex ( ch [ 29 ] ) && validHex ( ch [ 30 ] ) && validHex ( ch [ 31 ] ) && validHex ( ch [ 32 ] ) && validHex ( ch [ 33 ] ) && validHex ( ch [ 34 ] ) && validHex ( ch [ 35 ] ) ;


signature:
public class UUID { /** * Toggle UUID generator into sequential mode , so the random segment is in order and increases by one . In
 * sequential mode , there is presumably a desire that UUIDs generated around the same time should begin with similar
 * characters , but this is difficult in a distributed environment . The solution is to set the counter value based
 * on a hash of the UTC date and time up to a 10 minute precision . This means that UUID classes initialized at
 * similar times should start with similar counter values , but this is not guaranteed . If one of these classes
 * is generating vastly more UUIDs than others , then these counters can become skewed .
 * Calling this method more than once without toggling back to variable mode has no effect , so it probably makes
 * more sense to call this from a static context , like your main method or in a class ' static initialization . */
public static void useSequentialIds ( ) { } }

implementation:
if ( ! sequential ) { // get string that changes every 10 minutes
TimeZone tz = TimeZone . getTimeZone ( "UTC" ) ; DateFormat df = new SimpleDateFormat ( "yyyyMMddHHmm" ) ; df . setTimeZone ( tz ) ; String date = df . format ( new Date ( ) ) . substring ( 0 , 11 ) ; // run an md5 hash of the string , no reason this needs to be secure
byte [ ] digest ; try { MessageDigest md = MessageDigest . getInstance ( "MD5" ) ; digest = md . digest ( date . getBytes ( "UTF-8" ) ) ; } catch ( Exception e ) { throw new RuntimeException ( "Could not create hash of date for the sequential counter" , e ) ; } // create integer from first 4 bytes of md5 hash
int x ; x = ( ( int ) digest [ 0 ] & 0xFF ) ; x |= ( ( int ) digest [ 1 ] & 0xFF ) << 8 ; x |= ( ( int ) digest [ 2 ] & 0xFF ) << 16 ; x |= ( ( int ) digest [ 3 ] & 0xFF ) << 24 ; COUNTER . set ( x ) ; } sequential = true ;


signature:
public class UUID { /** * This method maps a hex character to its 4 - bit representation in an int .
 * @ param x Hex character in the range ( ' 0 ' - ' 9 ' , ' a ' - ' f ' , ' A ' - ' F ' ) .
 * @ return 4 - bit number in int representing hex offset from 0. */
private static int intValue ( char x ) { } }

implementation: if ( x >= '0' && x <= '9' ) return x - '0' ; if ( x >= 'a' && x <= 'f' ) return x - 'a' + 10 ; if ( x >= 'A' && x <= 'F' ) return x - 'A' + 10 ; throw new RuntimeException ( "Error parsing UUID at character: " + x ) ;


signature:
public class UUID { /** * Map two hex characters to 4 - bit numbers and combine them to produce 8 - bit number in byte .
 * @ param a First hex character .
 * @ param b Second hex character .
 * @ return Byte representation of given hex characters . */
private static byte mapToByte ( char a , char b ) { } }

implementation: int ai = intValue ( a ) ; int bi = intValue ( b ) ; return ( byte ) ( ( ai << 4 ) | bi ) ;


signature:
public class UUID { /** * Get the most significant bits ( the first half ) of the UUID content as a 64 - bit long .
 * @ return The first half of the UUID as a long . */
public long getMostSignificantBits ( ) { } }

implementation: long a ; a = ( ( long ) content [ 0 ] & 0xFF ) << 56 ; a |= ( ( long ) content [ 1 ] & 0xFF ) << 48 ; a |= ( ( long ) content [ 2 ] & 0xFF ) << 40 ; a |= ( ( long ) content [ 3 ] & 0xFF ) << 32 ; a |= ( ( long ) content [ 4 ] & 0xFF ) << 24 ; a |= ( ( long ) content [ 5 ] & 0xFF ) << 16 ; a |= ( ( long ) content [ 6 ] & 0xFF ) << 8 ; a |= ( ( long ) content [ 7 ] & 0xFF ) ; return a ;


signature:
public class UUID { /** * Get the least significant bits ( the second half ) of the UUID content as a 64 - bit long .
 * @ return The second half of the UUID as a long . */
public long getLeastSignificantBits ( ) { } }

implementation: long b ; b = ( ( long ) content [ 8 ] & 0xFF ) << 56 ; b |= ( ( long ) content [ 9 ] & 0xFF ) << 48 ; b |= ( ( long ) content [ 10 ] & 0xFF ) << 40 ; b |= ( ( long ) content [ 11 ] & 0xFF ) << 32 ; b |= ( ( long ) content [ 12 ] & 0xFF ) << 24 ; b |= ( ( long ) content [ 13 ] & 0xFF ) << 16 ; b |= ( ( long ) content [ 14 ] & 0xFF ) << 8 ; b |= ( ( long ) content [ 15 ] & 0xFF ) ; return b ;


signature:
public class UUID { /** * Extract timestamp from raw UUID bytes and return as int . If the UUID is not the default type , then we can ' t parse
 * the timestamp out and null is returned .
 * @ return Millisecond UTC timestamp from generation of the UUID , or null for unrecognized format . */
public Date getTimestamp ( ) { } }

implementation: if ( getVersion ( ) != VERSION ) return null ; long time ; time = ( ( long ) content [ 10 ] & 0xFF ) << 40 ; time |= ( ( long ) content [ 11 ] & 0xFF ) << 32 ; time |= ( ( long ) content [ 12 ] & 0xFF ) << 24 ; time |= ( ( long ) content [ 13 ] & 0xFF ) << 16 ; time |= ( ( long ) content [ 14 ] & 0xFF ) << 8 ; time |= ( ( long ) content [ 15 ] & 0xFF ) ; return new Date ( time ) ;


signature:
public class UUID { /** * Extract MAC address fragment from raw UUID bytes , setting missing values to 0 , thus the first 2 and a half bytes
 * will be 0 , followed by 3 and a half bytes of the active MAC address when the UUID was generated .
 * @ return Byte array of UUID fragment , or null for unrecognized format . */
public byte [ ] getMacFragment ( ) { } }

implementation: if ( getVersion ( ) != 'b' ) return null ; byte [ ] x = new byte [ 6 ] ; x [ 0 ] = 0 ; x [ 1 ] = 0 ; x [ 2 ] = ( byte ) ( content [ 6 ] & 0xF ) ; x [ 3 ] = content [ 7 ] ; x [ 4 ] = content [ 8 ] ; x [ 5 ] = content [ 9 ] ; return x ;


signature:
public class UUID { /** * Get the active MAC address on the current machine as a byte array . This is called when generating a new UUID .
 * Note that a machine can have multiple or no active MAC addresses . This method works by iterating through the list
 * of network interfaces , ignoring the loopback interface and any virtual interfaces ( which often have made - up
 * addresses ) , and returning the first one we find . If no valid addresses are found , then a byte array of the same
 * length with all zeros is returned .
 * @ return 6 - byte array for first active MAC address , or 6 - byte zeroed array if no interfaces are active . */
private static byte [ ] macAddress ( ) { } }

implementation:
try { Enumeration < NetworkInterface > interfaces = NetworkInterface . getNetworkInterfaces ( ) ; byte [ ] mac = null ; while ( interfaces . hasMoreElements ( ) && ( mac == null || mac . length != 6 ) ) { NetworkInterface netInterface = interfaces . nextElement ( ) ; if ( netInterface . isLoopback ( ) || netInterface . isVirtual ( ) ) continue ; mac = netInterface . getHardwareAddress ( ) ; } // if the machine is not connected to a network it has no active MAC address
if ( mac == null ) mac = new byte [ ] { 0 , 0 , 0 , 0 , 0 , 0 } ; return mac ; } catch ( Exception e ) { throw new RuntimeException ( "Could not get MAC address" ) ; }


signature:
public class UUID { /** * Get the process id of this JVM . I haven ' t tested this extensively so its possible that this performs differently
 * on esoteric JVMs . I copied this from :
 * http : / / stackoverflow . com / questions / 35842 / how - can - a - java - program - get - its - own - process - id
 * @ return Id of the current JVM process . */
private static int processId ( ) { } }

implementation:
// Note : may fail in some JVM implementations
// something like ' < pid > @ < hostname > ' , at least in SUN / Oracle JVMs
final String jvmName = ManagementFactory . getRuntimeMXBean ( ) . getName ( ) ; final int index = jvmName . indexOf ( '@' ) ; if ( index < 1 ) throw new RuntimeException ( "Could not get PID" ) ; try { return Integer . parseInt ( jvmName . substring ( 0 , index ) ) % MAX_PID ; } catch ( NumberFormatException e ) { throw new RuntimeException ( "Could not get PID" ) ; }


signature:
public class SocializeServiceImpl { /** * / * ( non - Javadoc )
 * @ see com . socialize . SocializeService # init ( android . content . Context ) */
@ Override public IOCContainer init ( Context context ) { } }

implementation: return init ( context , getSystem ( ) . getBeanConfig ( context ) ) ;


signature:
public class SocializeServiceImpl { /** * / * ( non - Javadoc )
 * @ see com . socialize . SocializeService # init ( android . content . Context , java . lang . String ) */
@ Override public IOCContainer init ( Context context , String ... paths ) { } }

implementation: try { return initWithContainer ( context , paths ) ; } catch ( Exception e ) { if ( logger != null ) { logger . error ( SocializeLogger . INITIALIZE_FAILED , e ) ; } else { SocializeLogger . e ( e . getMessage ( ) , e ) ; } } return null ;


signature:
public class SocializeServiceImpl { /** * ( non - Javadoc )
 * @ see com . socialize . SocializeService # initAsync ( android . content . Context , com . socialize . listener . SocializeInitListener ) */
@ Override public void initAsync ( Context context , SocializeInitListener listener ) { } }

implementation: initAsync ( context , listener , getSystem ( ) . getBeanConfig ( context ) ) ;


signature:
public class SocializeServiceImpl { /** * ( non - Javadoc )
 * @ see com . socialize . SocializeService # initAsync ( android . content . Context , com . socialize . listener . SocializeInitListener , java . lang . String [ ] ) */
@ Override public void initAsync ( Context context , SocializeInitListener listener , String ... paths ) { } }

implementation: new InitTask ( this , context , paths , listener , logger ) . execute ( ) ;


signature:
public class SocializeServiceImpl { /** * So we can mock */
protected int binarySearch ( String [ ] array , String str ) { } }

implementation:
// No longer a binary search because we don ' t want the list to be sorted as this distrubs the priority
for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] . equals ( str ) ) { return i ; } } return - 1 ;


signature:
public class SocializeServiceImpl { /** * / * ( non - Javadoc )
 * @ see com . socialize . SocializeService # init ( android . content . Context , com . socialize . android . ioc . IOCContainer ) */
@ Override public synchronized void init ( Context context , final IOCContainer container ) { } }

implementation: init ( context , container , getSystem ( ) . getSystemInitListener ( ) ) ;


signature:
public class SocializeServiceImpl { /** * ( non - Javadoc )
 * @ see com . socialize . SocializeService # destroy ( boolean ) */
@ Override public synchronized void destroy ( boolean force ) { } }

implementation: if ( force ) { if ( AsyncTaskManager . isManaged ( ) ) { AsyncTaskManager . terminateAll ( 10 , TimeUnit . SECONDS ) ; } if ( container != null ) { if ( logger != null && logger . isDebugEnabled ( ) ) { logger . debug ( "Destroying IOC container" ) ; } container . destroy ( ) ; } config . destroy ( ) ; system . destroy ( ) ; initCount = 0 ; initPaths = null ; entityLoader = null ; session = null ; authProviders = null ; } else { destroy ( ) ; }


signature:
public class SocializeServiceImpl { /** * ( non - Javadoc )
 * @ see com . socialize . SocializeService # authenticate ( android . content . Context , com . socialize . listener . SocializeAuthListener ) */
@ Override public synchronized void authenticate ( Context context , SocializeAuthListener authListener ) { } }

implementation: if ( assertInitialized ( context , authListener ) ) { userSystem . authenticate ( context , authListener , this ) ; }


signature:
public class SocializeServiceImpl { /** * ( non - Javadoc )
 * @ see com . socialize . SocializeService # isAuthenticatedForRead ( com . socialize . auth . AuthProviderType ) */
@ Override public boolean isAuthenticatedForRead ( AuthProviderType providerType , String ... permissions ) { } }

implementation: return isAuthenticated ( providerType , true , permissions ) ;


signature:
public class SocializeServiceImpl { /** * ( non - Javadoc )
 * @ see com . socialize . SocializeService # isAuthenticatedForWrite ( com . socialize . auth . AuthProviderType ) */
@ Override public boolean isAuthenticatedForWrite ( AuthProviderType providerType , String ... permissions ) { } }

implementation: return isAuthenticated ( providerType , false , permissions ) ;


signature:
public class SocializeServiceImpl { /** * ( non - Javadoc )
 * @ see com . socialize . SocializeService # isAuthenticated ( com . socialize . auth . AuthProviderType ) */
@ Deprecated @ Override public boolean isAuthenticated ( AuthProviderType providerType ) { } }

implementation: return isAuthenticated ( providerType , false , FacebookFacade . DEFAULT_PERMISSIONS ) ;


signature:
public class AbstractShareHandler { /** * / * ( non - Javadoc )
 * @ see com . socialize . share . ShareHandler # handle ( android . app . Activity , com . socialize . entity . Share , com . socialize . share . ShareHandlerListener ) */
@ Override public void handle ( final Activity context , final SocializeAction action , Location location , final String text , final SocialNetworkListener listener ) { } }

implementation: ShareType shareType = getShareType ( ) ; final SocialNetwork network = SocialNetwork . valueOf ( shareType ) ; PropagationInfoResponse propagationInfoResponse = action . getPropagationInfoResponse ( ) ; if ( propagationInfoResponse != null ) { final PropagationInfo propagationInfo = propagationInfoResponse . getPropagationInfo ( shareType ) ; if ( propagationInfo != null ) { try { if ( loopyService . isLoopyEnabled ( ) ) { if ( shareType . equals ( ShareType . OTHER ) ) { loopyService . showShareDialog ( context , "" , text , action . getEntity ( ) , propagationInfo , listener ) ; } else { loopyService . getTrackableUrl ( action . getEntity ( ) , shareType , propagationInfo . getEntityUrl ( ) , new ShareCallback ( ) { @ Override public void onResult ( Item item , Throwable error ) { PropagationInfo infoInUse = loopyService . setShortlinks ( propagationInfo , item , error ) ; try { handle ( context , action , text , infoInUse , listener ) ; } catch ( Exception e ) { if ( logger != null ) { logger . error ( "Error handling share" , e ) ; } if ( listener != null ) { listener . onNetworkError ( context , network , e ) ; } } } } ) ; } } else { handle ( context , action , text , propagationInfo , listener ) ; } } catch ( Exception e ) { if ( logger != null ) { logger . error ( "Error handling share" , e ) ; } if ( listener != null ) { listener . onNetworkError ( context , network , e ) ; } } } else { logError ( context , network , "No propagation info found for type [" + shareType + "].  Share will not propagate" , listener ) ; } } else { logError ( context , network , "No propagation info found for type [" + shareType + "].  Share will not propagate" , listener ) ; }


signature:
public class PostToWallActivity { /** * / * ( non - Javadoc )
 * @ see com . socialize . demo . DemoActivity # executeDemo ( ) */
@ Override public void executeDemo ( final String text ) { } }

implementation: if ( ! FacebookUtils . isLinkedForRead ( this , FacebookFacade . READ_PERMISSIONS ) ) { FacebookUtils . linkForRead ( this , new SocializeAuthListener ( ) { @ Override public void onError ( SocializeException error ) { handleError ( PostToWallActivity . this , error ) ; } @ Override public void onCancel ( ) { handleCancel ( ) ; } @ Override public void onAuthSuccess ( SocializeSession session ) { doPost ( text ) ; } @ Override public void onAuthFail ( SocializeException error ) { handleError ( PostToWallActivity . this , error ) ; } } , FacebookFacade . READ_PERMISSIONS ) ; } else { doPost ( text ) ; }


signature:
public class FacebookFacadeFactory { /** * / * ( non - Javadoc )
 * @ see com . socialize . android . ioc . IBeanMaker # getBeanName ( java . lang . Object , com . socialize . android . ioc . Container ) */
@ Override public String getBeanName ( Object parent , Container container ) { } }

implementation:
if ( FORCE_V2 ) { return v2BeanName ; } if ( beanName == null ) { try { Class . forName ( "com.facebook.Session" ) ; // We assume that if this class exists , we are v3 +
beanName = v3BeanName ; } catch ( ClassNotFoundException e ) { beanName = v2BeanName ; } } return beanName ;


signature:
public class CommonsHttpOAuthConsumerFactory { /** * / * ( non - Javadoc )
 * @ see com . socialize . oauth . OAuthConsumerFactory # createConsumer ( java . lang . String , java . lang . String ) */
@ Override public OAuthConsumer createConsumer ( String key , String secret ) { } }

implementation: return new CommonsHttpOAuthConsumer ( key , secret ) ;


signature:
public class OpenGraphActivity { /** * / * ( non - Javadoc )
 * @ see com . socialize . demo . SDKDemoActivity # executeDemo ( java . lang . String ) */
@ Override public void executeDemo ( final String text ) { } }

implementation:
// Link if we need to
FacebookUtils . linkForWrite ( this , new SocializeAuthListener ( ) { @ Override public void onError ( SocializeException error ) { handleError ( OpenGraphActivity . this , error ) ; } @ Override public void onCancel ( ) { handleCancel ( ) ; } @ Override public void onAuthSuccess ( SocializeSession session ) { // This could be a custom Open Graph path in the form namespace : action
final String graphPath = "me/og.likes" ; FacebookUtils . postEntity ( OpenGraphActivity . this , entity , text , new SocialNetworkShareListener ( ) { @ Override public boolean onBeforePost ( Activity parent , SocialNetwork socialNetwork , PostData postData ) { // Add / Change the contents of the post to fit with open graph
postData . setPath ( graphPath ) ; // Facebook like requires an " object " parameter
postData . getPostValues ( ) . put ( "object" , postData . getPropagationInfo ( ) . getEntityUrl ( ) ) ; return false ; } @ Override public void onNetworkError ( Activity context , SocialNetwork network , Exception error ) { handleError ( OpenGraphActivity . this , error ) ; } @ Override public void onCancel ( ) { handleCancel ( ) ; } @ Override public void onAfterPost ( Activity parent , SocialNetwork socialNetwork , JSONObject responseObject ) { try { handleResult ( responseObject . toString ( 4 ) ) ; } catch ( JSONException e ) { handleError ( OpenGraphActivity . this , e ) ; } } } ) ; } @ Override public void onAuthFail ( SocializeException error ) { handleError ( OpenGraphActivity . this , error ) ; } } ) ;


signature:
public class SocializeConfig { /** * Sets a custom property . This will override settings in socialize . properties .
 * @ param key
 * @ param value */
public void setProperty ( String key , String value ) { } }

implementation: if ( properties == null ) { properties = createProperties ( ) ; } if ( value != null ) { value = value . trim ( ) ; properties . put ( key , value ) ; } else { properties . remove ( key ) ; }


signature:
public class SocializeConfig { /** * Sets the Twitter App consumer key / secret pair for Twitter authentication .
 * @ param consumerKey Your Twitter App consumer key , obtained from https : / / dev . twitter . com /
 * @ param consumerSecret Your Twitter App consumer secret , obtained from https : / / dev . twitter . com / */
public void setTwitterKeySecret ( String consumerKey , String consumerSecret ) { } }

implementation: setProperty ( SocializeConfig . TWITTER_CONSUMER_KEY , consumerKey ) ; setProperty ( SocializeConfig . TWITTER_CONSUMER_SECRET , consumerSecret ) ;


signature:
public class SocializeConfig { /** * Sets the FB credentials for the current user if available .
 * @ param userId
 * @ param token
 * @ deprecated No longer used . Any values set here will be ignored . Use FacebookUtils to link a known user . */
@ Deprecated public void setFacebookUserCredentials ( String userId , String token ) { } }

implementation: setProperty ( SocializeConfig . FACEBOOK_USER_ID , userId ) ; setProperty ( SocializeConfig . FACEBOOK_USER_TOKEN , token ) ;


signature:
public class SocializeConfig { /** * Sets the Socialize credentials for your App .
 * @ param consumerKey Your consumer key , obtained via registration at http : / / getsocialize . com
 * @ param consumerSecret Your consumer secret , obtained via registration at http : / / getsocialize . com */
public void setSocializeCredentials ( String consumerKey , String consumerSecret ) { } }

implementation: setProperty ( SocializeConfig . SOCIALIZE_CONSUMER_KEY , consumerKey ) ; setProperty ( SocializeConfig . SOCIALIZE_CONSUMER_SECRET , consumerSecret ) ;


signature:
public class SocializeConfig { /** * Merge properties into the config .
 * @ param other */
public void merge ( Properties other , Set < String > toBeRemoved ) { } }

implementation: if ( properties == null ) { properties = createProperties ( ) ; } if ( other != null && other . size ( ) > 0 ) { Set < Entry < Object , Object > > entrySet = other . entrySet ( ) ; for ( Entry < Object , Object > entry : entrySet ) { properties . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } } if ( toBeRemoved != null && toBeRemoved . size ( ) > 0 ) { for ( String key : toBeRemoved ) { properties . remove ( key ) ; } toBeRemoved . clear ( ) ; }


signature:
public class SocializeShareSystem { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . ShareSystem # addShare ( android . content . Context , com . socialize . api . SocializeSession , com . socialize . entityKey . Entity , java . lang . String , com . socialize . api . action . ShareType , android . location . Location , com . socialize . listener . share . ShareListener ) */
@ Override public void addShare ( Context context , SocializeSession session , Entity entity , String text , ShareType shareType , Location location , ShareListener listener ) { } }

implementation: addShare ( context , session , entity , text , shareType , null , location , listener ) ;


signature:
public class SocializeShareSystem { /** * / * ( non - Javadoc )
 * @ see com . socialize . api . action . ShareSystem # getSharesByEntity ( com . socialize . api . SocializeSession , java . lang . String , int , int , com . socialize . listener . share . ShareListener ) */
@ Override public void getSharesByEntity ( SocializeSession session , String key , int startIndex , int endIndex , ShareListener listener ) { } }

implementation: listAsync ( session , ENDPOINT , key , null , null , startIndex , endIndex , listener ) ;


signature:
public class SocializeShareSystem { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareSystem # getSharesByApplication ( com . socialize . api . SocializeSession , int , int , com . socialize . listener . share . ShareListener ) */
@ Override public void getSharesByApplication ( SocializeSession session , int startIndex , int endIndex , ShareListener listener ) { } }

implementation: listAsync ( session , ENDPOINT , null , null , null , startIndex , endIndex , listener ) ;


signature:
public class SocializeShareSystem { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareSystem # getSharesByUser ( com . socialize . api . SocializeSession , long , int , int , com . socialize . listener . share . ShareListener ) */
@ Override public void getSharesByUser ( SocializeSession session , long userId , int startIndex , int endIndex , ShareListener listener ) { } }

implementation: String endpoint = "/user/" + userId + ENDPOINT ; listAsync ( session , endpoint , startIndex , endIndex , listener ) ;


signature:
public class SocializeShareSystem { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareSystem # getShare ( com . socialize . api . SocializeSession , long , com . socialize . listener . share . ShareListener ) */
@ Override public void getShare ( SocializeSession session , long id , ShareListener listener ) { } }

implementation: getAsync ( session , ENDPOINT , String . valueOf ( id ) , listener ) ;


signature:
public class SocializeShareSystem { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareSystem # getSharesById ( com . socialize . api . SocializeSession , com . socialize . listener . share . ShareListener , long [ ] ) */
@ Override public void getSharesById ( SocializeSession session , ShareListener listener , long ... ids ) { } }

implementation: if ( ids != null ) { String [ ] strIds = new String [ ids . length ] ; for ( int i = 0 ; i < ids . length ; i ++ ) { strIds [ i ] = String . valueOf ( ids [ i ] ) ; } listAsync ( session , ENDPOINT , null , 0 , SocializeConfig . MAX_LIST_RESULTS , listener , strIds ) ; } else { if ( listener != null ) { listener . onError ( new SocializeException ( "No ids supplied" ) ) ; } }


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # getUserShareOptions ( android . content . Context ) */
@ Override public ShareOptions getUserShareOptions ( Context context ) { } }

implementation: ShareOptions options = new ShareOptions ( ) ; populateActionOptions ( context , options ) ; return options ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # showLinkDialog ( android . app . Activity , com . socialize . ui . auth . AuthDialogListener ) */
@ Override public void showLinkDialog ( Activity context , AuthDialogListener listener ) { } }

implementation: authDialogFactory . show ( context , listener , ! config . isAllowSkipAuthOnAllActions ( ) ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # showShareDialog ( android . app . Activity , com . socialize . entity . Entity , int , com . socialize . api . action . share . SocialNetworkShareListener , com . socialize . ui . share . ShareDialogListener ) */
@ Override public void showShareDialog ( final Activity context , final Entity entity , int options , final SocialNetworkShareListener socialNetworkListener , final ShareDialogListener dialogListener ) { } }

implementation:
shareDialogFactory . show ( context , entity , socialNetworkListener , new ShareDialogListener ( ) { SharePanelView dialogView ; @ Override public void onCancel ( Dialog dialog ) { if ( dialogListener != null ) { dialogListener . onCancel ( dialog ) ; } } @ Override public void onShow ( Dialog dialog , SharePanelView dialogView ) { if ( dialogListener != null ) { dialogListener . onShow ( dialog , dialogView ) ; } this . dialogView = dialogView ; } @ Override public void onSimpleShare ( ShareType type ) { if ( dialogListener != null ) { dialogListener . onSimpleShare ( type ) ; } } @ Override public void onFlowInterrupted ( DialogFlowController controller ) { // Will not be called .
} @ Override public boolean onContinue ( final Dialog dialog , boolean remember , final SocialNetwork ... networks ) { boolean consumed = false ; if ( dialogListener != null ) { consumed = dialogListener . onContinue ( dialog , remember , networks ) ; } if ( ! consumed ) { doShare ( dialog , context , entity , socialNetworkListener , networks ) ; } else { dialogListener . onFlowInterrupted ( new DialogFlowController ( ) { @ Override public void onContinue ( String text ) { ShareOptions options = new ShareOptions ( ) ; options . setText ( text ) ; doShare ( dialog , context , entity , socialNetworkListener , options , networks ) ; } @ Override public void onCancel ( ) { if ( dialogView != null ) { dialogView . getContinueButton ( ) . setEnabled ( true ) ; } dialogListener . onCancel ( dialog ) ; } } ) ; } return false ; } } , options ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # registerShare ( android . app . Activity , com . socialize . entity . Entity , com . socialize . api . action . share . ShareOptions , com . socialize . listener . share . ShareAddListener , com . socialize . networks . SocialNetwork [ ] ) */
@ Override public void registerShare ( Activity context , Entity entity , ShareOptions shareOptions , ShareAddListener listener , SocialNetwork ... networks ) { } }

implementation: String text = null ; if ( shareOptions != null ) text = shareOptions . getText ( ) ; if ( text == null ) text = "" ; ShareType shareType = ShareType . OTHER ; if ( networks != null && networks . length > 0 ) { if ( networks . length == 1 ) { shareType = ShareType . valueOf ( networks [ 0 ] ) ; } } shareSystem . addShare ( context , getSocialize ( ) . getSession ( ) , entity , text , shareType , listener , networks ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # shareViaEmail ( android . app . Activity , com . socialize . entity . Entity , com . socialize . listener . share . ShareAddListener ) */
@ Override public void shareViaEmail ( Activity context , Entity entity , ShareAddListener listener ) { } }

implementation: doShare ( context , entity , ShareType . EMAIL , listener ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # shareViaGooglePlus ( android . app . Activity , com . socialize . entity . Entity , com . socialize . listener . share . ShareAddListener ) */
@ Override public void shareViaGooglePlus ( Activity context , Entity entity , ShareAddListener listener ) { } }

implementation: doShare ( context , entity , ShareType . GOOGLE_PLUS , listener ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # shareViaOther ( android . app . Activity , com . socialize . entity . Entity , com . socialize . listener . share . ShareAddListener ) */
@ Override public void shareViaOther ( Activity context , Entity entity , ShareAddListener listener ) { } }

implementation: doShare ( context , entity , ShareType . OTHER , listener ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # shareViaSMS ( android . app . Activity , com . socialize . entity . Entity , com . socialize . listener . share . ShareAddListener ) */
@ Override public void shareViaSMS ( Activity context , Entity entity , ShareAddListener listener ) { } }

implementation: doShare ( context , entity , ShareType . SMS , listener ) ;


signature:
public class SocializeShareUtils { /** * Creates the socialize share object . */
protected void doShare ( final Activity context , final Entity entity , final ShareType shareType , final ShareAddListener shareAddListener ) { } }

implementation: final SocializeSession session = getSocialize ( ) . getSession ( ) ; shareSystem . addShare ( context , session , entity , "" , shareType , null , new ShareAddListener ( ) { @ Override public void onError ( SocializeException error ) { if ( shareAddListener != null ) { shareAddListener . onError ( error ) ; } } @ Override public void onCreate ( Share share ) { if ( share != null && shareSystem != null ) { handleNonNetworkShare ( context , session , shareType , share , "" , null , shareAddListener ) ; } } } ) ;


signature:
public class SocializeShareUtils { /** * Handles a non - network share like email or SMS . */
protected void handleNonNetworkShare ( Activity activity , final SocializeSession session , final ShareType shareType , final Share share , String shareText , Location location , final ShareAddListener shareAddListener ) { } }

implementation: SocialNetworkListener snListener = new SocialNetworkListener ( ) { @ Override public void onNetworkError ( Activity context , SocialNetwork network , Exception error ) { if ( shareAddListener != null ) { shareAddListener . onError ( SocializeException . wrap ( error ) ) ; } } @ Override public void onCancel ( ) { if ( shareAddListener != null ) { shareAddListener . onCancel ( ) ; } } @ Override public boolean onBeforePost ( Activity parent , SocialNetwork socialNetwork , PostData postData ) { return shareAddListener instanceof SocialNetworkListener && ( ( SimpleShareListener ) shareAddListener ) . onBeforePost ( parent , socialNetwork , postData ) ; } @ Override public void onAfterPost ( Activity parent , SocialNetwork socialNetwork , JSONObject responseObject ) { if ( shareAddListener != null ) { shareAddListener . onCreate ( share ) ; } } } ; shareSystem . share ( activity , session , share , shareText , location , shareType , snListener ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # shareViaSocialNetworks ( android . app . Activity , com . socialize . entity . Entity , com . socialize . api . action . share . ShareOptions , com . socialize . api . action . share . SocialNetworkShareListener , com . socialize . networks . SocialNetwork [ ] ) */
@ Override public void shareViaSocialNetworks ( Activity context , final Entity entity , final ShareOptions shareOptions , final SocialNetworkShareListener listener , final SocialNetwork ... networks ) { } }

implementation: final SocializeSession session = getSocialize ( ) . getSession ( ) ; if ( isDisplayAuthDialog ( context , session , shareOptions , networks ) ) { authDialogFactory . show ( context , new AuthDialogListener ( ) { @ Override public void onShow ( Dialog dialog , AuthPanelView dialogView ) { } @ Override public void onCancel ( Dialog dialog ) { if ( listener != null ) { listener . onCancel ( ) ; } } @ Override public void onSkipAuth ( Activity context , Dialog dialog ) { dialog . dismiss ( ) ; doShare ( context , entity , listener , shareOptions , networks ) ; } @ Override public void onError ( Activity context , Dialog dialog , Exception error ) { dialog . dismiss ( ) ; if ( listener != null ) { listener . onError ( SocializeException . wrap ( error ) ) ; } } @ Override public void onAuthenticate ( Activity context , Dialog dialog , SocialNetwork network ) { dialog . dismiss ( ) ; doShare ( context , entity , listener , shareOptions , network ) ; } } , ! config . isAllowSkipAuthOnAllActions ( ) ) ; } else { doShare ( context , entity , listener , shareOptions , networks ) ; }


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # getShare ( android . app . Activity , com . socialize . listener . share . ShareGetListener , long ) */
@ Override public void getShare ( Activity context , ShareGetListener listener , long id ) { } }

implementation: shareSystem . getShare ( getSocialize ( ) . getSession ( ) , id , listener ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # getShares ( android . app . Activity , com . socialize . listener . share . ShareListListener , long [ ] ) */
@ Override public void getShares ( Activity context , ShareListListener listener , long ... ids ) { } }

implementation: shareSystem . getSharesById ( getSocialize ( ) . getSession ( ) , listener , ids ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # getSharesByUser ( android . app . Activity , long , int , int , com . socialize . listener . share . ShareListListener ) */
@ Override public void getSharesByUser ( Activity context , User user , int start , int end , ShareListListener listener ) { } }

implementation: shareSystem . getSharesByUser ( getSocialize ( ) . getSession ( ) , user . getId ( ) , start , end , listener ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # getSharesByEntity ( android . app . Activity , java . lang . String , int , int , com . socialize . listener . share . ShareListListener ) */
@ Override public void getSharesByEntity ( Activity context , String entityKey , int start , int end , ShareListListener listener ) { } }

implementation: shareSystem . getSharesByEntity ( getSocialize ( ) . getSession ( ) , entityKey , start , end , listener ) ;


signature:
public class SocializeShareUtils { /** * ( non - Javadoc )
 * @ see com . socialize . api . action . share . ShareUtilsProxy # getSharesByApplication ( android . app . Activity , int , int , com . socialize . listener . share . ShareListListener ) */
@ Override public void getSharesByApplication ( Activity context , int start , int end , ShareListListener listener ) { } }

implementation: shareSystem . getSharesByApplication ( getSocialize ( ) . getSession ( ) , start , end , listener ) ;


signature:
public class CommentUtils { /** * Adds a comment to the given entity . This method will also prompt the user to share their comment .
 * @ param context The current context .
 * @ param entity The entity on which the comment will be associated .
 * @ param text The text of the comment .
 * @ param listener A listener to handle the result . */
public static void addComment ( Activity context , Entity entity , String text , CommentAddListener listener ) { } }

implementation: proxy . addComment ( context , entity , text , listener ) ;


signature:
public class CommentUtils { /** * Deletes a comment . Only the person that created the comment can delete it .
 * @ param context The current context .
 * @ param id The ID of the comment to be deleted .
 * @ param listener A listener to handle the result . */
public static void deleteComment ( Activity context , long id , CommentDeleteListener listener ) { } }

implementation: proxy . deleteComment ( context , id , listener ) ;


signature:
public class CommentUtils { /** * Adds a comment to the given entity . This method will NOT prompt the user to share their comment as the desired networks are passed as a parameter .
 * @ param context The current context .
 * @ param entity The entity on which the comment will be associated .
 * @ param text The text of the comment .
 * @ param commentOptions Optional parameters for the comment .
 * @ param listener A listener to handle the result .
 * @ param networks 0 or more networks on which to share the comment . It is assumed that the user is already linked to the given networks . If not an error will be reported in the listener for each propagation failure . */
public static void addComment ( Activity context , Entity entity , String text , CommentOptions commentOptions , CommentAddListener listener , SocialNetwork ... networks ) { } }

implementation: proxy . addComment ( context , entity , text , commentOptions , listener , networks ) ;


signature:
public class CommentUtils { /** * Retrieves a single comment based on ID .
 * @ param context The current context .
 * @ param id
 * @ param listener A listener to handle the result . */
public static void getComment ( Activity context , CommentGetListener listener , long id ) { } }

implementation: proxy . getComment ( context , id , listener ) ;


signature:
public class CommentUtils { /** * Retrieves comments based on a set of IDs .
 * @ param context The current context .
 * @ param listener A listener to handle the result .
 * @ param ids An array of comment IDs */
public static void getComments ( Activity context , CommentListListener listener , long ... ids ) { } }

implementation: proxy . getComments ( context , listener , ids ) ;


signature:
public class CommentUtils { /** * Retrieves all comments made by the given user .
 * @ param context The current context .
 * @ param user The user .
 * @ param start The start index for pagination ( from 0 ) .
 * @ param end The end index for pagination .
 * @ param listener A listener to handle the result . */
public static void getCommentsByUser ( Activity context , User user , int start , int end , CommentListListener listener ) { } }

implementation: proxy . getCommentsByUser ( context , user , start , end , listener ) ;


signature:
public class CommentUtils { /** * Retrieves all comments associated with the given entity .
 * @ param context The current context .
 * @ param entityKey The entity on which the comment were associated .
 * @ param start The start index for pagination ( from 0 ) .
 * @ param end The end index for pagination .
 * @ param listener A listener to handle the result . */
public static void getCommentsByEntity ( Activity context , String entityKey , int start , int end , CommentListListener listener ) { } }

implementation: proxy . getCommentsByEntity ( context , entityKey , start , end , listener ) ;


signature:
public class CommentUtils { /** * Retrieves all comments across all entities .
 * @ param context The current context .
 * @ param start The start index for pagination ( from 0 ) .
 * @ param end The end index for pagination .
 * @ param listener A listener to handle the result . */
public static void getCommentsByApplication ( Activity context , int start , int end , CommentListListener listener ) { } }

implementation: proxy . getCommentsByApplication ( context , start , end , listener ) ;


signature:
public class CommentUtils { /** * Shows the comments for an entity .
 * @ param listener A listener to handle the result . */
public static void showCommentView ( Activity context , Entity entity , OnCommentViewActionListener listener ) { } }

implementation: proxy . showCommentView ( context , entity , listener ) ;


signature:
public class CommentListLauncher { /** * / * ( non - Javadoc )
 * @ see com . socialize . launcher . Launcher # launch ( android . app . Activity , android . os . Bundle ) */
@ Override public boolean launch ( Activity context , Bundle data ) { } }

implementation:
if ( entityLoaderUtils != null ) { entityLoaderUtils . initEntityLoader ( ) ; } // Expect an action id
Object idObj = data . get ( Socialize . ACTION_ID ) ; String actionType = data . getString ( Socialize . ACTION_TYPE ) ; if ( idObj != null && ! StringUtils . isEmpty ( actionType ) ) { long id = Long . parseLong ( idObj . toString ( ) ) ; try { ActionType type = ActionType . valueOf ( actionType ) ; SocializeSession session = notificationAuthenticator . authenticate ( context ) ; SocializeAction action = activitySystem . getAction ( session , id , type ) ; if ( action != null ) { CommentUtils . showCommentView ( context , action . getEntity ( ) ) ; return true ; } else { handleWarn ( "No action found for id [" + id + "]." ) ; } } catch ( SocializeException e ) { handleError ( "Failed to load entity" , e ) ; } } else { handleWarn ( "No action id found.  Action based notification cannot be handled" ) ; } return false ;


signature:
public class JSONParser { /** * Detects whether the inbound string is a JSONArray and if so wraps the array in an object with a single field called " data "
 * @ param json
 * @ return */
public JSONObject parseObject ( String json ) throws JSONException { } }

implementation: json = json . trim ( ) ; if ( json . startsWith ( "[" ) ) { JSONArray array = new JSONArray ( json ) ; JSONObject obj = new JSONObject ( ) ; obj . put ( "data" , array ) ; return obj ; } else { return new JSONObject ( json ) ; }


signature:
public class Util { /** * Connect to an HTTP URL and return the response as a string .
 * Note that the HTTP method override is used on non - GET requests . ( i . e .
 * requests are made as " POST " with method specified in the body ) .
 * @ param url - the resource to open : must be a welformed URL
 * @ param method - the HTTP method to use ( " GET " , " POST " , etc . )
 * @ param params - the query parameter for the URL ( e . g . access _ token = foo )
 * @ return the URL contents as a String
 * @ throws MalformedURLException - if the URL format is invalid
 * @ throws IOException - if a network problem occurs */
public static String openUrl ( String url , String method , Bundle params ) throws MalformedURLException , IOException { } }

implementation:
// random string as boundary for multi - part http post
String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f" ; String endLine = "\r\n" ; OutputStream os ; if ( method . equals ( "GET" ) ) { url = url + "?" + encodeUrl ( params ) ; } Util . logd ( "Facebook-Util" , method + " URL: " + url ) ; HttpURLConnection conn = ( HttpURLConnection ) new URL ( url ) . openConnection ( ) ; conn . setRequestProperty ( "User-Agent" , System . getProperties ( ) . getProperty ( "http.agent" ) + " FacebookAndroidSDK" ) ; if ( ! method . equals ( "GET" ) ) { Bundle dataparams = new Bundle ( ) ; for ( String key : params . keySet ( ) ) { Object parameter = params . get ( key ) ; if ( parameter instanceof byte [ ] ) { dataparams . putByteArray ( key , ( byte [ ] ) parameter ) ; } } // use method override
if ( ! params . containsKey ( "method" ) ) { params . putString ( "method" , method ) ; } if ( params . containsKey ( "access_token" ) ) { String decoded_token = URLDecoder . decode ( params . getString ( "access_token" ) ) ; params . putString ( "access_token" , decoded_token ) ; } conn . setRequestMethod ( "POST" ) ; conn . setRequestProperty ( "Content-Type" , "multipart/form-data;boundary=" + strBoundary ) ; conn . setDoOutput ( true ) ; conn . setDoInput ( true ) ; conn . setRequestProperty ( "Connection" , "Keep-Alive" ) ; conn . connect ( ) ; os = new BufferedOutputStream ( conn . getOutputStream ( ) ) ; os . write ( ( "--" + strBoundary + endLine ) . getBytes ( ) ) ; os . write ( ( encodePostBody ( params , strBoundary ) ) . getBytes ( ) ) ; os . write ( ( endLine + "--" + strBoundary + endLine ) . getBytes ( ) ) ; if ( ! dataparams . isEmpty ( ) ) { for ( String key : dataparams . keySet ( ) ) { os . write ( ( "Content-Disposition: form-data; filename=\"" + key + "\"" + endLine ) . getBytes ( ) ) ; os . write ( ( "Content-Type: content/unknown" + endLine + endLine ) . getBytes ( ) ) ; os . write ( dataparams . getByteArray ( key ) ) ; os . write ( ( endLine + "--" + strBoundary + endLine ) . getBytes ( ) ) ; } } os . flush ( ) ; } String response = "" ; try { response = read ( conn . getInputStream ( ) ) ; } catch ( FileNotFoundException e ) { // Error Stream contains JSON that we can parse to a FB error
response = read ( conn . getErrorStream ( ) ) ; } return response ; } private static String read ( InputStream in ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; BufferedReader r = new BufferedReader ( new InputStreamReader ( in ) , 1000 ) ; for ( String line = r . readLine ( ) ; line != null ; line = r . readLine ( ) ) { sb . append ( line ) ; } in . close ( ) ; return sb . toString ( ) ; } public static void clearCookies ( Context context ) { // Edge case : an illegal state exception is thrown if an instance of
// CookieSyncManager has not be created . CookieSyncManager is normally
// created by a WebKit view , but this might happen if you start the
// app , restore saved state , and click logout before running a UI
// dialog in a WebView - - in which case the app crashes
@ SuppressWarnings ( "unused" ) CookieSyncManager cookieSyncMngr = CookieSyncManager . createInstance ( context ) ; CookieManager cookieManager = CookieManager . getInstance ( ) ; cookieManager . removeAllCookie ( ) ;


signature:
public class Util { /** * Parse a server response into a JSON Object . This is a basic
 * implementation using org . json . JSONObject representation . More
 * sophisticated applications may wish to do their own parsing .
 * The parsed JSON is checked for a variety of error fields and
 * a FacebookException is thrown if an error condition is set ,
 * populated with the error message and error type or code if
 * available .
 * @ param response - string representation of the response
 * @ return the response as a JSON Object
 * @ throws JSONException - if the response is not valid JSON
 * @ throws FacebookError - if an error condition is set */
public static JSONObject parseJson ( String response ) throws JSONException , FacebookError { } }

implementation:
// Edge case : when sending a POST request to / [ post _ id ] / likes
// the return value is ' true ' or ' false ' . Unfortunately
// these values cause the JSONObject constructor to throw
// an exception .
if ( response . equals ( "false" ) ) { throw new FacebookError ( "request failed" ) ; } if ( response . equals ( "true" ) ) { response = "{value : true}" ; } JSONObject json = new JSONObject ( response ) ; // errors set by the server are not consistent
// they depend on the method and endpoint
if ( json . has ( "error" ) ) { JSONObject error = json . getJSONObject ( "error" ) ; throw new FacebookError ( error . getString ( "message" ) , error . getString ( "type" ) , 0 ) ; } if ( json . has ( "error_code" ) && json . has ( "error_msg" ) ) { throw new FacebookError ( json . getString ( "error_msg" ) , "" , Integer . parseInt ( json . getString ( "error_code" ) ) ) ; } if ( json . has ( "error_code" ) ) { throw new FacebookError ( "request failed" , "" , Integer . parseInt ( json . getString ( "error_code" ) ) ) ; } if ( json . has ( "error_msg" ) ) { throw new FacebookError ( json . getString ( "error_msg" ) ) ; } if ( json . has ( "error_reason" ) ) { throw new FacebookError ( json . getString ( "error_reason" ) ) ; } return json ;


signature:
public class Util { /** * Display a simple alert dialog with the given text and title .
 * @ param context
 * Android context in which the dialog should be displayed
 * @ param title
 * Alert dialog title
 * @ param text
 * Alert dialog message */
public static void showAlert ( Context context , String title , String text ) { } }

implementation: Builder alertBuilder = new Builder ( context ) ; alertBuilder . setTitle ( title ) ; alertBuilder . setMessage ( text ) ; alertBuilder . create ( ) . show ( ) ;


signature:
public class Util { /** * A proxy for Log . d api that kills log messages in release build . It
 * not recommended to send sensitive information to log output in
 * shipping apps .
 * @ param tag
 * @ param msg */
public static void logd ( String tag , String msg ) { } }

implementation: if ( ENABLE_LOG ) { Log . d ( tag , msg ) ; }


signature:
public class SocializeInitSnippetA { /** * begin - snippet - 0 */
@ Override protected void onCreate ( Bundle savedInstanceState ) { } }

implementation:
super . onCreate ( savedInstanceState ) ; // Initialize socialize
Socialize . initAsync ( this , new SocializeInitListener ( ) { @ Override public void onError ( SocializeException error ) { // Handle error
} @ Override public void onInit ( Context context , IOCContainer container ) { // If you want to access Socialize directly , do it here
} } ) ;


signature:
public class TypeAdapterRuntimeTypeWrapper { /** * Finds a compatible runtime type if it is more specific */
private Type getRuntimeTypeIfMoreSpecific ( Type type , Object value ) { } }

implementation: if ( value != null && ( type == Object . class || type instanceof TypeVariable < ? > || type instanceof Class < ? > ) ) { type = value . getClass ( ) ; } return type ;


signature:
public class TwitterUtilsImpl { /** * / * ( non - Javadoc )
 * @ see com . socialize . networks . twitter . TwitterUtilsProxy # link ( android . app . Activity , com . socialize . listener . SocializeAuthListener ) */
@ Override public void link ( Activity context , SocializeAuthListener listener ) { } }

implementation: getSocialize ( ) . authenticateForWrite ( context , AuthProviderType . TWITTER , listener ) ;


signature:
public class TwitterUtilsImpl { /** * / * ( non - Javadoc )
 * @ see com . socialize . networks . twitter . TwitterUtilsProxy # link ( android . app . Activity , java . lang . String , java . lang . String , com . socialize . listener . SocializeAuthListener ) */
@ Override public void link ( Activity context , String token , String secret , SocializeAuthListener listener ) { } }

implementation: TwitterAuthProviderInfo twInfo = new TwitterAuthProviderInfo ( ) ; twInfo . setConsumerKey ( config . getProperty ( SocializeConfig . TWITTER_CONSUMER_KEY ) ) ; twInfo . setConsumerSecret ( config . getProperty ( SocializeConfig . TWITTER_CONSUMER_SECRET ) ) ; DefaultUserProviderCredentials credentials = new DefaultUserProviderCredentials ( ) ; credentials . setAuthProviderInfo ( twInfo ) ; credentials . setAccessToken ( token ) ; credentials . setTokenSecret ( secret ) ; getSocialize ( ) . authenticateKnownUser ( context , credentials , listener ) ;


signature:
public class TwitterUtilsImpl { /** * / * ( non - Javadoc )
 * @ see com . socialize . networks . twitter . TwitterUtilsProxy # unlink ( android . app . Activity ) */
@ Override public void unlink ( Context context ) { } }

implementation: SocializeSession session = getSocialize ( ) . getSession ( ) ; session . clear ( AuthProviderType . TWITTER ) ; session . getUserSettings ( ) . setAutoPostTwitter ( false ) ; userSystem . saveSession ( context , session ) ;


signature:
public class TwitterUtilsImpl { /** * / * ( non - Javadoc )
 * @ see com . socialize . networks . twitter . TwitterUtilsProxy # setCredentials ( android . content . Context , java . lang . String , java . lang . String ) */
@ Override public void setCredentials ( Context context , String consumerKey , String consumerSecret ) { } }

implementation: config . setTwitterKeySecret ( consumerKey , consumerSecret ) ;


signature:
public class AddCommentActivity { /** * / * ( non - Javadoc )
 * @ see com . socialize . demo . DemoActivity # executeDemo ( ) */
@ Override public void executeDemo ( String text ) { } }

implementation: CommentUtils . addComment ( this , entity , text , new CommentAddListener ( ) { @ Override public void onError ( SocializeException error ) { handleError ( AddCommentActivity . this , error ) ; } @ Override public void onCreate ( Comment comment ) { handleSocializeResult ( comment ) ; } @ Override public void onCancel ( ) { handleCancel ( ) ; } } ) ;


signature:
public class SocializeAction { /** * Reverts to only set the entity key if the name is not defined .
 * This ensures an existing entity name is not wiped out when the action is saved .
 * @ param entity */
public void setEntitySafe ( Entity entity ) { } }

implementation: if ( StringUtils . isEmpty ( entity . getName ( ) ) ) { setEntityKey ( entity . getKey ( ) ) ; } else { setEntity ( entity ) ; }


signature:
public class SocializeAction { /** * Returns the text to display for this action when rendering on screen ( e . g . in a list )
 * @ return */
public String getDisplayText ( ) { } }

implementation: if ( entity != null ) { String name = entity . getName ( ) ; String key = entity . getKey ( ) ; if ( ! StringUtils . isEmpty ( name ) ) { return name ; } return key ; } return entityKey ;


signature:
public class FacebookUrlBuilder { /** * Constructs the URL to access the FB graph API and retrieve a profile image for the
 * user with the given facebook id .
 * @ param id
 * @ return */
public String buildProfileImageUrl ( String id ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; builder . append ( "http://graph.facebook.com/" ) ; builder . append ( id ) ; builder . append ( "/picture?type=large" ) ; return builder . toString ( ) ;


signature:
public class TwitterAuthWebView { /** * Starts the authentication process using the given twitter key / secret .
 * @ param consumerKey
 * @ param consumerSecret */
public synchronized void authenticate ( final String consumerKey , final String consumerSecret , final TwitterAuthListener listener ) { } }

implementation: TwitterOAuthProvider provider = newTwitterOAuthProvider ( ) ; CommonsHttpOAuthConsumer consumer = newCommonsHttpOAuthConsumer ( consumerKey , consumerSecret ) ; OAuthRequestListener oAuthRequestListener = newOAuthRequestListener ( listener , provider , consumer ) ; twitterWebViewClient . setOauthRequestListener ( oAuthRequestListener ) ; provider . retrieveRequestTokenAsync ( consumer , TwitterOAuthProvider . OAUTH_CALLBACK_URL , newOAuthRequestTokenUrlListener ( listener ) ) ;


signature:
public class ProfileLayoutView { /** * Called when the profile picture has been changed by the user .
 * @ param bitmap */
public void onImageChange ( Bitmap bitmap ) { } }

implementation: if ( bitmap != null ) { Bitmap scaled = bitmapUtils . getScaledBitmap ( bitmap , 200 , 200 ) ; content . onProfilePictureChange ( scaled ) ; }


signature:
public class SignatureBaseString { /** * Builds the signature base string from the data this instance was
 * configured with .
 * @ return the signature base string
 * @ throws OAuthMessageSignerException */
public String generate ( ) throws OAuthMessageSignerException { } }

implementation: try { String normalizedUrl = normalizeRequestUrl ( ) ; String normalizedParams = normalizeRequestParameters ( ) ; return request . getMethod ( ) + '&' + OAuth . percentEncode ( normalizedUrl ) + '&' + OAuth . percentEncode ( normalizedParams ) ; } catch ( Exception e ) { throw new OAuthMessageSignerException ( e ) ; }


signature:
public class SignatureBaseString { /** * Normalizes the set of request parameters this instance was configured
 * with , as per OAuth spec section 9.1.1.
 * @ param parameters
 * the set of request parameters
 * @ return the normalized params string
 * @ throws IOException */
public String normalizeRequestParameters ( ) throws IOException { } }

implementation: if ( requestParameters == null ) { return "" ; } StringBuilder sb = new StringBuilder ( ) ; Iterator < String > iter = requestParameters . keySet ( ) . iterator ( ) ; for ( int i = 0 ; iter . hasNext ( ) ; i ++ ) { String param = iter . next ( ) ; if ( OAuth . OAUTH_SIGNATURE . equals ( param ) || "realm" . equals ( param ) ) { continue ; } if ( i > 0 ) { sb . append ( "&" ) ; } sb . append ( requestParameters . getAsQueryString ( param ) ) ; } return sb . toString ( ) ;


signature:
public class SocializeC2DMReceiverHandler { /** * / * ( non - Javadoc )
 * @ see com . socialize . notifications . C2DMReceiverHandler # onMessage ( android . content . Context , android . content . Intent ) */
@ Override public void onMessage ( Context context , Intent intent ) { } }

implementation: try { if ( notificationCallback != null ) { if ( logger != null && logger . isDebugEnabled ( ) ) { logger . debug ( "SocializeC2DMReceiver received message" ) ; } Bundle extras = intent . getExtras ( ) ; if ( extras != null ) { notificationCallback . onMessage ( context , extras ) ; } else { logWarn ( "No extras bundle found in notification intent.  Notification cannot be processed" ) ; } } else { logWarn ( "No notificationCallback found in GCM receiver.  Initialization may have failed." ) ; } } catch ( Exception e ) { logError ( "Error processing GCM message" , e ) ; }


signature:
public class SocializeC2DMReceiverHandler { /** * / * ( non - Javadoc )
 * @ see com . socialize . notifications . C2DMReceiverHandler # onError ( android . content . Context , java . lang . String ) */
@ Override public void onError ( Context context , String errorId ) { } }

implementation: if ( logger != null ) { logger . error ( "GCM registration failed with error: " + errorId ) ; } if ( notificationCallback != null ) { notificationCallback . onError ( context , errorId ) ; } else { logWarn ( "No notificationCallback found in GCM receiver.  Initialization may have failed." ) ; }


signature:
public class SocializeC2DMReceiverHandler { /** * / * ( non - Javadoc )
 * @ see com . socialize . notifications . C2DMReceiverHandler # onRegistrered ( android . content . Context , java . lang . String ) */
@ Override public void onRegistered ( Context context , String registrationId ) { } }

implementation: try { if ( notificationCallback != null ) { notificationCallback . onRegister ( context , registrationId ) ; } else { logWarn ( "No notificationCallback found in GCM receiver.  Initialization may have failed." ) ; } } catch ( Exception e ) { logError ( "GCM registration failed" , e ) ; }


signature:
public class SocializeC2DMReceiverHandler { /** * / * ( non - Javadoc )
 * @ see com . socialize . notifications . C2DMReceiverHandler # onUnregistered ( android . content . Context ) */
@ Override public void onUnregistered ( Context context ) { } }

implementation: if ( notificationCallback != null ) { notificationCallback . onUnregister ( context ) ; if ( logger != null && logger . isDebugEnabled ( ) ) { logger . debug ( "SocializeC2DMReceiver successfully unregistered" ) ; } } else { logWarn ( "No notificationCallback found in GCM receiver.  Initialization may have failed." ) ; }


signature:
public class SocializeC2DMReceiverHandler { /** * / * ( non - Javadoc )
 * @ see com . socialize . notifications . C2DMReceiverHandler # onCreate ( ) */
@ Override public void onCreate ( Context context ) { } }

implementation: if ( logger != null && logger . isDebugEnabled ( ) ) { logger . debug ( "SocializeC2DMReceiver creating.." ) ; } try { container . onCreate ( context ) ; initBeans ( ) ; } catch ( Exception e ) { logError ( "Error initializing GCM receiver!" , e ) ; }


signature:
public class TwitterSharer { /** * ( non - Javadoc )
 * @ see com . socialize . networks . AbstractSocialNetworkSharer # doShare ( android . app . Activity , com . socialize . entity . Entity , com . socialize . entity . PropagationUrlSet , java . lang . String , com . socialize . networks . SocialNetworkListener , com . socialize . api . action . ActionType ) */
@ Override protected void doShare ( Activity context , Entity entity , PropagationInfo urlSet , String comment , SocialNetworkListener listener , ActionType type ) throws SocializeException { } }

implementation: Tweet tweet = new Tweet ( ) ; switch ( type ) { case SHARE : if ( StringUtils . isEmpty ( comment ) ) comment = "Shared " + entity . getDisplayName ( ) ; break ; case LIKE : comment = "\u2764 likes " + entity . getDisplayName ( ) ; break ; case VIEW : comment = "Viewed " + entity . getDisplayName ( ) ; break ; } StringBuilder status = new StringBuilder ( ) ; if ( StringUtils . isEmpty ( comment ) ) { status . append ( entity . getDisplayName ( ) ) ; } else { status . append ( comment ) ; } status . append ( ", " ) ; status . append ( urlSet . getEntityUrl ( ) ) ; tweet . setText ( status . toString ( ) ) ; UserSettings settings = UserUtils . getUserSettings ( context ) ; if ( settings != null && settings . isLocationEnabled ( ) ) { tweet . setLocation ( LocationUtils . getLastKnownLocation ( context ) ) ; tweet . setShareLocation ( true ) ; } twitterUtils . tweet ( context , tweet , listener ) ;


signature:
public class Facebook { /** * Default authorize method . Grants only basic permissions .
 * See authorize ( ) below for @ params . */
public void authorize ( Activity activity , final DialogListener listener ) { } }

implementation: authorize ( activity , new String [ ] { } , DEFAULT_AUTH_ACTIVITY_CODE , listener ) ;


signature:
public class Facebook { /** * Full authorize method .
 * Starts either an Activity or a dialog which prompts the user to log in to
 * Facebook and grant the requested permissions to the given application .
 * This method will , when possible , use Facebook ' s single sign - on for
 * Android to obtain an access token . This involves proxying a call through
 * the Facebook for Android stand - alone application , which will handle the
 * authentication flow , and return an OAuth access token for making API
 * calls .
 * Because this process will not be available for all users , if single
 * sign - on is not possible , this method will automatically fall back to the
 * OAuth 2.0 User - Agent flow . In this flow , the user credentials are handled
 * by Facebook in an embedded WebView , not by the client application . As
 * such , the dialog makes a network request and renders HTML content rather
 * than a native UI . The access token is retrieved from a redirect to a
 * special URL that the WebView handles .
 * Note that User credentials could be handled natively using the OAuth 2.0
 * Username and Password Flow , but this is not supported by this SDK .
 * See http : / / developers . facebook . com / docs / authentication / and
 * http : / / wiki . oauth . net / OAuth - 2 for more details .
 * Note that this method is asynchronous and the callback will be invoked in
 * the original calling thread ( not in a background thread ) .
 * Also note that requests may be made to the API without calling authorize
 * first , in which case only public information is returned .
 * IMPORTANT : Note that single sign - on authentication will not function
 * correctly if you do not include a call to the authorizeCallback ( ) method
 * in your onActivityResult ( ) function ! Please see below for more
 * information . single sign - on may be disabled by passing FORCE _ DIALOG _ AUTH
 * as the activityCode parameter in your call to authorize ( ) .
 * @ param activity
 * The Android activity in which we want to display the
 * authorization dialog .
 * @ param applicationId
 * The Facebook application identifier e . g . " 350685531728"
 * @ param permissions
 * A list of permissions required for this application : e . g .
 * " read _ stream " , " publish _ stream " , " offline _ access " , etc . see
 * http : / / developers . facebook . com / docs / authentication / permissions
 * This parameter should not be null - - if you do not require any
 * permissions , then pass in an empty String array .
 * @ param activityCode
 * Single sign - on requires an activity result to be called back
 * to the client application - - if you are waiting on other
 * activities to return data , pass a custom activity code here to
 * avoid collisions . If you would like to force the use of legacy
 * dialog - based authorization , pass FORCE _ DIALOG _ AUTH for this
 * parameter . Otherwise just omit this parameter and Facebook
 * will use a suitable default . See
 * http : / / developer . android . com / reference / android /
 * app / Activity . html for more information .
 * @ param listener
 * Callback interface for notifying the calling application when
 * the authentication dialog has completed , failed , or been
 * canceled . */
public void authorize ( Activity activity , String [ ] permissions , int activityCode , final DialogListener listener ) { } }

implementation:
boolean singleSignOnStarted = false ; mAuthDialogListener = listener ; // Prefer single sign - on , where available .
if ( activityCode >= 0 ) { singleSignOnStarted = startSingleSignOn ( activity , mAppId , permissions , activityCode ) ; } // Otherwise fall back to traditional dialog .
if ( ! singleSignOnStarted ) { startDialogAuth ( activity , permissions ) ; }


signature:
public class Facebook { /** * Internal method to handle single sign - on backend for authorize ( ) .
 * @ param activity
 * The Android Activity that will parent the ProxyAuth Activity .
 * @ param applicationId
 * The Facebook application identifier .
 * @ param permissions
 * A list of permissions required for this application . If you do
 * not require any permissions , pass an empty String array .
 * @ param activityCode
 * Activity code to uniquely identify the result Intent in the
 * callback . */
private boolean startSingleSignOn ( Activity activity , String applicationId , String [ ] permissions , int activityCode ) { } }

implementation:
boolean didSucceed = true ; Intent intent = new Intent ( ) ; intent . setClassName ( "com.facebook.katana" , "com.facebook.katana.ProxyAuth" ) ; intent . putExtra ( "client_id" , applicationId ) ; if ( permissions . length > 0 ) { intent . putExtra ( "scope" , TextUtils . join ( "," , permissions ) ) ; } // Verify that the application whose package name is
// com . facebook . katana . ProxyAuth
// has the expected FB app signature .
if ( ! validateActivityIntent ( activity , intent ) ) { return false ; } mAuthActivity = activity ; mAuthPermissions = permissions ; mAuthActivityCode = activityCode ; try { activity . startActivityForResult ( intent , activityCode ) ; } catch ( ActivityNotFoundException e ) { didSucceed = false ; } return didSucceed ;


signature:
public class Facebook { /** * Helper to validate an activity intent by resolving and checking the
 * provider ' s package signature .
 * @ param context
 * @ param intent
 * @ return true if the service intent resolution happens successfully and the
 * signatures match . */
private boolean validateActivityIntent ( Context context , Intent intent ) { } }

implementation: ResolveInfo resolveInfo = context . getPackageManager ( ) . resolveActivity ( intent , 0 ) ; if ( resolveInfo == null ) { return false ; } return validateAppSignatureForPackage ( context , resolveInfo . activityInfo . packageName ) ;


signature:
public class Facebook { /** * Internal method to handle dialog - based authentication backend for
 * authorize ( ) .
 * @ param activity
 * The Android Activity that will parent the auth dialog .
 * @ param applicationId
 * The Facebook application identifier .
 * @ param permissions
 * A list of permissions required for this application . If you do
 * not require any permissions , pass an empty String array . */
private void startDialogAuth ( Activity activity , String [ ] permissions ) { } }

implementation:
Bundle params = new Bundle ( ) ; if ( permissions . length > 0 ) { params . putString ( "scope" , TextUtils . join ( "," , permissions ) ) ; } CookieSyncManager . createInstance ( activity ) ; dialog ( activity , LOGIN , params , new DialogListener ( ) { public void onComplete ( Bundle values ) { // ensure any cookies set by the dialog are saved
CookieSyncManager . getInstance ( ) . sync ( ) ; setAccessToken ( values . getString ( TOKEN ) ) ; setAccessExpiresIn ( values . getString ( EXPIRES ) ) ; if ( isSessionValid ( ) ) { Util . logd ( "Facebook-authorize" , "Login Success! access_token=" + getAccessToken ( ) + " expires=" + getAccessExpires ( ) ) ; mAuthDialogListener . onComplete ( values ) ; } else { mAuthDialogListener . onFacebookError ( new FacebookError ( "Failed to receive access token." ) ) ; } } public void onError ( DialogError error ) { Util . logd ( "Facebook-authorize" , "Login failed: " + error ) ; mAuthDialogListener . onError ( error ) ; } public void onFacebookError ( FacebookError error ) { Util . logd ( "Facebook-authorize" , "Login failed: " + error ) ; mAuthDialogListener . onFacebookError ( error ) ; } public void onCancel ( ) { Util . logd ( "Facebook-authorize" , "Login canceled" ) ; mAuthDialogListener . onCancel ( ) ; } } ) ;


signature:
public class Facebook { /** * IMPORTANT : This method must be invoked at the top of the calling
 * activity ' s onActivityResult ( ) function or Facebook authentication will
 * not function properly !
 * If your calling activity does not currently implement onActivityResult ( ) ,
 * you must implement it and include a call to this method if you intend to
 * use the authorize ( ) method in this SDK .
 * For more information , see
 * http : / / developer . android . com / reference / android / app /
 * Activity . html # onActivityResult ( int , int , android . content . Intent ) */
public void authorizeCallback ( int requestCode , int resultCode , Intent data ) { } }

implementation:
if ( requestCode == mAuthActivityCode ) { // Successfully redirected .
if ( resultCode == Activity . RESULT_OK ) { // Check OAuth 2.0/2.10 error code .
String error = data . getStringExtra ( "error" ) ; if ( error == null ) { error = data . getStringExtra ( "error_type" ) ; } // A Facebook error occurred .
if ( error != null ) { if ( error . equals ( SINGLE_SIGN_ON_DISABLED ) || error . equals ( "AndroidAuthKillSwitchException" ) ) { Util . logd ( "Facebook-authorize" , "Hosted auth currently " + "disabled. Retrying dialog auth..." ) ; startDialogAuth ( mAuthActivity , mAuthPermissions ) ; } else if ( error . equals ( "access_denied" ) || error . equals ( "OAuthAccessDeniedException" ) ) { Util . logd ( "Facebook-authorize" , "Login canceled by user." ) ; mAuthDialogListener . onCancel ( ) ; } else { String description = data . getStringExtra ( "error_description" ) ; if ( description != null ) { error = error + ":" + description ; } Util . logd ( "Facebook-authorize" , "Login failed: " + error ) ; mAuthDialogListener . onFacebookError ( new FacebookError ( error ) ) ; } // No errors .
} else { setAccessToken ( data . getStringExtra ( TOKEN ) ) ; setAccessExpiresIn ( data . getStringExtra ( EXPIRES ) ) ; if ( isSessionValid ( ) ) { Util . logd ( "Facebook-authorize" , "Login Success! access_token=" + getAccessToken ( ) + " expires=" + getAccessExpires ( ) ) ; mAuthDialogListener . onComplete ( data . getExtras ( ) ) ; } else { mAuthDialogListener . onFacebookError ( new FacebookError ( "Failed to receive access token." ) ) ; } } // An error occurred before we could be redirected .
} else if ( resultCode == Activity . RESULT_CANCELED ) { // An Android error occured .
if ( data != null ) { Util . logd ( "Facebook-authorize" , "Login failed: " + data . getStringExtra ( "error" ) ) ; mAuthDialogListener . onError ( new DialogError ( data . getStringExtra ( "error" ) , data . getIntExtra ( "error_code" , - 1 ) , data . getStringExtra ( "failing_url" ) ) ) ; // User pressed the ' back ' button .
} else { Util . logd ( "Facebook-authorize" , "Login canceled by user." ) ; mAuthDialogListener . onCancel ( ) ; } } }


signature:
public class Facebook { /** * Refresh OAuth access token method . Binds to Facebook for Android
 * stand - alone application application to refresh the access token . This
 * method tries to connect to the Facebook App which will handle the
 * authentication flow , and return a new OAuth access token . This method
 * will automatically replace the old token with a new one . Note that this
 * method is asynchronous and the callback will be invoked in the original
 * calling thread ( not in a background thread ) .
 * @ param context
 * The Android Context that will be used to bind to the Facebook
 * RefreshToken Service
 * @ param serviceListener
 * Callback interface for notifying the calling application when
 * the refresh request has completed or failed ( can be null ) . In
 * case of a success a new token can be found inside the result
 * Bundle under Facebook . ACCESS _ TOKEN key .
 * @ return true if the binding to the RefreshToken Service was created */
public boolean extendAccessToken ( Context context , ServiceListener serviceListener ) { } }

implementation:
Intent intent = new Intent ( ) ; intent . setClassName ( "com.facebook.katana" , "com.facebook.katana.platform.TokenRefreshService" ) ; // Verify that the application whose package name is
// com . facebook . katana
// has the expected FB app signature .
if ( ! validateServiceIntent ( context , intent ) ) { return false ; } return context . bindService ( intent , new TokenRefreshServiceConnection ( context , serviceListener ) , Context . BIND_AUTO_CREATE ) ;


signature:
public class Facebook { /** * Invalidate the current user session by removing the access token in
 * memory , clearing the browser cookie , and calling auth . expireSession
 * through the API .
 * Note that this method blocks waiting for a network response , so do not
 * call it in a UI thread .
 * @ param context
 * The Android context in which the logout should be called : it
 * should be the same context in which the login occurred in
 * order to clear any stored cookies
 * @ throws IOException
 * @ throws MalformedURLException
 * @ return JSON string representation of the auth . expireSession response
 * ( " true " if successful ) */
public String logout ( Context context ) throws MalformedURLException , IOException { } }

implementation: Util . clearCookies ( context ) ; Bundle b = new Bundle ( ) ; b . putString ( "method" , "auth.expireSession" ) ; String response = request ( b ) ; setAccessToken ( null ) ; setAccessExpires ( 0 ) ; return response ;


signature:
public class Facebook { /** * Make a request to Facebook ' s old ( pre - graph ) API with the given
 * parameters . One of the parameter keys must be " method " and its value
 * should be a valid REST server API method .
 * See http : / / developers . facebook . com / docs / reference / rest /
 * Note that this method blocks waiting for a network response , so do not
 * call it in a UI thread .
 * Example :
 * < code >
 * Bundle parameters = new Bundle ( ) ;
 * parameters . putString ( " method " , " auth . expireSession " ) ;
 * String response = request ( parameters ) ;
 * < / code >
 * @ param parameters
 * Key - value pairs of parameters to the request . Refer to the
 * documentation : one of the parameters must be " method " .
 * @ throws IOException
 * if a network error occurs
 * @ throws MalformedURLException
 * if accessing an invalid endpoint
 * @ throws IllegalArgumentException
 * if one of the parameters is not " method "
 * @ return JSON string representation of the response */
public String request ( Bundle parameters ) throws MalformedURLException , IOException { } }

implementation: if ( ! parameters . containsKey ( "method" ) ) { throw new IllegalArgumentException ( "API method must be specified. " + "(parameters must contain key \"method\" and value). See" + " http://developers.facebook.com/docs/reference/rest/" ) ; } return request ( null , parameters , "GET" ) ;


signature:
public class Facebook { /** * Make a request to the Facebook Graph API with the given string parameters
 * using an HTTP GET ( default method ) .
 * See http : / / developers . facebook . com / docs / api
 * Note that this method blocks waiting for a network response , so do not
 * call it in a UI thread .
 * @ param graphPath
 * Path to resource in the Facebook graph , e . g . , to fetch data
 * about the currently logged authenticated user , provide " me " ,
 * which will fetch http : / / graph . facebook . com / me
 * @ param parameters
 * key - value string parameters , e . g . the path " search " with
 * parameters " q " : " facebook " would produce a query for the
 * following graph resource :
 * https : / / graph . facebook . com / search ? q = facebook
 * @ throws IOException
 * @ throws MalformedURLException
 * @ return JSON string representation of the response */
public String request ( String graphPath , Bundle parameters ) throws MalformedURLException , IOException { } }

implementation: return request ( graphPath , parameters , "GET" ) ;


signature:
public class Facebook { /** * Generate a UI dialog for the request action in the given Android context
 * with the provided parameters .
 * Note that this method is asynchronous and the callback will be invoked in
 * the original calling thread ( not in a background thread ) .
 * @ param context
 * The Android context in which we will generate this dialog .
 * @ param action
 * String representation of the desired method : e . g . " feed " . . .
 * @ param parameters
 * String key - value pairs to be passed as URL parameters .
 * @ param listener
 * Callback interface to notify the application when the dialog
 * has completed . */
public void dialog ( Context context , String action , Bundle parameters , final DialogListener listener ) { } }

implementation: String endpoint = DIALOG_BASE_URL + action ; parameters . putString ( "display" , "touch" ) ; parameters . putString ( "redirect_uri" , REDIRECT_URI ) ; if ( action . equals ( LOGIN ) ) { parameters . putString ( "type" , "user_agent" ) ; parameters . putString ( "client_id" , mAppId ) ; } else { parameters . putString ( "app_id" , mAppId ) ; } if ( isSessionValid ( ) ) { parameters . putString ( TOKEN , getAccessToken ( ) ) ; } String url = endpoint + "?" + Util . encodeUrl ( parameters ) ; if ( context . checkCallingOrSelfPermission ( Manifest . permission . INTERNET ) != PackageManager . PERMISSION_GRANTED ) { Util . showAlert ( context , "Error" , "Application requires permission to access the Internet" ) ; } else { new FbDialog ( context , url , listener ) . show ( ) ; }


signature:
public class Facebook { /** * Set the current session ' s duration ( in seconds since Unix epoch ) , or " 0"
 * if session doesn ' t expire .
 * @ param expiresIn
 * - duration in seconds ( or 0 if the session doesn ' t expire ) */
public void setAccessExpiresIn ( String expiresIn ) { } }

implementation: if ( expiresIn != null ) { long expires = expiresIn . equals ( "0" ) ? 0 : System . currentTimeMillis ( ) + Long . parseLong ( expiresIn ) * 1000L ; setAccessExpires ( expires ) ; }


signature:
public class DefaultUserProviderCredentialsMap { /** * ( non - Javadoc )
 * @ see com . socialize . auth . UserProviderCredentialsMap # put ( com . socialize . auth . AuthProviderType , com . socialize . auth . UserProviderCredentials ) */
@ Override public void put ( AuthProviderType type , UserProviderCredentials data ) { } }

implementation: map . put ( type , data ) ;


signature:
public class DefaultDateTypeAdapter { /** * See issue 162 */
public JsonElement serialize ( Date src , Type typeOfSrc , JsonSerializationContext context ) { } }

implementation: synchronized ( localFormat ) { String dateFormatAsString = enUsFormat . format ( src ) ; return new JsonPrimitive ( dateFormatAsString ) ; }


signature:
public class DefaultLocalizationService { /** * / * ( non - Javadoc )
 * @ see com . socialize . i18n . LocalizationService # getString ( android . content . Context , java . lang . String ) */
@ Override public String getString ( String key ) { } }

implementation: if ( properties != null ) { String property = properties . getProperty ( key ) ; if ( property == null ) { return key ; } else { return property ; } } return null ;


signature:
public class FacebookUtils { /** * Links the current user to a facebook account . The user will be presented with the Facebook authentication dialog .
 * @ param context The current context .
 * @ param listener A listener to handle the result . */
@ Deprecated public static void link ( Activity context , SocializeAuthListener listener ) { } }

implementation: proxy . link ( context , listener ) ;


signature:
public class FacebookUtils { /** * Links the current user to a facebook account with custom FB permissions . The user will be presented with the Facebook authentication dialog .
 * @ param context The current context .
 * @ param listener A listener to handle the result .
 * @ param permissions One or more permissions defined by http : / / developers . facebook . com / docs / authentication / permissions / */
@ Deprecated public static void link ( Activity context , SocializeAuthListener listener , String ... permissions ) { } }

implementation: proxy . link ( context , listener , permissions ) ;


signature:
public class FacebookUtils { /** * Links an existing Facebook access token with the current user . No authentication dialog will be shown .
 * @ param context The current context .
 * @ param token The Facebook access token .
 * @ param verifyPermissions If true this method will also verify that the permissions assigned to the given token match the default permissions required by Socialize .
 * If not an authentication with FB will be attempted . If this parameter is false it is ASSUMED that permissions are valid .
 * @ param listener A listener to handle the result . */
@ Deprecated public static void link ( Activity context , String token , boolean verifyPermissions , SocializeAuthListener listener ) { } }

implementation: proxy . link ( context , token , verifyPermissions , listener ) ;


signature:
public class FacebookUtils { /** * Posts an entity to the user ' s Facebook wall . Post data can be customized by implementing the onBeforePost method in the given SocialNetworkListener .
 * @ param context The current context .
 * @ param entity The Socialize entity to which the post corresponds ( Required )
 * @ param text The text for the post .
 * @ param listener A listnener to handle callbacks from the post . */
public static void postEntity ( final Activity context , final Entity entity , final String text , final SocialNetworkShareListener listener ) { } }

implementation: if ( proxy . isLinkedForWrite ( context ) ) { proxy . postEntity ( context , entity , text , listener ) ; } else { proxy . linkForWrite ( context , new SocializeAuthListener ( ) { @ Override public void onError ( SocializeException error ) { if ( listener != null ) { listener . onNetworkError ( context , SocialNetwork . FACEBOOK , error ) ; } } @ Override public void onCancel ( ) { if ( listener != null ) { listener . onCancel ( ) ; } } @ Override public void onAuthSuccess ( SocializeSession session ) { proxy . postEntity ( context , entity , text , listener ) ; } @ Override public void onAuthFail ( SocializeException error ) { if ( listener != null ) { listener . onNetworkError ( context , SocialNetwork . FACEBOOK , error ) ; } } } ) ; }


signature:
public class FacebookUtils { /** * Calls the Facebook graph API directly with a POST . This will NOT create a share object in Socialize and is simply a raw call to Facebook .
 * NOTE : The current user must first be authenticated using a call to ' link ' .
 * This method is asynchronous and can be run from the main UI thread .
 * @ param context The current context .
 * @ param graphPath The path on the Facebook graph api to be called for the CURRENT user . E . g . me / feed
 * @ param params The data to be sent in the request .
 * @ param listener A listener to handle the result . */
public static void post ( final Activity context , final String graphPath , final Map < String , Object > params , final SocialNetworkPostListener listener ) { } }

implementation: if ( proxy . isLinkedForWrite ( context ) ) { proxy . post ( context , graphPath , params , listener ) ; } else { proxy . linkForWrite ( context , new SocializeAuthListener ( ) { @ Override public void onError ( SocializeException error ) { if ( listener != null ) { listener . onNetworkError ( context , SocialNetwork . FACEBOOK , error ) ; } } @ Override public void onCancel ( ) { if ( listener != null ) { listener . onCancel ( ) ; } } @ Override public void onAuthSuccess ( SocializeSession session ) { proxy . post ( context , graphPath , params , listener ) ; } @ Override public void onAuthFail ( SocializeException error ) { if ( listener != null ) { listener . onNetworkError ( context , SocialNetwork . FACEBOOK , error ) ; } } } ) ; }


signature:
public class FacebookUtils { /** * Returns image data suitable for posting to facebook .
 * @ param context The current context .
 * @ param imagePath The path to the image .
 * @ return A byte array containing the bytes to be posted .
 * @ throws IOException */
public static byte [ ] getImageForPost ( Activity context , Uri imagePath ) throws IOException { } }

implementation: return proxy . getImageForPost ( context , imagePath ) ;


signature:
public class FacebookUtils { /** * Returns image data suitable for posting to facebook .
 * @ param context The current context .
 * @ param image The image to be compressed .
 * @ param format The compression format to use ( one of JPEG or PNG ) .
 * @ return A byte array containing the bytes to be posted .
 * @ throws IOException */
public static byte [ ] getImageForPost ( Activity context , Bitmap image , CompressFormat format ) throws IOException { } }

implementation: return proxy . getImageForPost ( context , image , format ) ;


signature:
public class FacebookUtils { /** * Extends the user ' s Facebook access token if needed .
 * @ param context The current context
 * @ param listener A listener to handle the result after re - authentication with Socialize .
 * @ deprecated Use onResume ( ) */
@ Deprecated public static void extendAccessToken ( Activity context , SocializeAuthListener listener ) { } }

implementation: proxy . extendAccessToken ( context , listener ) ;