/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 7 ĠThe ĠAndroid ĠOpen ĠSource ĠProject Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġcom . android . tools . idea . gradle . project . sync . project system Ċ Ċ import Ġcom . android . tools . idea . gradle . project . sync . Gradle Sync Listener Ċ import Ġcom . android . tools . idea . gradle . project . sync . Gradle Sync State Ċ import Ġcom . android . tools . idea . project system . PROJECT _ SYSTEM _ SYNC _ TOPIC Ċ import Ġcom . android . tools . idea . project system . Project System Sync Manager Ċ import Ġcom . intellij . openapi . project . Project Ċ Ċ /** Ċ Ġ* ĠList ens Ġfor Ġall Ġsync Ġresults Ġfor Ġan Ġassociated Ġproject Ġand Ġbroadcast s Ġthem Ġover Ġthe Ġproject 's Ġmessage Ġbus Ċ Ġ* Ġon Ġ[ PROJECT _ SYSTEM _ SYNC _ TOPIC ]. ĠThis Ġis Ġa Ġseparate Ġproject Ġservice Ġinstead Ġof Ġjust Ġa Ġlocal Ġfield Ġin ĠGradle Project System Sync Manager Ċ Ġ* Ġbecause Ġno ĠAndroid Project System Ġstructs Ġare Ġinitialized Ġuntil Ġone Ġof Ġthe Ġproject Ġsystem ĠAPIs Ġis Ġused . ĠWe Ġwant Ġto Ġmake Ċ Ġ* Ġsure Ġthat Ġsync Ġresults Ġare Ġbroadcast Ġon Ġ[ PROJECT _ SYSTEM _ SYNC _ TOPIC ] Ġand Ġthe Ġlatest Ġsync Ġresult Ġis Ġrecorded Ċ Ġ* Ġregardless Ġof Ġwhether Ġor Ġnot Ġa Ġproject Ġsystem Ġmethod Ġhas Ġbeen Ġcalled . Ċ Ġ*/ Ċ class ĠGradle Sync Result Publisher ( val Ġproject : ĠProject ) Ġ: ĠGradle Sync Listener Ġ{ ĊĠ Ġvar Ġlast Sync Result : ĠProject System Sync Manager . Sync Result Ġ= ĠProject System Sync Manager . Sync Result . UNKNOWN ĊĠĠĠ Ġprivate Ġset ĊĊĠ Ġinit Ġ{ ĊĠĠĠ ĠGradle Sync State . subscribe ( project , Ġthis ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġsync Succeeded ( project : ĠProject ) Ġ= Ġsync Finished ( project , ĠProject System Sync Manager . Sync Result . SUCCESS ) ĊĊĠ Ġoverride Ġfun Ġsync Failed ( project : ĠProject , ĠerrorMessage : ĠString ) Ġ= Ġsync Finished ( project , ĠProject System Sync Manager . Sync Result . FAILURE ) ĊĊĠ Ġoverride Ġfun Ġsync Skipped ( project : ĠProject ) Ġ= Ġsync Finished ( project , ĠProject System Sync Manager . Sync Result . SKIP PED ) ĊĊĠ Ġprivate Ġfun Ġsync Finished ( project : ĠProject , Ġresult : ĠProject System Sync Manager . Sync Result ) Ġ{ ĊĠĠĠ Ġif Ġ(! project . is Disposed ) Ġ{ ĊĠĠĠĠĠ Ġlast Sync Result Ġ= Ġresult ĊĠĠĠĠĠ Ġproject . message Bus . sync Publisher ( PROJECT _ SYSTEM _ SYNC _ TOPIC ). sync Ended ( result ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġ@ Jvm Static ĊĠĠĠ Ġfun ĠgetInstance ( project : ĠProject ): ĠGradle Sync Result Publisher Ġ= ĊĠĠĠĠĠ Ġproject . getService ( Gradle Sync Result Publisher :: class . java ) ĊĠ Ġ} Ċ }