充电桩app代码

MainMapActivity.java 306KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076
  1. package com.electric.chargingpile.activity;
  2. import android.Manifest;
  3. import android.app.Activity;
  4. import android.app.Application;
  5. import android.content.BroadcastReceiver;
  6. import android.content.ContentValues;
  7. import android.content.Context;
  8. import android.content.DialogInterface;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.SharedPreferences;
  12. import android.content.pm.PackageInfo;
  13. import android.content.pm.PackageManager;
  14. import android.database.Cursor;
  15. import android.database.sqlite.SQLiteDatabase;
  16. import android.graphics.Bitmap;
  17. import android.graphics.BitmapFactory;
  18. import android.graphics.Point;
  19. import android.graphics.drawable.BitmapDrawable;
  20. import android.graphics.drawable.Drawable;
  21. import android.net.ConnectivityManager;
  22. import android.net.NetworkInfo;
  23. import android.net.Uri;
  24. import android.os.Build;
  25. import android.os.Bundle;
  26. import android.os.Environment;
  27. import android.os.Handler;
  28. import android.os.Message;
  29. import androidx.annotation.NonNull;
  30. import androidx.annotation.Nullable;
  31. import androidx.constraintlayout.widget.ConstraintLayout;
  32. import androidx.core.content.FileProvider;
  33. import android.text.TextUtils;
  34. import android.util.Log;
  35. import android.view.Gravity;
  36. import android.view.KeyEvent;
  37. import android.view.LayoutInflater;
  38. import android.view.MotionEvent;
  39. import android.view.View;
  40. import android.view.ViewGroup;
  41. import android.view.animation.Animation;
  42. import android.view.animation.AnimationUtils;
  43. import android.webkit.WebView;
  44. import android.widget.AdapterView;
  45. import android.widget.BaseAdapter;
  46. import android.widget.Button;
  47. import android.widget.ImageView;
  48. import android.widget.LinearLayout;
  49. import android.widget.ListView;
  50. import android.widget.PopupWindow;
  51. import android.widget.RelativeLayout;
  52. import android.widget.TextView;
  53. import android.widget.Toast;
  54. import com.alibaba.fastjson.JSON;
  55. import com.amap.api.location.AMapLocation;
  56. import com.amap.api.location.AMapLocationClient;
  57. import com.amap.api.location.AMapLocationClientOption;
  58. import com.amap.api.location.AMapLocationClientOption.AMapLocationMode;
  59. import com.amap.api.location.AMapLocationListener;
  60. import com.amap.api.maps.AMap;
  61. import com.amap.api.maps.AMapUtils;
  62. import com.amap.api.maps.CameraUpdateFactory;
  63. import com.amap.api.maps.LocationSource;
  64. import com.amap.api.maps.MapView;
  65. import com.amap.api.maps.UiSettings;
  66. import com.amap.api.maps.model.BitmapDescriptor;
  67. import com.amap.api.maps.model.BitmapDescriptorFactory;
  68. import com.amap.api.maps.model.CameraPosition;
  69. import com.amap.api.maps.model.LatLng;
  70. import com.amap.api.maps.model.LatLngBounds;
  71. import com.amap.api.maps.model.Marker;
  72. import com.amap.api.maps.model.MarkerOptions;
  73. import com.amap.api.maps.model.MyLocationStyle;
  74. import com.amap.api.services.weather.LocalDayWeatherForecast;
  75. import com.amap.api.services.weather.LocalWeatherForecast;
  76. import com.amap.api.services.weather.LocalWeatherForecastResult;
  77. import com.amap.api.services.weather.LocalWeatherLive;
  78. import com.amap.api.services.weather.LocalWeatherLiveResult;
  79. import com.amap.api.services.weather.WeatherSearch;
  80. import com.amap.api.services.weather.WeatherSearchQuery;
  81. import com.blankj.utilcode.util.ActivityUtils;
  82. import com.blankj.utilcode.util.AppUtils;
  83. import com.blankj.utilcode.util.EmptyUtils;
  84. import com.blankj.utilcode.util.LogUtils;
  85. import com.bumptech.glide.Glide;
  86. import com.bumptech.glide.load.DataSource;
  87. import com.bumptech.glide.load.engine.GlideException;
  88. import com.bumptech.glide.request.RequestListener;
  89. import com.bumptech.glide.request.target.Target;
  90. import com.electric.chargingpile.R;
  91. import com.electric.chargingpile.application.MainApplication;
  92. import com.electric.chargingpile.base.BaseEvent;
  93. import com.electric.chargingpile.cluster.ClusterClickListener;
  94. import com.electric.chargingpile.cluster.ClusterItem;
  95. import com.electric.chargingpile.cluster.ClusterOverlay;
  96. import com.electric.chargingpile.cluster.ClusterRender;
  97. import com.electric.chargingpile.cluster.RegionItem;
  98. import com.electric.chargingpile.constant.BaseConstants;
  99. import com.electric.chargingpile.constant.UrlConstants;
  100. import com.electric.chargingpile.data.Adin;
  101. import com.electric.chargingpile.data.ChargingShareBean;
  102. import com.electric.chargingpile.data.City;
  103. import com.electric.chargingpile.data.DataRefresh;
  104. import com.electric.chargingpile.data.FindData;
  105. import com.electric.chargingpile.data.PileData;
  106. import com.electric.chargingpile.data.UpdateZhanDataBean;
  107. import com.electric.chargingpile.data.Zhan;
  108. import com.electric.chargingpile.data.ZhanDB;
  109. import com.electric.chargingpile.data.zhan_list;
  110. import com.electric.chargingpile.gen.DaoMaster;
  111. import com.electric.chargingpile.gen.DaoSession;
  112. import com.electric.chargingpile.gen.zhan_listDao;
  113. import com.electric.chargingpile.manager.ProfileManager;
  114. import com.electric.chargingpile.util.BarColorUtil;
  115. import com.electric.chargingpile.util.DES3;
  116. import com.electric.chargingpile.util.DES3S;
  117. import com.electric.chargingpile.util.DensityUtil;
  118. import com.electric.chargingpile.util.EventBusUtil;
  119. import com.electric.chargingpile.util.JsonUtils;
  120. import com.electric.chargingpile.util.LoadingDialog;
  121. import com.electric.chargingpile.util.Md5Util;
  122. import com.electric.chargingpile.util.OkHttpUtil;
  123. import com.electric.chargingpile.util.SharedPreferencesUtil;
  124. import com.electric.chargingpile.util.ToastUtil;
  125. import com.electric.chargingpile.util.Util;
  126. import com.electric.chargingpile.util.ZhanDBHelper;
  127. import com.electric.chargingpile.view.AlertDialogTwo;
  128. import com.electric.chargingpile.view.AlertDialogUpdate;
  129. import com.electric.chargingpile.view.SlideAdView;
  130. import com.electric.chargingpile.view.UpdateDialog;
  131. import com.google.gson.Gson;
  132. import com.google.gson.reflect.TypeToken;
  133. import com.google.zxing.client.android.constant.ChargingConstants;
  134. import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
  135. import com.squareup.okhttp.Request;
  136. import com.squareup.okhttp.Response;
  137. import com.squareup.picasso.Picasso;
  138. import com.umeng.analytics.MobclickAgent;
  139. import com.zhy.autolayout.AutoLayout;
  140. import com.zhy.http.okhttp.OkHttpUtils;
  141. import com.zhy.http.okhttp.callback.FileCallBack;
  142. import com.zhy.http.okhttp.callback.StringCallback;
  143. import org.greenrobot.eventbus.Subscribe;
  144. import org.greenrobot.eventbus.ThreadMode;
  145. import org.json.JSONException;
  146. import org.json.JSONObject;
  147. import java.io.BufferedReader;
  148. import java.io.BufferedWriter;
  149. import java.io.File;
  150. import java.io.FileOutputStream;
  151. import java.io.IOException;
  152. import java.io.InputStream;
  153. import java.io.InputStreamReader;
  154. import java.io.OutputStreamWriter;
  155. import java.io.PrintWriter;
  156. import java.net.Socket;
  157. import java.net.URISyntaxException;
  158. import java.net.URLEncoder;
  159. import java.security.MessageDigest;
  160. import java.text.NumberFormat;
  161. import java.util.ArrayList;
  162. import java.util.Calendar;
  163. import java.util.Date;
  164. import java.util.HashMap;
  165. import java.util.List;
  166. import java.util.Map;
  167. import java.util.Random;
  168. import cn.sharesdk.framework.Platform;
  169. import cn.sharesdk.framework.PlatformActionListener;
  170. import cn.sharesdk.framework.ShareSDK;
  171. import cn.sharesdk.tencent.qq.QQ;
  172. import cn.sharesdk.wechat.friends.Wechat;
  173. import cn.sharesdk.wechat.moments.WechatMoments;
  174. import okhttp3.Call;
  175. import pub.devrel.easypermissions.AfterPermissionGranted;
  176. import pub.devrel.easypermissions.AppSettingsDialog;
  177. import pub.devrel.easypermissions.EasyPermissions;
  178. public class MainMapActivity extends Activity implements LocationSource, AMapLocationListener,
  179. View.OnClickListener, AMap.OnMapLoadedListener, AMap.OnCameraChangeListener, AMap.OnMapClickListener,
  180. ClusterRender, ClusterClickListener, WeatherSearch.OnWeatherSearchListener, EasyPermissions.PermissionCallbacks,
  181. AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, AMap.OnInfoWindowClickListener {
  182. private static final String TAG = "MainMapActivity";
  183. public static String screen_jing = "", screen_wei = "";
  184. public static String location_city = "";
  185. public static String re_move = "true";
  186. List<LatLng> list_ll = new ArrayList<>();
  187. private LinearLayout ll_recommend;
  188. private WeatherSearchQuery mquery;
  189. private WeatherSearchQuery mquery1;
  190. private WeatherSearch mweathersearch;
  191. private WeatherSearch mweathersearch1;
  192. private RelativeLayout window_ll_zhan;
  193. public static MainMapActivity m;
  194. public static MainMapActivity mainMapActivity;
  195. private int clusterRadius = 80;
  196. private ClusterOverlay mClusterOverlay;
  197. private Map<Integer, Drawable> mBackDrawAbles = new HashMap<Integer, Drawable>();
  198. private IntentFilter intentFilter;
  199. private NetworkChangeReceiver networkChangeReceiver;
  200. private List<zhan_list> zhan_lists;
  201. private MapView mapView;
  202. public static String back = "";
  203. private static AMap aMap;
  204. private AlertDialogUpdate alterDialog;
  205. public static boolean tag = false;
  206. public static String condition;
  207. public static int level;
  208. private UiSettings mUiSettings;
  209. private OnLocationChangedListener mListener;
  210. private AMapLocationClient mlocationClient;
  211. private AMapLocationClientOption mLocationOption;
  212. private Marker currentClickedMarker;
  213. private Marker detailMarker;
  214. public static boolean onResumeRefresh = false;
  215. public static boolean search_back = false;
  216. private ImageView iv_guzhang, iVpoint;
  217. private boolean clickMarker = false;
  218. public static LatLng center = null;
  219. private static boolean firstOpen = true;
  220. private static boolean firstCheck = true;
  221. public static long cha;
  222. String gd_jing, gd_wei, bg_jing, bg_wei;
  223. private String is_dui = "";
  224. private final int SEARCH_CODE = 1;
  225. static String token = "";
  226. private String Token = "";
  227. public static int have_message = 0;
  228. public static int have_pinglun = 0;
  229. public static int msg_num = 0;
  230. public static int num1 = 0, num2 = 0;
  231. public static int zhuang_no = 0;
  232. public static int city_no = 0;
  233. private static int count = 1;
  234. private static int have_order = 0;
  235. private static float minZoomLevel;
  236. private static float maxZoomLevel;
  237. public static RelativeLayout rl_tuijian_tip;
  238. public static boolean detailsBack = false;
  239. private int city_able = 0;
  240. private Socket socket;
  241. private int time_out = 0;
  242. private Marker search_marker;
  243. public static Marker recommend_marker_one, recommend_marker_two, recommend_marker_three;
  244. private double bd_lon, bd_lat, bd_jing, bd_wei;
  245. private LoadingDialog loadingDialog;
  246. Context context;
  247. public static boolean moveRefresh = true;
  248. public static LinearLayout ll_map_control;
  249. private List<String> stringTid = new ArrayList<String>();
  250. public static List<Zhan> list = new ArrayList<Zhan>();
  251. public static List<Zhan> listt = new ArrayList<Zhan>();
  252. public static List<Zhan> list1 = new ArrayList<Zhan>();
  253. public static List<Zhan> list2 = new ArrayList<Zhan>();
  254. public static List<Zhan> list3 = new ArrayList<Zhan>();
  255. public static List<ZhanDB> list_db = new ArrayList<ZhanDB>();
  256. public static List<City> cityList = new ArrayList<City>();
  257. private int yindaoye = 0;
  258. MarkerOptions ooyes = null;
  259. MarkerOptions oogift = null;
  260. MarkerOptions oocity = null;
  261. MarkerOptions oono = null;
  262. MarkerOptions oo = null;
  263. MarkerOptions oote = null;
  264. private Marker mMarkerYes;
  265. private Marker mMarkerNo;
  266. private Marker mMarkerTe;
  267. private Marker mMarkerTed;
  268. private Marker mMarkerGift;
  269. private Marker mMarkerCity;
  270. private Marker keep = null;
  271. private int sortTye = 1;
  272. private SlideAdView sav;
  273. private static TextView userLogin;
  274. private float mPosX;
  275. private float mCurPosX;
  276. private float mPosY;
  277. private float mCurPosY;
  278. private TextView tv_msg_num;
  279. BitmapDescriptor bdyes = BitmapDescriptorFactory.fromResource(R.drawable.icon_sgreen);
  280. BitmapDescriptor bdgift = BitmapDescriptorFactory.fromResource(R.drawable.icon_sgift);
  281. BitmapDescriptor bdno = BitmapDescriptorFactory.fromResource(R.drawable.icon_sorange);
  282. BitmapDescriptor bigno = BitmapDescriptorFactory.fromResource(R.drawable.icon_borange);
  283. BitmapDescriptor bigyes = BitmapDescriptorFactory.fromResource(R.drawable.icon_bgreen);
  284. BitmapDescriptor biggift = BitmapDescriptorFactory.fromResource(R.drawable.icon_bgift);
  285. public static boolean canRefreshthree = true;
  286. public static boolean canRefreshtwo = true;
  287. private boolean gestureguide;
  288. private TextView mTvMarkerViewNum;
  289. private TextView mTvMarkerViewNumAppB;
  290. private TextView mTvMarkerViewNumAppS;
  291. private ImageView mIvMarkerBg;
  292. private ImageView mIvMarkerAppS;
  293. private ImageView mIvMarkerAppB;
  294. private TextView mTvMarkerViewNum1;
  295. private ImageView mIvMarkerBg1;
  296. private ImageView mIvMarkerBgYes;
  297. private TextView mTvMarkerViewNumcity;
  298. private ImageView mIvMarkerBgcity;
  299. private ImageView iv_tuijian_close;
  300. private ImageView iv_tuijian_tip_close;
  301. private String againPoint = "";
  302. private LoadingDialog dialog;
  303. private LinearLayout tab_qa;
  304. public static boolean isR = false;
  305. private boolean isListShow = false;
  306. private View mMarkerView;
  307. private View mMarkerView1;
  308. private View mMarkerViewAppS;
  309. private View mMarkerViewAppB;
  310. private View mMarkerViewYes;
  311. private View mMarkerViewcity;
  312. public static float now_zoom = 0;
  313. private TextView tv_tishi, paoName, paoName1, paoAddress, paoCostWay, paoDaohang, paoDistance,
  314. paoFast, paoSlow, paoAlter, paoTotal, tingche, fuwu, dian, tv_grade, tv_shaixuan, tv_recommend_tip,
  315. tv_daohang, tvOne, tvTwo, tv_num, tvThree, tv_sortDistance, tv_sortStarLevel, iv_list, tv_sortFreeTime;
  316. public static TextView tv_atCity;
  317. public static RelativeLayout paoRl;
  318. public static LinearLayout rl_control;
  319. private RelativeLayout rela, ll_comment, rl_ad, rl_grade, rl_search, ll_paoxiang, rl_charging_notice;
  320. private RelativeLayout tv_notice, tv_citynotice, rl_mapList, ll_tab_find;
  321. private LinearLayout ll_paogo, ll_title, ll_open, tab_me, tab_screen;
  322. public static LinearLayout ll_tuijian, ll_top_right;
  323. private PopupWindow popupWindow;
  324. private View popupWindowView;
  325. private Button cancleButton;
  326. private ListView lvZhan;
  327. private ZhanAdapter adapter;
  328. private long exitTime = 0;
  329. private ImageView iv_clear;
  330. private ImageView iv_sceen;
  331. private ImageView iv_refresh, iv_route;
  332. private ImageView iv_our;
  333. private ImageView iv_tuijian;
  334. private static ImageView inBtn;
  335. private static ImageView outBtn;
  336. private ImageView paopaoAd;
  337. private ImageView iv_example;
  338. private ImageView iv_clear_address;
  339. private ImageView iv_bg_example;
  340. private String now_versionCode, now_versionName, app_version, title;
  341. private String login_meg = "";
  342. private ImageView iv_yindaoye, iv_grade, iv_roadCondition, iv_find, iv_main, iv_screening;
  343. private TextView tv_search, tv_main, tv_tuijian_feedback;
  344. public static String comments_num;
  345. private zhan_listDao zhan_listDao;
  346. public static zhan_list current_chargePoint;
  347. public static Marker nMarker;
  348. private boolean paoShow = false;
  349. private TextView windowName, windowGrade, windowCost, window_tv_fast_free_num, window_tv_fast_free_label, window_tv_fast_total_num,
  350. window_tv_slow_free_label, window_tv_slow_free_num, window_tv_slow_total_num, windowCommentNum, windowDistance, stopCost;
  351. private RelativeLayout windowGo, windowZhanDetails, windowComments;
  352. private ImageView windowAd, windowGradeImg;
  353. public static RelativeLayout windowLayout;
  354. public static int question_unread = 0;
  355. public static int comment_unread = 0;
  356. public static int system_unread = 0;
  357. public static int total_unread = 0;
  358. public static boolean isStatusBack = false;
  359. private static final int RC_CAMERA_PERM = 123;
  360. private static final int RC_SAVE_PERM = 124;
  361. private String adfloatUrl = "";
  362. private UpdateDialog updateDialog;
  363. //标识,用于判断是否只显示一次定位信息和用户重新定位
  364. private boolean isFirstLoc = true;
  365. private Handler myHandler = new Handler() {
  366. @Override
  367. public void handleMessage(Message msg) {
  368. super.handleMessage(msg);
  369. switch (msg.what) {
  370. case 0x01:
  371. Bundle data = msg.getData();
  372. String format = data.getString("format");
  373. String f = data.getString("progress");
  374. String s = f.substring(0, f.indexOf("."));
  375. LogUtils.e(s);
  376. updateDialog.updateMsg("当前已下载:" + format);
  377. updateDialog.updateProgress(Integer.parseInt(s));
  378. break;
  379. }
  380. }
  381. };
  382. private Handler hand = new Handler() {
  383. public void handleMessage(android.os.Message msg) {
  384. SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
  385. switch (msg.what) {
  386. //获取站点评论数
  387. case 1:
  388. try {
  389. JSONObject jsonObject = new JSONObject(msg.obj.toString());
  390. String comment_num = jsonObject.getString("rtnMsg");
  391. comments_num = comment_num;
  392. windowCommentNum.setText("评论(" + comment_num + ")");
  393. // tv_num.setText("(" + comment_num + ")");
  394. } catch (JSONException e) {
  395. e.printStackTrace();
  396. }
  397. break;
  398. //获取版本号及首页广告
  399. case 2:
  400. try {
  401. String data = JsonUtils.getKeyResult(msg.obj.toString(), "data");
  402. if (!data.equals("")) {
  403. // 二手车广告
  404. String adfloat = JsonUtils.getKeyResult(data, "ad_float");
  405. if (adfloat != null && !adfloat.equals("")) {
  406. List<Adin> listAdfloat = JsonUtils.parseToObjectList(adfloat, Adin.class);
  407. if (listAdfloat.size() > 0) {
  408. loadAdfloatImg(listAdfloat.get(0));
  409. }
  410. }
  411. String adin = JsonUtils.getKeyResult(data, "adin");
  412. if (null != adin) {
  413. List<Adin> listAdin = JsonUtils.parseToObjectList(adin, Adin.class);
  414. System.out.print("size:" + listAdin.size());
  415. if (listAdin.size() > 0) {
  416. sav.initData(listAdin);
  417. rl_ad.setVisibility(View.VISIBLE);
  418. for (Adin item : listAdin) {
  419. if (item.getAdvertiser().equals("1")) {
  420. loadDmpData();
  421. break;
  422. }
  423. }
  424. }
  425. }
  426. String version = JsonUtils.getKeyResult(data, "version");
  427. com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(version);
  428. if (jsonArray != null) {
  429. com.alibaba.fastjson.JSONObject version1 = jsonArray.getJSONObject(0);
  430. String android = JsonUtils.getKeyResult(version1.toJSONString(), "android");
  431. title = JsonUtils.getKeyResult(version1.toJSONString(), "title");
  432. login_meg = JsonUtils.getKeyResult(version1.toJSONString(), "login_meg");
  433. title = title.replace("\\n", "\n");
  434. now_versionCode = JsonUtils.getKeyResult(android, "versionCode");
  435. now_versionName = JsonUtils.getKeyResult(android, "versionName");
  436. String[] key = now_versionName.split("\\.");
  437. if (key.length - 1 > 2) {
  438. dialogup_other();
  439. } else {
  440. dialogup();
  441. }
  442. }
  443. }
  444. } catch (Exception e) {
  445. e.printStackTrace();
  446. }
  447. //获取站点数据
  448. case 3:
  449. try {
  450. stringTid.clear();
  451. if (socket != null) {
  452. if (socket.isInputShutdown()) {
  453. stringTid.clear();
  454. }
  455. }
  456. String rtnCode = JsonUtils.getKeyResult(msg.obj.toString(), "rtnCode");
  457. if (rtnCode.equals("03")) {
  458. if (time_out < 3) {
  459. ete("{\"fun\":\"timer\"}");
  460. clickMarker = false;
  461. // SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
  462. // sharedPreferencesUtil.setFileName("CurrentMarkerInfo");
  463. // sharedPreferencesUtil.clearData();
  464. time_out++;
  465. }
  466. } else {
  467. time_out = 0;
  468. try {
  469. String date = JsonUtils.getKeyResult(msg.obj.toString(), "data");
  470. // Log.d("678543", date);
  471. System.out.print("678543" + date);
  472. // Log.e("ete1", "执行");
  473. List<Zhan> mZhan = JsonUtils.parseToObjectList(date, Zhan.class);
  474. System.out.print("222:" + mZhan.size());
  475. // Log.e(TAG, "handleMessage: " + mZhan.size());
  476. for (int i = 0; i < mZhan.size(); i++) {
  477. Zhan aZhan = mZhan.get(i);
  478. // System.err.println(aZhan.getZhan_name());
  479. }
  480. list.clear();
  481. listt.clear();
  482. list1.clear();
  483. list2.clear();
  484. list3.clear();
  485. // aMap.clear();
  486. if (mZhan != null && mZhan.size() > 0) {
  487. list.addAll(mZhan);
  488. listt.addAll(mZhan);
  489. if (center != null) {
  490. for (int i = 0; i < list.size(); i++) {
  491. String wei = list.get(i).getPoi_wei().trim();
  492. String jing = list.get(i).getPoi_jing().trim();
  493. int position_jing = jing.length() - jing.indexOf(".") - 1;
  494. int position_wei = wei.length() - wei.indexOf(".") - 1;
  495. LatLng ll;
  496. if (position_jing > 13 || position_wei > 13) {
  497. ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
  498. } else {
  499. double dwei = Double.parseDouble(wei);
  500. double djing = Double.parseDouble(jing);
  501. getGaode(djing, dwei);
  502. ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
  503. }
  504. double d = AMapUtils.calculateLineDistance(center, ll);
  505. list.get(i).setDistance(Util.getDistance(d));
  506. // if (mZhan.get(i).getSupplier().equals("特来电")) {
  507. // stringTid.add(mZhan.get(i).getTid());
  508. // getDetailThread(mZhan.get(i).getTid());
  509. //// Log.e("Tid", mZhan.get(i).getTid());
  510. // }
  511. }
  512. }
  513. } else {
  514. // showTextToast("没有合适的充电桩");
  515. if (center != null) {
  516. BitmapDescriptor point = BitmapDescriptorFactory
  517. .fromResource(R.drawable.point_icon);
  518. MarkerOptions oo = new MarkerOptions().position(center)
  519. .anchor(0.5f, 0.5f).zIndex(7).icon(point)
  520. .draggable(true);
  521. aMap.addMarker(oo);
  522. }
  523. }
  524. lvZhan.setAdapter(adapter);
  525. lvZhan.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  526. @Override
  527. public void onItemClick(AdapterView<?> parent, View view,
  528. int position, long id) {
  529. MainApplication.details_flag = "2";
  530. Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
  531. intent.putExtra("zhan_id", list.get(position).getZhan_id());
  532. startActivity(intent);
  533. }
  534. });
  535. if (list.size() > 0) {
  536. if (sortTye == 1) {
  537. list = Util.getSortList(listt);
  538. } else if (sortTye == 2) {
  539. list = Util.getSortPFList(listt);
  540. } else if (sortTye == 3) {
  541. list = Util.getSortFTList(listt);
  542. }
  543. if (MainApplication.isMap == false) {
  544. tv_tishi.setVisibility(View.GONE);
  545. }
  546. } else {
  547. if (MainApplication.isMap == false) {
  548. tv_tishi.setVisibility(View.VISIBLE);
  549. }
  550. }
  551. adapter.notifyDataSetChanged();
  552. } catch (Exception e) {
  553. BitmapDescriptor point = BitmapDescriptorFactory
  554. .fromResource(R.drawable.point_icon);
  555. if (center != null) {
  556. oo = new MarkerOptions().position(center).
  557. anchor(0.5f, 0.5f).zIndex(7)
  558. .draggable(true).icon(point);
  559. aMap.addMarker(oo);
  560. }
  561. // Toast.makeText(getActivity(), "该范围内没有充电桩", Toast.LENGTH_SHORT).show();
  562. }
  563. }
  564. } catch (Exception e) {
  565. e.printStackTrace();
  566. }
  567. break;
  568. //城市站点数量
  569. case 4:
  570. try {
  571. // JSONObject jsonObj = new JSONObject(msg.obj.toString());
  572. // String data = jsonObj.getString("data");
  573. // String time = jsonObj.getString("time");
  574. // String pic = jsonObj.getString("pic");
  575. // Log.i("data-----",data);
  576. //// Log.i("pic------",pic);
  577. // String zhan_data = DES3.decode(data);
  578. // Log.i("zhan_data-----",zhan_data);
  579. //
  580. //// Log.d("appTime---", DateUtils.getCurrentDate());
  581. //
  582. // long phpTime = Long.parseLong(time);
  583. //
  584. // Log.i("phpTime(long)---", phpTime+"");
  585. // long appTime1 = System.currentTimeMillis()/1000;
  586. // Log.i("appTime(long)---", appTime1+"");
  587. // cha = appTime1 - phpTime;
  588. // SharedPreferences mySharedPreferences= MainFragment.getSharedPreferences("userName",
  589. // Activity.MODE_PRIVATE);
  590. // SharedPreferences.Editor editor = mySharedPreferences.edit();
  591. // editor.putInt("cha", cha);
  592. // editor.commit();
  593. // Log.d("cha(long)---", cha + "");
  594. try {
  595. String date = JsonUtils.getKeyResult(msg.obj.toString(), "data");
  596. // Log.e("data", date);
  597. Gson g = new Gson();
  598. List<City> ll = g.fromJson(date, new TypeToken<List<City>>() {
  599. }.getType());
  600. stringTid.clear();
  601. cityList.clear();
  602. aMap.clear();
  603. if (ll != null && ll.size() > 0) {
  604. cityList.addAll(ll);
  605. if (center != null) {
  606. for (int i = 0; i < cityList.size(); i++) {
  607. double dwei = Double.parseDouble(list.get(i).getPoi_wei());
  608. double djing = Double.parseDouble(list.get(i).getPoi_jing());
  609. LatLng lll = new LatLng(dwei, djing);
  610. }
  611. }
  612. } else {
  613. if (center != null) {
  614. BitmapDescriptor point = BitmapDescriptorFactory
  615. .fromResource(R.drawable.point_icon);
  616. oo = new MarkerOptions().position(center)
  617. .anchor(0.5f, 0.5f).zIndex(7).icon(point)
  618. .draggable(false);
  619. aMap.addMarker(oo);
  620. }
  621. }
  622. // listt = list;
  623. // if (list.size() > 0) {
  624. // dialog.show();
  625. // list = Util.getSortList(listt);
  626. // list1 = list;
  627. // dialog.cancel();
  628. // }
  629. // adapter.notifyDataSetChanged();
  630. } catch (Exception e) {
  631. BitmapDescriptor point = BitmapDescriptorFactory
  632. .fromResource(R.drawable.point_icon);
  633. oo = new MarkerOptions().position(center).
  634. anchor(0.5f, 0.5f).zIndex(7)
  635. .draggable(true).icon(point);
  636. aMap.addMarker(oo);
  637. // Toast.makeText(getActivity(),"该范围内没有充电桩",Toast.LENGTH_SHORT).show();
  638. }
  639. } catch (Exception e) {
  640. e.printStackTrace();
  641. }
  642. break;
  643. default:
  644. break;
  645. }
  646. }
  647. };
  648. private View infoWindow;
  649. private String zhanInfo;
  650. private TextView windowChargeRecordCnt;
  651. private View windowChargeRecordCntLine;
  652. private TextView windowZongjia;
  653. private LinearLayout windowZongjiaLayout;
  654. private ImageView windowRedPaperBag;
  655. private TextView windowLabelPublic;
  656. private TextView windowLabelGround;
  657. private TextView windowLabelFreePark;
  658. private ConstraintLayout windowChat;
  659. private LatLng markerPosition;
  660. private ImageView second_hand_car;
  661. private LinearLayout private_telephone;
  662. @Override
  663. protected void onCreate(Bundle savedInstanceState) {
  664. super.onCreate(savedInstanceState);
  665. AutoLayout.getInstance().auto(this);
  666. setContentView(R.layout.activity_main_map);
  667. BarColorUtil.initStatusBarColor(MainMapActivity.this);
  668. m = this;
  669. // mquery = new WeatherSearchQuery("北京", WeatherSearchQuery.WEATHER_TYPE_FORECAST);
  670. // mweathersearch=new WeatherSearch(this);
  671. // mweathersearch.setOnWeatherSearchListener(this);
  672. // mweathersearch.setQuery(mquery);
  673. // mweathersearch.searchWeatherAsyn(); //异步搜索
  674. //
  675. // mquery1 = new WeatherSearchQuery("北京", WeatherSearchQuery.WEATHER_TYPE_LIVE);
  676. // mweathersearch1=new WeatherSearch(this);
  677. // mweathersearch1.setOnWeatherSearchListener(this);
  678. // mweathersearch1.setQuery(mquery1);
  679. // mweathersearch1.searchWeatherAsyn(); //异步搜索
  680. mainMapActivity = MainMapActivity.this;
  681. intentFilter = new IntentFilter();
  682. intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
  683. networkChangeReceiver = new NetworkChangeReceiver();
  684. registerReceiver(networkChangeReceiver, intentFilter);
  685. EventBusUtil.register(this);
  686. if (!MainApplication.h5_url.equals("") && MainApplication.type.equals("PushWeb")) {
  687. Intent intent = new Intent(getApplicationContext(), MyWebViewActivity.class);
  688. intent.putExtra("url", MainApplication.h5_url);
  689. startActivity(intent);
  690. MainApplication.h5_url = "";
  691. MainApplication.type = "";
  692. }
  693. if (!MainApplication.h5_url.equals("") && MainApplication.type.equals("PushComment")) {
  694. startActivity(new Intent(getApplication(), MyMessageActivity.class));
  695. MainApplication.h5_url = "";
  696. MainApplication.type = "";
  697. MainApplication.mainSkip = "1";
  698. finish();
  699. }
  700. if (MainApplication.type.equals("PushBalance")) {
  701. if (MainApplication.isLogin()) {
  702. startActivity(new Intent(getApplication(), MyBalanceActivity.class));
  703. MainApplication.h5_url = "";
  704. MainApplication.type = "";
  705. MainApplication.mainSkip = "1";
  706. finish();
  707. }
  708. }
  709. if (MainApplication.type.equals("PushRanking")) {
  710. if (MainApplication.isLogin()) {
  711. startActivity(new Intent(getApplication(), RankingListActivity.class));
  712. MainApplication.h5_url = "";
  713. MainApplication.type = "";
  714. MainApplication.mainSkip = "1";
  715. finish();
  716. }
  717. }
  718. if (MainApplication.type.equals("PushRecharge")) {
  719. if (MainApplication.isLogin()) {
  720. startActivity(new Intent(getApplication(), AccountRechargeActivity.class));
  721. MainApplication.h5_url = "";
  722. MainApplication.type = "";
  723. MainApplication.mainSkip = "1";
  724. finish();
  725. }
  726. }
  727. if (MainApplication.type.equals("PushInvite")) {
  728. if (MainApplication.isLogin()) {
  729. Intent intent4 = new Intent(getApplication(), MyWebViewActivity.class);
  730. intent4.putExtra("url", "https://evcharge.cc/cdz/yqm.html?code=" + UserCenterActivity.getShareNo(Integer.parseInt(MainApplication.userId)) + "&phone=" + MainApplication.userPhone);
  731. // intent4.putExtra("tag", "2");
  732. startActivity(intent4);
  733. MainApplication.h5_url = "";
  734. MainApplication.type = "";
  735. MainApplication.mainSkip = "1";
  736. finish();
  737. }
  738. }
  739. if (MainApplication.type.equals("first") || MainApplication.type.equals("second") || MainApplication.type.equals("three")) {
  740. if (MainApplication.isLogin()) {
  741. long appTime4 = System.currentTimeMillis() / 1000;
  742. long updatetime4 = appTime4 - MainMapActivity.cha - 1;
  743. String token4 = String.valueOf(updatetime4);
  744. Intent intent4 = new Intent(getApplication(), MyWebViewActivity.class);
  745. String web1 = null;
  746. try {
  747. web1 = MainApplication.url + "/zhannew/basic/web/index.php/discount/redlist?userid=" + MainApplication.userId + "&token=" + URLEncoder.encode(DES3.encode(token4));
  748. } catch (Exception e) {
  749. e.printStackTrace();
  750. }
  751. intent4.putExtra("url", web1);
  752. // intent4.putExtra("tag", "4");
  753. startActivity(intent4);
  754. MainApplication.h5_url = "";
  755. MainApplication.type = "";
  756. MainApplication.mainSkip = "1";
  757. finish();
  758. }
  759. }
  760. if (MainApplication.type.equals("PushCommodity")) {
  761. long appTime11 = System.currentTimeMillis() / 1000;
  762. // Log.e("sfv_url===", getIntent().getStringExtra("shareUrl"));
  763. // Log.i("appTime(long)---", appTime11 + "");
  764. long updatetime1 = appTime11 - MainMapActivity.cha - 5;
  765. // Log.i("updatetime(long)---", updatetime1 + "");
  766. // Log.i("cha---", MainMapActivity.cha + "");
  767. String token1 = String.valueOf(updatetime1);
  768. String encode_token = null;
  769. try {
  770. encode_token = DES3.encode(token1);
  771. } catch (Exception e) {
  772. e.printStackTrace();
  773. }
  774. String replace = URLEncoder.encode(encode_token);
  775. // startActivity(new Intent(getApplication(), ShopActivity.class));
  776. Intent intent11 = new Intent();
  777. intent11.setClass(getApplicationContext(), CreditActivity.class);
  778. intent11.putExtra("navColor", "#fcfcfc"); //配置导航条的背景颜色,请用#ffffff长格式。
  779. intent11.putExtra("titleColor", "#222222"); //配置导航条标题的颜色,请用#ffffff长格式。
  780. MainApplication.goods_type = "details";
  781. // MainApplication.current_url = getIntent().getStringExtra("shareUrl");
  782. // MainApplication.current_url = "http://www.duiba.com.cn/mobile/appItemDetail?appItemId=453087";
  783. if (!MainApplication.isLogin()) {
  784. intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.h5_url); //配置自动登陆地址,每次需服务端动态生成。
  785. } else {
  786. intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace + "&url=" + MainApplication.h5_url); //配置自动登陆地址,每次需服务端动态生成。
  787. }
  788. startActivity(intent11);
  789. MainApplication.ad_link = "";
  790. overridePendingTransition(0, 0);
  791. CreditActivity.creditsListener = new CreditActivity.CreditsListener() {
  792. /**
  793. * 当点击分享按钮被点击
  794. * @param shareUrl 分享的地址
  795. * @param shareThumbnail 分享的缩略图
  796. * @param shareTitle 分享的标题
  797. * @param shareSubtitle 分享的副标题
  798. */
  799. public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
  800. //当分享按钮被点击时,会调用此处代码。在这里处理分享的业务逻辑。
  801. // new AlertDialog.Builder(webView.getContext())
  802. // .setTitle("分享信息")
  803. // .setItems(new String[] {"标题:"+shareTitle,"副标题:"+shareSubtitle,"缩略图地址:"+shareThumbnail,"链接:"+shareUrl}, null)
  804. // .setNegativeButton("确定", null)
  805. // .show();
  806. ChargingShareBean chargingShareBean = new ChargingShareBean();
  807. chargingShareBean.setIcon(shareThumbnail);
  808. chargingShareBean.setTitle(shareTitle);
  809. chargingShareBean.setUrl(shareUrl);
  810. chargingShareBean.setText("");
  811. showSimpleBottomSheetGrid(chargingShareBean);
  812. }
  813. /**
  814. * 当点击“请先登录”按钮唤起登录时,会调用此处代码。
  815. * 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
  816. * @param webView 用于登录成功后返回到当前的webview刷新登录状态。
  817. * @param currentUrl 当前页面的url
  818. */
  819. public void onLoginClick(WebView webView, final String currentUrl) {
  820. //当未登录的用户点击去登录时,会调用此处代码。
  821. //用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
  822. //为了用户登录后能回到未登录前的页面(currentUrl)。
  823. //当用户登录成功后,需要重新请求一次服务端,带上currentUrl。
  824. //用该方法中的webview变量加载请求链接。
  825. //服务端收到请求后在生成免登录url时,将currentUrl放入redirect参数,通知客户端302跳转到新生成的免登录URL。
  826. new android.app.AlertDialog.Builder(webView.getContext())
  827. .setTitle("跳转登录")
  828. .setMessage("跳转到登录页面?")
  829. .setPositiveButton("是", new DialogInterface.OnClickListener() {
  830. @Override
  831. public void onClick(DialogInterface dialog, int which) {
  832. // MainApplication.current_url = currentUrl;
  833. MainApplication.h5_url = currentUrl;
  834. context.startActivity(new Intent(getApplicationContext(), LoginActivity.class));
  835. }
  836. })
  837. .setNegativeButton("否", null)
  838. .show();
  839. }
  840. /**
  841. * 当点击“复制”按钮时,触发该方法,回调获取到券码code
  842. * @param webView webview对象。
  843. * @param code 复制的券码
  844. */
  845. public void onCopyCode(WebView webView, String code) {
  846. //当未登录的用户点击去登录时,会调用此处代码。
  847. new android.app.AlertDialog.Builder(webView.getContext())
  848. .setTitle("复制券码")
  849. .setMessage("已复制,券码为:" + code)
  850. .setPositiveButton("是", null)
  851. .setNegativeButton("否", null)
  852. .show();
  853. }
  854. /**
  855. * 积分商城返回首页刷新积分时,触发该方法。
  856. */
  857. public void onLocalRefresh(WebView mWebView, String credits) {
  858. //String credits为积分商城返回的最新积分,不保证准确。
  859. //触发更新本地积分,这里建议用ajax向自己服务器请求积分值,比较准确。
  860. // Toast.makeText(getApplicationContext(), "触发本地刷新积分:" + credits, Toast.LENGTH_SHORT).show();
  861. }
  862. };
  863. }
  864. if (MainApplication.ad_link.equals("1")) {
  865. againPoint = "1";
  866. is_dui = getIntent().getStringExtra("is_dui");
  867. // Log.e("is_dui===", is_dui);
  868. String url1 = getIntent().getStringExtra("shareUrl"); // web address
  869. // Log.e("z222", url1);
  870. if (is_dui.equals("0")) {
  871. Intent intent2 = new Intent(getApplication(), HomeWebActivity.class);
  872. // intent2.putExtra("shareUrl",url1);
  873. intent2.putExtra("shareUrl", url1);
  874. intent2.putExtra("shareTitle", getIntent().getStringExtra("shareTitle"));
  875. intent2.putExtra("shareIcon", getIntent().getStringExtra("shareIcon"));
  876. intent2.putExtra("shareContent", getIntent().getStringExtra("shareContent"));
  877. intent2.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  878. startActivity(intent2);
  879. MainApplication.ad_link = "";
  880. overridePendingTransition(0, 0);
  881. } else {
  882. long appTime11 = System.currentTimeMillis() / 1000;
  883. // Log.e("sfv_url===", getIntent().getStringExtra("shareUrl"));
  884. // Log.i("appTime(long)---", appTime11 + "");
  885. long updatetime1 = appTime11 - MainMapActivity.cha - 5;
  886. // Log.i("updatetime(long)---", updatetime1 + "");
  887. // Log.i("cha---", MainMapActivity.cha + "");
  888. String token1 = String.valueOf(updatetime1);
  889. String encode_token = null;
  890. try {
  891. encode_token = DES3.encode(token1);
  892. } catch (Exception e) {
  893. e.printStackTrace();
  894. }
  895. String replace = URLEncoder.encode(encode_token);
  896. // startActivity(new Intent(getApplication(), ShopActivity.class));
  897. Intent intent11 = new Intent();
  898. intent11.setClass(getApplicationContext(), CreditActivity.class);
  899. intent11.putExtra("navColor", "#fcfcfc"); //配置导航条的背景颜色,请用#ffffff长格式。
  900. intent11.putExtra("titleColor", "#222222"); //配置导航条标题的颜色,请用#ffffff长格式。
  901. MainApplication.goods_type = "details";
  902. MainApplication.current_url = getIntent().getStringExtra("shareUrl");
  903. // MainApplication.current_url = "http://www.duiba.com.cn/mobile/appItemDetail?appItemId=453087";
  904. if (!MainApplication.isLogin()) {
  905. intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.current_url); //配置自动登陆地址,每次需服务端动态生成。
  906. } else {
  907. intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace + "&url=" + MainApplication.current_url); //配置自动登陆地址,每次需服务端动态生成。
  908. }
  909. startActivity(intent11);
  910. MainApplication.ad_link = "";
  911. overridePendingTransition(0, 0);
  912. CreditActivity.creditsListener = new CreditActivity.CreditsListener() {
  913. /**
  914. * 当点击分享按钮被点击
  915. * @param shareUrl 分享的地址
  916. * @param shareThumbnail 分享的缩略图
  917. * @param shareTitle 分享的标题
  918. * @param shareSubtitle 分享的副标题
  919. */
  920. public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
  921. ChargingShareBean chargingShareBean = new ChargingShareBean();
  922. chargingShareBean.setIcon(shareThumbnail);
  923. chargingShareBean.setTitle(shareTitle);
  924. chargingShareBean.setUrl(shareUrl);
  925. chargingShareBean.setText("");
  926. showSimpleBottomSheetGrid(chargingShareBean);
  927. }
  928. /**
  929. * 当点击“请先登录”按钮唤起登录时,会调用此处代码。
  930. * 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
  931. * @param webView 用于登录成功后返回到当前的webview刷新登录状态。
  932. * @param currentUrl 当前页面的url
  933. */
  934. public void onLoginClick(WebView webView, final String currentUrl) {
  935. //当未登录的用户点击去登录时,会调用此处代码。
  936. //用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
  937. //为了用户登录后能回到未登录前的页面(currentUrl)。
  938. //当用户登录成功后,需要重新请求一次服务端,带上currentUrl。
  939. //用该方法中的webview变量加载请求链接。
  940. //服务端收到请求后在生成免登录url时,将currentUrl放入redirect参数,通知客户端302跳转到新生成的免登录URL。
  941. new android.app.AlertDialog.Builder(webView.getContext())
  942. .setTitle("跳转登录")
  943. .setMessage("跳转到登录页面?")
  944. .setPositiveButton("是", new DialogInterface.OnClickListener() {
  945. @Override
  946. public void onClick(DialogInterface dialog, int which) {
  947. // MainApplication.current_url = currentUrl;
  948. MainApplication.current_url = currentUrl;
  949. context.startActivity(new Intent(getApplicationContext(), LoginActivity.class));
  950. }
  951. })
  952. .setNegativeButton("否", null)
  953. .show();
  954. }
  955. /**
  956. * 当点击“复制”按钮时,触发该方法,回调获取到券码code
  957. * @param webView webview对象。
  958. * @param code 复制的券码
  959. */
  960. public void onCopyCode(WebView webView, String code) {
  961. //当未登录的用户点击去登录时,会调用此处代码。
  962. new android.app.AlertDialog.Builder(webView.getContext())
  963. .setTitle("复制券码")
  964. .setMessage("已复制,券码为:" + code)
  965. .setPositiveButton("是", null)
  966. .setNegativeButton("否", null)
  967. .show();
  968. }
  969. /**
  970. * 积分商城返回首页刷新积分时,触发该方法。
  971. */
  972. public void onLocalRefresh(WebView mWebView, String credits) {
  973. //String credits为积分商城返回的最新积分,不保证准确。
  974. //触发更新本地积分,这里建议用ajax向自己服务器请求积分值,比较准确。
  975. // Toast.makeText(getApplicationContext(), "触发本地刷新积分:" + credits, Toast.LENGTH_SHORT).show();
  976. }
  977. };
  978. }
  979. // finish();
  980. }
  981. context = this;
  982. gestureguide = ProfileManager.getInstance().getGestureguide(getApplicationContext());
  983. // //开启logcat输出,方便debug,发布时请关闭
  984. // XGPushConfig.enableDebug(this, false);
  985. // XGPushManager.registerPush(context);
  986. //
  987. // Context context = getApplicationContext();
  988. // Intent service = new Intent(context, XGPushService.class);
  989. // context.startService(service);
  990. dialog = new LoadingDialog(this);
  991. dialog.setCanceledOnTouchOutside(false);
  992. setUserData();
  993. setlogin();
  994. mMarkerView = LayoutInflater.from(this).inflate(R.layout.view_custom_marker, null);
  995. mMarkerView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
  996. LinearLayout.LayoutParams.WRAP_CONTENT));
  997. mMarkerViewYes = LayoutInflater.from(this).inflate(R.layout.view_custom_yes, null);
  998. mMarkerViewYes.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
  999. LinearLayout.LayoutParams.WRAP_CONTENT));
  1000. mMarkerView1 = LayoutInflater.from(this).inflate(R.layout.view_custom_marker1, null);
  1001. mMarkerView1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
  1002. LinearLayout.LayoutParams.WRAP_CONTENT));
  1003. mMarkerViewcity = LayoutInflater.from(this).inflate(R.layout.view_custom_markercity, null);
  1004. mMarkerViewcity.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
  1005. LinearLayout.LayoutParams.WRAP_CONTENT));
  1006. mMarkerViewAppS = LayoutInflater.from(this).inflate(R.layout.view_custom_marker_apps, null);
  1007. mMarkerViewAppS.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
  1008. LinearLayout.LayoutParams.WRAP_CONTENT));
  1009. mMarkerViewAppB = LayoutInflater.from(this).inflate(R.layout.view_custom_marker_appb, null);
  1010. mMarkerViewAppB.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
  1011. LinearLayout.LayoutParams.WRAP_CONTENT));
  1012. mapView = (MapView) findViewById(R.id.mapView);
  1013. mapView.onCreate(savedInstanceState);
  1014. initViews();
  1015. getRecyclerViewData();
  1016. File databasePath = getDatabasePath("zhan_list");
  1017. if (databasePath.exists()) {
  1018. eteinit("{\"fun\":\"timer\"}");
  1019. try {
  1020. getZhanData();
  1021. } catch (Exception e) {
  1022. e.printStackTrace();
  1023. }
  1024. } else {
  1025. LogUtils.e("不存在");
  1026. try {
  1027. initDataBase();
  1028. } catch (IOException e) {
  1029. e.printStackTrace();
  1030. }
  1031. }
  1032. showUi(MainApplication.isMap);
  1033. if (MainApplication.haveActivity == true) {
  1034. List<Adin> listAdin = JsonUtils.parseToObjectList("[" + MainApplication.ad_major + "]", Adin.class);
  1035. // System.out.print("size:" + listAdin.size());
  1036. if (listAdin.size() > 0) {
  1037. sav.initData(listAdin);
  1038. rl_ad.setVisibility(View.VISIBLE);
  1039. }
  1040. }
  1041. new Handler().postDelayed(new Runnable() {
  1042. @Override
  1043. public void run() {
  1044. if (login_meg.equals("")) {
  1045. login_meg = "我知道你关注我很久了,快来注册登录吧,登录后可以在特来电、聚电科技充电桩扫码充电";
  1046. }
  1047. if (MainApplication.count == 2 || MainApplication.count == 24 || MainApplication.count == 44 || MainApplication.count == 64 || MainApplication.count == 84 || MainApplication.count == 104) {
  1048. if (MainApplication.isIgnore == true) {
  1049. new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
  1050. .setMsg(login_meg)
  1051. .setPositiveButton("去登录", new View.OnClickListener() {
  1052. @Override
  1053. public void onClick(View v) {
  1054. Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
  1055. startActivity(intent);
  1056. }
  1057. }).setNegativeButton("忽略", new View.OnClickListener() {
  1058. @Override
  1059. public void onClick(View v) {
  1060. MainApplication.isIgnore = false;
  1061. }
  1062. }).show();
  1063. MobclickAgent.onEvent(context, "0041");
  1064. }
  1065. }
  1066. }
  1067. }, 2000);
  1068. }
  1069. private void initViews() {
  1070. rl_charging_notice = (RelativeLayout) findViewById(R.id.rl_charging_notice);
  1071. rl_charging_notice.setOnClickListener(this);
  1072. tab_qa = (LinearLayout) findViewById(R.id.tab_qa);
  1073. tab_qa.setOnClickListener(this);
  1074. iv_guzhang = (ImageView) findViewById(R.id.iv_guzhang);
  1075. windowName = (TextView) findViewById(R.id.window_tv_zhan_name);
  1076. stopCost = findViewById(R.id.window_tv_stop_cost);
  1077. windowGrade = (TextView) findViewById(R.id.window_tv_zhan_grade);
  1078. windowCost = (TextView) findViewById(R.id.window_tv_zhan_cost);
  1079. private_telephone = findViewById(R.id.private_telephone);
  1080. window_tv_fast_free_num = (TextView) findViewById(R.id.window_tv_fast_free_num);
  1081. window_tv_fast_free_label = findViewById(R.id.window_tv_fast_free_label);
  1082. window_tv_fast_total_num = findViewById(R.id.window_tv_fast_total_num);
  1083. window_tv_slow_free_label = findViewById(R.id.window_tv_slow_free_label);
  1084. window_tv_slow_free_num = findViewById(R.id.window_tv_slow_free_num);
  1085. window_tv_slow_total_num = findViewById(R.id.window_tv_slow_total_num);
  1086. windowCommentNum = (TextView) findViewById(R.id.window_tv_comment_num);
  1087. // windowDistance = (TextView) findViewById(R.id.window_tv_zhan_distance);
  1088. windowChargeRecordCnt = findViewById(R.id.window_tv_charge_record_cnt);
  1089. windowChargeRecordCntLine = findViewById(R.id.window_tv_charge_record_cnt_line);
  1090. windowZongjia = findViewById(R.id.window_tv_zongjia);
  1091. windowZongjiaLayout = findViewById(R.id.window_tv_zongjia_layout);
  1092. windowRedPaperBag = findViewById(R.id.iv_red_paper_bag);
  1093. windowLabelPublic = findViewById(R.id.iv_label_public);
  1094. windowLabelGround = findViewById(R.id.iv_label_ground);
  1095. windowLabelFreePark = findViewById(R.id.iv_label_free_park);
  1096. // windowChat = findViewById(R.id.iv_chat);
  1097. windowGo = (RelativeLayout) findViewById(R.id.window_rl_go);
  1098. windowZhanDetails = (RelativeLayout) findViewById(R.id.window_rl_zhan_details);
  1099. windowComments = (RelativeLayout) findViewById(R.id.window_rl_comment);
  1100. windowAd = (ImageView) findViewById(R.id.window_iv_ad);
  1101. windowGradeImg = (ImageView) findViewById(R.id.window_iv_zhan_grade);
  1102. iv_tuijian_close = (ImageView) findViewById(R.id.iv_tuijian_close);
  1103. iv_tuijian_tip_close = (ImageView) findViewById(R.id.iv_tuijian_tip_close);
  1104. iv_tuijian_close.setOnClickListener(this);
  1105. iv_tuijian_tip_close.setOnClickListener(this);
  1106. ll_recommend = (LinearLayout) findViewById(R.id.ll_recommend);
  1107. tv_recommend_tip = (TextView) findViewById(R.id.tv_recommend_tip);
  1108. tv_tuijian_feedback = (TextView) findViewById(R.id.tv_tuijian_feedback);
  1109. tv_tuijian_feedback.setOnClickListener(this);
  1110. ll_map_control = (LinearLayout) findViewById(R.id.ll_map_control);
  1111. windowLayout = (RelativeLayout) findViewById(R.id.window_ll_zhan);
  1112. ll_top_right = (LinearLayout) findViewById(R.id.ll_top_right);
  1113. iv_tuijian = (ImageView) findViewById(R.id.iv_tuijian);
  1114. iv_route = (ImageView) findViewById(R.id.iv_route);
  1115. second_hand_car = findViewById(R.id.second_hand_car);
  1116. iv_tuijian.setOnClickListener(this);
  1117. iv_route.setOnClickListener(this);
  1118. second_hand_car.setOnClickListener(this);
  1119. iVpoint = findViewById(R.id.iv_point);
  1120. window_ll_zhan = (RelativeLayout) findViewById(R.id.window_ll_zhan);
  1121. tv_search = (TextView) findViewById(R.id.tv_search);
  1122. tv_msg_num = (TextView) findViewById(R.id.tv_msg_num);
  1123. tv_shaixuan = (TextView) findViewById(R.id.tv_shaixuan);
  1124. tv_shaixuan.setOnClickListener(this);
  1125. iv_example = (ImageView) findViewById(R.id.iv_example);
  1126. iv_example.setOnClickListener(this);
  1127. iv_clear_address = (ImageView) findViewById(R.id.iv_clear_address);
  1128. iv_clear_address.setOnClickListener(this);
  1129. ll_tuijian = (LinearLayout) findViewById(R.id.ll_tuijian);
  1130. ll_tuijian.setOnClickListener(new View.OnClickListener() {
  1131. @Override
  1132. public void onClick(View v) {
  1133. Log.e(TAG, "onClick: 333");
  1134. }
  1135. });
  1136. ll_tuijian.setOnTouchListener(new View.OnTouchListener() {
  1137. float mCurPosX, mCurPosY, mPosX, mPosY;
  1138. @Override
  1139. public boolean onTouch(View v, MotionEvent event) {
  1140. switch (event.getAction()) {
  1141. case MotionEvent.ACTION_UP:
  1142. mCurPosX = event.getX();
  1143. mCurPosY = event.getY();
  1144. Log.e(TAG, "onTouch: 111");
  1145. break;
  1146. case MotionEvent.ACTION_DOWN:
  1147. mPosX = event.getX();
  1148. mPosY = event.getY();
  1149. Log.e(TAG, "onTouch: 222");
  1150. break;
  1151. case MotionEvent.ACTION_MOVE:
  1152. if (mCurPosY - mPosY > 0
  1153. && (Math.abs(mCurPosY - mPosY) > 25)) {
  1154. Log.e(TAG, "onTouch: 向下滑動");
  1155. //向下滑動
  1156. } else if (mCurPosY - mPosY < 0
  1157. && (Math.abs(mCurPosY - mPosY) > 25)) {
  1158. Log.e(TAG, "onTouch: 向上滑动");
  1159. //向上滑动
  1160. }
  1161. Log.e(TAG, "onTouch: qqqq");
  1162. break;
  1163. }
  1164. return false;
  1165. }
  1166. });
  1167. // add by hyg 气泡红包图标点击操作
  1168. windowRedPaperBag.setOnClickListener(new View.OnClickListener() {
  1169. @Override
  1170. public void onClick(View view) {
  1171. Intent intent_example = new Intent(getApplicationContext(), ExampleActivity.class);
  1172. intent_example.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  1173. startActivity(intent_example);
  1174. overridePendingTransition(0, 0);
  1175. }
  1176. });
  1177. // add by hyg 点击跳转到聊聊 隐藏该功能
  1178. // windowChat.setOnClickListener(new View.OnClickListener() {
  1179. // @Override
  1180. // public void onClick(View view) {
  1181. // if (socket != null) {
  1182. // try {
  1183. // socket.close();
  1184. // } catch (IOException e) {
  1185. // e.printStackTrace();
  1186. // }
  1187. // }
  1188. // MobclickAgent.onEvent(getApplicationContext(), "1121");
  1189. // Intent i = new Intent(getApplication(), ChatActivity.class);//聊聊页面
  1190. // i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  1191. // startActivity(i);
  1192. // overridePendingTransition(0, 0);
  1193. // if (count == 1) {
  1194. //
  1195. // count = 2;
  1196. // }
  1197. // MobclickAgent.onEvent(getApplicationContext(), "0999");
  1198. // windowLayout.setVisibility(View.GONE);
  1199. //
  1200. //
  1201. // rl_control.setVisibility(View.VISIBLE);
  1202. // if (nMarker != null) {
  1203. // nMarker.hideInfoWindow();
  1204. // MarkerOptions markerOptionss = new MarkerOptions();
  1205. // if (current_chargePoint.getOwn_pay().equals("1")) {
  1206. // nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
  1207. // } else {
  1208. // if (current_chargePoint.getSuit_car().equals("特斯拉")) {
  1209. // nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  1210. // } else {
  1211. // if (WelcomeActivity.canCost.contains(current_chargePoint.getSupplier())) {
  1212. // nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
  1213. // } else {
  1214. // nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  1215. // }
  1216. // }
  1217. // }
  1218. // }
  1219. //
  1220. // }
  1221. // });
  1222. tv_sortDistance = (TextView) findViewById(R.id.tv_sortDistance);
  1223. tv_sortDistance.setOnClickListener(this);
  1224. tv_sortStarLevel = (TextView) findViewById(R.id.tv_sortStarLevel);
  1225. tv_sortStarLevel.setOnClickListener(this);
  1226. tv_sortFreeTime = (TextView) findViewById(R.id.tv_sortFreeTime);
  1227. tv_sortFreeTime.setOnClickListener(this);
  1228. rl_mapList = (RelativeLayout) findViewById(R.id.rl_mapList);
  1229. iv_roadCondition = (ImageView) findViewById(R.id.iv_roadCondition);
  1230. iv_roadCondition.setOnClickListener(this);
  1231. iv_yindaoye = (ImageView) findViewById(R.id.iv_yindaoye);
  1232. iv_yindaoye.setOnClickListener(this);
  1233. rl_grade = (RelativeLayout) findViewById(R.id.rl_grade);
  1234. iv_grade = (ImageView) findViewById(R.id.iv_grade);
  1235. tv_grade = (TextView) findViewById(R.id.tv_grade);
  1236. userLogin = (TextView) findViewById(R.id.tv_userLogin);
  1237. mTvMarkerViewNum = (TextView) mMarkerView.findViewById(R.id.tv_num);
  1238. mTvMarkerViewNumAppS = (TextView) mMarkerViewAppS.findViewById(R.id.tv_num);
  1239. mTvMarkerViewNumAppB = (TextView) mMarkerViewAppB.findViewById(R.id.tv_num);
  1240. mIvMarkerBg = (ImageView) mMarkerView.findViewById(R.id.iv_icon);
  1241. mIvMarkerAppS = (ImageView) mMarkerViewAppS.findViewById(R.id.iv_icon);
  1242. mIvMarkerAppB = (ImageView) mMarkerViewAppB.findViewById(R.id.iv_icon);
  1243. mTvMarkerViewNum1 = (TextView) mMarkerView1.findViewById(R.id.tv_num);
  1244. mIvMarkerBg1 = (ImageView) mMarkerView1.findViewById(R.id.iv_icon);
  1245. mIvMarkerBgYes = (ImageView) mMarkerViewYes.findViewById(R.id.iv_icon);
  1246. mIvMarkerBgcity = (ImageView) mMarkerViewcity.findViewById(R.id.iv_icon);
  1247. mTvMarkerViewNumcity = (TextView) mMarkerViewcity.findViewById(R.id.tv_num);
  1248. //用户中心图标
  1249. iv_our = (ImageView) findViewById(R.id.iv_our);
  1250. //首页广告
  1251. rl_ad = (RelativeLayout) findViewById(R.id.rl_ad);
  1252. //首页广告pager
  1253. sav = (SlideAdView) findViewById(R.id.imageView8);
  1254. //首页广告关闭按钮
  1255. iv_clear = (ImageView) findViewById(R.id.iv_clear);
  1256. iv_clear.setOnClickListener(this);
  1257. tv_citynotice = (RelativeLayout) findViewById(R.id.tv_citynotice);
  1258. tv_citynotice.setOnClickListener(new View.OnClickListener() {
  1259. @Override
  1260. public void onClick(View v) {
  1261. tv_citynotice.setVisibility(View.GONE);
  1262. tv_notice.setVisibility(View.GONE);
  1263. city_no = 1;
  1264. }
  1265. });
  1266. ll_tab_find = (RelativeLayout) findViewById(R.id.ll_tab_find);
  1267. ll_tab_find.setOnClickListener(this);
  1268. tab_screen = (LinearLayout) findViewById(R.id.tab_screening);
  1269. tab_screen.setOnClickListener(this);
  1270. tab_me = (LinearLayout) findViewById(R.id.tab_me);
  1271. tab_me.setOnClickListener(this);
  1272. // if (firstOpen == true) {
  1273. // getVersion();
  1274. //// eteinit("{\"fun\":\"timer\"}");
  1275. // getMessage();
  1276. //// clickMarker = false;
  1277. // firstOpen = false;
  1278. // }
  1279. // getMessage();
  1280. inBtn = (ImageView) findViewById(R.id.zoomin);
  1281. inBtn.setOnClickListener(this);
  1282. outBtn = (ImageView) findViewById(R.id.zoomout);
  1283. outBtn.setOnClickListener(this);
  1284. //站点地图列表切换按钮
  1285. iv_list = (TextView) findViewById(R.id.iv_list);
  1286. iv_list.setOnClickListener(this);
  1287. SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
  1288. //站点列表
  1289. lvZhan = (ListView) findViewById(R.id.lv_zhan_list);
  1290. adapter = new ZhanAdapter();
  1291. //条件筛选按钮
  1292. iv_sceen = (ImageView) findViewById(R.id.tv_person);
  1293. iv_sceen.setOnClickListener(this);
  1294. rl_control = (LinearLayout) findViewById(R.id.rl_control);
  1295. tv_tishi = (TextView) findViewById(R.id.tv_tishi);
  1296. //切换城市按钮
  1297. tv_atCity = (TextView) findViewById(R.id.tv_switch_city);
  1298. tv_atCity.setOnClickListener(this);
  1299. ll_open = (LinearLayout) findViewById(R.id.ll_open);
  1300. //显示该站点评论数量
  1301. tv_num = (TextView) findViewById(R.id.tv_num);
  1302. //定位按钮
  1303. iv_refresh = (ImageView) findViewById(R.id.iv_point_again);
  1304. iv_refresh.setOnClickListener(this);
  1305. paoRl = (RelativeLayout) findViewById(R.id.rela_paopao);
  1306. paoName = (TextView) findViewById(R.id.window_tv_zhan_name);
  1307. paoName.setFocusable(true);
  1308. paoAddress = (TextView) findViewById(R.id.tv_address);
  1309. paoCostWay = (TextView) findViewById(R.id.window_tv_zhan_cost);
  1310. paoDaohang = (TextView) findViewById(R.id.detail_daohang);
  1311. // paoDistance = (TextView) findViewById(R.id.window_tv_zhan_distance);
  1312. paoFast = (TextView) findViewById(R.id.tv_fastNum);
  1313. paoSlow = (TextView) findViewById(R.id.tv_slowNum);
  1314. paoAlter = (TextView) findViewById(R.id.tv_detail_alter);
  1315. paoTotal = (TextView) findViewById(R.id.tv_totalNum);
  1316. paopaoAd = (ImageView) findViewById(R.id.window_iv_ad);
  1317. tv_daohang = (TextView) findViewById(R.id.tv_daohang);
  1318. rela = (RelativeLayout) findViewById(R.id.rela);
  1319. ll_comment = (RelativeLayout) findViewById(R.id.window_rl_comment);
  1320. ll_paoxiang = (RelativeLayout) findViewById(R.id.window_rl_go);
  1321. rl_tuijian_tip = (RelativeLayout) findViewById(R.id.rl_tuijian_tip);
  1322. rl_tuijian_tip.setOnClickListener(this);
  1323. ll_paogo = (LinearLayout) findViewById(R.id.ll_paogo);
  1324. tingche = (TextView) findViewById(R.id.tv_park);
  1325. fuwu = (TextView) findViewById(R.id.tv_service);
  1326. dian = (TextView) findViewById(R.id.tv_charge);
  1327. rl_search = (RelativeLayout) findViewById(R.id.rl_search);
  1328. rl_search.setOnClickListener(this);
  1329. // tv_detail_alter.setOnClickListener(this);
  1330. ll_title = (LinearLayout) findViewById(R.id.ll_title);
  1331. if (aMap == null) {
  1332. aMap = mapView.getMap();
  1333. Util.setMapCustomStyleFile(aMap, getApplicationContext());
  1334. maxZoomLevel = aMap.getMaxZoomLevel();
  1335. minZoomLevel = aMap.getMinZoomLevel();
  1336. MyLocationStyle myLocationStyle = new MyLocationStyle();
  1337. myLocationStyle.myLocationIcon(BitmapDescriptorFactory
  1338. .fromResource(R.drawable.point_icon));// 设置小蓝点的图标
  1339. myLocationStyle.strokeColor(getResources().getColor(R.color.transparent));
  1340. myLocationStyle.radiusFillColor(getResources().getColor(R.color.transparent));
  1341. aMap.setMyLocationStyle(myLocationStyle);
  1342. mUiSettings = aMap.getUiSettings();
  1343. setUpMap();
  1344. }
  1345. iv_find = (ImageView) findViewById(R.id.iv_find);
  1346. iv_main = (ImageView) findViewById(R.id.iv_main);
  1347. iv_screening = (ImageView) findViewById(R.id.iv_screening);
  1348. tv_main = (TextView) findViewById(R.id.tv_main);
  1349. if (MainApplication.festival_time.equals("1")) {
  1350. iv_screening.setImageResource(R.drawable.icon_cj2);
  1351. iv_main.setImageResource(R.drawable.icon_cj1);
  1352. iv_find.setImageResource(R.drawable.icon_cj3);
  1353. tv_main.setTextColor(getResources().getColor(R.color.jieri));
  1354. iv_list.setTextColor(getResources().getColor(R.color.white));
  1355. ll_title.setBackgroundResource(R.color.jieri);
  1356. tv_atCity.setTextColor(getResources().getColor(R.color.white));
  1357. Drawable nav_up = getResources().getDrawable(R.drawable.iocn_down_white);
  1358. nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
  1359. tv_atCity.setCompoundDrawables(null, null, nav_up, null);
  1360. } else if (MainApplication.festival_time.equals("2")) {
  1361. iv_screening.setImageResource(R.drawable.icon_yx2);
  1362. iv_main.setImageResource(R.drawable.icon_yx1);
  1363. iv_find.setImageResource(R.drawable.icon_yx3);
  1364. tv_main.setTextColor(getResources().getColor(R.color.jieri));
  1365. iv_list.setTextColor(getResources().getColor(R.color.white));
  1366. ll_title.setBackgroundResource(R.color.jieri);
  1367. tv_atCity.setTextColor(getResources().getColor(R.color.white));
  1368. Drawable nav_up = getResources().getDrawable(R.drawable.iocn_down_white);
  1369. nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
  1370. tv_atCity.setCompoundDrawables(null, null, nav_up, null);
  1371. }
  1372. }
  1373. private void loadAdfloatImg(Adin adin) {
  1374. adfloatUrl = adin.getUrl();
  1375. Glide.with(this).load(MainApplication.url + "/zhannew/uploadfile/" + adin.getIcon()).listener(new RequestListener<Drawable>() {
  1376. @Override
  1377. public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
  1378. second_hand_car.setVisibility(View.GONE);
  1379. return false;
  1380. }
  1381. @Override
  1382. public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
  1383. second_hand_car.setVisibility(View.VISIBLE);
  1384. return false;
  1385. }
  1386. }).into(second_hand_car);
  1387. }
  1388. /**
  1389. * 设置一些amap的属性
  1390. */
  1391. private void setUpMap() {
  1392. // aMap.setOnMarkerClickListener(this);// 设置点击marker事件监听器
  1393. aMap.setOnCameraChangeListener(this);
  1394. aMap.setLocationSource(this);// 设置定位监听
  1395. aMap.setOnMapClickListener(this);
  1396. aMap.setOnMarkerClickListener(this);
  1397. aMap.setInfoWindowAdapter(this);
  1398. aMap.setOnInfoWindowClickListener(this);
  1399. aMap.setOnMapLoadedListener(this);// 设置amap加载成功事件监听器
  1400. aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
  1401. aMap.getUiSettings().setZoomControlsEnabled(false);// 设置默认缩放按钮是否显示
  1402. aMap.getUiSettings().setScaleControlsEnabled(true);// 设置比例尺是否显示
  1403. aMap.getUiSettings().setRotateGesturesEnabled(false);// 设置地图是否旋转
  1404. // aMap.getUiSettings().setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_CENTER);
  1405. aMap.setTrafficEnabled(true);
  1406. }
  1407. @Override
  1408. protected void onNewIntent(Intent intent) {
  1409. super.onNewIntent(intent);
  1410. setIntent(intent);
  1411. }
  1412. /**
  1413. * 方法必须重写
  1414. */
  1415. @Override
  1416. protected void onResume() {
  1417. super.onResume();
  1418. String search_address = ProfileManager.getInstance().getSearchAddress(this);
  1419. if (search_address.equals("")) {
  1420. tv_search.setText("请输入地址/关键字");
  1421. iv_clear_address.setVisibility(View.INVISIBLE);
  1422. } else {
  1423. tv_search.setText(search_address);
  1424. iv_clear_address.setVisibility(View.VISIBLE);
  1425. }
  1426. String from = getIntent().getStringExtra("from");
  1427. if ("search_from_activity".equals(from)) {
  1428. searchAll();
  1429. }
  1430. if (FindActivity.haveFindMessage == true) {
  1431. iVpoint.setVisibility(View.VISIBLE);
  1432. } else {
  1433. iVpoint.setVisibility(View.GONE);
  1434. }
  1435. saveTask();
  1436. if (MainApplication.haveActivity == false) {
  1437. if (MainApplication.isLogin() && MainApplication.isAppStart == true) {
  1438. userChargingCheck();
  1439. } else {
  1440. rl_charging_notice.setVisibility(View.GONE);
  1441. }
  1442. getMessageNum();
  1443. }
  1444. if (onResumeRefresh == true) {
  1445. try {
  1446. getZhanData();
  1447. } catch (Exception e) {
  1448. e.printStackTrace();
  1449. }
  1450. onResumeRefresh = false;
  1451. }
  1452. if (ProfileManager.getInstance().getRoadCondition(getApplicationContext()) == false) {
  1453. iv_roadCondition.setImageResource(R.drawable.icon_wulukuang_main);
  1454. aMap.setTrafficEnabled(false);
  1455. } else {
  1456. iv_roadCondition.setImageResource(R.drawable.icon_youlukuang_main);
  1457. aMap.setTrafficEnabled(true);
  1458. }
  1459. mapView.onResume();
  1460. if (againPoint.equals("1") && back.equals("1")) {
  1461. if (!isFirstLoc) {
  1462. isFirstLoc = true;
  1463. mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
  1464. aMap.setLocationSource(this);// 设置定位监听
  1465. aMap.setMyLocationEnabled(true);// 是否可触发定位并显示定位层
  1466. aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
  1467. mlocationClient.startLocation();
  1468. }
  1469. againPoint = "";
  1470. back = "";
  1471. }
  1472. detailsBack = false;
  1473. changeButton();
  1474. }
  1475. private void searchAll() {
  1476. if ("请输入地址/关键字".equals(tv_search.getText().toString())) {
  1477. if (search_marker != null) {
  1478. search_marker.remove();
  1479. }
  1480. return;
  1481. }
  1482. double jing = Double.valueOf(getIntent().getStringExtra("jing"));
  1483. double wei = Double.valueOf(getIntent().getStringExtra("wei"));
  1484. MainApplication.search_jing = jing;
  1485. MainApplication.search_wei = wei;
  1486. final LatLng screenCity = new LatLng(wei, jing);
  1487. aMap = mapView.getMap();
  1488. Util.setMapCustomStyleFile(aMap, getApplicationContext());
  1489. new Handler().postDelayed(new Runnable() {
  1490. @Override
  1491. public void run() {
  1492. aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
  1493. }
  1494. }, 500);
  1495. if (search_marker != null) {
  1496. search_marker.remove();
  1497. }
  1498. if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
  1499. LatLng latLng = new LatLng(MainApplication.search_wei, MainApplication.search_jing);
  1500. search_marker = aMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.icon_search_address))));
  1501. search_marker.setPeriod(8);
  1502. }
  1503. ete("{\"fun\":\"timer\"}");
  1504. }
  1505. /**
  1506. * 方法必须重写
  1507. */
  1508. @Override
  1509. protected void onPause() {
  1510. super.onPause();
  1511. mapView.onPause();
  1512. // Log.e("onPause", "onPause");
  1513. deactivate();
  1514. }
  1515. /**
  1516. * 方法必须重写
  1517. */
  1518. @Override
  1519. protected void onSaveInstanceState(Bundle outState) {
  1520. super.onSaveInstanceState(outState);
  1521. mapView.onSaveInstanceState(outState);
  1522. // Log.e("onSaveInstanceState", "onSaveInstanceState");
  1523. }
  1524. /**
  1525. * 方法必须重写
  1526. */
  1527. @Override
  1528. protected void onDestroy() {
  1529. super.onDestroy();
  1530. unregisterReceiver(networkChangeReceiver);
  1531. if (mClusterOverlay != null) {
  1532. mClusterOverlay.onDestroy();
  1533. }
  1534. mapView.onDestroy();
  1535. EventBusUtil.unregister(this);
  1536. // Log.e("onDestroy", "onDestroy");
  1537. if (null != mlocationClient) {
  1538. mlocationClient.onDestroy();
  1539. }
  1540. OkHttpUtils.getInstance().cancelTag(MainMapActivity.this);
  1541. SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
  1542. sharedPreferencesUtil.setFileName("CurrentMarkerInfo");
  1543. sharedPreferencesUtil.clearData();
  1544. }
  1545. @Override
  1546. public void activate(OnLocationChangedListener listener) {
  1547. mListener = listener;
  1548. if (mlocationClient == null) {
  1549. mlocationClient = new AMapLocationClient(this);
  1550. mLocationOption = new AMapLocationClientOption();
  1551. //设置定位监听
  1552. mlocationClient.setLocationListener(this);
  1553. //设置为高精度定位模式
  1554. mLocationOption.setLocationMode(AMapLocationMode.Battery_Saving);
  1555. // mLocationOption.setGpsFirst(true);
  1556. // mLocationOption.setOnceLocation(true);
  1557. mLocationOption.setInterval(1500);
  1558. //设置是否强制刷新WIFI,默认为强制刷新
  1559. // mLocationOption.setWifiActiveScan(true);
  1560. //设置定位参数
  1561. mlocationClient.setLocationOption(mLocationOption);
  1562. // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
  1563. // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
  1564. // 在定位结束后,在合适的生命周期调用onDestroy()方法
  1565. // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
  1566. // 设置是否只定位一次,默认为false
  1567. mLocationOption.setOnceLocation(false);
  1568. //设置是否强制刷新WIFI,默认为强制刷新
  1569. //mLocationOption.setWifiActiveScan(false);
  1570. mLocationOption.setWifiScan(true);
  1571. mlocationClient.startLocation();
  1572. }
  1573. }
  1574. @Override
  1575. public void deactivate() {
  1576. mListener = null;
  1577. if (mlocationClient != null) {
  1578. mlocationClient.stopLocation();
  1579. mlocationClient.onDestroy();
  1580. }
  1581. mlocationClient = null;
  1582. }
  1583. @Override
  1584. public void onLocationChanged(AMapLocation amapLocation) {
  1585. if (mListener != null && amapLocation != null) {
  1586. if (amapLocation != null && amapLocation.getErrorCode() == 0) {
  1587. try {
  1588. MainApplication.atCity = amapLocation.getCity().substring(0, amapLocation.getCity().length() - 1);
  1589. location_city = MainApplication.atCity;
  1590. tv_atCity.setText(MainApplication.atCity);
  1591. } catch (NullPointerException e) {
  1592. e.printStackTrace();
  1593. }
  1594. ProfileManager.getInstance().setAtCity(getApplicationContext(), MainApplication.atCity);
  1595. center = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude());
  1596. MainApplication.center = center;
  1597. ete("{\"fun\":\"timer\"}");
  1598. mlocationClient.stopLocation();
  1599. if (MainApplication.haveActivity == false) {
  1600. getBaidu(amapLocation.getLongitude(), amapLocation.getLatitude());
  1601. String uid;
  1602. if (MainApplication.isLogin()) {
  1603. uid = MainApplication.userId;
  1604. } else {
  1605. uid = "";
  1606. }
  1607. String url = "{\"fun\":\"dingwei\",\"poi_jing\":" + "\"" + String.format("%.6f", bd_lon) +
  1608. "\"" + ",\"poi_wei\":" + "\"" + String.format("%.6f", bd_lat) + "\"" + ",\"imei\":"
  1609. + "\"" + "android_" + Util.getUdid() + "\"" + ",\"timer\":" + "\"" + Token
  1610. + "\"" + ",\"registration_id\":" + "\"" + MainApplication.push_id + "\""
  1611. + ",\"userid\":" + "\"" + uid + "\"" + "}";
  1612. eteLocation(url);
  1613. }
  1614. if (isFirstLoc) {
  1615. //设置缩放级别
  1616. //将地图移动到定位点
  1617. aMap.moveCamera(CameraUpdateFactory.changeLatLng(center));
  1618. new Handler().postDelayed(new Runnable() {
  1619. @Override
  1620. public void run() {
  1621. aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
  1622. }
  1623. }, 2000);
  1624. //点击定位按钮 能够将地图的中心移动到定位点
  1625. mListener.onLocationChanged(amapLocation);
  1626. isFirstLoc = false;
  1627. }
  1628. } else {
  1629. String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
  1630. // Log.e("AmapErr", errText);
  1631. // mLocationErrText.setVisibility(View.VISIBLE);
  1632. Toast.makeText(this, errText, Toast.LENGTH_SHORT).show();
  1633. }
  1634. }
  1635. }
  1636. //地图缩放方法
  1637. public static void controlZoomShow() {
  1638. if (aMap != null) {
  1639. float zoom = aMap.getCameraPosition().zoom;
  1640. Log.e(TAG, "controlZoomShow: " + zoom);
  1641. try {
  1642. if (zoom >= maxZoomLevel) {
  1643. inBtn.setImageResource(R.drawable.icon_zoom_in_no);
  1644. inBtn.setEnabled(false);
  1645. // Toast.makeText(getApplication(), "已放大到最大级别", Toast.LENGTH_SHORT)
  1646. // .show();
  1647. return;
  1648. } else {
  1649. inBtn.setImageResource(R.drawable.icon_zoom_in_yes);
  1650. inBtn.setEnabled(true);
  1651. }
  1652. if (zoom <= minZoomLevel) {
  1653. outBtn.setImageResource(R.drawable.icon_zoom_out_no);
  1654. outBtn.setEnabled(false);
  1655. // Toast.makeText(getApplication(), "已缩小到最小级别", Toast.LENGTH_SHORT)
  1656. // .show();
  1657. return;
  1658. } else {
  1659. outBtn.setImageResource(R.drawable.icon_zoom_out_yes);
  1660. outBtn.setEnabled(true);
  1661. }
  1662. } catch (Exception e) {
  1663. e.printStackTrace();
  1664. }
  1665. }
  1666. }
  1667. public void eteinit(final String params) {
  1668. // LogUtils.e("11111");
  1669. new Thread(new Runnable() {
  1670. @Override
  1671. public void run() {
  1672. try {
  1673. String host = "";
  1674. if (MainApplication.url.contains("cdz.evcharge.cc")) {
  1675. host = "cdz.evcharge.cc";
  1676. } else {
  1677. host = "59.110.68.162";
  1678. }
  1679. socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
  1680. // 向服务器发送消息
  1681. PrintWriter out = new PrintWriter(new BufferedWriter(
  1682. new OutputStreamWriter(socket.getOutputStream())), true);
  1683. out.println(params);
  1684. // out.println("{\"fun\":\"getcity\"}");
  1685. // 接收来自服务器的消息
  1686. BufferedReader br = new BufferedReader(new InputStreamReader(
  1687. socket.getInputStream()));
  1688. String msg = br.readLine();
  1689. token = msg;
  1690. int time = (int) (System.currentTimeMillis() / 1000);
  1691. cha = time - Integer.parseInt(msg);
  1692. Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
  1693. ete2("{\"fun\":\"init\",\"timer\":" + "\"" + Token + "\"" + "}");
  1694. MainApplication.uptime = ProfileManager.getInstance().getDataUptime(getApplicationContext());
  1695. newUpdataZhanData(Token, MainApplication.uptime);
  1696. } catch (Exception e) {
  1697. e.printStackTrace();
  1698. }
  1699. }
  1700. }).start();
  1701. }
  1702. private void newUpdataZhanData(String token, String uptime) {
  1703. String url = MainApplication.url + ":9080/update_db";
  1704. OkHttpUtils.get().url(url)
  1705. .addParams("timer", token)
  1706. .addParams("uptime", uptime)
  1707. .build().execute(new StringCallback() {
  1708. @Override
  1709. public void onError(Call call, Exception e) {
  1710. e.printStackTrace();
  1711. }
  1712. @Override
  1713. public void onResponse(String response) {
  1714. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  1715. if ("0".equals(rtnCode)) {
  1716. String data = JsonUtils.getKeyResult(response, "data");
  1717. if (EmptyUtils.isNotEmpty(data)) {
  1718. final List<UpdateZhanDataBean> list = JsonUtils.parseToObjectList(data, UpdateZhanDataBean.class);
  1719. if (list.size() > 0) {
  1720. new Thread(new Runnable() {
  1721. @Override
  1722. public void run() {
  1723. dealUpdateData(list);
  1724. }
  1725. }).start();
  1726. }
  1727. }
  1728. }
  1729. }
  1730. });
  1731. }
  1732. private void dealUpdateData(List<UpdateZhanDataBean> list) {
  1733. String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
  1734. String uptime = "";
  1735. try {
  1736. SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
  1737. db.beginTransaction();//开始事务
  1738. try {
  1739. for (int i = 0; i < list.size(); i++) {
  1740. UpdateZhanDataBean bean = list.get(i);
  1741. ContentValues cv = new ContentValues();
  1742. cv.put("id", bean.getId());
  1743. cv.put("status", bean.getStatus());
  1744. cv.put("poi_jing", bean.getPoi_jing());
  1745. cv.put("poi_wei", bean.getPoi_wei());
  1746. cv.put("total_num", bean.getTotal_num());
  1747. cv.put("fast_num", bean.getFast_num());
  1748. cv.put("slow_num", bean.getSlow_num());
  1749. cv.put("charge_cost_way", bean.getCharge_cost_way());
  1750. cv.put("city", bean.getCity());
  1751. cv.put("belong_attribute", bean.getBelong_attribute());
  1752. cv.put("suit_car", bean.getSuit_car());
  1753. cv.put("own_pay", bean.getOwn_pay());
  1754. cv.put("supplier", bean.getSupplier());
  1755. cv.put("stop_cost", bean.getStop_cost());
  1756. cv.put("zhuang_num", bean.getZhuang_num());
  1757. long mub = db.replace("zhan_list", null, cv);
  1758. if (mub > 0) {
  1759. uptime = bean.getUptime();
  1760. // LogUtils.e("添加成功: id = " + bean.getId() + ", uptime = " + ProfileManager.getInstance().getDataUptime(getApplicationContext()));
  1761. } else {
  1762. // LogUtils.e("添加失败---" + bean.getId());
  1763. }
  1764. }
  1765. db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
  1766. } catch (Exception e) {
  1767. e.printStackTrace();
  1768. } finally {
  1769. db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务
  1770. }
  1771. db.close();
  1772. } catch (Exception e) {
  1773. e.printStackTrace();
  1774. }
  1775. if (!"".equals(uptime)) {
  1776. ProfileManager.getInstance().setDataUptime(getApplicationContext(), uptime);
  1777. }
  1778. }
  1779. public void ete(final String params) {
  1780. new Thread(new Runnable() {
  1781. @Override
  1782. public void run() {
  1783. try {
  1784. String host = "";
  1785. if (MainApplication.url.contains("cdz.evcharge.cc")) {
  1786. host = "cdz.evcharge.cc";
  1787. } else {
  1788. host = "59.110.68.162";
  1789. }
  1790. socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
  1791. // 向服务器发送消息
  1792. PrintWriter out = new PrintWriter(new BufferedWriter(
  1793. new OutputStreamWriter(socket.getOutputStream())), true);
  1794. out.println(params);
  1795. // out.println("{\"fun\":\"getcity\"}");
  1796. // 接收来自服务器的消息
  1797. BufferedReader br = new BufferedReader(new InputStreamReader(
  1798. socket.getInputStream()));
  1799. String msg = br.readLine();
  1800. token = msg;
  1801. // Log.e("msg===", msg);
  1802. int time = (int) (System.currentTimeMillis() / 1000);
  1803. cha = time - Integer.parseInt(msg);
  1804. Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
  1805. // Log.e("Token===", System.currentTimeMillis() / 1000 - cha + "");
  1806. // Point p1 = new Point(0, 0);
  1807. // LatLng locLeftTop = mapView.getMap().getProjection().fromScreenLocation(p1);
  1808. // Point p2 = new Point(MainApplication.mScreenWidth, mapView
  1809. // .getHeight());
  1810. // LatLng llRightBottom = mapView.getMap().getProjection()
  1811. // .fromScreenLocation(p2);
  1812. // System.out.print("qazwsx:"+url);
  1813. if (MainApplication.userTpye == "") {
  1814. MainApplication.userTpye = "1";
  1815. }
  1816. // getBaidu(locLeftTop.longitude - 0.01, locLeftTop.latitude + 0.01);
  1817. // getBaidu1(llRightBottom.longitude + 0.01, llRightBottom.latitude - 0.01);
  1818. // String own_pay = "";
  1819. // if (MainApplication.support.equals("true")) {
  1820. // own_pay = "1";
  1821. // } else {
  1822. // own_pay = "";
  1823. // }
  1824. String llon, llat, rlon, rlat;
  1825. if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
  1826. llon = String.valueOf(MainApplication.search_jing - 0.047414454728858857);
  1827. llat = String.valueOf(MainApplication.search_wei + 0.047414454728858857);
  1828. rlon = String.valueOf(MainApplication.search_jing + 0.047414454728858857);
  1829. rlat = String.valueOf(MainApplication.search_wei - 0.041842459916509256);
  1830. } else {
  1831. llon = String.valueOf(center.longitude - 0.047414454728858857);
  1832. llat = String.valueOf(center.latitude + 0.047414454728858857);
  1833. rlon = String.valueOf(center.longitude + 0.047414454728858857);
  1834. rlat = String.valueOf(center.latitude - 0.041842459916509256);
  1835. }
  1836. // Log.e("ggg", llon);
  1837. HashMap<String, String> map = new HashMap<String, String>();
  1838. map.put("fun", "zhangetlist");
  1839. map.put("poi_lux", llon);
  1840. map.put("poi_luy", llat);
  1841. map.put("poi_rdx", rlon);
  1842. map.put("poi_rdy", rlat);
  1843. map.put("suit_car2", MainApplication.userTpye);
  1844. map.put("status", MainApplication.mapStatus);
  1845. map.put("charge_cost_way", "");
  1846. map.put("belong_attribute", MainApplication.shuxing);
  1847. map.put("speed", MainApplication.sudu);
  1848. map.put("timer", Token);
  1849. map.put("supplier", MainApplication.costWay);
  1850. map.put("stop_free", MainApplication.mianStop);
  1851. int hotel, expressway, jingdian;
  1852. if (MainApplication.selecthotel.equals("true")) {
  1853. MainApplication.selecthotel = "true";
  1854. ProfileManager.getInstance().setSelecthotel(MainMapActivity.this, "true");
  1855. hotel = 1;
  1856. } else {
  1857. MainApplication.selecthotel = "false";
  1858. ProfileManager.getInstance().setSelecthotel(MainMapActivity.this, "false");
  1859. hotel = 0;
  1860. ;
  1861. }
  1862. if (MainApplication.selectexpressway.equals("true")) {
  1863. MainApplication.selectexpressway = "true";
  1864. ProfileManager.getInstance().setSelectExpressway(MainMapActivity.this, "true");
  1865. expressway = 2;
  1866. } else {
  1867. MainApplication.selectexpressway = "false";
  1868. ProfileManager.getInstance().setSelectExpressway(MainMapActivity.this, "false");
  1869. expressway = 0;
  1870. ;
  1871. }
  1872. if (MainApplication.selectjingdian.equals("true")) {
  1873. MainApplication.selectjingdian = "true";
  1874. ProfileManager.getInstance().setKeySelectjingdian(MainMapActivity.this, "true");
  1875. jingdian = 4;
  1876. } else {
  1877. MainApplication.selectjingdian = "false";
  1878. ProfileManager.getInstance().setKeySelectjingdian(MainMapActivity.this, "false");
  1879. jingdian = 0;
  1880. ;
  1881. }
  1882. int total = hotel + expressway + jingdian;
  1883. String num;
  1884. if (total == 0) {
  1885. num = "";
  1886. } else {
  1887. num = String.valueOf(total);
  1888. }
  1889. map.put("zhuang_num", num);
  1890. if (ProfileManager.getInstance().getSupport(getApplicationContext()).equals("true")) {
  1891. map.put("own_pay", "1");
  1892. } else {
  1893. map.put("own_pay", "");
  1894. }
  1895. String socket_string = JsonUtils.mapToJson(map);
  1896. // Log.e("socket_string", socket_string);
  1897. // String url = "{\"fun\":\"zhangetlist\",\"poi_lux\":" + "\"" + bd_lon + "\"" + ",\"poi_luy\":" + "\"" + bd_lat + "\"" + ",\"poi_rdx\":" + "\"" + bd_jing + "\"" + ",\"poi_rdy\":" + "\"" + bd_wei + "\"" + ",\"suit_car2\":" + "\"" + MainApplication.userTpye + "\"" + ",\"status\":" + "\"" + MainApplication.mapStatus + "\"" + ",\"charge_cost_way\":" + "\"" + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + ",\"supplier\":" + "\"" + MainApplication.costWay + "\"" + "}";
  1898. // String url = "{\"fun\":\"zhangetlist\",\"poi_lux\":" + "\"" + locLeftTop.longitude + "\"" + ",\"poi_luy\":" + "\"" + locLeftTop.latitude + "\"" + ",\"poi_rdx\":" + "\"" + llRightBottom.longitude + "\"" + ",\"poi_rdy\":" + "\"" + llRightBottom.latitude + "\"" + ",\"suit_car2\":" + "\"" + MainApplication.userTpye + "\"" + ",\"status\":" + "\"" + MainApplication.mapStatus + "\"" + ",\"charge_cost_way\":" + "\"" + MainApplication.costWay + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + "}";
  1899. // Log.d("wwwww", url);
  1900. ete1(socket_string);
  1901. // Log.e("ete", "执行");
  1902. } catch (Exception e) {
  1903. }
  1904. }
  1905. }).start();
  1906. }
  1907. private void changeButton() {
  1908. if (MainApplication.userTpye.equals("5") && MainApplication.mapStatus.equals("4") && MainApplication.shuxing.equals("") && MainApplication.sudu.equals("0") && MainApplication.costWay.equals("") && MainApplication.mianStop.equals("")) {
  1909. iv_sceen.setImageResource(R.drawable.icon_screen_main);
  1910. } else {
  1911. iv_sceen.setImageResource(R.drawable.icon_screen_main_selected);
  1912. }
  1913. }
  1914. public void updateZhanData(final String params) {
  1915. new Thread(new Runnable() {
  1916. @Override
  1917. public void run() {
  1918. try {
  1919. String host = "";
  1920. if (MainApplication.url.contains("cdz.evcharge.cc")) {
  1921. host = "cdz.evcharge.cc";
  1922. } else {
  1923. host = "59.110.68.162";
  1924. }
  1925. socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
  1926. socket.setReceiveBufferSize(1000000000);
  1927. // 向服务器发送消息
  1928. PrintWriter out = new PrintWriter(new BufferedWriter(
  1929. new OutputStreamWriter(socket.getOutputStream())), true);
  1930. out.println(params);
  1931. // out.println("{\"fun\":\"getcity\"}");
  1932. // 接收来自服务器的消息
  1933. BufferedReader br = new BufferedReader(new InputStreamReader(
  1934. socket.getInputStream()));
  1935. String msg = br.readLine();
  1936. if (null != msg) {
  1937. Log.d("msg=====update", msg);
  1938. String maxid = JsonUtils.getKeyResult(msg, "maxid");
  1939. Log.e(TAG, "run: max_id=" + maxid);
  1940. if (null != maxid && Integer.parseInt(maxid) > Integer.parseInt(MainApplication.logid)) {
  1941. MainApplication.logid = maxid;
  1942. ProfileManager.getInstance().setLogid(getApplicationContext(), maxid);
  1943. String data = JsonUtils.getKeyResult(msg, "data");
  1944. Log.e("updateZhanData===data", data);
  1945. Gson g = new Gson();
  1946. if (null != data) {
  1947. Log.e(TAG, "run: 有更新");
  1948. String add = JsonUtils.getKeyResult(data, "add");
  1949. if (null != add) {
  1950. if (!add.equals("")) {
  1951. List<DataRefresh> list_add = g.fromJson(add, new TypeToken<List<DataRefresh>>() {
  1952. }.getType());
  1953. Log.e("list_add===", list_add.size() + "");
  1954. addData(list_add);
  1955. } else {
  1956. // Log.e("updateZhanData===", "add_null");
  1957. }
  1958. }
  1959. String up = JsonUtils.getKeyResult(data, "up");
  1960. // Log.e("updateZhanData===up", up);
  1961. if (null != up) {
  1962. List<DataRefresh> list_up = g.fromJson(up, new TypeToken<List<DataRefresh>>() {
  1963. }.getType());
  1964. Log.e("list_up===", list_up.size() + "");
  1965. upData(list_up);
  1966. } else {
  1967. // Log.e("updateZhanData===", "up_null");
  1968. }
  1969. String del = JsonUtils.getKeyResult(data, "del");
  1970. if (del != null) {
  1971. List<DataRefresh> list_del = g.fromJson(del, new TypeToken<List<DataRefresh>>() {
  1972. }.getType());
  1973. Log.e("list_del===", list_del.size() + "");
  1974. if (null != del || list_del.size() > 0) {
  1975. delData(list_del);
  1976. } else {
  1977. // Log.e("updateZhanData===", "del_null");
  1978. }
  1979. }
  1980. } else {
  1981. // Log.e("updateZhanData===", "data == null");
  1982. }
  1983. } else {
  1984. // Log.e(TAG, "run: 没有更新");
  1985. }
  1986. }
  1987. } catch (Exception e) {
  1988. e.printStackTrace();
  1989. }
  1990. }
  1991. }).start();
  1992. }
  1993. private void eteLocation(final String params) {
  1994. new Thread(new Runnable() {
  1995. @Override
  1996. public void run() {
  1997. try {
  1998. // 创建Socket
  1999. // socket = new Socket("192.168.1.110",54321);
  2000. // if (mapView.getMap().getMapStatus().zoom < 9.5f) {
  2001. // socket.close();
  2002. // stringTid.clear();
  2003. // } else
  2004. {
  2005. String host = "";
  2006. if (MainApplication.url.contains("cdz.evcharge.cc")) {
  2007. host = "cdz.evcharge.cc";
  2008. } else {
  2009. host = "59.110.68.162";
  2010. }
  2011. socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
  2012. // 向服务器发送消息
  2013. PrintWriter out = new PrintWriter(new BufferedWriter(
  2014. new OutputStreamWriter(socket.getOutputStream())), true);
  2015. out.println(params);
  2016. // out.println("{\"fun\":\"getcity\"}");
  2017. // 接收来自服务器的消息
  2018. BufferedReader br = new BufferedReader(new InputStreamReader(
  2019. socket.getInputStream()));
  2020. String msg = br.readLine();
  2021. // Log.d("dddddmsg===", msg);
  2022. if (msg != null) {
  2023. Message mes = new Message();
  2024. mes.obj = msg;
  2025. mes.what = 5;
  2026. hand.sendMessage(mes);
  2027. }
  2028. // if (msg != null) {
  2029. // // mTextView.setText(msg);
  2030. // } else {
  2031. // // mTextView.setText("数据错误!");
  2032. // }
  2033. // System.err.println("msg:"+msg);
  2034. // String t1 = String.valueOf(new Date().getTime()/1000);
  2035. // System.err.println(t1);
  2036. // 关闭流
  2037. out.close();
  2038. br.close();
  2039. // 关闭Socket
  2040. socket.close();
  2041. }
  2042. } catch (Exception e) {
  2043. e.printStackTrace();
  2044. }
  2045. }
  2046. }).start();
  2047. }
  2048. public void ete1(final String params) {
  2049. new Thread(new Runnable() {
  2050. @Override
  2051. public void run() {
  2052. try {
  2053. // 创建Socket
  2054. // socket = new Socket("192.168.1.110",54321);
  2055. // if (mapView.getMap().getMapStatus().zoom < 9.5f) {
  2056. // socket.close();
  2057. // stringTid.clear();
  2058. // } else
  2059. {
  2060. String host = "";
  2061. if (MainApplication.url.contains("cdz.evcharge.cc")) {
  2062. host = "cdz.evcharge.cc";
  2063. } else {
  2064. host = "59.110.68.162";
  2065. }
  2066. socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
  2067. socket.setReceiveBufferSize(99999); // 接收缓冲大小
  2068. socket.setSendBufferSize(99999);
  2069. // 向服务器发送消息
  2070. PrintWriter out = new PrintWriter(new BufferedWriter(
  2071. new OutputStreamWriter(socket.getOutputStream())), true);
  2072. out.println(params);
  2073. // out.println("{\"fun\":\"getcity\"}");
  2074. // 接收来自服务器的消息
  2075. BufferedReader br = new BufferedReader(new InputStreamReader(
  2076. socket.getInputStream()));
  2077. String msg = br.readLine();
  2078. // Log.d("dddddmsg", msg);
  2079. if (msg != null) {
  2080. Message mes = new Message();
  2081. mes.obj = msg;
  2082. mes.what = 3;
  2083. hand.sendMessage(mes);
  2084. }
  2085. out.close();
  2086. br.close();
  2087. // 关闭Socket
  2088. socket.close();
  2089. }
  2090. } catch (Exception e) {
  2091. }
  2092. }
  2093. }).start();
  2094. }
  2095. public void ete2(final String params) {
  2096. new Thread(new Runnable() {
  2097. @Override
  2098. public void run() {
  2099. try {
  2100. String host = "";
  2101. if (MainApplication.url.contains("cdz.evcharge.cc")) {
  2102. host = "cdz.evcharge.cc";
  2103. } else {
  2104. host = "59.110.68.162";
  2105. }
  2106. socket = new Socket(host, 9503);
  2107. // 向服务器发送消息
  2108. PrintWriter out = new PrintWriter(new BufferedWriter(
  2109. new OutputStreamWriter(socket.getOutputStream())), true);
  2110. out.println(params);
  2111. // out.println("{\"fun\":\"getcity\"}");
  2112. // 接收来自服务器的消息
  2113. BufferedReader br = new BufferedReader(new InputStreamReader(
  2114. socket.getInputStream()));
  2115. // Message message = handle.obtainMessage();
  2116. // message.obj = line;
  2117. // message.arg1 = 1;
  2118. // handle.sendMessage(message);
  2119. String msg = br.readLine();
  2120. if (msg != null) {
  2121. Message mes = new Message();
  2122. mes.obj = msg;
  2123. mes.what = 2;
  2124. hand.sendMessage(mes);
  2125. }
  2126. } catch (Exception e) {
  2127. e.printStackTrace();
  2128. }
  2129. }
  2130. }).start();
  2131. }
  2132. private void getCommentNum(final String zhan_id) {
  2133. new Thread(new Runnable() {
  2134. @Override
  2135. public void run() {
  2136. Request request = new Request.Builder().url(MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/getcont?zhanid=" + zhan_id).build();
  2137. Response response = null;
  2138. try {
  2139. response = OkHttpUtil.execute(request);
  2140. if (response.code() == 200) {
  2141. String json = "";
  2142. try {
  2143. json = response.body().string();
  2144. Message msg = new Message();
  2145. msg.obj = json;
  2146. msg.what = 1;
  2147. hand.sendMessage(msg);
  2148. } catch (Exception e) {
  2149. e.printStackTrace();
  2150. Message msg = new Message();
  2151. msg.what = 2;
  2152. hand.sendMessage(msg);
  2153. }
  2154. }
  2155. } catch (Exception e) {
  2156. e.printStackTrace();
  2157. Message msg = new Message();
  2158. msg.what = 2;
  2159. hand.sendMessage(msg);
  2160. }
  2161. }
  2162. }).start();
  2163. }
  2164. public static String getMD5(String content) {
  2165. try {
  2166. MessageDigest digest = MessageDigest.getInstance("MD5");
  2167. digest.update(content.getBytes());
  2168. return getHashString(digest);
  2169. } catch (Exception e) {
  2170. e.printStackTrace();
  2171. }
  2172. return null;
  2173. }
  2174. private static String getHashString(MessageDigest digest) {
  2175. StringBuilder builder = new StringBuilder();
  2176. for (byte b : digest.digest()) {
  2177. builder.append(Integer.toHexString((b >> 4) & 0xf));
  2178. builder.append(Integer.toHexString(b & 0xf));
  2179. }
  2180. return builder.toString().toLowerCase();
  2181. }
  2182. private Bitmap getMarkerBmpYes(int i) {
  2183. if (i == 1) {
  2184. mIvMarkerBgYes.setImageResource(R.drawable.icon_sgreen);
  2185. } else if (i == 2) {
  2186. mIvMarkerBgYes.setImageResource(R.drawable.icon_bgreen);
  2187. } else if (i == 3) {
  2188. mIvMarkerBgYes.setImageResource(R.drawable.icon_sorange);
  2189. } else if (i == 4) {
  2190. mIvMarkerBgYes.setImageResource(R.drawable.icon_borange);
  2191. } else if (i == 5) {
  2192. mIvMarkerBgYes.setImageResource(R.drawable.icon_sgift);
  2193. } else if (i == 6) {
  2194. mIvMarkerBgYes.setImageResource(R.drawable.icon_bgift);
  2195. } else if (i == 7) {
  2196. mIvMarkerBgYes.setImageResource(R.drawable.icon_sblue);
  2197. } else if (i == 8) {
  2198. mIvMarkerBgYes.setImageResource(R.drawable.icon_bblue);
  2199. }
  2200. Bitmap bmp = getBitmapFromView(mMarkerViewYes);
  2201. return bmp;
  2202. }
  2203. private Bitmap getMarkerBmp(int num) {
  2204. mIvMarkerBg.setImageResource(R.drawable.icon_konglog1105);
  2205. if (num > 10) {
  2206. mTvMarkerViewNum.setText(Integer.toString(num));
  2207. } else {
  2208. mTvMarkerViewNum.setText(Integer.toString(num));
  2209. }
  2210. Bitmap bmp = getBitmapFromView(mMarkerView);
  2211. return bmp;
  2212. }
  2213. private Bitmap getMarkerApps(int num) {
  2214. mIvMarkerAppS.setImageResource(R.drawable.icon_sapp);
  2215. if (num > 10) {
  2216. mTvMarkerViewNumAppS.setText(Integer.toString(num));
  2217. } else {
  2218. mTvMarkerViewNumAppS.setText(Integer.toString(num));
  2219. }
  2220. Bitmap bmp = getBitmapFromView(mMarkerViewAppS);
  2221. return bmp;
  2222. }
  2223. private Bitmap getMarkerAppb(int num) {
  2224. mIvMarkerAppB.setImageResource(R.drawable.icon_bapp);
  2225. if (num > 10) {
  2226. mTvMarkerViewNumAppB.setText(Integer.toString(num));
  2227. } else {
  2228. mTvMarkerViewNumAppB.setText(Integer.toString(num));
  2229. }
  2230. Bitmap bmp = getBitmapFromView(mMarkerViewAppB);
  2231. return bmp;
  2232. }
  2233. private Bitmap getMarkerBmp1(int num) {
  2234. mIvMarkerBg1.setImageResource(R.drawable.icon_konglogb);
  2235. if (num > 10) {
  2236. mTvMarkerViewNum1.setText(Integer.toString(num));
  2237. } else {
  2238. mTvMarkerViewNum1.setText(Integer.toString(num));
  2239. }
  2240. Bitmap bmp = getBitmapFromView(mMarkerView1);
  2241. return bmp;
  2242. }
  2243. private Bitmap getMarkerBmpCity(String num) {
  2244. String no = num;
  2245. mIvMarkerBgcity.setImageResource(R.drawable.icon_cityno);
  2246. mTvMarkerViewNumcity.setText(no);
  2247. Bitmap bmp = getBitmapFromView(mMarkerViewcity);
  2248. return bmp;
  2249. }
  2250. public static Bitmap getBitmapFromView(View view) {
  2251. view.destroyDrawingCache();
  2252. view.measure(View.MeasureSpec.makeMeasureSpec(0,
  2253. View.MeasureSpec.UNSPECIFIED), View.MeasureSpec
  2254. .makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
  2255. view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
  2256. view.setDrawingCacheEnabled(true);
  2257. Bitmap tmp = view.getDrawingCache();
  2258. Bitmap bitmap = tmp.copy(Bitmap.Config.ARGB_8888, false);
  2259. tmp.recycle();
  2260. return bitmap;
  2261. }
  2262. @Override
  2263. public void onClick(View v) {
  2264. SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
  2265. switch (v.getId()) {
  2266. case R.id.iv_tuijian:
  2267. if (null != center) {
  2268. MobclickAgent.onEvent(getApplicationContext(), "0111");
  2269. Intent i = new Intent(getApplicationContext(), RecommendZhanActivity.class);
  2270. i.putExtra("center_jing", String.valueOf(center.longitude));
  2271. i.putExtra("center_wei", String.valueOf(center.latitude));
  2272. startActivity(i);
  2273. } else {
  2274. ToastUtil.showToast(getApplicationContext(), "没有获取到您当前的位置,请检查网络或定位权限", Toast.LENGTH_SHORT);
  2275. }
  2276. MobclickAgent.onEvent(context, "0068");
  2277. break;
  2278. case R.id.iv_clear_address:
  2279. tv_search.setText("请输入地址/关键字");
  2280. iv_clear_address.setVisibility(View.INVISIBLE);
  2281. ProfileManager.getInstance().setSearchAddress(this, "");
  2282. MainApplication.search_jing = 0.0;
  2283. MainApplication.search_wei = 0.0;
  2284. ete("{\"fun\":\"timer\"}");
  2285. if (search_marker != null) {
  2286. search_marker.remove();
  2287. }
  2288. break;
  2289. case R.id.iv_example:
  2290. MobclickAgent.onEvent(getApplicationContext(), "0114");
  2291. Intent intent_example = new Intent(getApplicationContext(), ExampleActivity.class);
  2292. intent_example.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  2293. startActivity(intent_example);
  2294. overridePendingTransition(0, 0);
  2295. break;
  2296. case R.id.iv_bg_example:
  2297. break;
  2298. case R.id.tv_sortDistance:
  2299. MobclickAgent.onEvent(getApplicationContext(), "0057");
  2300. sortTye = 1;
  2301. tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
  2302. tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
  2303. tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
  2304. tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
  2305. tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
  2306. tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
  2307. if (list1.size() > 0) {
  2308. list.clear();
  2309. list.addAll(list1);
  2310. adapter.notifyDataSetChanged();
  2311. } else {
  2312. list.clear();
  2313. list = Util.getSortList(listt);
  2314. adapter.notifyDataSetChanged();
  2315. }
  2316. break;
  2317. case R.id.tv_sortStarLevel:
  2318. MobclickAgent.onEvent(getApplicationContext(), "0058");
  2319. sortTye = 2;
  2320. tv_sortDistance.setTextColor(getResources().getColor(R.color.ui_62));
  2321. tv_sortDistance.setBackgroundColor(getResources().getColor(R.color.white));
  2322. tv_sortStarLevel.setTextColor(getResources().getColor(R.color.lvse));
  2323. tv_sortStarLevel.setBackgroundResource(R.drawable.bg_lv);
  2324. tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
  2325. tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
  2326. if (list2.size() > 0) {
  2327. list.clear();
  2328. list.addAll(list2);
  2329. adapter.notifyDataSetChanged();
  2330. } else {
  2331. list.clear();
  2332. list = Util.getSortPFList(listt);
  2333. adapter.notifyDataSetChanged();
  2334. }
  2335. break;
  2336. case R.id.tv_sortFreeTime:
  2337. MobclickAgent.onEvent(getApplicationContext(), "0059");
  2338. sortTye = 3;
  2339. tv_sortDistance.setTextColor(getResources().getColor(R.color.ui_62));
  2340. tv_sortDistance.setBackgroundColor(getResources().getColor(R.color.white));
  2341. tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
  2342. tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
  2343. tv_sortFreeTime.setTextColor(getResources().getColor(R.color.lvse));
  2344. tv_sortFreeTime.setBackgroundResource(R.drawable.bg_lv);
  2345. if (list3.size() > 0) {
  2346. list.clear();
  2347. list.addAll(list3);
  2348. adapter.notifyDataSetChanged();
  2349. } else {
  2350. list.clear();
  2351. list = Util.getSortFTList(listt);
  2352. adapter.notifyDataSetChanged();
  2353. }
  2354. break;
  2355. case R.id.iv_route:
  2356. startActivity(new Intent(getApplication(), RoutePlanShowAddressActivity.class));
  2357. MobclickAgent.onEvent(getApplicationContext(), "0112");
  2358. break;
  2359. case R.id.second_hand_car:
  2360. Intent adfloatIntent = new Intent(this, MyWebViewActivity.class);
  2361. adfloatIntent.putExtra("url", adfloatUrl);
  2362. startActivity(adfloatIntent);
  2363. break;
  2364. case R.id.iv_roadCondition:
  2365. MobclickAgent.onEvent(getApplicationContext(), "0113");
  2366. if (ProfileManager.getInstance().getRoadCondition(getApplicationContext()) == false) {
  2367. iv_roadCondition.setImageResource(R.drawable.icon_youlukuang_main);
  2368. ProfileManager.getInstance().setRoadCondition(this, true);
  2369. aMap.setTrafficEnabled(true);
  2370. ToastUtil.showToast(this, "实时路况已打开", Toast.LENGTH_SHORT);
  2371. MobclickAgent.onEvent(getApplicationContext(), "0066");
  2372. } else {
  2373. iv_roadCondition.setImageResource(R.drawable.icon_wulukuang_main);
  2374. ProfileManager.getInstance().setRoadCondition(this, false);
  2375. aMap.setTrafficEnabled(false);
  2376. ToastUtil.showToast(this, "实时路况已关闭", Toast.LENGTH_SHORT);
  2377. MobclickAgent.onEvent(getApplicationContext(), "0067");
  2378. }
  2379. break;
  2380. case R.id.zoomin:
  2381. aMap.moveCamera(CameraUpdateFactory.zoomIn());
  2382. controlZoomShow();
  2383. break;
  2384. case R.id.zoomout:
  2385. aMap.moveCamera(CameraUpdateFactory.zoomOut());
  2386. controlZoomShow();
  2387. break;
  2388. //地图&列表切换按钮
  2389. case R.id.iv_list:
  2390. sharedPreferencesUtil.putBoolean("cdz_recommend_more_detail", true);
  2391. String jing, wei;
  2392. if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
  2393. Log.e(TAG, "onClick: 有搜索");
  2394. jing = String.valueOf(MainApplication.search_jing);
  2395. wei = String.valueOf(MainApplication.search_wei);
  2396. } else {
  2397. Log.e(TAG, "onClick: 当前位置");
  2398. if (null == center) {
  2399. ToastUtil.showToast(getApplicationContext(), "请确认当前定位是否可用", Toast.LENGTH_SHORT);
  2400. break;
  2401. } else {
  2402. jing = String.valueOf(center.longitude);
  2403. wei = String.valueOf(center.latitude);
  2404. }
  2405. }
  2406. if (null != jing && null != wei) {
  2407. MobclickAgent.onEvent(getApplicationContext(), "1135");
  2408. Intent intent = new Intent(getApplicationContext(), RecommendChargingStationActivity.class);
  2409. intent.putExtra("center_jing", jing);
  2410. intent.putExtra("center_wei", wei);
  2411. startActivity(intent);
  2412. }
  2413. break;
  2414. //定位刷新按钮
  2415. case R.id.iv_point_again:
  2416. if (!isFirstLoc) {
  2417. isFirstLoc = true;
  2418. mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
  2419. aMap.setLocationSource(this);// 设置定位监听
  2420. aMap.setMyLocationEnabled(true);// 是否可触发定位并显示定位层
  2421. aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
  2422. mlocationClient.startLocation();
  2423. }
  2424. windowLayout.setVisibility(View.GONE);
  2425. rl_control.setVisibility(View.VISIBLE);
  2426. ll_open.setVisibility(View.GONE);
  2427. break;
  2428. //条件筛选按钮
  2429. case R.id.tv_person:
  2430. windowLayout.setVisibility(View.GONE);
  2431. rl_control.setVisibility(View.VISIBLE);
  2432. if (nMarker != null) {
  2433. nMarker.hideInfoWindow();
  2434. MarkerOptions markerOptionss = new MarkerOptions();
  2435. if (current_chargePoint.getOwn_pay().equals("1")) {
  2436. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
  2437. } else {
  2438. if (current_chargePoint.getSuit_car().equals("特斯拉")) {
  2439. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  2440. } else {
  2441. if (WelcomeActivity.canCost.contains(current_chargePoint.getSupplier())) {
  2442. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
  2443. } else {
  2444. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  2445. }
  2446. }
  2447. }
  2448. }
  2449. Intent intent = new Intent(getApplication(), NewScreenActivity.class);
  2450. startActivity(intent);
  2451. MobclickAgent.onEvent(getApplicationContext(), "0110");
  2452. break;
  2453. case R.id.tv_shaixuan:
  2454. isListShow = true;
  2455. windowLayout.setVisibility(View.GONE);
  2456. if (null != current_chargePoint) {
  2457. resetMarker();
  2458. }
  2459. MobclickAgent.onEvent(getApplicationContext(), "0110");
  2460. Intent intentt = new Intent(getApplication(), NewScreenActivity.class);
  2461. startActivity(intentt);
  2462. break;
  2463. case R.id.tv_switch_city:
  2464. if (isListShow == false) {
  2465. windowLayout.setVisibility(View.GONE);
  2466. rl_control.setVisibility(View.VISIBLE);
  2467. }
  2468. if (null != current_chargePoint) {
  2469. resetMarker();
  2470. }
  2471. MobclickAgent.onEvent(getApplicationContext(), "0107");
  2472. startActivity(new Intent(getApplicationContext(), NewSelectCityActivity.class));
  2473. if (ll_tuijian.getVisibility() == View.VISIBLE) {
  2474. ll_tuijian.setVisibility(View.GONE);
  2475. rl_tuijian_tip.setVisibility(View.VISIBLE);
  2476. ll_top_right.setVisibility(View.VISIBLE);
  2477. ll_map_control.setVisibility(View.VISIBLE);
  2478. }
  2479. break;
  2480. case R.id.tab_screening:
  2481. if (socket != null) {
  2482. try {
  2483. socket.close();
  2484. } catch (IOException e) {
  2485. e.printStackTrace();
  2486. }
  2487. }
  2488. if (!MainApplication.isLogin()) {
  2489. startActivity(new Intent(getApplication(), LoginActivity.class));
  2490. } else if (!cameraTask()) {
  2491. EasyPermissions.requestPermissions(
  2492. this,
  2493. "该功能需要开启摄像头权限,是否前往开启?",
  2494. RC_CAMERA_PERM,
  2495. Manifest.permission.CAMERA);
  2496. } else {
  2497. Intent iintent = new Intent(getApplicationContext(), com.google.zxing.client.android.CaptureActivity.class);
  2498. iintent.putExtra("url", MainApplication.url);
  2499. iintent.putExtra("user_id", MainApplication.userId);
  2500. iintent.putExtra("user_password", MainApplication.userPassword);
  2501. iintent.putExtra("user_phone", ProfileManager.getInstance().getUsername(getApplicationContext()));
  2502. LogUtils.e(ProfileManager.getInstance().getUsername(getApplicationContext()));
  2503. iintent.putExtra("cha", MainMapActivity.cha);
  2504. iintent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  2505. startActivity(iintent);
  2506. overridePendingTransition(0, 0);
  2507. if (count == 1) {
  2508. MobclickAgent.onEvent(getApplicationContext(), "0104");
  2509. count = 2;
  2510. }
  2511. }
  2512. break;
  2513. //发现界面tab
  2514. case R.id.ll_tab_find:
  2515. if (socket != null) {
  2516. try {
  2517. socket.close();
  2518. } catch (IOException e) {
  2519. e.printStackTrace();
  2520. }
  2521. }
  2522. Intent intent1 = new Intent(getApplication(), FindActivity.class);
  2523. intent1.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  2524. startActivity(intent1);
  2525. overridePendingTransition(0, 0);
  2526. if (count == 1) {
  2527. MobclickAgent.onEvent(getApplicationContext(), "0105");
  2528. count = 2;
  2529. }
  2530. break;
  2531. case R.id.tab_qa:
  2532. if (socket != null) {
  2533. try {
  2534. socket.close();
  2535. } catch (IOException e) {
  2536. e.printStackTrace();
  2537. }
  2538. }
  2539. Intent i = new Intent(getApplication(), ChatActivity.class);//聊聊页面
  2540. i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  2541. startActivity(i);
  2542. overridePendingTransition(0, 0);
  2543. if (count == 1) {
  2544. MobclickAgent.onEvent(getApplicationContext(), "0999");
  2545. count = 2;
  2546. }
  2547. break;
  2548. //用户中心tab
  2549. case R.id.tab_me:
  2550. if (socket != null) {
  2551. try {
  2552. socket.close();
  2553. } catch (IOException e) {
  2554. e.printStackTrace();
  2555. }
  2556. }
  2557. Intent intent2 = new Intent(getApplication(), UserCenterActivity.class);
  2558. intent2.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  2559. startActivity(intent2);
  2560. if (sav.getVisibility() == View.VISIBLE) {
  2561. sav.setVisibility(View.GONE);
  2562. }
  2563. overridePendingTransition(0, 0);
  2564. if (count == 1) {
  2565. MobclickAgent.onEvent(getApplicationContext(), "0106");
  2566. count = 2;
  2567. }
  2568. break;
  2569. case R.id.iv_clear:
  2570. rl_ad.setVisibility(View.GONE);
  2571. break;
  2572. case R.id.rl_search:
  2573. if (isListShow == false) {
  2574. windowLayout.setVisibility(View.GONE);
  2575. rl_control.setVisibility(View.VISIBLE);
  2576. }
  2577. if (null != current_chargePoint) {
  2578. resetMarker();
  2579. }
  2580. MobclickAgent.onEvent(getApplicationContext(), "0108");
  2581. startActivityForResult(new Intent(getApplication(), SearchActivity.class), SEARCH_CODE);
  2582. if (ll_tuijian.getVisibility() == View.VISIBLE) {
  2583. ll_tuijian.setVisibility(View.GONE);
  2584. rl_tuijian_tip.setVisibility(View.VISIBLE);
  2585. ll_top_right.setVisibility(View.VISIBLE);
  2586. ll_map_control.setVisibility(View.VISIBLE);
  2587. }
  2588. break;
  2589. default:
  2590. break;
  2591. }
  2592. }
  2593. public void showMap() {
  2594. if (MainApplication.isMap) {
  2595. if (list.size() == 0) {
  2596. ete("{\"fun\":\"timer\"}");
  2597. }
  2598. MainApplication.isMap = false;
  2599. //显示列表站点
  2600. lvZhan.setVisibility(View.VISIBLE);
  2601. isListShow = true;
  2602. if (list.size() > 0) {
  2603. rl_mapList.setVisibility(View.VISIBLE);
  2604. tv_tishi.setVisibility(View.GONE);
  2605. } else if (list.size() == 0) {
  2606. rl_mapList.setVisibility(View.VISIBLE);
  2607. tv_tishi.setVisibility(View.VISIBLE);
  2608. }
  2609. iv_sceen.setVisibility(View.GONE);
  2610. iv_example.setVisibility(View.GONE);
  2611. if (windowLayout.getVisibility() == View.VISIBLE) {
  2612. paoShow = true;
  2613. windowLayout.setVisibility(View.GONE);
  2614. } else {
  2615. rl_control.setVisibility(View.GONE);
  2616. }
  2617. iv_roadCondition.setVisibility(View.GONE);
  2618. MobclickAgent.onEvent(getApplicationContext(), "0063");
  2619. } else {
  2620. //显示地图站点
  2621. MainApplication.isMap = true;
  2622. lvZhan.setVisibility(View.GONE);
  2623. rl_mapList.setVisibility(View.GONE);
  2624. tv_tishi.setVisibility(View.GONE);
  2625. if (paoShow == true && isListShow == false) {
  2626. windowLayout.setVisibility(View.VISIBLE);
  2627. rl_control.setVisibility(View.GONE);
  2628. paoShow = false;
  2629. } else {
  2630. rl_control.setVisibility(View.VISIBLE);
  2631. }
  2632. isListShow = false;
  2633. iv_sceen.setVisibility(View.VISIBLE);
  2634. iv_example.setVisibility(View.VISIBLE);
  2635. sortTye = 1;
  2636. tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
  2637. tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
  2638. tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
  2639. tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
  2640. tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
  2641. tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
  2642. iv_roadCondition.setVisibility(View.VISIBLE);
  2643. }
  2644. }
  2645. private void showUi(boolean status) {
  2646. if (status == true) {
  2647. lvZhan.setVisibility(View.GONE);
  2648. rl_mapList.setVisibility(View.GONE);
  2649. tv_tishi.setVisibility(View.GONE);
  2650. rl_control.setVisibility(View.VISIBLE);
  2651. iv_sceen.setVisibility(View.VISIBLE);
  2652. sortTye = 1;
  2653. tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
  2654. tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
  2655. tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
  2656. tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
  2657. tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
  2658. tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
  2659. iv_roadCondition.setVisibility(View.VISIBLE);
  2660. iv_example.setVisibility(View.VISIBLE);
  2661. } else {
  2662. lvZhan.setVisibility(View.VISIBLE);
  2663. if (list.size() > 0) {
  2664. rl_mapList.setVisibility(View.VISIBLE);
  2665. tv_tishi.setVisibility(View.GONE);
  2666. } else if (list.size() == 0) {
  2667. rl_mapList.setVisibility(View.VISIBLE);
  2668. tv_tishi.setVisibility(View.VISIBLE);
  2669. }
  2670. rl_control.setVisibility(View.GONE);
  2671. iv_sceen.setVisibility(View.GONE);
  2672. if (windowLayout.getVisibility() == View.VISIBLE) {
  2673. windowLayout.setVisibility(View.GONE);
  2674. rl_control.setVisibility(View.VISIBLE);
  2675. ll_open.setVisibility(View.GONE);
  2676. }
  2677. iv_roadCondition.setVisibility(View.GONE);
  2678. iv_example.setVisibility(View.GONE);
  2679. }
  2680. }
  2681. @Override
  2682. public void onMapLoaded() {
  2683. aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
  2684. // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
  2685. aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
  2686. aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
  2687. }
  2688. @Override
  2689. public void onCameraChange(CameraPosition cameraPosition) {
  2690. }
  2691. @Override
  2692. public void onCameraChangeFinish(CameraPosition cameraPosition) {
  2693. }
  2694. @Override
  2695. public void onMapClick(LatLng latLng) {
  2696. float zoom = aMap.getCameraPosition().zoom;
  2697. aMap.moveCamera(CameraUpdateFactory.zoomTo(zoom));
  2698. Animation animation = AnimationUtils.loadAnimation(this, R.anim.out);
  2699. animation.setDuration(500);
  2700. windowLayout.startAnimation(animation);
  2701. new Handler().postDelayed(new Runnable() {
  2702. @Override
  2703. public void run() {
  2704. windowLayout.setVisibility(View.GONE);
  2705. }
  2706. }, 500);
  2707. SharedPreferencesUtil sharedPreferencesUtil1 = new SharedPreferencesUtil(getApplication());
  2708. sharedPreferencesUtil1.setFileName("CurrentMarkerInfo");
  2709. sharedPreferencesUtil1.clearData();
  2710. rl_control.setVisibility(View.VISIBLE);
  2711. ll_open.setVisibility(View.GONE);
  2712. }
  2713. @Override
  2714. public void onWeatherLiveSearched(LocalWeatherLiveResult weatherLiveResult, int rCode) {
  2715. if (rCode == 1000) {
  2716. if (weatherLiveResult != null & weatherLiveResult.getLiveResult() != null) {
  2717. LocalWeatherLive weatherlive = weatherLiveResult.getLiveResult();
  2718. } else {
  2719. }
  2720. } else {
  2721. ToastUtil.showToast(MainMapActivity.this, rCode + "", Toast.LENGTH_SHORT);
  2722. }
  2723. }
  2724. @Override
  2725. public void onWeatherForecastSearched(LocalWeatherForecastResult localWeatherForecastResult, int i) {
  2726. if (i == 1000) {
  2727. if (localWeatherForecastResult != null & localWeatherForecastResult.getForecastResult() != null) {
  2728. LocalWeatherForecast weatherlive = localWeatherForecastResult.getForecastResult();
  2729. Log.e(TAG, "onWeatherLiveSearched: " + "-------" + weatherlive.getCity() + "-------" + weatherlive.getAdCode()
  2730. + "-------" + weatherlive.getWeatherForecast() + "-------" + weatherlive.getProvince() + "-------" + weatherlive.getReportTime());
  2731. List<LocalDayWeatherForecast> list = weatherlive.getWeatherForecast();
  2732. list.get(0).getDate();
  2733. for (int a = 0; a < list.size(); a++) {
  2734. Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDate());
  2735. Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDayTemp());
  2736. Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDayWeather());
  2737. Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getNightTemp());
  2738. Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getNightWeather());
  2739. }
  2740. } else {
  2741. }
  2742. } else {
  2743. }
  2744. }
  2745. @Override
  2746. public void onPermissionsGranted(int requestCode, List<String> perms) {
  2747. if (requestCode == RC_CAMERA_PERM) {
  2748. Intent iintent = new Intent(getApplicationContext(), com.google.zxing.client.android.CaptureActivity.class);
  2749. iintent.putExtra("url", MainApplication.url);
  2750. iintent.putExtra("user_id", MainApplication.userId);
  2751. iintent.putExtra("user_password", MainApplication.userPassword);
  2752. iintent.putExtra("user_phone", MainApplication.userPhone);
  2753. iintent.putExtra("cha", MainMapActivity.cha);
  2754. iintent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  2755. startActivity(iintent);
  2756. overridePendingTransition(0, 0);
  2757. }
  2758. }
  2759. @Override
  2760. public void onPermissionsDenied(int requestCode, List<String> perms) {
  2761. for (String s : perms) {
  2762. LogUtils.e(s);
  2763. }
  2764. if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
  2765. new AppSettingsDialog.Builder(MainMapActivity.this).build().show();
  2766. // TODO add by hyg20200525
  2767. // new AppSettingsDialog.Builder(MainMapActivity.this,
  2768. // "该功能需要开启摄像头权限,是否前往开启?").build().show();
  2769. }
  2770. }
  2771. @Override
  2772. public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  2773. super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  2774. EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
  2775. }
  2776. private boolean hasCameraPermission() {
  2777. return EasyPermissions.hasPermissions(this, Manifest.permission.CAMERA);
  2778. }
  2779. private boolean isPermissionOK() {
  2780. return EasyPermissions.hasPermissions(this,
  2781. Manifest.permission.CAMERA,
  2782. Manifest.permission.WRITE_EXTERNAL_STORAGE,
  2783. Manifest.permission.READ_EXTERNAL_STORAGE
  2784. );
  2785. }
  2786. @AfterPermissionGranted(RC_SAVE_PERM)
  2787. public boolean saveTask() {
  2788. if (isPermissionOK()) {
  2789. // Have permission, do the thing!
  2790. // Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
  2791. return true;
  2792. } else {
  2793. // Ask for one permission
  2794. // EasyPermissions.requestPermissions(
  2795. // this,
  2796. // "该功能需要开启摄像头权限,是否前往开启?",
  2797. // RC_CAMERA_PERM,
  2798. // Manifest.permission.CAMERA);
  2799. return false;
  2800. }
  2801. }
  2802. @AfterPermissionGranted(RC_CAMERA_PERM)
  2803. public boolean cameraTask() {
  2804. if (hasCameraPermission()) {
  2805. // Have permission, do the thing!
  2806. // Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
  2807. return true;
  2808. } else {
  2809. // Ask for one permission
  2810. // EasyPermissions.requestPermissions(
  2811. // this,
  2812. // "该功能需要开启摄像头权限,是否前往开启?",
  2813. // RC_CAMERA_PERM,
  2814. // Manifest.permission.CAMERA);
  2815. return false;
  2816. }
  2817. }
  2818. @Override
  2819. public boolean onMarkerClick(Marker marker) {
  2820. return false;
  2821. }
  2822. /**
  2823. * 监听自定义infowindow窗口的infowindow时间回调
  2824. * add by hyg
  2825. *
  2826. * @param marker
  2827. * @return
  2828. */
  2829. @Override
  2830. public View getInfoWindow(Marker marker) {
  2831. if (infoWindow == null) {
  2832. infoWindow = getLayoutInflater().inflate(R.layout.custom_info_window, null);
  2833. }
  2834. return infoWindow;
  2835. }
  2836. @Override
  2837. public View getInfoContents(Marker marker) {
  2838. return null;
  2839. }
  2840. /**
  2841. * 自定义infowindow窗口
  2842. * 如果想修改自定义Infow中内容,请通过view找到它并修改
  2843. */
  2844. public void updateInfoWindow(String text) {
  2845. if (nMarker == null) {
  2846. return;
  2847. }
  2848. if (infoWindow == null) {
  2849. return;
  2850. }
  2851. infoWindow.findViewById(R.id.infoWindowNavigate).setOnClickListener(new View.OnClickListener() {
  2852. @Override
  2853. public void onClick(View view) {
  2854. MobclickAgent.onEvent(getApplicationContext(), "1120");
  2855. infoViewNavigate();
  2856. }
  2857. });
  2858. TextView distance = infoWindow.findViewById(R.id.distance);
  2859. distance.setText(text);
  2860. }
  2861. /**
  2862. * 点击自定义气泡,进行导航操作
  2863. * add by hyg
  2864. *
  2865. * @param marker
  2866. */
  2867. @Override
  2868. public void onInfoWindowClick(Marker marker) {
  2869. }
  2870. public class ZhanAdapter extends BaseAdapter {
  2871. @Override
  2872. public int getCount() {
  2873. if (list.size() > 30) {
  2874. return 30;
  2875. } else {
  2876. return list.size();
  2877. }
  2878. }
  2879. @Override
  2880. public Object getItem(int position) {
  2881. return list.get(position);
  2882. }
  2883. @Override
  2884. public long getItemId(int position) {
  2885. return position;
  2886. }
  2887. @Override
  2888. public View getView(final int position, View convertView, ViewGroup parent) {
  2889. ViewHolder viewHolder = null;
  2890. if (convertView == null) {
  2891. convertView = LayoutInflater.from(getApplication()).inflate(
  2892. R.layout.item_zhandian, null);
  2893. viewHolder = new ViewHolder();
  2894. viewHolder.item_zhan_name = (TextView) convertView.findViewById(R.id.item_zhan_name);
  2895. viewHolder.item_zhan_go = (TextView) convertView.findViewById(R.id.item_zhan_go);
  2896. viewHolder.item_zhan_distance = (TextView) convertView.findViewById(R.id.item_zhan_distance);
  2897. viewHolder.item_zhan_cost = (TextView) convertView.findViewById(R.id.item_zhan_cost);
  2898. viewHolder.item_fast_num = (TextView) convertView.findViewById(R.id.item_fast_num);
  2899. viewHolder.item_fastable = (TextView) convertView.findViewById(R.id.item_fastable);
  2900. viewHolder.item_fastable_num = (TextView) convertView.findViewById(R.id.item_fastable_num);
  2901. viewHolder.item_slowable = (TextView) convertView.findViewById(R.id.item_slowable);
  2902. viewHolder.item_slowable_num = (TextView) convertView.findViewById(R.id.item_slowable_num);
  2903. viewHolder.item_slow_num = (TextView) convertView.findViewById(R.id.item_slow_num);
  2904. viewHolder.item_grade_pic = (ImageView) convertView.findViewById(R.id.item_grade_pic);
  2905. viewHolder.item_layout = (LinearLayout) convertView.findViewById(R.id.item_layout);
  2906. convertView.setTag(viewHolder);
  2907. } else {
  2908. viewHolder = (ViewHolder) convertView.getTag();
  2909. }
  2910. if (list.size() > 0) {
  2911. viewHolder.item_zhan_name.setText(list.get(position).getZhan_name());
  2912. if (list.get(position).getStar_level().equals("") || list.get(position).getStar_level().equals("0")) {
  2913. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_0xing);
  2914. } else {
  2915. String star_level = list.get(position).getStar_level().toString();
  2916. double d;
  2917. d = Double.parseDouble(star_level);
  2918. String grade = String.format("%.1f", d);
  2919. if (d > 0 && d < 1) {
  2920. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_05xing);
  2921. } else if (d >= 1 && d < 1.5) {
  2922. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_1xing);
  2923. } else if (d >= 1.5 && d < 2) {
  2924. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_15xing);
  2925. } else if (d >= 2 && d < 2.5) {
  2926. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_2xing);
  2927. } else if (d >= 2.5 && d < 3) {
  2928. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_25xing);
  2929. } else if (d >= 3 && d < 3.5) {
  2930. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_3xing);
  2931. } else if (d >= 3.5 && d < 4) {
  2932. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_35xing);
  2933. } else if (d >= 4 && d < 4.5) {
  2934. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_4xing);
  2935. } else if (d >= 4.5 && d < 5) {
  2936. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_45xing);
  2937. } else {
  2938. viewHolder.item_grade_pic.setImageResource(R.drawable.icon_5xing);
  2939. }
  2940. }
  2941. if (list.get(position).getOwn_pay().equals("1")) {
  2942. viewHolder.item_zhan_cost.setText("可使用本APP扫码支付");
  2943. } else {
  2944. if (list.get(position).getCharge_cost_way2().equals("")) {
  2945. viewHolder.item_zhan_cost.setText("暂无");
  2946. } else {
  2947. if (list.get(position).getCharge_cost_way2().equals("微信支付")) {
  2948. viewHolder.item_zhan_cost.setText(list.get(position).getCharge_cost_way2());
  2949. } else {
  2950. viewHolder.item_zhan_cost.setText(list.get(position).getCharge_cost_way2() + "支付");
  2951. }
  2952. }
  2953. }
  2954. String fast = list.get(position).getFast_num();
  2955. String slow = list.get(position).getSlow_num();
  2956. String acNum = null, dcNum = null, acableNum = null, dcableNum = null;
  2957. acNum = list.get(position).getAcNum();
  2958. dcNum = list.get(position).getDcNum();
  2959. acableNum = list.get(position).getAcableNum();
  2960. dcableNum = list.get(position).getDcableNum();
  2961. if (null != acableNum && null != acNum
  2962. && null != dcableNum && null != dcNum && !acableNum.equals("")
  2963. && !acNum.equals("") && !dcableNum.equals("") && !dcNum.equals("")) {
  2964. viewHolder.item_fast_num.setText(dcNum);
  2965. viewHolder.item_fastable_num.setText(dcableNum);
  2966. viewHolder.item_fastable.setVisibility(View.VISIBLE);
  2967. viewHolder.item_fastable_num.setVisibility(View.VISIBLE);
  2968. viewHolder.item_slow_num.setText(acNum);
  2969. viewHolder.item_slowable_num.setText(acableNum);
  2970. viewHolder.item_slowable.setVisibility(View.VISIBLE);
  2971. viewHolder.item_slowable_num.setVisibility(View.VISIBLE);
  2972. } else {
  2973. viewHolder.item_fast_num.setText(fast);
  2974. viewHolder.item_fastable.setVisibility(View.GONE);
  2975. viewHolder.item_fastable_num.setVisibility(View.GONE);
  2976. viewHolder.item_slow_num.setText(slow);
  2977. viewHolder.item_slowable.setVisibility(View.GONE);
  2978. viewHolder.item_slowable_num.setVisibility(View.GONE);
  2979. }
  2980. if ("0m".equals(list.get(position).getDistance())) {
  2981. viewHolder.item_zhan_distance.setText("未知");
  2982. } else {
  2983. viewHolder.item_zhan_distance.setText(list.get(position).getDistance());
  2984. }
  2985. viewHolder.item_zhan_go.setOnClickListener(new View.OnClickListener() {
  2986. @Override
  2987. public void onClick(View v) {
  2988. MobclickAgent.onEvent(getApplicationContext(), "0060");
  2989. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
  2990. !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  2991. getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
  2992. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  2993. intent.putExtra("start_jing", center.longitude + "");
  2994. intent.putExtra("start_wei", center.latitude + "");
  2995. intent.putExtra("stop_jing", gd_jing + "");
  2996. intent.putExtra("stop_wei", gd_wei + "");
  2997. startActivity(intent);
  2998. detailsBack = true;
  2999. HashMap<String, String> map = new HashMap<String, String>();
  3000. map.put("Name", list.get(position).getZhan_name());
  3001. map.put("CostWay", list.get(position).getCharge_cost_way());
  3002. map.put("City", list.get(position).getCity());
  3003. MobclickAgent.onEvent(context, "0033", map);
  3004. map.clear();
  3005. } else {
  3006. if (center != null) {
  3007. LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  3008. popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
  3009. popupWindow = new PopupWindow(popupWindowView,
  3010. ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
  3011. true);
  3012. popupWindow.setBackgroundDrawable(new BitmapDrawable());
  3013. // 设置PopupWindow的弹出和消失效果
  3014. popupWindow.setAnimationStyle(R.style.popupAnimation);
  3015. LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
  3016. if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  3017. ll_tvTwo.setVisibility(View.GONE);
  3018. }
  3019. LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
  3020. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
  3021. ll_tvOne.setVisibility(View.GONE);
  3022. }
  3023. cancleButton = (Button) popupWindowView
  3024. .findViewById(R.id.cancleButton);
  3025. cancleButton.setOnClickListener(new View.OnClickListener() {
  3026. @Override
  3027. public void onClick(View view) {
  3028. // Toast.makeText(ZhanDetailsNew.this, "NO", Toast.LENGTH_SHORT).show();
  3029. popupWindow.dismiss();
  3030. }
  3031. });
  3032. tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
  3033. tvThree.setOnClickListener(new View.OnClickListener() {
  3034. @Override
  3035. public void onClick(View v) {
  3036. getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
  3037. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  3038. intent.putExtra("start_jing", center.longitude + "");
  3039. intent.putExtra("start_wei", center.latitude + "");
  3040. intent.putExtra("stop_jing", gd_jing + "");
  3041. intent.putExtra("stop_wei", gd_wei + "");
  3042. startActivity(intent);
  3043. detailsBack = true;
  3044. popupWindow.dismiss();
  3045. HashMap<String, String> map = new HashMap<String, String>();
  3046. map.put("Name", list.get(position).getZhan_name());
  3047. map.put("CostWay", list.get(position).getCharge_cost_way());
  3048. map.put("City", list.get(position).getCity());
  3049. MobclickAgent.onEvent(context, "0033", map);
  3050. map.clear();
  3051. }
  3052. });
  3053. tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
  3054. tvOne.setOnClickListener(new View.OnClickListener() {
  3055. @Override
  3056. public void onClick(View view) {
  3057. Intent intent = null;
  3058. // try {
  3059. //// intent = Intent.getIntent("intent://map/direction?origin=latlng:"+center.latitude+","+center.longitude+"&destination=latlng:"+ll.latitude+","+ll.longitude+"|name:"+finalMarkerInfo.getZhan_name()+"&mode=driving&region=&src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end");
  3060. // } catch (URISyntaxException e) {
  3061. // e.printStackTrace();
  3062. // }
  3063. double dwei = Double.parseDouble(list.get(position).getPoi_wei());
  3064. double djing = Double.parseDouble(list.get(position).getPoi_jing());
  3065. getBaidu(center.longitude, center.latitude);
  3066. try {
  3067. String s = "intent://map/direction?" +
  3068. "origin=" + bd_lat + "," + bd_lon + "&" +
  3069. "destination=" + dwei + "," + djing +
  3070. "&mode=driving&" +
  3071. "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
  3072. // Log.e("sss", s);
  3073. intent = Intent.getIntent(s);
  3074. detailsBack = true;
  3075. HashMap<String, String> map = new HashMap<String, String>();
  3076. map.put("Name", list.get(position).getZhan_name());
  3077. map.put("CostWay", list.get(position).getCharge_cost_way());
  3078. map.put("City", list.get(position).getCity());
  3079. MobclickAgent.onEvent(context, "0031", map);
  3080. map.clear();
  3081. } catch (URISyntaxException e) {
  3082. e.printStackTrace();
  3083. }
  3084. startActivity(intent);
  3085. // if (MainFragment.center != null) {
  3086. // double dwei = Double.parseDouble(zhan.getPoi_wei());
  3087. // double djing = Double.parseDouble(zhan.getPoi_jing());
  3088. // LatLng ll = new LatLng(dwei, djing);
  3089. //
  3090. // startNavi(MainFragment.center, ll);
  3091. //
  3092. // }
  3093. // startNavi(center, ll);
  3094. popupWindow.dismiss();
  3095. }
  3096. });
  3097. tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
  3098. tvTwo.setOnClickListener(new View.OnClickListener() {
  3099. @Override
  3100. public void onClick(View view) {
  3101. try {
  3102. // getBeginGaode(center.longitude, center.latitude);
  3103. getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
  3104. Intent intent4 = new Intent("android.intent.action.VIEW",
  3105. android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + gd_wei + "&dlon=" + gd_jing + "&dname=" + list.get(position).getZhan_name() + "&dev=0&m=0&t=2"));
  3106. intent4.setPackage("com.autonavi.minimap");
  3107. startActivity(intent4);
  3108. detailsBack = true;
  3109. popupWindow.dismiss();
  3110. HashMap<String, String> map = new HashMap<String, String>();
  3111. map.put("Name", list.get(position).getZhan_name());
  3112. map.put("CostWay", list.get(position).getCharge_cost_way());
  3113. map.put("City", list.get(position).getCity());
  3114. MobclickAgent.onEvent(context, "0032", map);
  3115. map.clear();
  3116. } catch (Exception e) {
  3117. e.printStackTrace();
  3118. Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
  3119. }
  3120. }
  3121. });
  3122. popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
  3123. // startNavi(center, ll);
  3124. } else {
  3125. Toast.makeText(getApplication(),
  3126. "没有定位到您的当前位置", Toast.LENGTH_SHORT)
  3127. .show();
  3128. }
  3129. }
  3130. }
  3131. });
  3132. }
  3133. return convertView;
  3134. }
  3135. class ViewHolder {
  3136. TextView item_zhan_name, item_zhan_go, item_zhan_distance, item_zhan_cost, item_fast_num, item_fastable, item_fastable_num,
  3137. item_slowable, item_slowable_num, item_slow_num;
  3138. ImageView item_grade_pic;
  3139. LinearLayout item_layout;
  3140. }
  3141. }
  3142. @Override
  3143. public boolean onKeyDown(int keyCode, KeyEvent event) {
  3144. if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
  3145. // 判断气泡弹窗视图是否已经隐藏
  3146. if (windowLayout.getVisibility() == View.VISIBLE) {
  3147. Animation animation = AnimationUtils.loadAnimation(this, R.anim.out);
  3148. animation.setDuration(500);
  3149. windowLayout.startAnimation(animation);
  3150. new Handler().postDelayed(new Runnable() {
  3151. @Override
  3152. public void run() {
  3153. windowLayout.setVisibility(View.GONE);
  3154. rl_control.setVisibility(View.VISIBLE);
  3155. }
  3156. }, 500);
  3157. return false;
  3158. }
  3159. if ((System.currentTimeMillis() - exitTime) > 2000) {
  3160. Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
  3161. exitTime = System.currentTimeMillis();
  3162. } else {
  3163. // ActivityManagerApplication.destoryActivity("MainMapActivity");
  3164. if (MainMapActivity.mainMapActivity != null) {
  3165. MainMapActivity.mainMapActivity.finish();
  3166. }
  3167. SharedPreferences mySharedPreferences = getSharedPreferences("showdialog",
  3168. Activity.MODE_PRIVATE);
  3169. SharedPreferences.Editor editor1 = mySharedPreferences.edit();
  3170. editor1.clear();
  3171. ProfileManager.getInstance().setSearchAddress(this, "");
  3172. ActivityUtils.finishAllActivities();
  3173. // finish();
  3174. android.os.Process.killProcess(android.os.Process.myPid());
  3175. }
  3176. }
  3177. return true;
  3178. // return super.onKeyDown(keyCode, event);
  3179. }
  3180. @Override
  3181. public void onActivityResult(int requestCode, int resultCode, Intent data) {
  3182. super.onActivityResult(requestCode, resultCode, data);
  3183. if (isListShow == false) {
  3184. windowLayout.setVisibility(View.GONE);
  3185. rl_control.setVisibility(View.VISIBLE);
  3186. }
  3187. if (requestCode == SEARCH_CODE && resultCode == 101) {
  3188. double jing = Double.valueOf(data.getStringExtra("jing"));
  3189. double wei = Double.valueOf(data.getStringExtra("wei"));
  3190. MainApplication.search_jing = jing;
  3191. MainApplication.search_wei = wei;
  3192. final LatLng screenCity = new LatLng(wei, jing);
  3193. aMap = mapView.getMap();
  3194. Util.setMapCustomStyleFile(aMap, getApplicationContext());
  3195. new Handler().postDelayed(new Runnable() {
  3196. @Override
  3197. public void run() {
  3198. aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
  3199. }
  3200. }, 500);
  3201. if (search_marker != null) {
  3202. search_marker.remove();
  3203. }
  3204. if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
  3205. LatLng latLng = new LatLng(MainApplication.search_wei, MainApplication.search_jing);
  3206. search_marker = aMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.icon_search_address))));
  3207. search_marker.setPeriod(8);
  3208. }
  3209. ete("{\"fun\":\"timer\"}");
  3210. } else if (requestCode == SEARCH_CODE && resultCode == 102) {
  3211. double jing = Double.valueOf(data.getStringExtra("jing"));
  3212. double wei = Double.valueOf(data.getStringExtra("wei"));
  3213. final LatLng screenCity = new LatLng(wei, jing);
  3214. aMap = mapView.getMap();
  3215. Util.setMapCustomStyleFile(aMap, getApplicationContext());
  3216. new Handler().postDelayed(new Runnable() {
  3217. @Override
  3218. public void run() {
  3219. aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
  3220. }
  3221. }, 500);
  3222. }
  3223. }
  3224. private void dialogup() {
  3225. int code = Integer.parseInt(now_versionCode);
  3226. if (code - getVersionCode(getApplication()) > 0) {
  3227. new AlertDialogUpdate(MainMapActivity.this).builder()
  3228. .setTitle("更新提示 " + now_versionName)
  3229. .setMsg(title.trim())
  3230. .setPositiveButton("更新", new View.OnClickListener() {
  3231. @Override
  3232. public void onClick(View v) {
  3233. Intent intent = new Intent();
  3234. intent.setAction("android.intent.action.VIEW");
  3235. Uri content_url = Uri.parse("http://cdz.evcharge.cc/app/app.apk");
  3236. intent.setData(content_url);
  3237. startActivity(intent);
  3238. }
  3239. }).setNegativeButton("忽略", new View.OnClickListener() {
  3240. @Override
  3241. public void onClick(View v) {
  3242. }
  3243. }).show();
  3244. }
  3245. }
  3246. private void showProgressWindow() {
  3247. updateDialog = new UpdateDialog(MainMapActivity.this);
  3248. updateDialog.builder().setMsg("").setCancelable(false).show();
  3249. }
  3250. private void dialogup_other() {
  3251. int code = Integer.parseInt(now_versionCode);
  3252. if (code - getVersionCode(getApplication()) > 0) {
  3253. alterDialog = new AlertDialogUpdate(MainMapActivity.this);
  3254. alterDialog.builder()
  3255. .setTitle("更新提示 " + now_versionName)
  3256. .setMsg(title.trim())
  3257. .setPositiveButton("更新", new View.OnClickListener() {
  3258. @Override
  3259. public void onClick(View v) {
  3260. showProgressWindow();
  3261. ToastUtil.showToast(getApplicationContext(), "正在下载中", Toast.LENGTH_SHORT);
  3262. OkHttpUtils.get().url("http://cdz.evcharge.cc/app/app.apk").build()
  3263. .execute(new FileCallBack(Environment.getExternalStorageDirectory().getAbsolutePath(), "cdz_install") {
  3264. @Override
  3265. public void inProgress(final float progress, long total) {
  3266. NumberFormat numberFormat = NumberFormat.getInstance();
  3267. // 设置精确到小数点后2位
  3268. numberFormat.setMaximumFractionDigits(2);
  3269. String format = numberFormat.format(progress * 100);
  3270. Message message = new Message();
  3271. message.what = 0x01;
  3272. Bundle bundle = new Bundle();
  3273. bundle.putString("format", format + "%");
  3274. LogUtils.e("当前:" + format);
  3275. if (!format.contains(".")) {
  3276. bundle.putString("progress", format + ".");
  3277. } else {
  3278. bundle.putString("progress", format);
  3279. }
  3280. message.setData(bundle);
  3281. myHandler.sendMessage(message);
  3282. }
  3283. @Override
  3284. public void onError(Call call, Exception e) {
  3285. // LogUtils.e(e.getMessage());
  3286. }
  3287. @Override
  3288. public void onResponse(File response) {
  3289. String path = getDatabasePath("zhan_list").getPath();
  3290. com.blankj.utilcode.util.LogUtils.e(path);
  3291. AppUtils.cleanAppData(path);
  3292. Intent intent = new Intent();
  3293. intent.setAction(android.content.Intent.ACTION_VIEW);
  3294. Uri uri;
  3295. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  3296. Uri contentUri = FileProvider.getUriForFile(context,
  3297. context.getApplicationContext().getPackageName() + ".provider",
  3298. response);
  3299. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  3300. intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  3301. intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
  3302. } else {
  3303. uri = Uri.fromFile(response);
  3304. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  3305. intent.setDataAndType(uri, "application/vnd.android.package-archive");
  3306. }
  3307. context.startActivity(intent);
  3308. android.os.Process.killProcess(android.os.Process.myPid());
  3309. }
  3310. });
  3311. }
  3312. }).setNegativeButton("退出", new View.OnClickListener() {
  3313. @Override
  3314. public void onClick(View v) {
  3315. SharedPreferences mySharedPreferences = getSharedPreferences("showdialog",
  3316. Activity.MODE_PRIVATE);
  3317. SharedPreferences.Editor editor1 = mySharedPreferences.edit();
  3318. editor1.clear();
  3319. finish();
  3320. ProfileManager.getInstance().setSearchAddress(getApplicationContext(), "");
  3321. android.os.Process.killProcess(android.os.Process.myPid());
  3322. }
  3323. }).setCancelable(false).show();
  3324. }
  3325. }
  3326. public static int getVersionCode(Context context)//获取版本号(内部识别号)
  3327. {
  3328. try {
  3329. PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
  3330. // Log.e("versionCode", pi.versionCode + "");
  3331. return pi.versionCode;
  3332. } catch (PackageManager.NameNotFoundException e) {
  3333. // TODO Auto-generated catch block
  3334. e.printStackTrace();
  3335. return 0;
  3336. }
  3337. }
  3338. public void getVersion() {
  3339. try {
  3340. PackageManager manager = getApplication().getPackageManager();
  3341. PackageInfo info = manager.getPackageInfo(getApplication().getPackageName(), 0);
  3342. app_version = info.versionName;
  3343. // return this.getString(R.string.version_name) + version;
  3344. // Log.e("version", app_version);
  3345. } catch (Exception e) {
  3346. e.printStackTrace();
  3347. // return this.getString(R.string.can_not_find_version_name);
  3348. }
  3349. }
  3350. private void getPingLun() {
  3351. new Thread(new Runnable() {
  3352. @Override
  3353. public void run() {
  3354. String url = null;
  3355. try {
  3356. url = MainApplication.url + "/zhannew/basic/web/index.php/tpmember/commentcount?userid=" + MainApplication.userId;
  3357. } catch (Exception e) {
  3358. e.printStackTrace();
  3359. }
  3360. submitPingLun(url);
  3361. }
  3362. }).start();
  3363. }
  3364. private void submitPingLun(String sms) {
  3365. // Log.e("url", sms);
  3366. Request request = new Request.Builder().url(sms).build();
  3367. Response response = null;
  3368. try {
  3369. if (request == null) {
  3370. Message msg = new Message();
  3371. msg.what = 5;
  3372. hand.sendMessage(msg);
  3373. return;
  3374. }
  3375. response = OkHttpUtil.execute(request);
  3376. if (response.code() == 200) {
  3377. String json = "";
  3378. try {
  3379. json = response.body().string();
  3380. Message msg = new Message();
  3381. msg.obj = json;
  3382. msg.what = 17;
  3383. hand.sendMessage(msg);
  3384. // Log.e("url", json);
  3385. } catch (Exception e) {
  3386. e.printStackTrace();
  3387. Message msg = new Message();
  3388. msg.what = 5;
  3389. hand.sendMessage(msg);
  3390. }
  3391. }
  3392. } catch (Exception e) {
  3393. e.printStackTrace();
  3394. Message msg = new Message();
  3395. msg.what = 5;
  3396. hand.sendMessage(msg);
  3397. }
  3398. }
  3399. //获取系统消息
  3400. private void getMessage() {
  3401. new Thread(new Runnable() {
  3402. @Override
  3403. public void run() {
  3404. long appTime1 = System.currentTimeMillis() / 1000;
  3405. // Log.i("appTime(long)---", appTime1 + "");
  3406. String token = String.valueOf(appTime1);
  3407. // Log.e("token", token);
  3408. String url = null;
  3409. if (MainApplication.msgTime.equals("0")) {
  3410. MainApplication.firstOpenTime = token;
  3411. ProfileManager.getInstance().setFirstOpenTime(getApplicationContext(), token);
  3412. MainApplication.msgTime = token;
  3413. ProfileManager.getInstance().setSystemMsgTime(getApplicationContext(), token);
  3414. }
  3415. try {
  3416. url = MainApplication.url + "/zhannew/basic/web/index.php/zhangonggao/release?timer=" + MainApplication.msgTime;
  3417. // Log.e("890", url);
  3418. } catch (Exception e) {
  3419. e.printStackTrace();
  3420. }
  3421. submitMessage(url);
  3422. }
  3423. }).start();
  3424. }
  3425. private void submitMessage(String sms) {
  3426. // Log.e("url", sms);
  3427. Request request = new Request.Builder().url(sms).build();
  3428. Response response = null;
  3429. try {
  3430. if (request == null) {
  3431. Message msg = new Message();
  3432. msg.what = 5;
  3433. hand.sendMessage(msg);
  3434. return;
  3435. }
  3436. response = OkHttpUtil.execute(request);
  3437. if (response.code() == 200) {
  3438. String json = "";
  3439. try {
  3440. json = response.body().string();
  3441. Message msg = new Message();
  3442. msg.obj = json;
  3443. msg.what = 7;
  3444. hand.sendMessage(msg);
  3445. // Log.e("url", json);
  3446. } catch (Exception e) {
  3447. e.printStackTrace();
  3448. Message msg = new Message();
  3449. msg.what = 5;
  3450. hand.sendMessage(msg);
  3451. }
  3452. }
  3453. } catch (Exception e) {
  3454. e.printStackTrace();
  3455. Message msg = new Message();
  3456. msg.what = 5;
  3457. hand.sendMessage(msg);
  3458. }
  3459. }
  3460. public void MainMapp() {
  3461. eteCityTime("{\"fun\":\"timer\"}");
  3462. clickMarker = false;
  3463. SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
  3464. sharedPreferencesUtil.setFileName("CurrentMarkerInfo");
  3465. sharedPreferencesUtil.clearData();
  3466. }
  3467. public void eteCityTime(final String params) {
  3468. new Thread(new Runnable() {
  3469. @Override
  3470. public void run() {
  3471. try {
  3472. String host = "";
  3473. if (MainApplication.url.contains("cdz.evcharge.cc")) {
  3474. host = "cdz.evcharge.cc";
  3475. } else {
  3476. host = "59.110.68.162";
  3477. }
  3478. socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
  3479. // 向服务器发送消息
  3480. PrintWriter out = new PrintWriter(new BufferedWriter(
  3481. new OutputStreamWriter(socket.getOutputStream())), true);
  3482. out.println(params);
  3483. // out.println("{\"fun\":\"getcity\"}");
  3484. // 接收来自服务器的消息
  3485. BufferedReader br = new BufferedReader(new InputStreamReader(
  3486. socket.getInputStream()));
  3487. // Message message = handle.obtainMessage();
  3488. // message.obj = line;
  3489. // message.arg1 = 1;
  3490. // handle.sendMessage(message);
  3491. String msg = br.readLine();
  3492. // Log.d("dddddss",msg);
  3493. // System.out.print("www:"+qqq);
  3494. // Log.d("qqq",key);
  3495. // if (msg != null) {
  3496. // Message mes = new Message();
  3497. // mes.obj = msg;
  3498. // mes.what = 2;
  3499. // hand.sendMessage(mes);
  3500. // }
  3501. // Message message = handler.obtainMessage();
  3502. // message.obj = line;
  3503. // message.arg1 = 17;
  3504. // handler.sendMessage(message);
  3505. token = msg;
  3506. int time = (int) (System.currentTimeMillis() / 1000);
  3507. // cha = String.valueOf(time - Integer.parseInt(msg));
  3508. cha = time - Integer.parseInt(msg);
  3509. Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
  3510. // url = "http://cdz.d1ev.com/zhannew/basic/web/index.php/zhanlist/getlist?poi_lux=" + locLeftTop.longitude + "" + "&poi_luy=" + locLeftTop.latitude + "" + "&poi_rdx=" + llRightBottom.longitude + "" + "&poi_rdy=" + llRightBottom.latitude + "" + "&suit_car2=" + MainApplication.userTpye + "&status=" + MainApplication.mapStatus + "&charge_cost_way=" + MainApplication.costWay;
  3511. String url = "{\"fun\":\"getcity\",\"suit_car2\":" + "\"" + MainApplication.userTpye + "\"" + ",\"status\":" + "\"" + MainApplication.mapStatus + "\"" + ",\"charge_cost_way\":" + "\"" + MainApplication.costWay + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + "}";
  3512. // Log.d("wwwww", url);
  3513. // System.out.print("qazwsx:"+url);
  3514. if (MainApplication.userTpye == "") {
  3515. MainApplication.userTpye = "1";
  3516. }
  3517. eteCity("{\"fun\":\"getcity\",\"suit_car2\":" + "\"" + MainApplication.userTpye + "\"" + ",\"status\":" + "\"" + MainApplication.mapStatus + "\"" + ",\"charge_cost_way\":" + "\"" + MainApplication.costWay + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + "}");
  3518. } catch (Exception e) {
  3519. }
  3520. }
  3521. }).start();
  3522. }
  3523. public void eteCity(final String params) {
  3524. new Thread(new Runnable() {
  3525. @Override
  3526. public void run() {
  3527. try {
  3528. String host = "";
  3529. if (MainApplication.url.contains("cdz.evcharge.cc")) {
  3530. host = "cdz.evcharge.cc";
  3531. } else {
  3532. host = "59.110.68.162";
  3533. }
  3534. socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
  3535. // 向服务器发送消息
  3536. PrintWriter out = new PrintWriter(new BufferedWriter(
  3537. new OutputStreamWriter(socket.getOutputStream())), true);
  3538. out.println(params);
  3539. // out.println("{\"fun\":\"getcity\"}");
  3540. // 接收来自服务器的消息
  3541. BufferedReader br = new BufferedReader(new InputStreamReader(
  3542. socket.getInputStream()));
  3543. String msg = br.readLine();
  3544. // Log.d("dddddmsg",msg);
  3545. if (msg != null) {
  3546. Message mes = new Message();
  3547. mes.obj = msg;
  3548. mes.what = 4;
  3549. hand.sendMessage(mes);
  3550. }
  3551. // 关闭流
  3552. out.close();
  3553. br.close();
  3554. // 关闭Socket
  3555. socket.close();
  3556. // }
  3557. } catch (Exception e) {
  3558. }
  3559. }
  3560. }).start();
  3561. }
  3562. //登陆状态判断
  3563. private void setlogin() {
  3564. if (TextUtils
  3565. .isEmpty(ProfileManager.getInstance().getId(getApplication()))) {
  3566. if (MainApplication.userNickname.equals("")) {
  3567. // userLogin.setText(MainApplication.userNickname);
  3568. } else {
  3569. // userLogin.setText(Util.handlePhone(""));
  3570. }
  3571. MainApplication.sql = ProfileManager.getInstance().getSQL(this);
  3572. } else {
  3573. MainApplication.userPhone = ProfileManager.getInstance().getUsername(getApplication());
  3574. MainApplication.userId = ProfileManager.getInstance().getUserid(getApplication());
  3575. MainApplication.userIcon = ProfileManager.getInstance().getUsericon(getApplication());
  3576. MainApplication.userNickname = ProfileManager.getInstance().getNickname(getApplication());
  3577. MainApplication.sql = ProfileManager.getInstance().getSQL(getApplication());
  3578. // Log.e("MainApplication.sql===", MainApplication.sql);
  3579. if (!MainApplication.userId.equals("")) {
  3580. getPingLun();
  3581. }
  3582. }
  3583. }
  3584. private boolean isAvilible(Context context, String packageName) {
  3585. //获取packagemanager
  3586. final PackageManager packageManager = context.getPackageManager();
  3587. //获取所有已安装程序的包信息
  3588. List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
  3589. //用于存储所有已安装程序的包名
  3590. List<String> packageNames = new ArrayList<String>();
  3591. //从pinfo中将包名字逐一取出,压入pName list中
  3592. if (packageInfos != null) {
  3593. for (int i = 0; i < packageInfos.size(); i++) {
  3594. String packName = packageInfos.get(i).packageName;
  3595. packageNames.add(packName);
  3596. }
  3597. }
  3598. //判断packageNames中是否有目标程序的包名,有TRUE,没有FALSE
  3599. return packageNames.contains(packageName);
  3600. }
  3601. private void getGaode(Double jing, Double wei) {
  3602. double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  3603. double gg_lon;
  3604. double gg_lat;
  3605. double x = jing - 0.0065, y = wei - 0.006;
  3606. double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
  3607. double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
  3608. gg_lon = z * Math.cos(theta);
  3609. gd_jing = String.valueOf(gg_lon);
  3610. gg_lat = z * Math.sin(theta);
  3611. gd_wei = String.valueOf(gg_lat);
  3612. }
  3613. private void getBaidu(Double jing, Double wei) {
  3614. double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  3615. double x = jing;
  3616. double y = wei;
  3617. double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
  3618. double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
  3619. bd_lon = z * Math.cos(theta) + 0.0065;
  3620. bd_lat = z * Math.sin(theta) + 0.006;
  3621. }
  3622. private void getBaidu1(Double jing, Double wei) {
  3623. double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  3624. double x = jing;
  3625. double y = wei;
  3626. double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
  3627. double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
  3628. bd_jing = z * Math.cos(theta) + 0.0065;
  3629. bd_wei = z * Math.sin(theta) + 0.006;
  3630. }
  3631. private void getBeginGaode(Double jing, Double wei) {
  3632. double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
  3633. double gg_lon;
  3634. double gg_lat;
  3635. double x = jing - 0.0065, y = wei - 0.006;
  3636. double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
  3637. double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
  3638. gg_lon = z * Math.cos(theta);
  3639. bg_jing = String.valueOf(gg_lon);
  3640. gg_lat = z * Math.sin(theta);
  3641. bg_wei = String.valueOf(gg_lat);
  3642. }
  3643. private void setUserData() {
  3644. if (!ProfileManager.getInstance().getGuide(this)) {
  3645. MainApplication.messageToken = "0";
  3646. MainApplication.userTpye = "1";
  3647. ProfileManager.getInstance().setGuide(this, true);
  3648. MainApplication.sql = ProfileManager.getInstance().getSQL(this);
  3649. MainApplication.sudu = ProfileManager.getInstance().getSudu(this);
  3650. } else {
  3651. MainApplication.userTpye = ProfileManager.getInstance().getTpey(this);
  3652. // Log.e("type!", MainApplication.userTpye);
  3653. MainApplication.mapStatus = ProfileManager.getInstance().getMapstatus(this);
  3654. MainApplication.costWay = ProfileManager.getInstance().getCostway(this);
  3655. MainApplication.map = ProfileManager.getInstance().getMap(this);
  3656. MainApplication.shuxing = ProfileManager.getInstance().getShuxing(this);
  3657. MainApplication.sudu = ProfileManager.getInstance().getSudu(this);
  3658. MainApplication.atCity = ProfileManager.getInstance().getAtCity(this);
  3659. MainApplication.sql = ProfileManager.getInstance().getSQL(this);
  3660. MainApplication.support = ProfileManager.getInstance().getSupport(this);
  3661. MainApplication.freestop = ProfileManager.getInstance().getFreeStop(this);
  3662. MainApplication.selecthotel = ProfileManager.getInstance().getSelectHotel(this);
  3663. MainApplication.selectexpressway = ProfileManager.getInstance().getSelectExpressway(this);
  3664. MainApplication.selectjingdian = ProfileManager.getInstance().getSelectJingdian(this);
  3665. MainApplication.logid = ProfileManager.getInstance().getLogid(this);
  3666. MainApplication.messageToken = ProfileManager.getInstance().getKeyMessageToken(this);
  3667. }
  3668. }
  3669. private void userChargingCheck() {
  3670. OkHttpUtils.get().url(UrlConstants.USER_CHARGING_CHECK_URL)
  3671. .addParams(ChargingConstants.USERID, MainApplication.userId)
  3672. .addParams(ChargingConstants.PWD, MainApplication.userPassword)
  3673. .build().connTimeOut(10000).readTimeOut(10000).execute(new StringCallback() {
  3674. @Override
  3675. public void onError(Call call, Exception e) {
  3676. }
  3677. @Override
  3678. public void onResponse(final String response) {
  3679. LogUtils.e(response);
  3680. if (EmptyUtils.isNotEmpty(response)) {
  3681. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  3682. if ("306".equals(rtnCode)) {
  3683. LogUtils.e("有订单");
  3684. rl_charging_notice.setVisibility(View.VISIBLE);
  3685. if (firstCheck) {
  3686. if (isStatusBack == false) {
  3687. String data = JsonUtils.getKeyResult(response, "data");
  3688. String orderid = JsonUtils.getKeyResult(data, "orderId");
  3689. Intent intent = new Intent(getApplicationContext(), ChargingStatusActivity.class);
  3690. intent.putExtra(ChargingConstants.ORDERID, orderid);
  3691. startActivity(intent);
  3692. }
  3693. firstCheck = false;
  3694. }
  3695. rl_charging_notice.setOnClickListener(new View.OnClickListener() {
  3696. @Override
  3697. public void onClick(View view) {
  3698. String data = JsonUtils.getKeyResult(response, "data");
  3699. String orderid = JsonUtils.getKeyResult(data, "orderId");
  3700. Intent intent = new Intent(getApplicationContext(), ChargingStatusActivity.class);
  3701. intent.putExtra(ChargingConstants.ORDERID, orderid);
  3702. startActivity(intent);
  3703. }
  3704. });
  3705. } else {
  3706. LogUtils.e("没有订单");
  3707. rl_charging_notice.setVisibility(View.GONE);
  3708. MainApplication.isAppStart = false;
  3709. ProfileManager.getInstance().setAppStart(getApplicationContext(), MainApplication.isAppStart);
  3710. }
  3711. }
  3712. }
  3713. });
  3714. }
  3715. // private void chargingStatus() {
  3716. // long appTime1 = System.currentTimeMillis() / 1000;
  3717. // long updatetime = appTime1 - MainMapActivity.cha - 3;
  3718. // String token = String.valueOf(updatetime);
  3719. // String url = MainApplication.url + "/zhannew/basic/web/index.php/xxapi/status_v2" +
  3720. // "?supplier=星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&password="+MainApplication.userPassword+"&ver=1.0&sign="
  3721. // + Md5Util.md5("password="+MainApplication.userPassword+"supplier=星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a");
  3722. //// Log.e("urlstatus", url);
  3723. // OkHttpUtils.get()
  3724. // .url(url)
  3725. // .build()
  3726. // .connTimeOut(10000)
  3727. // .readTimeOut(10000)
  3728. // .execute(new StringCallback() {
  3729. // @Override
  3730. // public void onError(Call call, Exception e) {
  3731. // Toast.makeText(getApplicationContext(), "网络不给力", Toast.LENGTH_SHORT).show();
  3732. // }
  3733. //
  3734. // @Override
  3735. // public void onResponse(final String response) {
  3736. // new Handler().postDelayed(new Runnable() {
  3737. // @Override
  3738. // public void run() {
  3739. // String code = JsonUtils.getKeyResult(response, "code");
  3740. // if (code.equals("200")) {
  3741. // rl_charging_notice.setVisibility(View.VISIBLE);
  3742. // if (firstCheck) {
  3743. // Intent intent3 = new Intent(getApplication(), MainScanActivity.class);
  3744. // intent3.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  3745. // startActivity(intent3);
  3746. // overridePendingTransition(0, 0);
  3747. // ActivityManagerApplication.addDestoryActivity(MainMapActivity.this, "MainMapActivity");
  3748. // MainScanActivity.tag = "1";
  3749. // firstCheck = false;
  3750. // }
  3751. // Log.e("首页查询订单=", "有");
  3752. // } else {
  3753. // rl_charging_notice.setVisibility(View.GONE);
  3754. // MainScanActivity.tag = "";
  3755. // Log.e("首页查询订单=", "没有");
  3756. // MainApplication.isAppStart = false;
  3757. // ProfileManager.getInstance().setAppStart(getApplicationContext(),MainApplication.isAppStart);
  3758. // }
  3759. // }
  3760. // }, 2000);
  3761. //
  3762. // }
  3763. // });
  3764. // }
  3765. private void getZhanListData(int level) {
  3766. aMap.clear();
  3767. ZhanDBHelper dbHelper = new ZhanDBHelper(this);
  3768. try {
  3769. dbHelper.createDataBase();
  3770. SQLiteDatabase db = dbHelper.getWritableDatabase();
  3771. db.beginTransaction();
  3772. String sql = "";
  3773. if (level == 3) {
  3774. sql = "SELECT count(*) as cnt,substr(poi_jing,0,4) as pjing,substr(poi_wei,0,3) as pwei,avg(poi_jing) as pjing2,avg(poi_wei) as pwei2 FROM zhan_list where city != '1'" + MainApplication.sql + "GROUP BY pjing,pwei";
  3775. } else if (level == 2) {
  3776. sql = "SELECT count(*) as cnt,substr(poi_jing,0,6) as pjing,substr(poi_wei,0,5) as pwei,avg(poi_jing) as pjing2,avg(poi_wei) as pwei2 FROM zhan_list where city != '1'" + MainApplication.sql + "GROUP BY pjing,pwei";
  3777. }
  3778. Cursor cursor = db.rawQuery(sql, null);
  3779. ZhanDB zhan_db;
  3780. while (cursor.moveToNext()) {
  3781. zhan_db = new ZhanDB();
  3782. zhan_db.setCnt(cursor.getString(cursor.getColumnIndex("cnt")));
  3783. zhan_db.setPjing2(cursor.getString(cursor.getColumnIndex("pjing2")));
  3784. zhan_db.setPwei2(cursor.getString(cursor.getColumnIndex("pwei2")));
  3785. list_db.add(zhan_db);
  3786. }
  3787. cursor.close();
  3788. db.endTransaction();
  3789. db.close();
  3790. } catch (IOException e) {
  3791. e.printStackTrace();
  3792. }
  3793. }
  3794. private void delData(List<DataRefresh> list_del) {
  3795. String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
  3796. try {
  3797. SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
  3798. db.beginTransaction();//开始事务
  3799. try {
  3800. for (int i = 0; i < list_del.size(); i++) {
  3801. String[] args = {String.valueOf(list_del.get(i).getId())};
  3802. int mub = db.delete("zhan_list", "id=?", args);
  3803. if (mub > 0) {
  3804. // Log.e(TAG, "删除成功");
  3805. } else {
  3806. // Log.e(TAG, "删除失败---" + list_del.get(i).getId());
  3807. }
  3808. }
  3809. db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
  3810. } finally {
  3811. db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务
  3812. }
  3813. db.close();
  3814. } catch (Exception e) {
  3815. e.printStackTrace();
  3816. }
  3817. }
  3818. private void addData(List<DataRefresh> list_add) {
  3819. String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
  3820. try {
  3821. SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
  3822. db.beginTransaction();//开始事务
  3823. try {
  3824. for (int i = 0; i < list_add.size(); i++) {
  3825. ContentValues cv = new ContentValues();
  3826. cv.put("id", list_add.get(i).getId());
  3827. cv.put("status", list_add.get(i).getStatus());
  3828. cv.put("poi_jing", list_add.get(i).getPoi_jing());
  3829. cv.put("poi_wei", list_add.get(i).getPoi_wei());
  3830. cv.put("total_num", list_add.get(i).getTotal_num());
  3831. cv.put("fast_num", list_add.get(i).getFast_num());
  3832. cv.put("slow_num", list_add.get(i).getSlow_num());
  3833. cv.put("charge_cost_way", list_add.get(i).getCharge_cost_way());
  3834. cv.put("belong_attribute", list_add.get(i).getBelong_attribute());
  3835. cv.put("suit_car", list_add.get(i).getSuit_car());
  3836. cv.put("own_pay", list_add.get(i).getOwn_pay());
  3837. cv.put("city", list_add.get(i).getCity());
  3838. cv.put("supplier", list_add.get(i).getSupplier());
  3839. long mub = db.insert("zhan_list", null, cv);
  3840. if (mub > 0) {
  3841. Log.e(TAG, "添加成功");
  3842. } else {
  3843. Log.e(TAG, "添加失败---" + list_add.get(i).getId());
  3844. }
  3845. }
  3846. db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
  3847. } finally {
  3848. db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务
  3849. }
  3850. db.close();
  3851. } catch (Exception e) {
  3852. e.printStackTrace();
  3853. }
  3854. }
  3855. private void upData(List<DataRefresh> list_up) {
  3856. String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
  3857. try {
  3858. SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
  3859. db.beginTransaction();//开始事务
  3860. try {
  3861. for (int i = 0; i < list_up.size(); i++) {
  3862. String[] args = {String.valueOf(list_up.get(i).getId())};
  3863. ContentValues cv = new ContentValues();
  3864. cv.put("id", list_up.get(i).getId());
  3865. cv.put("status", list_up.get(i).getStatus());
  3866. cv.put("poi_jing", list_up.get(i).getPoi_jing());
  3867. cv.put("poi_wei", list_up.get(i).getPoi_wei());
  3868. cv.put("total_num", list_up.get(i).getTotal_num());
  3869. cv.put("fast_num", list_up.get(i).getFast_num());
  3870. cv.put("slow_num", list_up.get(i).getSlow_num());
  3871. cv.put("charge_cost_way", list_up.get(i).getCharge_cost_way());
  3872. cv.put("belong_attribute", list_up.get(i).getBelong_attribute());
  3873. cv.put("suit_car", list_up.get(i).getSuit_car());
  3874. cv.put("own_pay", list_up.get(i).getOwn_pay());
  3875. cv.put("city", list_up.get(i).getCity());
  3876. cv.put("supplier", list_up.get(i).getSupplier());
  3877. long mub = db.update("zhan_list", cv, "id=?", args);
  3878. if (mub > 0) {
  3879. Log.e(TAG, "up成功");
  3880. } else {
  3881. Log.e(TAG, "up失败---" + list_up.get(i).getId());
  3882. }
  3883. }
  3884. db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
  3885. } finally {
  3886. db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务
  3887. }
  3888. db.close();
  3889. } catch (Exception e) {
  3890. e.printStackTrace();
  3891. }
  3892. }
  3893. public String getAssetsCacheFile(Context context, String fileName) throws Exception {
  3894. File cacheFile = new File(context.getCacheDir(), fileName);
  3895. try {
  3896. InputStream inputStream = context.getAssets().open(fileName);
  3897. try {
  3898. FileOutputStream outputStream = new FileOutputStream(cacheFile);
  3899. try {
  3900. byte[] buf = new byte[1024];
  3901. int len;
  3902. while ((len = inputStream.read(buf)) > 0) {
  3903. outputStream.write(buf, 0, len);
  3904. }
  3905. } finally {
  3906. outputStream.close();
  3907. }
  3908. } finally {
  3909. inputStream.close();
  3910. }
  3911. } catch (IOException e) {
  3912. e.printStackTrace();
  3913. }
  3914. getZhanData();
  3915. return cacheFile.getAbsolutePath();
  3916. }
  3917. class NetworkChangeReceiver extends BroadcastReceiver {
  3918. @Override
  3919. public void onReceive(Context context, Intent intent) {
  3920. ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  3921. NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
  3922. if (null != networkInfo && networkInfo.isAvailable()) {
  3923. } else {
  3924. Toast.makeText(context, "当前网络不可用", Toast.LENGTH_SHORT).show();
  3925. }
  3926. }
  3927. }
  3928. private void getZhanData() throws Exception {
  3929. if (zhan_lists != null) {
  3930. zhan_lists.clear();
  3931. }
  3932. if (mClusterOverlay != null) {
  3933. mClusterOverlay.onDestroy();
  3934. }
  3935. DaoMaster daoMaster = new DaoMaster(SQLiteDatabase.openOrCreateDatabase(getDatabasePath("zhan_list"), null));
  3936. DaoSession mDaoSession = daoMaster.newSession();
  3937. zhan_listDao = mDaoSession.getZhan_listDao();
  3938. zhan_lists = zhan_listDao.queryRaw("where status = ? " + MainApplication.sql, new String[]{"4"});
  3939. if (onResumeRefresh == true) {
  3940. ToastUtil.showToast(getApplicationContext(), "共" + zhan_lists.size() + "个符合条件的站点", Toast.LENGTH_SHORT);
  3941. }
  3942. new Thread() {
  3943. public void run() {
  3944. List<ClusterItem> items = new ArrayList<ClusterItem>();
  3945. if (zhan_lists != null && zhan_lists.size() > 0) {
  3946. for (int i = 0; i < zhan_lists.size(); i++) {
  3947. String jing = zhan_lists.get(i).getPoi_jing();
  3948. String wei = zhan_lists.get(i).getPoi_wei();
  3949. if (jing != null && !jing.equals("") && !wei.equals("") && wei != null) {
  3950. int position_jing = jing.length() - jing.indexOf(".") - 1;
  3951. int position_wei = wei.length() - wei.indexOf(".") - 1;
  3952. LatLng ll;
  3953. if (position_jing > 13 || position_wei > 13) {
  3954. ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
  3955. } else {
  3956. double dwei = Double.parseDouble(wei);
  3957. double djing = Double.parseDouble(jing);
  3958. getGaode(djing, dwei);
  3959. ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
  3960. }
  3961. if (null != String.valueOf(ll.longitude) && null != String.valueOf(ll.latitude)) {
  3962. if (null != zhan_lists) {
  3963. zhan_lists.get(i).setPoi_jing(String.valueOf(ll.longitude));
  3964. zhan_lists.get(i).setPoi_wei(String.valueOf(ll.latitude));
  3965. }
  3966. }
  3967. }
  3968. }
  3969. }
  3970. for (int i = 0; i < zhan_lists.size(); i++) {
  3971. if (null != zhan_lists.get(i).getPoi_jing() && null != zhan_lists.get(i).getPoi_wei()) {
  3972. double lat, lon;
  3973. if (zhan_lists.get(i).getPoi_wei().equals("") || zhan_lists.get(i).getPoi_wei() == null) {
  3974. lat = 0.00;
  3975. } else {
  3976. lat = Double.parseDouble(zhan_lists.get(i).getPoi_wei());
  3977. }
  3978. if (zhan_lists.get(i).getPoi_jing().equals("") || zhan_lists.get(i).getPoi_jing() == null) {
  3979. lon = 0.00;
  3980. } else {
  3981. lon = Double.parseDouble(zhan_lists.get(i).getPoi_jing());
  3982. }
  3983. LatLng latLng = new LatLng(lat, lon, false);
  3984. RegionItem regionItem = new RegionItem(latLng, "test" + i);
  3985. //注意这里在设置数据的时候把 自己的原始点的信息设置到区域Item中 方便在回调方法中拿到这些数据
  3986. // zhan_lists.get(i).setPoi_jing(String.valueOf(ll.longitude));
  3987. // zhan_lists.get(i).setPoi_wei(String.valueOf(ll.latitude));
  3988. regionItem.setChargePoint(zhan_lists.get(i));
  3989. items.add(regionItem);
  3990. }
  3991. }
  3992. mClusterOverlay = new ClusterOverlay(aMap, items, dp2px(getApplicationContext(), clusterRadius), getApplicationContext());
  3993. mClusterOverlay.setClusterRenderer(MainMapActivity.this);
  3994. mClusterOverlay.setOnClusterClickListener(MainMapActivity.this);
  3995. }
  3996. }.start();
  3997. }
  3998. private void showMapMarker() {
  3999. List<ClusterItem> items = new ArrayList<ClusterItem>();
  4000. for (int i = 0; i < zhan_lists.size(); i++) {
  4001. if (null != zhan_lists.get(i).getPoi_jing() && null != zhan_lists.get(i).getPoi_wei()) {
  4002. double lat, lon;
  4003. if (zhan_lists.get(i).getPoi_wei().equals("") || zhan_lists.get(i).getPoi_wei() == null) {
  4004. lat = 0.00;
  4005. } else {
  4006. lat = Double.parseDouble(zhan_lists.get(i).getPoi_wei());
  4007. }
  4008. if (zhan_lists.get(i).getPoi_jing().equals("") || zhan_lists.get(i).getPoi_jing() == null) {
  4009. lon = 0.00;
  4010. } else {
  4011. lon = Double.parseDouble(zhan_lists.get(i).getPoi_jing());
  4012. }
  4013. LatLng latLng = new LatLng(lat, lon, false);
  4014. RegionItem regionItem = new RegionItem(latLng, "test" + i);
  4015. //注意这里在设置数据的时候把 自己的原始点的信息设置到区域Item中 方便在回调方法中拿到这些数据
  4016. // zhan_lists.get(i).setPoi_jing(String.valueOf(ll.longitude));
  4017. // zhan_lists.get(i).setPoi_wei(String.valueOf(ll.latitude));
  4018. regionItem.setChargePoint(zhan_lists.get(i));
  4019. items.add(regionItem);
  4020. }
  4021. }
  4022. mClusterOverlay = new ClusterOverlay(aMap, items, dp2px(getApplicationContext(), clusterRadius), getApplicationContext());
  4023. mClusterOverlay.setClusterRenderer(MainMapActivity.this);
  4024. mClusterOverlay.setOnClusterClickListener(MainMapActivity.this);
  4025. }
  4026. private void initDataBase() throws IOException {
  4027. File databasePath = getDatabasePath("zhan_list");
  4028. databasePath.getParentFile().mkdirs();
  4029. databasePath.createNewFile();
  4030. InputStream inputStream = getAssets().open("zhan_list.db");
  4031. FileOutputStream fileOutputStream = new FileOutputStream(databasePath);
  4032. byte[] buf = new byte[1024 * 10];
  4033. int length = 0;
  4034. while ((length = inputStream.read(buf)) != -1) {
  4035. fileOutputStream.write(buf, 0, length);
  4036. fileOutputStream.flush();
  4037. }
  4038. inputStream.close();
  4039. fileOutputStream.close();
  4040. // Log.d(TAG, "initDataBase: length=" + databasePath.length());
  4041. eteinit("{\"fun\":\"timer\"}");
  4042. try {
  4043. getZhanData();
  4044. } catch (Exception e) {
  4045. e.printStackTrace();
  4046. }
  4047. }
  4048. @Override
  4049. public Drawable getDrawAble(int clusterNum) {
  4050. int radius = dp2px(getApplicationContext(), 60);
  4051. if (clusterNum == 1) {
  4052. Drawable bitmapDrawable = mBackDrawAbles.get(1);
  4053. if (bitmapDrawable == null) {
  4054. bitmapDrawable =
  4055. getApplication().getResources().getDrawable(
  4056. R.drawable.icon_sorange);
  4057. mBackDrawAbles.put(1, bitmapDrawable);
  4058. }
  4059. return bitmapDrawable;
  4060. } else if (clusterNum > 1 && clusterNum < 999) {
  4061. Drawable bitmapDrawable = mBackDrawAbles.get(2);
  4062. if (bitmapDrawable == null) {
  4063. bitmapDrawable =
  4064. getApplication().getResources().getDrawable(
  4065. R.drawable.icon_marker1_999);
  4066. mBackDrawAbles.put(2, bitmapDrawable);
  4067. // bitmapDrawable = new BitmapDrawable(null, drawCircle(radius,
  4068. // Color.argb(159, 210, 154, 6)));
  4069. // mBackDrawAbles.put(2, bitmapDrawable);
  4070. }
  4071. return bitmapDrawable;
  4072. } else if (clusterNum > 1000) {
  4073. Drawable bitmapDrawable = mBackDrawAbles.get(3);
  4074. if (bitmapDrawable == null) {
  4075. bitmapDrawable =
  4076. getApplication().getResources().getDrawable(
  4077. R.drawable.icon_marker1000);
  4078. // bitmapDrawable = new BitmapDrawable(null, drawCircle(radius,
  4079. // Color.argb(199, 217, 114, 0)));
  4080. mBackDrawAbles.put(3, bitmapDrawable);
  4081. }
  4082. return bitmapDrawable;
  4083. } else {
  4084. Drawable bitmapDrawable = mBackDrawAbles.get(4);
  4085. if (bitmapDrawable == null) {
  4086. bitmapDrawable =
  4087. getApplication().getResources().getDrawable(
  4088. R.drawable.icon_marker1_999);
  4089. // bitmapDrawable = new BitmapDrawable(null, drawCircle(radius,
  4090. // Color.argb(235, 215, 66, 2)));
  4091. mBackDrawAbles.put(4, bitmapDrawable);
  4092. }
  4093. return bitmapDrawable;
  4094. }
  4095. }
  4096. private Bitmap drawCircle(int radius, int color) {
  4097. Bitmap bitmap = BitmapFactory.decodeResource(MainApplication.context.getResources(), R.drawable.icon_newmarker4);
  4098. Bitmap bitmap1 = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), false);
  4099. // Bitmap bitmap = Bitmap.createBitmap(radius * 2, radius * 2,
  4100. // Bitmap.Config.ARGB_8888);
  4101. // Canvas canvas = new Canvas(bitmap1);
  4102. // Paint paint = new Paint();
  4103. // RectF rectF = new RectF(0, 0, radius * 2, radius * 2);
  4104. //// paint.setColor(color);
  4105. // canvas.drawArc(rectF, 0, 360, true, paint);
  4106. return bitmap1;
  4107. }
  4108. /**
  4109. * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
  4110. */
  4111. public int dp2px(Context context, float dpValue) {
  4112. final float scale = context.getResources().getDisplayMetrics().density;
  4113. return (int) (dpValue * scale + 0.5f);
  4114. }
  4115. @Override
  4116. public void onClick(Marker marker, List<ClusterItem> clusterItems) {
  4117. LatLngBounds.Builder builder = new LatLngBounds.Builder();
  4118. for (ClusterItem clusterItem : clusterItems) {
  4119. builder.include(clusterItem.getPosition());
  4120. }
  4121. //这里处理一下Marker的点击事件
  4122. if (clusterItems.size() == 1) {
  4123. MobclickAgent.onEvent(context, "0102");
  4124. Log.e(TAG, "onClick: !!" + "!!");
  4125. rl_control.setVisibility(View.GONE);
  4126. moveRefresh = false;
  4127. ClusterItem clusterItem = clusterItems.get(0);
  4128. markerPosition = clusterItem.getPosition();
  4129. RegionItem regionItem = (RegionItem) clusterItems.get(0);
  4130. zhan_list chargePoint = regionItem.getChargePoint();
  4131. String own_pay = chargePoint.getOwn_pay();
  4132. String supplier = chargePoint.getSupplier();
  4133. String suit_car = chargePoint.getSuit_car();
  4134. if (null != own_pay && own_pay.equals("1")) {
  4135. marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig1));
  4136. } else {
  4137. if (null != suit_car && suit_car.equals("特斯拉")) {
  4138. marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig3));
  4139. } else {
  4140. if (null != supplier && WelcomeActivity.canCost.contains(supplier)) {
  4141. marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig2));
  4142. } else {
  4143. marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig3));
  4144. }
  4145. }
  4146. }
  4147. // Log.e(TAG, "onClick: " + own_pay + "=====" + supplier);
  4148. if (nMarker != null && current_chargePoint.getId() != chargePoint.getId()) {
  4149. MarkerOptions markerOptionss = new MarkerOptions();
  4150. if (null != current_chargePoint.getOwn_pay() && current_chargePoint.getOwn_pay().equals("1")) {
  4151. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
  4152. } else {
  4153. if (null != current_chargePoint.getSuit_car() && current_chargePoint.getSuit_car().equals("特斯拉")) {
  4154. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  4155. } else {
  4156. if (null != current_chargePoint.getSupplier() && WelcomeActivity.canCost.contains(current_chargePoint.getSupplier())) {
  4157. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
  4158. } else {
  4159. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  4160. }
  4161. }
  4162. }
  4163. nMarker = aMap.addMarker(markerOptionss);
  4164. }
  4165. // Log.d(TAG, "onClick: latitude=" + position.latitude + " long=" + position.longitude + "\n" + ((RegionItem) clusterItem).getChargePoint().toString());
  4166. Long zhan_id = ((RegionItem) clusterItem).getChargePoint().getId();
  4167. nMarker = marker;
  4168. zhanInfo = null;
  4169. // add by hyg 显示气泡
  4170. nMarker.showInfoWindow();
  4171. current_chargePoint = chargePoint;
  4172. dialog.show();
  4173. if (null != marker.getPosition()) {
  4174. getSingleZhanInfo(String.valueOf(zhan_id), marker.getPosition());
  4175. }
  4176. } else {
  4177. LatLngBounds latLngBounds = builder.build();
  4178. aMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 0));
  4179. }
  4180. }
  4181. private void clickMarkAndMove(int adHeight) {
  4182. if (markerPosition == null) {
  4183. return;
  4184. }
  4185. float zoom = aMap.getCameraPosition().zoom;
  4186. int width = mapView.getMeasuredWidth();
  4187. int height = mapView.getMeasuredHeight();
  4188. if (height > 1122) {
  4189. Point point = aMap.getProjection().toScreenLocation(markerPosition);
  4190. int y = point.y - (height - 1122) - DensityUtil.dip2px(getApplicationContext(), adHeight);
  4191. aMap.moveCamera(CameraUpdateFactory.scrollBy(point.x - width / 2, y));
  4192. } else {
  4193. aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(markerPosition, zoom));
  4194. }
  4195. }
  4196. private void getSingleZhanInfo(String zhan_id, final LatLng ll) {
  4197. String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/zhan-info2?zhan_id=" + zhan_id + "&version=" + MainApplication.current_code;
  4198. // Log.e(TAG, "getSingleZhanInfo: url="+url );
  4199. OkHttpUtils.get().url(url).build().execute(new StringCallback() {
  4200. @Override
  4201. public void onError(Call call, Exception e) {
  4202. }
  4203. @Override
  4204. public void onResponse(String response) {
  4205. Log.e(TAG, "onResponse: " + response);
  4206. dialog.cancel();
  4207. String info = JsonUtils.getKeyResult(response, "info");
  4208. // String info = "JbCMZl5FRHmpKqIywO0ntFtBJfaZYHk7bQGy9WjREYixObR+49H+MAJTiHTKnvSQz73LDfLo4MQMAldzbOFyNkhapUrlWOF5Og7H8HmFX/0A1mLAIDGIXMepmpS45gYVdzn8xvGDh3JXdiNU1AAohz4R3WdpSIo5Pvt+RbsIqH+/Uuk3/mRrizGxZmWhQzzIpc9KMY/69vUAEaxTz8YQLgdbHWUE/wD1e79BiXKTRmrbqayVFd8tFDrM6pvovDE15wUomION2gKdHLCvA2Dg5loIiany/FVkB7tmQLu2SiiCgfHArwWqr/axUP9Vbu878PrJRxLYSW616iFSBFYJHVe1PIDTXA6g8mvxUnCCnfhUVoRJ5mn18hXo2EsTdqbLnp3UpOAXicoGWoP4ztXu/M2P0xA+MnPk7Wa4NunMhPVeKpmTsYXV2RzQaUQknwtEgSRvtTEX6HSUxPnrNESiQML5fLCNiWms2z5vp2GUSFYQTGKnCsqlw7HsAJCf0VBJAz6Ii46kr8NBtk3WwOfld5ZO/pIhTuS3Mg1HHlu9nR1Vqu6/UPJiu0zF1AfOUB1f1mSM3d1p2tsPSGKbugRIP7vWOQ57vgUYK3n3UUo51aCemgpy3eIxo9cCdtTEXU5O4A4FpyQEKP8uIiAp7dIUqvkCGfatTI/dJVJ70Sv5sCpXCfdYIRpiWVj63nt8p4KUnxF7x5KrMDiZY+ntQLXzufgIHa+pL6E/ToJ2lznXaMOaMSt0O2bWz++2qa2TvpOj7S9qsaJgtySs7Mwrk+Yg3UULyp8BkMK6lcRxBv4jz43pt84fPO4imm42SDr/H0X/88CmmyhzJtLExchpZQA1nqmTyWkfj9V0Z62s+9IAcw90bHm/J6x5vSY3K+N5chBR47VEt77tg6DKPTW2u9R+lDGEPluYvPjZ2i20qeDkUJ19U6vM+QnYF8Sa4AlzT3G9SJlqHGyXRyTn7WOLnvg6pSKSAsTp/lFAaeNHAvJtx1bSq+43vDlFbs6jXPQXcVvTZf6ALge/rLFItYA8muOwKj2DxFftshKFwkufxA/nTS19rJoDNvLtVbTfe6E3Za2ei7LCaWNV5UtrDJOSdEGzFKqroB59Ika0Ijdn1ZI2f54feYgnUYZHKDb8UUbGQlRWzwcYBv4PjDGVVKbSWUMkeDA0FB4t+X1Rfu28UnSJ2GShL8cotnm6vwD1Psy3NDAShfvCBVqSx6O6PqTic0KBQq2Ufjlx1OWKexE08qEWWUEyEvMOPkTx2t94zdxQZVCIfR1DIvHCklvBTh7zyfcLXQol/6AnoTBh6X+R8Hh1Ih8FLnlZfeB4bde8hHZbNS2GyQb8Hs4haZmeYyVdUYy3OuXIBFd1Ve5UzKv+AY1JipsKI/ha/h19Xozpvr86sQUYDhlpbKyYAVtrZhYvTFcKuj6Jl46KGkJMXv6GU1QpYvjxF8W156HfGv9uN35Q1bVVcHOXerM4e8DXqUvXTK6g5zMTPes0smYLlTn73CO1iuc4c2wDmEiTEk367qJf6VDefWPRZpkOsKZHxc06OTfw3tAuEK9X8mnVaVhb+6OHkPKtnD//5K/6VYYPcXaIoSAcFdkgcMkYe5vSKyw7TNfgSBSGNlxFrYPkhotshDoKt6FP/KTn9lFxQtl/BKG6if5wfp2hp7Ufn339wJh6SKd7ibtM38AS3HFHxvq7pC+wREAkhW4gyD8t7S3BZKsw+M50vhI3rmg9gebH4MJxC2iK5JDhPnHyw6fVz72pgluqD0cWpvy/3hFt+QxFfpbVnMhC6fvmspLpk/WZf3CKIb5T8TLoUOSMX7wBlTrl+oh6A0c/OdUpScoIv1dFGSN/7FXXnWLlMz4nkRcsN3ob6RT/QXqaE3cpo8HmR/6x9A+qNkMvVndDLBw3v/S4Fq6pr1DVsJpYAhwmgx461Z1pQTB+ORKDZOdiz+WAeHzNH5tD2Ers4VK8IWoK/FX1JABSC3Qxad3gUTAGc7Bpx4VZ8fdGzr6gfMeg8HT5WSeCkffepjLTQ0+Z4S+vjQ==";
  4209. Log.e(TAG, "onResponse: info=" + info);
  4210. String info_decode = "";
  4211. try {
  4212. info_decode = DES3S.decode(info);
  4213. } catch (Exception e) {
  4214. e.printStackTrace();
  4215. }
  4216. Log.e(TAG, "onResponse: info_decode=" + info_decode);
  4217. if (null != info_decode && !info_decode.equals("")) {
  4218. showInfoWindow(info_decode, ll);
  4219. }
  4220. }
  4221. });
  4222. }
  4223. private void showInfoWindow(String info, final LatLng ll) {
  4224. zhanInfo = info;
  4225. final String id = JsonUtils.getKeyResult(info, "id");
  4226. getCommentNum(id);
  4227. zhanGrade(id);
  4228. final String zhan_name = JsonUtils.getKeyResult(info, "zhan_name");
  4229. String stop_cost = JsonUtils.getKeyResult(info, "stop_cost");
  4230. String own_pay = JsonUtils.getKeyResult(info, "own_pay"); // 1:可支付
  4231. String charge_cost_way2 = JsonUtils.getKeyResult(info, "charge_cost_way2");
  4232. final String charge_cost_way = JsonUtils.getKeyResult(info, "charge_cost_way");
  4233. String other_cost = JsonUtils.getKeyResult(info, "other_cost");
  4234. String charge_cost = JsonUtils.getKeyResult(info, "charge_cost");
  4235. String total_num = JsonUtils.getKeyResult(info, "total_num");
  4236. String slow_num = JsonUtils.getKeyResult(info, "slow_num");
  4237. String fast_num = JsonUtils.getKeyResult(info, "fast_num");
  4238. String remind = JsonUtils.getKeyResult(info, "remind");
  4239. String charge_record_cnt = JsonUtils.getKeyResult(info, "charge_record_cnt");
  4240. String zongjia = JsonUtils.getKeyResult(info, "zongjia");
  4241. String belong_attribute = JsonUtils.getKeyResult(info, "belong_attribute");
  4242. String park_location = JsonUtils.getKeyResult(info, "park_location");
  4243. final String city = JsonUtils.getKeyResult(info, "city");
  4244. final String poi_jing = JsonUtils.getKeyResult(info, "poi_jing");
  4245. final String poi_wei = JsonUtils.getKeyResult(info, "poi_wei");
  4246. final String fenshi_is = JsonUtils.getKeyResult(info, "fenshi_is");
  4247. final String telephone = JsonUtils.getKeyResult(info, "telephone");
  4248. TextView fenshi_info_textview = findViewById(R.id.fenshi_info_textview);
  4249. fenshi_info_textview.setText("");
  4250. if ("1".equals(fenshi_is)) {
  4251. final String fenshi_info = JsonUtils.getKeyResult(info, "fenshi_info");
  4252. ArrayList<PileData.FenshiInfoBean> fenshiList = (ArrayList<PileData.FenshiInfoBean>) JsonUtils.parseToObjectList(fenshi_info, PileData.FenshiInfoBean.class);
  4253. if (fenshiList.size() == 1) {
  4254. fenshi_info_textview.setText("全天价格统一");
  4255. } else {
  4256. Calendar calendar = Calendar.getInstance();
  4257. int hours = calendar.get(Calendar.HOUR_OF_DAY);
  4258. int minutes = calendar.get(Calendar.MINUTE);
  4259. int totalMinutes = hours * 60 + minutes;
  4260. for (PileData.FenshiInfoBean bean : fenshiList) {
  4261. if (bean.getStartTotalMinutes() > totalMinutes) {
  4262. double service_free = 0;
  4263. double charge_free = 0;
  4264. try {
  4265. service_free = Double.valueOf(bean.getService_free());
  4266. charge_free = Double.valueOf(bean.getCharge_free());
  4267. } catch (Exception e) {
  4268. e.printStackTrace();
  4269. }
  4270. fenshi_info_textview.setText(String.format("%s开始 %.2f元/度", bean.getStart(), service_free + charge_free));
  4271. break;
  4272. }
  4273. }
  4274. }
  4275. } else {
  4276. double totalPrice = 0;
  4277. try {
  4278. totalPrice = Double.valueOf(zongjia);
  4279. } catch (Exception e) {
  4280. e.printStackTrace();
  4281. }
  4282. if (totalPrice != 0) {
  4283. fenshi_info_textview.setText("全天价格统一");
  4284. }
  4285. }
  4286. if (belong_attribute != null && belong_attribute.contains("私人")) {
  4287. private_telephone.setVisibility(View.VISIBLE);
  4288. private_telephone.setOnClickListener(new View.OnClickListener() {
  4289. @Override
  4290. public void onClick(View v) {
  4291. new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
  4292. .setMsg(zhan_name + " " + telephone)
  4293. .setPositiveButton("呼叫", new View.OnClickListener() {
  4294. @Override
  4295. public void onClick(View v) {
  4296. Intent intent = new Intent();
  4297. intent.setAction("android.intent.action.CALL");
  4298. intent.addCategory("android.intent.category.DEFAULT");
  4299. intent.setData(Uri.parse("tel:" + telephone));
  4300. startActivity(intent);
  4301. }
  4302. }).setNegativeButton("取消", new View.OnClickListener() {
  4303. @Override
  4304. public void onClick(View v) {
  4305. }
  4306. }).show();
  4307. }
  4308. });
  4309. } else {
  4310. private_telephone.setVisibility(View.GONE);
  4311. }
  4312. // remind 0 正常 2 休息中 other 故障
  4313. // own_pay 1 可支付
  4314. // 显示顺序 故障>可支付>休息中
  4315. if (remind.equals("0")) {
  4316. if ("1".equals(own_pay)) {
  4317. iv_guzhang.setVisibility(View.VISIBLE);
  4318. iv_guzhang.setImageResource(R.drawable.icon_is_cost);
  4319. } else {
  4320. iv_guzhang.setVisibility(View.GONE);
  4321. }
  4322. } else if (remind.equals("2")) {
  4323. iv_guzhang.setVisibility(View.VISIBLE);
  4324. iv_guzhang.setImageResource(R.drawable.icon_rest);
  4325. } else {
  4326. iv_guzhang.setVisibility(View.VISIBLE);
  4327. iv_guzhang.setImageResource(R.drawable.icon_guzhang_window);
  4328. }
  4329. windowName.setText(zhan_name);
  4330. if (stop_cost != null && !stop_cost.equals("")) {
  4331. stopCost.setVisibility(View.VISIBLE);
  4332. stopCost.setText("停车费:" + stop_cost);
  4333. } else {
  4334. stopCost.setVisibility(View.GONE);
  4335. }
  4336. if (center != null) {
  4337. String wei = poi_wei;
  4338. String jing = poi_jing;
  4339. int position_jing = jing.length() - jing.indexOf(".") - 1;
  4340. int position_wei = wei.length() - wei.indexOf(".") - 1;
  4341. LatLng latLng;
  4342. if (position_jing > 13 || position_wei > 13) {
  4343. latLng = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
  4344. } else {
  4345. double dwei = Double.parseDouble(wei);
  4346. double djing = Double.parseDouble(jing);
  4347. getGaode(djing, dwei);
  4348. latLng = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
  4349. }
  4350. // OK
  4351. double d = AMapUtils.calculateLineDistance(center, latLng);
  4352. if ("0m".equals(Util.getDistance(d))) {
  4353. // windowDistance.setText("未知");
  4354. updateInfoWindow("未知距离");
  4355. } else {
  4356. String text = Util.getDistance(d);
  4357. // windowDistance.setText(text);
  4358. updateInfoWindow("距您 " + text);
  4359. }
  4360. }
  4361. if (charge_record_cnt != null) {
  4362. int count = Integer.parseInt(charge_record_cnt);
  4363. // 成功充电次数
  4364. if (count == 0) {
  4365. windowChargeRecordCnt.setText("");
  4366. windowChargeRecordCntLine.setVisibility(View.GONE);
  4367. } else {
  4368. windowChargeRecordCntLine.setVisibility(View.VISIBLE);
  4369. if (count < 1000) {
  4370. windowChargeRecordCnt.setText(count + "次充电");
  4371. } else if (count < 10000) {
  4372. windowChargeRecordCnt.setText(count / 1000 + "k+次充电");
  4373. } else {
  4374. windowChargeRecordCnt.setText(count / 10000 + "w+次充电");
  4375. }
  4376. }
  4377. } else {
  4378. windowChargeRecordCnt.setText("");
  4379. windowChargeRecordCntLine.setVisibility(View.GONE);
  4380. }
  4381. if (zongjia != null) {
  4382. double zongjiaValue = Double.parseDouble(zongjia);
  4383. if (zongjiaValue == 0) {
  4384. windowZongjiaLayout.setVisibility(View.GONE);
  4385. } else {
  4386. windowZongjiaLayout.setVisibility(View.VISIBLE);
  4387. windowZongjia.setText(String.format("%.2f", zongjiaValue));
  4388. }
  4389. } else {
  4390. windowZongjiaLayout.setVisibility(View.GONE);
  4391. }
  4392. // 气泡红包显示
  4393. windowRedPaperBag.setVisibility("1".equals(own_pay) ? View.VISIBLE : View.GONE);
  4394. windowLabelPublic.setText(belong_attribute);
  4395. windowLabelGround.setText("0".equals(park_location) ? "地下" : "地上");
  4396. windowLabelFreePark.setVisibility(stop_cost.contains("免费") ? View.VISIBLE : View.GONE);
  4397. String acNum = null, dcNum = null, acableNum = null, dcableNum = null;
  4398. if (null != JsonUtils.getKeyResult(info, "acNum")) {
  4399. acNum = JsonUtils.getKeyResult(info, "acNum");
  4400. dcNum = JsonUtils.getKeyResult(info, "dcNum");
  4401. acableNum = JsonUtils.getKeyResult(info, "acableNum");
  4402. dcableNum = JsonUtils.getKeyResult(info, "dcableNum");
  4403. // Log.e("dcableNum", dcableNum);
  4404. }
  4405. if (null != acableNum && null != acNum
  4406. && null != dcableNum && null != dcNum) { // 有桩状态
  4407. window_tv_fast_free_num.setText(dcableNum); // 快充空闲桩数量
  4408. window_tv_fast_total_num.setText("/" + dcNum); // 快充桩总数
  4409. window_tv_fast_free_label.setVisibility(View.VISIBLE);
  4410. window_tv_fast_total_num.setVisibility(View.VISIBLE);
  4411. window_tv_slow_free_num.setText(acableNum); // 慢充空闲桩数量
  4412. window_tv_slow_total_num.setText("/" + acNum);
  4413. window_tv_slow_free_label.setVisibility(View.VISIBLE);
  4414. window_tv_slow_total_num.setVisibility(View.VISIBLE);
  4415. } else { // 没有桩状态
  4416. if (fast_num.equals("")) {
  4417. window_tv_fast_free_num.setText("0");
  4418. } else {
  4419. window_tv_fast_free_num.setText(fast_num);
  4420. }
  4421. window_tv_fast_free_label.setVisibility(View.GONE);
  4422. window_tv_fast_total_num.setVisibility(View.GONE);
  4423. if (slow_num.equals("")) {
  4424. window_tv_slow_free_num.setText("0");
  4425. } else {
  4426. window_tv_slow_free_num.setText(slow_num);
  4427. }
  4428. window_tv_slow_free_label.setVisibility(View.GONE);
  4429. window_tv_slow_total_num.setVisibility(View.GONE);
  4430. }
  4431. //OK
  4432. if (own_pay.equals("1")) {
  4433. windowCost.setText("可使用本APP扫码支付");
  4434. } else {
  4435. if (charge_cost_way2.equals("")) {
  4436. windowCost.setText("暂无");
  4437. } else {
  4438. windowCost.setText(charge_cost_way2);
  4439. }
  4440. }
  4441. windowZhanDetails.setOnClickListener(new View.OnClickListener() {
  4442. @Override
  4443. public void onClick(View v) {
  4444. Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
  4445. intent.putExtra("zhan_id", id);
  4446. intent.putExtra("poi_jing", poi_jing);
  4447. intent.putExtra("poi_wei", poi_wei);
  4448. startActivity(intent);
  4449. MainMapActivity.isR = true;
  4450. HashMap<String, String> map = new HashMap<String, String>();
  4451. map.put("type", "详情");
  4452. MobclickAgent.onEvent(context, "0102", map);
  4453. map.clear();
  4454. }
  4455. });
  4456. windowLayout.setOnTouchListener(new View.OnTouchListener() {
  4457. @Override
  4458. public boolean onTouch(View view, MotionEvent motionEvent) {
  4459. switch (motionEvent.getAction()) {
  4460. case MotionEvent.ACTION_DOWN:
  4461. mPosX = motionEvent.getX();
  4462. mPosY = motionEvent.getY();
  4463. mCurPosX = 0;
  4464. mCurPosY = 0;
  4465. break;
  4466. case MotionEvent.ACTION_MOVE:
  4467. mCurPosX = motionEvent.getX();
  4468. mCurPosY = motionEvent.getY();
  4469. break;
  4470. case MotionEvent.ACTION_UP:
  4471. if (mCurPosY != 0 && mCurPosY > mPosY && Math.abs(mCurPosY - mPosY) > 25) { // 向下滑动
  4472. // 取消气泡选中状态
  4473. if (nMarker != null) {
  4474. nMarker.hideInfoWindow();
  4475. if (current_chargePoint.getOwn_pay().equals("1")) {
  4476. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
  4477. } else {
  4478. if (current_chargePoint.getSuit_car().equals("特斯拉")) {
  4479. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  4480. } else {
  4481. if (WelcomeActivity.canCost.contains(current_chargePoint.getSupplier())) {
  4482. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
  4483. } else {
  4484. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  4485. }
  4486. }
  4487. }
  4488. }
  4489. // 隐藏气泡弹窗视图
  4490. Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out);
  4491. animation.setDuration(500);
  4492. windowLayout.startAnimation(animation);
  4493. new Handler().postDelayed(new Runnable() {
  4494. @Override
  4495. public void run() {
  4496. windowLayout.setVisibility(View.GONE);
  4497. rl_control.setVisibility(View.VISIBLE);
  4498. }
  4499. }, 500);
  4500. } else if (mCurPosY != 0 && mCurPosY < mPosY && Math.abs(mCurPosY - mPosY) > 25) { // 向上活动
  4501. System.out.println("up");
  4502. } else if (mCurPosX != 0 && mCurPosX > mPosX && Math.abs(mCurPosX - mPosX) > 25) { // 向右滑动
  4503. System.out.println("right");
  4504. } else if (mCurPosX != 0 && mCurPosX < mPosX && Math.abs(mCurPosX - mPosX) > 25) { // 向左滑动
  4505. System.out.println("left");
  4506. } else { // 点击事件
  4507. Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
  4508. intent.putExtra("zhan_id", id);
  4509. intent.putExtra("poi_jing", poi_jing);
  4510. intent.putExtra("poi_wei", poi_wei);
  4511. startActivity(intent);
  4512. MainMapActivity.isR = true;
  4513. HashMap<String, String> map = new HashMap<String, String>();
  4514. map.put("type", "详情");
  4515. MobclickAgent.onEvent(context, "0102", map);
  4516. map.clear();
  4517. }
  4518. break;
  4519. }
  4520. return true;
  4521. }
  4522. });
  4523. windowComments.setOnClickListener(new View.OnClickListener() {
  4524. @Override
  4525. public void onClick(View v) {
  4526. Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
  4527. intent.putExtra("zhan_id", id);
  4528. intent.putExtra("poi_jing", poi_jing);
  4529. intent.putExtra("poi_wei", poi_wei);
  4530. MainApplication.details_flag = "3";
  4531. startActivity(intent);
  4532. HashMap<String, String> map = new HashMap<String, String>();
  4533. map.put("type", "评论");
  4534. MobclickAgent.onEvent(context, "0102", map);
  4535. map.clear();
  4536. }
  4537. });
  4538. //站点广告
  4539. // Log.e(TAG, "showInfoWindow: MainApplication.list_addetail="+MainApplication.list_addetail.size() );
  4540. if (MainApplication.list_addetail != null) {
  4541. Random random = new Random();
  4542. final int result = random.nextInt(MainApplication.list_addetail.size());
  4543. Picasso.with(MainApplication.context)
  4544. .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + MainApplication.list_addetail.get(result).getImg())
  4545. .into(windowAd);
  4546. windowAd.setVisibility(View.VISIBLE);
  4547. clickMarkAndMove(0);
  4548. windowAd.setOnClickListener(new View.OnClickListener() {
  4549. @Override
  4550. public void onClick(View v) {
  4551. MobclickAgent.onEvent(context, "0052");
  4552. if (MainApplication.list_addetail.get(result).getIs_dui().equals("1")) {
  4553. long appTime11 = System.currentTimeMillis() / 1000;
  4554. long updatetime1 = appTime11 - MainMapActivity.cha - 5;
  4555. String token1 = String.valueOf(updatetime1);
  4556. String encode_token = null;
  4557. try {
  4558. encode_token = DES3.encode(token1);
  4559. } catch (Exception e) {
  4560. e.printStackTrace();
  4561. }
  4562. String replace = URLEncoder.encode(encode_token);
  4563. Intent intent11 = new Intent();
  4564. intent11.setClass(getApplicationContext(), CreditActivity.class);
  4565. intent11.putExtra("navColor", "#fcfcfc"); //配置导航条的背景颜色,请用#ffffff长格式。
  4566. intent11.putExtra("titleColor", "#222222"); //配置导航条标题的颜色,请用#ffffff长格式。
  4567. MainApplication.goods_type = "details";
  4568. MainApplication.current_url = MainApplication.list_addetail.get(result).getUrl();
  4569. // MainApplication.current_url = "http://www.duiba.com.cn/mobile/appItemDetail?appItemId=453087";
  4570. if (!MainApplication.isLogin()) {
  4571. intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.current_url); //配置自动登陆地址,每次需服务端动态生成。
  4572. } else {
  4573. intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace + "&url=" + MainApplication.current_url); //配置自动登陆地址,每次需服务端动态生成。
  4574. }
  4575. startActivity(intent11);
  4576. overridePendingTransition(0, 0);
  4577. CreditActivity.creditsListener = new CreditActivity.CreditsListener() {
  4578. /**
  4579. * 当点击分享按钮被点击
  4580. * @param shareUrl 分享的地址
  4581. * @param shareThumbnail 分享的缩略图
  4582. * @param shareTitle 分享的标题
  4583. * @param shareSubtitle 分享的副标题
  4584. */
  4585. public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
  4586. //当分享按钮被点击时,会调用此处代码。在这里处理分享的业务逻辑。
  4587. ChargingShareBean chargingShareBean = new ChargingShareBean();
  4588. chargingShareBean.setIcon(shareThumbnail);
  4589. chargingShareBean.setTitle(shareTitle);
  4590. chargingShareBean.setUrl(shareUrl);
  4591. chargingShareBean.setText("");
  4592. showSimpleBottomSheetGrid(chargingShareBean);
  4593. }
  4594. /**
  4595. * 当点击“请先登录”按钮唤起登录时,会调用此处代码。
  4596. * 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
  4597. * @param webView 用于登录成功后返回到当前的webview刷新登录状态。
  4598. * @param currentUrl 当前页面的url
  4599. */
  4600. public void onLoginClick(WebView webView, final String currentUrl) {
  4601. //当未登录的用户点击去登录时,会调用此处代码。
  4602. //用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
  4603. //为了用户登录后能回到未登录前的页面(currentUrl)。
  4604. //当用户登录成功后,需要重新请求一次服务端,带上currentUrl。
  4605. //用该方法中的webview变量加载请求链接。
  4606. //服务端收到请求后在生成免登录url时,将currentUrl放入redirect参数,通知客户端302跳转到新生成的免登录URL。
  4607. new android.app.AlertDialog.Builder(webView.getContext())
  4608. .setTitle("跳转登录")
  4609. .setMessage("跳转到登录页面?")
  4610. .setPositiveButton("是", new DialogInterface.OnClickListener() {
  4611. @Override
  4612. public void onClick(DialogInterface dialog, int which) {
  4613. // MainApplication.current_url = currentUrl;
  4614. MainApplication.current_url = currentUrl;
  4615. context.startActivity(new Intent(getApplicationContext(), LoginActivity.class));
  4616. }
  4617. })
  4618. .setNegativeButton("否", null)
  4619. .show();
  4620. }
  4621. /**
  4622. * 当点击“复制”按钮时,触发该方法,回调获取到券码code
  4623. * @param webView webview对象。
  4624. * @param code 复制的券码
  4625. */
  4626. public void onCopyCode(WebView webView, String code) {
  4627. //当未登录的用户点击去登录时,会调用此处代码。
  4628. new android.app.AlertDialog.Builder(webView.getContext())
  4629. .setTitle("复制券码")
  4630. .setMessage("已复制,券码为:" + code)
  4631. .setPositiveButton("是", null)
  4632. .setNegativeButton("否", null)
  4633. .show();
  4634. }
  4635. /**
  4636. * 积分商城返回首页刷新积分时,触发该方法。
  4637. */
  4638. public void onLocalRefresh(WebView mWebView, String credits) {
  4639. //String credits为积分商城返回的最新积分,不保证准确。
  4640. //触发更新本地积分,这里建议用ajax向自己服务器请求积分值,比较准确。
  4641. // Toast.makeText(getApplicationContext(), "触发本地刷新积分:" + credits, Toast.LENGTH_SHORT).show();
  4642. }
  4643. };
  4644. } else {
  4645. Intent intent145 = new Intent(getApplication(), MyWebViewActivity.class);
  4646. String url = MainApplication.list_addetail.get(result).getUrl();
  4647. if (EmptyUtils.isNotEmpty(url)) {
  4648. if (url.contains("?")) {
  4649. url = MainApplication.list_addetail.get(result).getUrl() + "&cdzshareid=" + MainApplication.list_addetail.get(result).getId();
  4650. } else {
  4651. url = MainApplication.list_addetail.get(result).getUrl() + "?cdzshareid=" + MainApplication.list_addetail.get(result).getId();
  4652. }
  4653. // url = "http://192.168.1.104:8000/";
  4654. // url = "https://www.d1ev.com/special/t/application.html?s=JUU1JUE1JTg3JUU3JTkxJTlFJUU1JUIwJThGJUU4JTlBJTgyJUU4JTlBJTgxLCVFNiVBQyVBNyVFNiU4QiU4OVIxLCVFNSU4QyU5NyVFNiVCMSVCREVDMw==";
  4655. // intent_text,intent_icon,intent_title,intent_url;
  4656. intent145.putExtra("url", url);
  4657. // intent145.putExtra("tag", "8");
  4658. // intent145.putExtra("intent_text", MainApplication.list_addetail.get(result).getContent());
  4659. // intent145.putExtra("intent_icon", MainApplication.list_addetail.get(result).getIcon());
  4660. // intent145.putExtra("intent_title", MainApplication.list_addetail.get(result).getTitle());
  4661. // intent145.putExtra("intent_url", MainApplication.list_addetail.get(result).getUrl());
  4662. startActivity(intent145);
  4663. }
  4664. }
  4665. }
  4666. });
  4667. } else {
  4668. windowAd.setVisibility(View.GONE);
  4669. clickMarkAndMove(65);
  4670. }
  4671. //站点导航
  4672. final String finalRemind = remind;
  4673. windowGo.setOnClickListener(new View.OnClickListener() {
  4674. @Override
  4675. public void onClick(View v) {
  4676. infoViewNavigate();
  4677. }
  4678. });
  4679. Animation animation = AnimationUtils.loadAnimation(this, R.anim.in);
  4680. animation.setDuration(500);
  4681. windowLayout.startAnimation(animation);
  4682. windowLayout.setVisibility(View.VISIBLE);
  4683. SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
  4684. boolean showedExampleActivity = sharedPreferencesUtil.hasKey("cdz_showed_example_activity");
  4685. if (!showedExampleActivity) {
  4686. Intent pIntent = new Intent(getApplicationContext(), ExampleActivity.class);
  4687. pIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  4688. startActivity(pIntent);
  4689. overridePendingTransition(0, 0);
  4690. }
  4691. }
  4692. /**
  4693. * 点击气泡进行导航
  4694. * add by hyg
  4695. */
  4696. private void infoViewNavigate() {
  4697. if (zhanInfo == null) {
  4698. return;
  4699. }
  4700. if (nMarker == null) {
  4701. return;
  4702. }
  4703. final LatLng ll = nMarker.getPosition();
  4704. final String id = JsonUtils.getKeyResult(zhanInfo, "id");
  4705. final String zhan_name = JsonUtils.getKeyResult(zhanInfo, "zhan_name");
  4706. String stop_cost = JsonUtils.getKeyResult(zhanInfo, "stop_cost");
  4707. String own_pay = JsonUtils.getKeyResult(zhanInfo, "own_pay");
  4708. String charge_cost_way2 = JsonUtils.getKeyResult(zhanInfo, "charge_cost_way2");
  4709. final String charge_cost_way = JsonUtils.getKeyResult(zhanInfo, "charge_cost_way");
  4710. String other_cost = JsonUtils.getKeyResult(zhanInfo, "other_cost");
  4711. String charge_cost = JsonUtils.getKeyResult(zhanInfo, "charge_cost");
  4712. String total_num = JsonUtils.getKeyResult(zhanInfo, "total_num");
  4713. String slow_num = JsonUtils.getKeyResult(zhanInfo, "slow_num");
  4714. String fast_num = JsonUtils.getKeyResult(zhanInfo, "fast_num");
  4715. String remind = JsonUtils.getKeyResult(zhanInfo, "remind"); // remind 0 正常 2 休息中 other 故障
  4716. final String city = JsonUtils.getKeyResult(zhanInfo, "city");
  4717. final String poi_jing = JsonUtils.getKeyResult(zhanInfo, "poi_jing");
  4718. final String poi_wei = JsonUtils.getKeyResult(zhanInfo, "poi_wei");
  4719. String belongAttribute = JsonUtils.getKeyResult(zhanInfo, "belong_attribute");
  4720. HashMap<String, String> mapp = new HashMap<String, String>();
  4721. mapp.put("type", "导航");
  4722. MobclickAgent.onEvent(context, "0102", mapp);
  4723. mapp.clear();
  4724. if (remind.equals("0")) { // 正常显示导航
  4725. if (belongAttribute.contains("私人")) {
  4726. new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
  4727. .setMsg("该站为私人站点,建议\n先联系桩主后再前往")
  4728. .setPositiveButton("继续", new View.OnClickListener() {
  4729. @Override
  4730. public void onClick(View v) {
  4731. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") && !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  4732. if (null == center) {
  4733. ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT);
  4734. } else {
  4735. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  4736. intent.putExtra("start_jing", center.longitude + "");
  4737. intent.putExtra("start_wei", center.latitude + "");
  4738. intent.putExtra("stop_jing", ll.longitude + "");
  4739. intent.putExtra("stop_wei", ll.latitude + "");
  4740. startActivity(intent);
  4741. detailsBack = true;
  4742. HashMap<String, String> map = new HashMap<String, String>();
  4743. map.put("Name", zhan_name);
  4744. map.put("CostWay", charge_cost_way);
  4745. map.put("City", city);
  4746. MobclickAgent.onEvent(context, "0033", map);
  4747. map.clear();
  4748. }
  4749. } else {
  4750. if (center != null) {
  4751. LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  4752. popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
  4753. popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, true);
  4754. popupWindow.setBackgroundDrawable(new BitmapDrawable());
  4755. // 设置PopupWindow的弹出和消失效果
  4756. popupWindow.setAnimationStyle(R.style.popupAnimation);
  4757. LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
  4758. if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  4759. ll_tvTwo.setVisibility(View.GONE);
  4760. }
  4761. LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
  4762. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
  4763. ll_tvOne.setVisibility(View.GONE);
  4764. }
  4765. cancleButton = (Button) popupWindowView.findViewById(R.id.cancleButton);
  4766. cancleButton.setOnClickListener(new View.OnClickListener() {
  4767. @Override
  4768. public void onClick(View view) {
  4769. popupWindow.dismiss();
  4770. }
  4771. });
  4772. tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
  4773. tvThree.setOnClickListener(new View.OnClickListener() {
  4774. @Override
  4775. public void onClick(View v) {
  4776. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  4777. intent.putExtra("start_jing", center.longitude + "");
  4778. intent.putExtra("start_wei", center.latitude + "");
  4779. intent.putExtra("stop_jing", ll.longitude + "");
  4780. intent.putExtra("stop_wei", ll.latitude + "");
  4781. startActivity(intent);
  4782. detailsBack = true;
  4783. popupWindow.dismiss();
  4784. HashMap<String, String> map = new HashMap<String, String>();
  4785. map.put("Name", zhan_name);
  4786. map.put("CostWay", charge_cost_way);
  4787. map.put("City", city);
  4788. MobclickAgent.onEvent(context, "0033", map);
  4789. map.clear();
  4790. }
  4791. });
  4792. tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
  4793. tvOne.setOnClickListener(new View.OnClickListener() {
  4794. @Override
  4795. public void onClick(View view) {
  4796. Intent intent = null;
  4797. int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1;
  4798. int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1;
  4799. if (position_jing > 13 || position_wei > 13) {
  4800. getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei));
  4801. } else {
  4802. bd_jing = Double.parseDouble(poi_jing);
  4803. bd_wei = Double.parseDouble(poi_wei);
  4804. }
  4805. getBaidu(center.longitude, center.latitude);
  4806. try {
  4807. String s = "intent://map/direction?" + "origin=" + bd_lat + "," + bd_lon + "&" + "destination=" + bd_wei + "," + bd_jing + "&mode=driving&" + "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
  4808. intent = Intent.getIntent(s);
  4809. detailsBack = true;
  4810. HashMap<String, String> map = new HashMap<String, String>();
  4811. map.put("Name", zhan_name);
  4812. map.put("CostWay", charge_cost_way);
  4813. map.put("City", city);
  4814. MobclickAgent.onEvent(context, "0031", map);
  4815. map.clear();
  4816. } catch (URISyntaxException e) {
  4817. e.printStackTrace();
  4818. }
  4819. startActivity(intent);
  4820. popupWindow.dismiss();
  4821. }
  4822. });
  4823. tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
  4824. tvTwo.setOnClickListener(new View.OnClickListener() {
  4825. @Override
  4826. public void onClick(View view) {
  4827. try {
  4828. Intent intent4 = new Intent("android.intent.action.VIEW", android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + ll.latitude + "&dlon=" + ll.longitude + "&dname=" + zhan_name + "&dev=0&m=0&t=2"));
  4829. intent4.setPackage("com.autonavi.minimap");
  4830. startActivity(intent4);
  4831. detailsBack = true;
  4832. popupWindow.dismiss();
  4833. HashMap<String, String> map = new HashMap<String, String>();
  4834. map.put("Name", zhan_name);
  4835. map.put("CostWay", charge_cost_way);
  4836. map.put("City", city);
  4837. MobclickAgent.onEvent(context, "0032", map);
  4838. map.clear();
  4839. } catch (Exception e) {
  4840. e.printStackTrace();
  4841. Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
  4842. }
  4843. }
  4844. });
  4845. popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
  4846. } else {
  4847. Toast.makeText(getApplication(), "没有定位到您的当前位置", Toast.LENGTH_SHORT).show();
  4848. }
  4849. }
  4850. }
  4851. }).setNegativeButton("取消", new View.OnClickListener() {
  4852. @Override
  4853. public void onClick(View v) {
  4854. }
  4855. }).show();
  4856. } else {
  4857. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") && !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  4858. if (null == center) {
  4859. ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT);
  4860. } else {
  4861. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  4862. intent.putExtra("start_jing", center.longitude + "");
  4863. intent.putExtra("start_wei", center.latitude + "");
  4864. intent.putExtra("stop_jing", ll.longitude + "");
  4865. intent.putExtra("stop_wei", ll.latitude + "");
  4866. startActivity(intent);
  4867. detailsBack = true;
  4868. HashMap<String, String> map = new HashMap<String, String>();
  4869. map.put("Name", zhan_name);
  4870. map.put("CostWay", charge_cost_way);
  4871. map.put("City", city);
  4872. MobclickAgent.onEvent(context, "0033", map);
  4873. map.clear();
  4874. }
  4875. } else {
  4876. if (center != null) {
  4877. LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  4878. popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
  4879. popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, true);
  4880. popupWindow.setBackgroundDrawable(new BitmapDrawable());
  4881. // 设置PopupWindow的弹出和消失效果
  4882. popupWindow.setAnimationStyle(R.style.popupAnimation);
  4883. LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
  4884. if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  4885. ll_tvTwo.setVisibility(View.GONE);
  4886. }
  4887. LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
  4888. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
  4889. ll_tvOne.setVisibility(View.GONE);
  4890. }
  4891. cancleButton = (Button) popupWindowView.findViewById(R.id.cancleButton);
  4892. cancleButton.setOnClickListener(new View.OnClickListener() {
  4893. @Override
  4894. public void onClick(View view) {
  4895. popupWindow.dismiss();
  4896. }
  4897. });
  4898. tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
  4899. tvThree.setOnClickListener(new View.OnClickListener() {
  4900. @Override
  4901. public void onClick(View v) {
  4902. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  4903. intent.putExtra("start_jing", center.longitude + "");
  4904. intent.putExtra("start_wei", center.latitude + "");
  4905. intent.putExtra("stop_jing", ll.longitude + "");
  4906. intent.putExtra("stop_wei", ll.latitude + "");
  4907. startActivity(intent);
  4908. detailsBack = true;
  4909. popupWindow.dismiss();
  4910. HashMap<String, String> map = new HashMap<String, String>();
  4911. map.put("Name", zhan_name);
  4912. map.put("CostWay", charge_cost_way);
  4913. map.put("City", city);
  4914. MobclickAgent.onEvent(context, "0033", map);
  4915. map.clear();
  4916. }
  4917. });
  4918. tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
  4919. tvOne.setOnClickListener(new View.OnClickListener() {
  4920. @Override
  4921. public void onClick(View view) {
  4922. Intent intent = null;
  4923. int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1;
  4924. int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1;
  4925. if (position_jing > 13 || position_wei > 13) {
  4926. getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei));
  4927. } else {
  4928. bd_jing = Double.parseDouble(poi_jing);
  4929. bd_wei = Double.parseDouble(poi_wei);
  4930. }
  4931. getBaidu(center.longitude, center.latitude);
  4932. try {
  4933. String s = "intent://map/direction?" + "origin=" + bd_lat + "," + bd_lon + "&" + "destination=" + bd_wei + "," + bd_jing + "&mode=driving&" + "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
  4934. intent = Intent.getIntent(s);
  4935. detailsBack = true;
  4936. HashMap<String, String> map = new HashMap<String, String>();
  4937. map.put("Name", zhan_name);
  4938. map.put("CostWay", charge_cost_way);
  4939. map.put("City", city);
  4940. MobclickAgent.onEvent(context, "0031", map);
  4941. map.clear();
  4942. } catch (URISyntaxException e) {
  4943. e.printStackTrace();
  4944. }
  4945. startActivity(intent);
  4946. popupWindow.dismiss();
  4947. }
  4948. });
  4949. tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
  4950. tvTwo.setOnClickListener(new View.OnClickListener() {
  4951. @Override
  4952. public void onClick(View view) {
  4953. try {
  4954. Intent intent4 = new Intent("android.intent.action.VIEW", android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + ll.latitude + "&dlon=" + ll.longitude + "&dname=" + zhan_name + "&dev=0&m=0&t=2"));
  4955. intent4.setPackage("com.autonavi.minimap");
  4956. startActivity(intent4);
  4957. detailsBack = true;
  4958. popupWindow.dismiss();
  4959. HashMap<String, String> map = new HashMap<String, String>();
  4960. map.put("Name", zhan_name);
  4961. map.put("CostWay", charge_cost_way);
  4962. map.put("City", city);
  4963. MobclickAgent.onEvent(context, "0032", map);
  4964. map.clear();
  4965. } catch (Exception e) {
  4966. e.printStackTrace();
  4967. Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
  4968. }
  4969. }
  4970. });
  4971. popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
  4972. } else {
  4973. Toast.makeText(getApplication(), "没有定位到您的当前位置", Toast.LENGTH_SHORT).show();
  4974. }
  4975. }
  4976. }
  4977. } else if (remind.equals("2")) {
  4978. new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
  4979. .setTitle("暂时未营业")
  4980. .setMsg("该站点当前不在营业时间\n" + "可能无法正常充电,是否继续前往")
  4981. .setPositiveButton("继续", new View.OnClickListener() {
  4982. @Override
  4983. public void onClick(View v) {
  4984. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
  4985. !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  4986. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  4987. intent.putExtra("start_jing", center.longitude + "");
  4988. intent.putExtra("start_wei", center.latitude + "");
  4989. intent.putExtra("stop_jing", ll.longitude + "");
  4990. intent.putExtra("stop_wei", ll.latitude + "");
  4991. startActivity(intent);
  4992. detailsBack = true;
  4993. HashMap<String, String> map = new HashMap<String, String>();
  4994. map.put("Name", zhan_name);
  4995. map.put("CostWay", charge_cost_way);
  4996. map.put("City", city);
  4997. MobclickAgent.onEvent(context, "0033", map);
  4998. map.clear();
  4999. } else {
  5000. if (center != null) {
  5001. LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  5002. popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
  5003. popupWindow = new PopupWindow(popupWindowView,
  5004. ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
  5005. true);
  5006. popupWindow.setBackgroundDrawable(new BitmapDrawable());
  5007. // 设置PopupWindow的弹出和消失效果
  5008. popupWindow.setAnimationStyle(R.style.popupAnimation);
  5009. LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
  5010. if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  5011. ll_tvTwo.setVisibility(View.GONE);
  5012. }
  5013. LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
  5014. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
  5015. ll_tvOne.setVisibility(View.GONE);
  5016. }
  5017. cancleButton = (Button) popupWindowView
  5018. .findViewById(R.id.cancleButton);
  5019. cancleButton.setOnClickListener(new View.OnClickListener() {
  5020. @Override
  5021. public void onClick(View view) {
  5022. popupWindow.dismiss();
  5023. }
  5024. });
  5025. tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
  5026. tvThree.setOnClickListener(new View.OnClickListener() {
  5027. @Override
  5028. public void onClick(View v) {
  5029. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  5030. intent.putExtra("start_jing", center.longitude + "");
  5031. intent.putExtra("start_wei", center.latitude + "");
  5032. intent.putExtra("stop_jing", ll.longitude + "");
  5033. intent.putExtra("stop_wei", ll.latitude + "");
  5034. startActivity(intent);
  5035. detailsBack = true;
  5036. popupWindow.dismiss();
  5037. HashMap<String, String> map = new HashMap<String, String>();
  5038. map.put("Name", zhan_name);
  5039. map.put("CostWay", charge_cost_way);
  5040. map.put("City", city);
  5041. MobclickAgent.onEvent(context, "0033", map);
  5042. map.clear();
  5043. }
  5044. });
  5045. tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
  5046. tvOne.setOnClickListener(new View.OnClickListener() {
  5047. @Override
  5048. public void onClick(View view) {
  5049. Intent intent = null;
  5050. int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1;
  5051. int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1;
  5052. if (position_jing > 13 || position_wei > 13) {
  5053. getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei));
  5054. } else {
  5055. bd_jing = Double.parseDouble(poi_jing);
  5056. bd_wei = Double.parseDouble(poi_wei);
  5057. }
  5058. getBaidu(center.longitude, center.latitude);
  5059. try {
  5060. String s = "intent://map/direction?" + "origin=" + bd_lat + "," + bd_lon + "&" + "destination=" + bd_wei + "," + bd_jing + "&mode=driving&" + "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
  5061. intent = Intent.getIntent(s);
  5062. detailsBack = true;
  5063. HashMap<String, String> map = new HashMap<String, String>();
  5064. map.put("Name", zhan_name);
  5065. map.put("CostWay", charge_cost_way);
  5066. map.put("City", city);
  5067. MobclickAgent.onEvent(context, "0031", map);
  5068. map.clear();
  5069. } catch (URISyntaxException e) {
  5070. e.printStackTrace();
  5071. }
  5072. startActivity(intent);
  5073. popupWindow.dismiss();
  5074. }
  5075. });
  5076. tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
  5077. tvTwo.setOnClickListener(new View.OnClickListener() {
  5078. @Override
  5079. public void onClick(View view) {
  5080. try {
  5081. Intent intent4 = new Intent("android.intent.action.VIEW",
  5082. android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + ll.latitude + "&dlon=" + ll.longitude + "&dname=" + zhan_name + "&dev=0&m=0&t=2"));
  5083. intent4.setPackage("com.autonavi.minimap");
  5084. startActivity(intent4);
  5085. detailsBack = true;
  5086. popupWindow.dismiss();
  5087. HashMap<String, String> map = new HashMap<String, String>();
  5088. map.put("Name", zhan_name);
  5089. map.put("CostWay", charge_cost_way);
  5090. map.put("City", city);
  5091. MobclickAgent.onEvent(context, "0032", map);
  5092. map.clear();
  5093. } catch (Exception e) {
  5094. e.printStackTrace();
  5095. Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
  5096. }
  5097. }
  5098. });
  5099. popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
  5100. } else {
  5101. ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT);
  5102. }
  5103. }
  5104. }
  5105. }).setNegativeButton("取消", new View.OnClickListener() {
  5106. @Override
  5107. public void onClick(View v) {
  5108. }
  5109. }).show();
  5110. } else {
  5111. new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
  5112. .setTitle("站点故障")
  5113. .setMsg("该站点充电桩均为离线或故障\n" + "可能无法正常充电,是否继续前往")
  5114. .setPositiveButton("继续", new View.OnClickListener() {
  5115. @Override
  5116. public void onClick(View v) {
  5117. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
  5118. !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  5119. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  5120. intent.putExtra("start_jing", center.longitude + "");
  5121. intent.putExtra("start_wei", center.latitude + "");
  5122. intent.putExtra("stop_jing", ll.longitude + "");
  5123. // Log.e("123", ll.longitude + "");
  5124. intent.putExtra("stop_wei", ll.latitude + "");
  5125. // Log.e("123", ll.latitude + "");
  5126. startActivity(intent);
  5127. detailsBack = true;
  5128. HashMap<String, String> map = new HashMap<String, String>();
  5129. map.put("Name", zhan_name);
  5130. map.put("CostWay", charge_cost_way);
  5131. map.put("City", city);
  5132. MobclickAgent.onEvent(context, "0033", map);
  5133. map.clear();
  5134. } else {
  5135. if (center != null) {
  5136. LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  5137. popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
  5138. popupWindow = new PopupWindow(popupWindowView,
  5139. ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
  5140. true);
  5141. popupWindow.setBackgroundDrawable(new BitmapDrawable());
  5142. // 设置PopupWindow的弹出和消失效果
  5143. popupWindow.setAnimationStyle(R.style.popupAnimation);
  5144. LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
  5145. if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
  5146. ll_tvTwo.setVisibility(View.GONE);
  5147. }
  5148. LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
  5149. if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
  5150. ll_tvOne.setVisibility(View.GONE);
  5151. }
  5152. cancleButton = (Button) popupWindowView
  5153. .findViewById(R.id.cancleButton);
  5154. cancleButton.setOnClickListener(new View.OnClickListener() {
  5155. @Override
  5156. public void onClick(View view) {
  5157. // Toast.makeText(ZhanDetailsNew.this, "NO", Toast.LENGTH_SHORT).show();
  5158. popupWindow.dismiss();
  5159. }
  5160. });
  5161. tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
  5162. tvThree.setOnClickListener(new View.OnClickListener() {
  5163. @Override
  5164. public void onClick(View v) {
  5165. Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
  5166. intent.putExtra("start_jing", center.longitude + "");
  5167. intent.putExtra("start_wei", center.latitude + "");
  5168. intent.putExtra("stop_jing", ll.longitude + "");
  5169. intent.putExtra("stop_wei", ll.latitude + "");
  5170. startActivity(intent);
  5171. detailsBack = true;
  5172. popupWindow.dismiss();
  5173. HashMap<String, String> map = new HashMap<String, String>();
  5174. map.put("Name", zhan_name);
  5175. map.put("CostWay", charge_cost_way);
  5176. map.put("City", city);
  5177. MobclickAgent.onEvent(context, "0033", map);
  5178. map.clear();
  5179. }
  5180. });
  5181. tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
  5182. tvOne.setOnClickListener(new View.OnClickListener() {
  5183. @Override
  5184. public void onClick(View view) {
  5185. Intent intent = null;
  5186. int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1;
  5187. int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1;
  5188. if (position_jing > 13 || position_wei > 13) {
  5189. getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei));
  5190. } else {
  5191. bd_jing = Double.parseDouble(poi_jing);
  5192. bd_wei = Double.parseDouble(poi_wei);
  5193. }
  5194. getBaidu(center.longitude, center.latitude);
  5195. try {
  5196. String s = "intent://map/direction?" +
  5197. "origin=" + bd_lat + "," + bd_lon + "&" +
  5198. "destination=" + bd_wei + "," + bd_jing +
  5199. "&mode=driving&" +
  5200. "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
  5201. // Log.e("sss", s);
  5202. intent = Intent.getIntent(s);
  5203. detailsBack = true;
  5204. HashMap<String, String> map = new HashMap<String, String>();
  5205. map.put("Name", zhan_name);
  5206. map.put("CostWay", charge_cost_way);
  5207. map.put("City", city);
  5208. MobclickAgent.onEvent(context, "0031", map);
  5209. map.clear();
  5210. } catch (URISyntaxException e) {
  5211. e.printStackTrace();
  5212. }
  5213. startActivity(intent);
  5214. popupWindow.dismiss();
  5215. }
  5216. });
  5217. tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
  5218. tvTwo.setOnClickListener(new View.OnClickListener() {
  5219. @Override
  5220. public void onClick(View view) {
  5221. try {
  5222. Intent intent4 = new Intent("android.intent.action.VIEW",
  5223. android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + ll.latitude + "&dlon=" + ll.longitude + "&dname=" + zhan_name + "&dev=0&m=0&t=2"));
  5224. intent4.setPackage("com.autonavi.minimap");
  5225. startActivity(intent4);
  5226. detailsBack = true;
  5227. popupWindow.dismiss();
  5228. HashMap<String, String> map = new HashMap<String, String>();
  5229. map.put("Name", zhan_name);
  5230. map.put("CostWay", charge_cost_way);
  5231. map.put("City", city);
  5232. MobclickAgent.onEvent(context, "0032", map);
  5233. map.clear();
  5234. } catch (Exception e) {
  5235. e.printStackTrace();
  5236. Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
  5237. }
  5238. }
  5239. });
  5240. popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
  5241. // startNavi(center, ll);
  5242. } else {
  5243. ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT);
  5244. }
  5245. }
  5246. }
  5247. }).setNegativeButton("取消", new View.OnClickListener() {
  5248. @Override
  5249. public void onClick(View v) {
  5250. }
  5251. }).show();
  5252. }
  5253. }
  5254. private void zhanGrade(String zhan_id) {
  5255. long appTime1 = System.currentTimeMillis() / 1000;
  5256. long updatetime = appTime1 - MainMapActivity.cha - 3;
  5257. String token = String.valueOf(updatetime);
  5258. String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanstar/getstar" +
  5259. "?supplier=星星充电&timer=" + token + "&ver=1.0&zhan_id=" + zhan_id + "&sign="
  5260. + Md5Util.md5("supplier=星星充电&timer=" + token + "&zhan_id=" + zhan_id + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a");
  5261. // Log.e("zhanGrade===", url);
  5262. OkHttpUtils.get()
  5263. .url(url)
  5264. .build()
  5265. .execute(new StringCallback() {
  5266. @Override
  5267. public void onError(Call call, Exception e) {
  5268. }
  5269. @Override
  5270. public void onResponse(String response) {
  5271. if (null != response) {
  5272. // Log.e("zhanGrade===", response);
  5273. String code = JsonUtils.getKeyResult(response, "code");
  5274. String star_num = JsonUtils.getKeyResult(response, "star_level");
  5275. if (star_num.equals("") || star_num.equals("0")) {
  5276. windowGrade.setText("暂无评分");
  5277. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_0xing);
  5278. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5279. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5280. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5281. } else {
  5282. String star_level = star_num;
  5283. double d;
  5284. d = Double.parseDouble(star_level);
  5285. String grade = String.format("%.1f", d);
  5286. if (d > 0 && d < 1) {
  5287. windowGrade.setText(grade + "分");
  5288. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_05xing);
  5289. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5290. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5291. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5292. } else if (d >= 1 && d < 1.5) {
  5293. windowGrade.setText(grade + "分");
  5294. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_1xing);
  5295. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5296. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5297. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5298. } else if (d >= 1.5 && d < 2) {
  5299. windowGrade.setText(grade + "分");
  5300. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_15xing);
  5301. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5302. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5303. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5304. } else if (d >= 2 && d < 2.5) {
  5305. windowGrade.setText(grade + "分");
  5306. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_2xing);
  5307. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5308. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5309. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5310. } else if (d >= 2.5 && d < 3) {
  5311. windowGrade.setText(grade + "分");
  5312. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_25xing);
  5313. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5314. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5315. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5316. } else if (d >= 3 && d < 3.5) {
  5317. windowGrade.setText(grade + "分");
  5318. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_3xing);
  5319. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5320. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5321. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5322. } else if (d >= 3.5 && d < 4) {
  5323. windowGrade.setText(grade + "分");
  5324. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_35xing);
  5325. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5326. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5327. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5328. } else if (d >= 4 && d < 4.5) {
  5329. windowGrade.setText(grade + "分");
  5330. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_4xing);
  5331. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5332. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5333. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5334. } else if (d >= 4.5 && d < 5) {
  5335. windowGrade.setText(grade + "分");
  5336. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_45xing);
  5337. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5338. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5339. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5340. } else {
  5341. windowGrade.setText(grade + "分");
  5342. Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_5xing);
  5343. rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
  5344. windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
  5345. windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
  5346. }
  5347. }
  5348. }
  5349. }
  5350. });
  5351. }
  5352. private void resetMarker() {
  5353. if (nMarker != null) {
  5354. nMarker.hideInfoWindow();
  5355. if (current_chargePoint.getOwn_pay().equals("1")) {
  5356. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
  5357. } else {
  5358. if (current_chargePoint.getSuit_car().equals("特斯拉")) {
  5359. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  5360. } else {
  5361. if (WelcomeActivity.canCost.contains(MainMapActivity.current_chargePoint.getSupplier())) {
  5362. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
  5363. } else {
  5364. nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
  5365. }
  5366. }
  5367. }
  5368. }
  5369. }
  5370. private void getShareIntegral() {
  5371. String url = MainApplication.url + "/zhannew/basic/web/index.php/member/insert-task?userid=" + MainApplication.userId;
  5372. OkHttpUtils.get().url(url).build().execute(new StringCallback() {
  5373. @Override
  5374. public void onError(Call call, Exception e) {
  5375. }
  5376. @Override
  5377. public void onResponse(String response) {
  5378. Log.e(TAG, "onResponse: getShareIntegral=" + response);
  5379. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  5380. if (rtnCode.equals("01")) {
  5381. } else {
  5382. // ToastUtil.showToast(getApplicationContext(),"分享成功",Toast.LENGTH_SHORT);
  5383. }
  5384. }
  5385. });
  5386. }
  5387. private void getMessageNum() {
  5388. long appTime1 = System.currentTimeMillis() / 1000;
  5389. String token = String.valueOf(appTime1);
  5390. if (MainApplication.msgTime.equals("0")) {
  5391. MainApplication.firstOpenTime = token;
  5392. ProfileManager.getInstance().setFirstOpenTime(getApplicationContext(), token);
  5393. MainApplication.msgTime = token;
  5394. ProfileManager.getInstance().setSystemMsgTime(getApplicationContext(), token);
  5395. }
  5396. String url = MainApplication.url + "/zhannew/basic/web/index.php/question/center?user_id=" +
  5397. MainApplication.userId + "&timer=" + MainApplication.msgTime + "&phone=" + MainApplication.userPhone
  5398. + "&password=" + MainApplication.userPassword;
  5399. // Log.e(TAG, "getMessageNum: url="+url );
  5400. OkHttpUtils.get().tag(MainMapActivity.this).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
  5401. @Override
  5402. public void onError(Call call, Exception e) {
  5403. }
  5404. @Override
  5405. public void onResponse(String response) {
  5406. // Log.e(TAG, "onResponse: "+response );
  5407. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  5408. if ("01".equals(rtnCode)) {
  5409. String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
  5410. question_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "question_unread"));
  5411. comment_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "comment_unread"));
  5412. system_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "system_unread"));
  5413. total_unread = question_unread + comment_unread + system_unread;
  5414. if (total_unread > 0) {
  5415. tv_msg_num.setVisibility(View.VISIBLE);
  5416. tv_msg_num.setText(total_unread + "");
  5417. } else {
  5418. tv_msg_num.setVisibility(View.GONE);
  5419. }
  5420. }
  5421. }
  5422. });
  5423. }
  5424. //Eventbus的方法
  5425. @Subscribe(threadMode = ThreadMode.MAIN)
  5426. public void handleEvent(BaseEvent event) {
  5427. if (event.getType().equals(BaseConstants.EVENT_SELECT_CITY)) {
  5428. String locationCity = MainApplication.getInstance().getmCurrentCity();
  5429. tv_atCity.setText(locationCity);
  5430. MainApplication.atCity = locationCity;
  5431. final LatLng cityLatLng = new LatLng(event.getPoi_lat(), event.getPoi_lon());
  5432. new Handler().postDelayed(new Runnable() {
  5433. @Override
  5434. public void run() {
  5435. aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(cityLatLng, 14.0f));
  5436. }
  5437. }, 500);
  5438. } else {
  5439. if (!isFirstLoc) {
  5440. isFirstLoc = true;
  5441. mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
  5442. aMap.setLocationSource(this);// 设置定位监听
  5443. aMap.setMyLocationEnabled(true);// 是否可触发定位并显示定位层
  5444. aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
  5445. mlocationClient.setLocationListener(this);
  5446. mlocationClient.startLocation();
  5447. }
  5448. }
  5449. }
  5450. private void showSimpleBottomSheetGrid(final ChargingShareBean chargingShareBean) {
  5451. final int TAG_SHARE_WECHAT_FRIEND = 0;
  5452. final int TAG_SHARE_WECHAT_MOMENT = 1;
  5453. final int TAG_SHARE_QQ = 2;
  5454. QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(MainMapActivity.this);
  5455. QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
  5456. .addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
  5457. .addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
  5458. .setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() {
  5459. @Override
  5460. public void onClick(QMUIBottomSheet dialog, View itemView) {
  5461. dialog.dismiss();
  5462. int tag = (int) itemView.getTag();
  5463. switch (tag) {
  5464. case TAG_SHARE_WECHAT_FRIEND:
  5465. share(Wechat.NAME, chargingShareBean);
  5466. break;
  5467. case TAG_SHARE_WECHAT_MOMENT:
  5468. share(WechatMoments.NAME, chargingShareBean);
  5469. break;
  5470. case TAG_SHARE_QQ:
  5471. share(QQ.NAME, chargingShareBean);
  5472. break;
  5473. }
  5474. }
  5475. }).build();
  5476. // build.
  5477. build.show();
  5478. }
  5479. private void share(final String name, ChargingShareBean chargingShareBean) {
  5480. Platform.ShareParams paramsToShare = new Platform.ShareParams();
  5481. paramsToShare.setText(chargingShareBean.getText());
  5482. paramsToShare.setTitle(chargingShareBean.getTitle());
  5483. paramsToShare.setTitleUrl(chargingShareBean.getUrl());
  5484. paramsToShare.setUrl(chargingShareBean.getUrl());
  5485. paramsToShare.setImageUrl(chargingShareBean.getIcon());
  5486. paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
  5487. Platform platform = ShareSDK.getPlatform(name);
  5488. platform.setPlatformActionListener(new PlatformActionListener() {
  5489. @Override
  5490. public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
  5491. if (MainApplication.isLogin()) {
  5492. getShareIntegral();
  5493. }
  5494. // ToastUtil.showToast(getApplicationContext(),"分享成功",Toast.LENGTH_SHORT);
  5495. }
  5496. @Override
  5497. public void onError(Platform platform, int i, Throwable throwable) {
  5498. LogUtils.e(throwable.getMessage());
  5499. }
  5500. @Override
  5501. public void onCancel(Platform platform, int i) {
  5502. }
  5503. });
  5504. platform.share(paramsToShare);
  5505. }
  5506. private void getRecyclerViewData() {
  5507. String findDate = ProfileManager.getInstance().getFindDate(MainMapActivity.this);
  5508. if (EmptyUtils.isEmpty(findDate)) {
  5509. findDate = String.valueOf(System.currentTimeMillis() / 1000);
  5510. ProfileManager.getInstance().setFindDate(MainMapActivity.this, findDate);
  5511. }
  5512. String url = MainApplication.url + "/zhannew/basic/web/index.php/discovery/menu-list";
  5513. OkHttpUtils.get().url(url).addParams("timer", findDate).build().execute(new StringCallback() {
  5514. @Override
  5515. public void onError(Call call, Exception e) {
  5516. }
  5517. @Override
  5518. public void onResponse(String response) {
  5519. if (EmptyUtils.isNotEmpty(response)) {
  5520. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  5521. if ("01".equals(rtnCode)) {
  5522. String data = JsonUtils.getKeyResult(response, "data");
  5523. List<FindData> list = JsonUtils.parseToObjectList(data, FindData.class);
  5524. if (list.size() > 0) {
  5525. for (FindData findData : list) {
  5526. if (findData.getUnread().equals("0")) {
  5527. FindActivity.haveFindMessage = true;
  5528. iVpoint.setVisibility(View.VISIBLE);
  5529. return;
  5530. }
  5531. }
  5532. }
  5533. }
  5534. }
  5535. }
  5536. });
  5537. }
  5538. private void loadDmpData() {
  5539. OkHttpUtils.get().url(MainApplication.url + "/zhannew/xd_url.php").build().connTimeOut(3000).readTimeOut(3000)
  5540. .execute(new StringCallback() {
  5541. @Override
  5542. public void onError(Call call, Exception e) {
  5543. e.printStackTrace();
  5544. }
  5545. @Override
  5546. public void onResponse(String response) {
  5547. String show_url = JsonUtils.getKeyResult(response, "show_url");
  5548. String click_url = JsonUtils.getKeyResult(response, "click_url");
  5549. uploadDmp(show_url);
  5550. sav.setClick_url(click_url);
  5551. }
  5552. });
  5553. }
  5554. private void uploadDmp(String url) {
  5555. url = Util.generateDmpUrl(url);
  5556. OkHttpUtils.get().url(url).build().connTimeOut(3000).readTimeOut(3000)
  5557. .execute(new StringCallback() {
  5558. @Override
  5559. public void onError(Call call, Exception e) {
  5560. e.printStackTrace();
  5561. }
  5562. @Override
  5563. public void onResponse(String response) {
  5564. }
  5565. });
  5566. }
  5567. }