1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076 |
- package com.electric.chargingpile.activity;
- import android.Manifest;
- import android.app.Activity;
- import android.app.Application;
- import android.content.BroadcastReceiver;
- import android.content.ContentValues;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.content.SharedPreferences;
- import android.content.pm.PackageInfo;
- import android.content.pm.PackageManager;
- import android.database.Cursor;
- import android.database.sqlite.SQLiteDatabase;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.graphics.Point;
- import android.graphics.drawable.BitmapDrawable;
- import android.graphics.drawable.Drawable;
- import android.net.ConnectivityManager;
- import android.net.NetworkInfo;
- import android.net.Uri;
- import android.os.Build;
- import android.os.Bundle;
- import android.os.Environment;
- import android.os.Handler;
- import android.os.Message;
- import androidx.annotation.NonNull;
- import androidx.annotation.Nullable;
- import androidx.constraintlayout.widget.ConstraintLayout;
- import androidx.core.content.FileProvider;
- import android.text.TextUtils;
- import android.util.Log;
- import android.view.Gravity;
- import android.view.KeyEvent;
- import android.view.LayoutInflater;
- import android.view.MotionEvent;
- import android.view.View;
- import android.view.ViewGroup;
- import android.view.animation.Animation;
- import android.view.animation.AnimationUtils;
- import android.webkit.WebView;
- import android.widget.AdapterView;
- import android.widget.BaseAdapter;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ListView;
- import android.widget.PopupWindow;
- import android.widget.RelativeLayout;
- import android.widget.TextView;
- import android.widget.Toast;
- import com.alibaba.fastjson.JSON;
- import com.amap.api.location.AMapLocation;
- import com.amap.api.location.AMapLocationClient;
- import com.amap.api.location.AMapLocationClientOption;
- import com.amap.api.location.AMapLocationClientOption.AMapLocationMode;
- import com.amap.api.location.AMapLocationListener;
- import com.amap.api.maps.AMap;
- import com.amap.api.maps.AMapUtils;
- import com.amap.api.maps.CameraUpdateFactory;
- import com.amap.api.maps.LocationSource;
- import com.amap.api.maps.MapView;
- import com.amap.api.maps.UiSettings;
- import com.amap.api.maps.model.BitmapDescriptor;
- import com.amap.api.maps.model.BitmapDescriptorFactory;
- import com.amap.api.maps.model.CameraPosition;
- import com.amap.api.maps.model.LatLng;
- import com.amap.api.maps.model.LatLngBounds;
- import com.amap.api.maps.model.Marker;
- import com.amap.api.maps.model.MarkerOptions;
- import com.amap.api.maps.model.MyLocationStyle;
- import com.amap.api.services.weather.LocalDayWeatherForecast;
- import com.amap.api.services.weather.LocalWeatherForecast;
- import com.amap.api.services.weather.LocalWeatherForecastResult;
- import com.amap.api.services.weather.LocalWeatherLive;
- import com.amap.api.services.weather.LocalWeatherLiveResult;
- import com.amap.api.services.weather.WeatherSearch;
- import com.amap.api.services.weather.WeatherSearchQuery;
- import com.blankj.utilcode.util.ActivityUtils;
- import com.blankj.utilcode.util.AppUtils;
- import com.blankj.utilcode.util.EmptyUtils;
- import com.blankj.utilcode.util.LogUtils;
- import com.bumptech.glide.Glide;
- import com.bumptech.glide.load.DataSource;
- import com.bumptech.glide.load.engine.GlideException;
- import com.bumptech.glide.request.RequestListener;
- import com.bumptech.glide.request.target.Target;
- import com.electric.chargingpile.R;
- import com.electric.chargingpile.application.MainApplication;
- import com.electric.chargingpile.base.BaseEvent;
- import com.electric.chargingpile.cluster.ClusterClickListener;
- import com.electric.chargingpile.cluster.ClusterItem;
- import com.electric.chargingpile.cluster.ClusterOverlay;
- import com.electric.chargingpile.cluster.ClusterRender;
- import com.electric.chargingpile.cluster.RegionItem;
- import com.electric.chargingpile.constant.BaseConstants;
- import com.electric.chargingpile.constant.UrlConstants;
- import com.electric.chargingpile.data.Adin;
- import com.electric.chargingpile.data.ChargingShareBean;
- import com.electric.chargingpile.data.City;
- import com.electric.chargingpile.data.DataRefresh;
- import com.electric.chargingpile.data.FindData;
- import com.electric.chargingpile.data.PileData;
- import com.electric.chargingpile.data.UpdateZhanDataBean;
- import com.electric.chargingpile.data.Zhan;
- import com.electric.chargingpile.data.ZhanDB;
- import com.electric.chargingpile.data.zhan_list;
- import com.electric.chargingpile.gen.DaoMaster;
- import com.electric.chargingpile.gen.DaoSession;
- import com.electric.chargingpile.gen.zhan_listDao;
- import com.electric.chargingpile.manager.ProfileManager;
- import com.electric.chargingpile.util.BarColorUtil;
- import com.electric.chargingpile.util.DES3;
- import com.electric.chargingpile.util.DES3S;
- import com.electric.chargingpile.util.DensityUtil;
- import com.electric.chargingpile.util.EventBusUtil;
- import com.electric.chargingpile.util.JsonUtils;
- import com.electric.chargingpile.util.LoadingDialog;
- import com.electric.chargingpile.util.Md5Util;
- import com.electric.chargingpile.util.OkHttpUtil;
- import com.electric.chargingpile.util.SharedPreferencesUtil;
- import com.electric.chargingpile.util.ToastUtil;
- import com.electric.chargingpile.util.Util;
- import com.electric.chargingpile.util.ZhanDBHelper;
- import com.electric.chargingpile.view.AlertDialogTwo;
- import com.electric.chargingpile.view.AlertDialogUpdate;
- import com.electric.chargingpile.view.SlideAdView;
- import com.electric.chargingpile.view.UpdateDialog;
- import com.google.gson.Gson;
- import com.google.gson.reflect.TypeToken;
- import com.google.zxing.client.android.constant.ChargingConstants;
- import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
- import com.squareup.okhttp.Request;
- import com.squareup.okhttp.Response;
- import com.squareup.picasso.Picasso;
- import com.umeng.analytics.MobclickAgent;
- import com.zhy.autolayout.AutoLayout;
- import com.zhy.http.okhttp.OkHttpUtils;
- import com.zhy.http.okhttp.callback.FileCallBack;
- import com.zhy.http.okhttp.callback.StringCallback;
- import org.greenrobot.eventbus.Subscribe;
- import org.greenrobot.eventbus.ThreadMode;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.OutputStreamWriter;
- import java.io.PrintWriter;
- import java.net.Socket;
- import java.net.URISyntaxException;
- import java.net.URLEncoder;
- import java.security.MessageDigest;
- import java.text.NumberFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.Random;
- import cn.sharesdk.framework.Platform;
- import cn.sharesdk.framework.PlatformActionListener;
- import cn.sharesdk.framework.ShareSDK;
- import cn.sharesdk.tencent.qq.QQ;
- import cn.sharesdk.wechat.friends.Wechat;
- import cn.sharesdk.wechat.moments.WechatMoments;
- import okhttp3.Call;
- import pub.devrel.easypermissions.AfterPermissionGranted;
- import pub.devrel.easypermissions.AppSettingsDialog;
- import pub.devrel.easypermissions.EasyPermissions;
- public class MainMapActivity extends Activity implements LocationSource, AMapLocationListener,
- View.OnClickListener, AMap.OnMapLoadedListener, AMap.OnCameraChangeListener, AMap.OnMapClickListener,
- ClusterRender, ClusterClickListener, WeatherSearch.OnWeatherSearchListener, EasyPermissions.PermissionCallbacks,
- AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, AMap.OnInfoWindowClickListener {
- private static final String TAG = "MainMapActivity";
- public static String screen_jing = "", screen_wei = "";
- public static String location_city = "";
- public static String re_move = "true";
- List<LatLng> list_ll = new ArrayList<>();
- private LinearLayout ll_recommend;
- private WeatherSearchQuery mquery;
- private WeatherSearchQuery mquery1;
- private WeatherSearch mweathersearch;
- private WeatherSearch mweathersearch1;
- private RelativeLayout window_ll_zhan;
- public static MainMapActivity m;
- public static MainMapActivity mainMapActivity;
- private int clusterRadius = 80;
- private ClusterOverlay mClusterOverlay;
- private Map<Integer, Drawable> mBackDrawAbles = new HashMap<Integer, Drawable>();
- private IntentFilter intentFilter;
- private NetworkChangeReceiver networkChangeReceiver;
- private List<zhan_list> zhan_lists;
- private MapView mapView;
- public static String back = "";
- private static AMap aMap;
- private AlertDialogUpdate alterDialog;
- public static boolean tag = false;
- public static String condition;
- public static int level;
- private UiSettings mUiSettings;
- private OnLocationChangedListener mListener;
- private AMapLocationClient mlocationClient;
- private AMapLocationClientOption mLocationOption;
- private Marker currentClickedMarker;
- private Marker detailMarker;
- public static boolean onResumeRefresh = false;
- public static boolean search_back = false;
- private ImageView iv_guzhang, iVpoint;
- private boolean clickMarker = false;
- public static LatLng center = null;
- private static boolean firstOpen = true;
- private static boolean firstCheck = true;
- public static long cha;
- String gd_jing, gd_wei, bg_jing, bg_wei;
- private String is_dui = "";
- private final int SEARCH_CODE = 1;
- static String token = "";
- private String Token = "";
- public static int have_message = 0;
- public static int have_pinglun = 0;
- public static int msg_num = 0;
- public static int num1 = 0, num2 = 0;
- public static int zhuang_no = 0;
- public static int city_no = 0;
- private static int count = 1;
- private static int have_order = 0;
- private static float minZoomLevel;
- private static float maxZoomLevel;
- public static RelativeLayout rl_tuijian_tip;
- public static boolean detailsBack = false;
- private int city_able = 0;
- private Socket socket;
- private int time_out = 0;
- private Marker search_marker;
- public static Marker recommend_marker_one, recommend_marker_two, recommend_marker_three;
- private double bd_lon, bd_lat, bd_jing, bd_wei;
- private LoadingDialog loadingDialog;
- Context context;
- public static boolean moveRefresh = true;
- public static LinearLayout ll_map_control;
- private List<String> stringTid = new ArrayList<String>();
- public static List<Zhan> list = new ArrayList<Zhan>();
- public static List<Zhan> listt = new ArrayList<Zhan>();
- public static List<Zhan> list1 = new ArrayList<Zhan>();
- public static List<Zhan> list2 = new ArrayList<Zhan>();
- public static List<Zhan> list3 = new ArrayList<Zhan>();
- public static List<ZhanDB> list_db = new ArrayList<ZhanDB>();
- public static List<City> cityList = new ArrayList<City>();
- private int yindaoye = 0;
- MarkerOptions ooyes = null;
- MarkerOptions oogift = null;
- MarkerOptions oocity = null;
- MarkerOptions oono = null;
- MarkerOptions oo = null;
- MarkerOptions oote = null;
- private Marker mMarkerYes;
- private Marker mMarkerNo;
- private Marker mMarkerTe;
- private Marker mMarkerTed;
- private Marker mMarkerGift;
- private Marker mMarkerCity;
- private Marker keep = null;
- private int sortTye = 1;
- private SlideAdView sav;
- private static TextView userLogin;
- private float mPosX;
- private float mCurPosX;
- private float mPosY;
- private float mCurPosY;
- private TextView tv_msg_num;
- BitmapDescriptor bdyes = BitmapDescriptorFactory.fromResource(R.drawable.icon_sgreen);
- BitmapDescriptor bdgift = BitmapDescriptorFactory.fromResource(R.drawable.icon_sgift);
- BitmapDescriptor bdno = BitmapDescriptorFactory.fromResource(R.drawable.icon_sorange);
- BitmapDescriptor bigno = BitmapDescriptorFactory.fromResource(R.drawable.icon_borange);
- BitmapDescriptor bigyes = BitmapDescriptorFactory.fromResource(R.drawable.icon_bgreen);
- BitmapDescriptor biggift = BitmapDescriptorFactory.fromResource(R.drawable.icon_bgift);
- public static boolean canRefreshthree = true;
- public static boolean canRefreshtwo = true;
- private boolean gestureguide;
- private TextView mTvMarkerViewNum;
- private TextView mTvMarkerViewNumAppB;
- private TextView mTvMarkerViewNumAppS;
- private ImageView mIvMarkerBg;
- private ImageView mIvMarkerAppS;
- private ImageView mIvMarkerAppB;
- private TextView mTvMarkerViewNum1;
- private ImageView mIvMarkerBg1;
- private ImageView mIvMarkerBgYes;
- private TextView mTvMarkerViewNumcity;
- private ImageView mIvMarkerBgcity;
- private ImageView iv_tuijian_close;
- private ImageView iv_tuijian_tip_close;
- private String againPoint = "";
- private LoadingDialog dialog;
- private LinearLayout tab_qa;
- public static boolean isR = false;
- private boolean isListShow = false;
- private View mMarkerView;
- private View mMarkerView1;
- private View mMarkerViewAppS;
- private View mMarkerViewAppB;
- private View mMarkerViewYes;
- private View mMarkerViewcity;
- public static float now_zoom = 0;
- private TextView tv_tishi, paoName, paoName1, paoAddress, paoCostWay, paoDaohang, paoDistance,
- paoFast, paoSlow, paoAlter, paoTotal, tingche, fuwu, dian, tv_grade, tv_shaixuan, tv_recommend_tip,
- tv_daohang, tvOne, tvTwo, tv_num, tvThree, tv_sortDistance, tv_sortStarLevel, iv_list, tv_sortFreeTime;
- public static TextView tv_atCity;
- public static RelativeLayout paoRl;
- public static LinearLayout rl_control;
- private RelativeLayout rela, ll_comment, rl_ad, rl_grade, rl_search, ll_paoxiang, rl_charging_notice;
- private RelativeLayout tv_notice, tv_citynotice, rl_mapList, ll_tab_find;
- private LinearLayout ll_paogo, ll_title, ll_open, tab_me, tab_screen;
- public static LinearLayout ll_tuijian, ll_top_right;
- private PopupWindow popupWindow;
- private View popupWindowView;
- private Button cancleButton;
- private ListView lvZhan;
- private ZhanAdapter adapter;
- private long exitTime = 0;
- private ImageView iv_clear;
- private ImageView iv_sceen;
- private ImageView iv_refresh, iv_route;
- private ImageView iv_our;
- private ImageView iv_tuijian;
- private static ImageView inBtn;
- private static ImageView outBtn;
- private ImageView paopaoAd;
- private ImageView iv_example;
- private ImageView iv_clear_address;
- private ImageView iv_bg_example;
- private String now_versionCode, now_versionName, app_version, title;
- private String login_meg = "";
- private ImageView iv_yindaoye, iv_grade, iv_roadCondition, iv_find, iv_main, iv_screening;
- private TextView tv_search, tv_main, tv_tuijian_feedback;
- public static String comments_num;
- private zhan_listDao zhan_listDao;
- public static zhan_list current_chargePoint;
- public static Marker nMarker;
- private boolean paoShow = false;
- private TextView windowName, windowGrade, windowCost, window_tv_fast_free_num, window_tv_fast_free_label, window_tv_fast_total_num,
- window_tv_slow_free_label, window_tv_slow_free_num, window_tv_slow_total_num, windowCommentNum, windowDistance, stopCost;
- private RelativeLayout windowGo, windowZhanDetails, windowComments;
- private ImageView windowAd, windowGradeImg;
- public static RelativeLayout windowLayout;
- public static int question_unread = 0;
- public static int comment_unread = 0;
- public static int system_unread = 0;
- public static int total_unread = 0;
- public static boolean isStatusBack = false;
- private static final int RC_CAMERA_PERM = 123;
- private static final int RC_SAVE_PERM = 124;
- private String adfloatUrl = "";
- private UpdateDialog updateDialog;
-
- private boolean isFirstLoc = true;
- private Handler myHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- switch (msg.what) {
- case 0x01:
- Bundle data = msg.getData();
- String format = data.getString("format");
- String f = data.getString("progress");
- String s = f.substring(0, f.indexOf("."));
- LogUtils.e(s);
- updateDialog.updateMsg("当前已下载:" + format);
- updateDialog.updateProgress(Integer.parseInt(s));
- break;
- }
- }
- };
- private Handler hand = new Handler() {
- public void handleMessage(android.os.Message msg) {
- SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
- switch (msg.what) {
-
- case 1:
- try {
- JSONObject jsonObject = new JSONObject(msg.obj.toString());
- String comment_num = jsonObject.getString("rtnMsg");
- comments_num = comment_num;
- windowCommentNum.setText("评论(" + comment_num + ")");
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
-
- case 2:
- try {
- String data = JsonUtils.getKeyResult(msg.obj.toString(), "data");
- if (!data.equals("")) {
-
- String adfloat = JsonUtils.getKeyResult(data, "ad_float");
- if (adfloat != null && !adfloat.equals("")) {
- List<Adin> listAdfloat = JsonUtils.parseToObjectList(adfloat, Adin.class);
- if (listAdfloat.size() > 0) {
- loadAdfloatImg(listAdfloat.get(0));
- }
- }
- String adin = JsonUtils.getKeyResult(data, "adin");
- if (null != adin) {
- List<Adin> listAdin = JsonUtils.parseToObjectList(adin, Adin.class);
- System.out.print("size:" + listAdin.size());
- if (listAdin.size() > 0) {
- sav.initData(listAdin);
- rl_ad.setVisibility(View.VISIBLE);
- for (Adin item : listAdin) {
- if (item.getAdvertiser().equals("1")) {
- loadDmpData();
- break;
- }
- }
- }
- }
- String version = JsonUtils.getKeyResult(data, "version");
- com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(version);
- if (jsonArray != null) {
- com.alibaba.fastjson.JSONObject version1 = jsonArray.getJSONObject(0);
- String android = JsonUtils.getKeyResult(version1.toJSONString(), "android");
- title = JsonUtils.getKeyResult(version1.toJSONString(), "title");
- login_meg = JsonUtils.getKeyResult(version1.toJSONString(), "login_meg");
- title = title.replace("\\n", "\n");
- now_versionCode = JsonUtils.getKeyResult(android, "versionCode");
- now_versionName = JsonUtils.getKeyResult(android, "versionName");
- String[] key = now_versionName.split("\\.");
- if (key.length - 1 > 2) {
- dialogup_other();
- } else {
- dialogup();
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- case 3:
- try {
- stringTid.clear();
- if (socket != null) {
- if (socket.isInputShutdown()) {
- stringTid.clear();
- }
- }
- String rtnCode = JsonUtils.getKeyResult(msg.obj.toString(), "rtnCode");
- if (rtnCode.equals("03")) {
- if (time_out < 3) {
- ete("{\"fun\":\"timer\"}");
- clickMarker = false;
- time_out++;
- }
- } else {
- time_out = 0;
- try {
- String date = JsonUtils.getKeyResult(msg.obj.toString(), "data");
- System.out.print("678543" + date);
- List<Zhan> mZhan = JsonUtils.parseToObjectList(date, Zhan.class);
- System.out.print("222:" + mZhan.size());
- for (int i = 0; i < mZhan.size(); i++) {
- Zhan aZhan = mZhan.get(i);
- }
- list.clear();
- listt.clear();
- list1.clear();
- list2.clear();
- list3.clear();
- if (mZhan != null && mZhan.size() > 0) {
- list.addAll(mZhan);
- listt.addAll(mZhan);
- if (center != null) {
- for (int i = 0; i < list.size(); i++) {
- String wei = list.get(i).getPoi_wei().trim();
- String jing = list.get(i).getPoi_jing().trim();
- int position_jing = jing.length() - jing.indexOf(".") - 1;
- int position_wei = wei.length() - wei.indexOf(".") - 1;
- LatLng ll;
- if (position_jing > 13 || position_wei > 13) {
- ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
- } else {
- double dwei = Double.parseDouble(wei);
- double djing = Double.parseDouble(jing);
- getGaode(djing, dwei);
- ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
- }
- double d = AMapUtils.calculateLineDistance(center, ll);
- list.get(i).setDistance(Util.getDistance(d));
- }
- }
- } else {
- if (center != null) {
- BitmapDescriptor point = BitmapDescriptorFactory
- .fromResource(R.drawable.point_icon);
- MarkerOptions oo = new MarkerOptions().position(center)
- .anchor(0.5f, 0.5f).zIndex(7).icon(point)
- .draggable(true);
- aMap.addMarker(oo);
- }
- }
- lvZhan.setAdapter(adapter);
- lvZhan.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
- MainApplication.details_flag = "2";
- Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
- intent.putExtra("zhan_id", list.get(position).getZhan_id());
- startActivity(intent);
- }
- });
- if (list.size() > 0) {
- if (sortTye == 1) {
- list = Util.getSortList(listt);
- } else if (sortTye == 2) {
- list = Util.getSortPFList(listt);
- } else if (sortTye == 3) {
- list = Util.getSortFTList(listt);
- }
- if (MainApplication.isMap == false) {
- tv_tishi.setVisibility(View.GONE);
- }
- } else {
- if (MainApplication.isMap == false) {
- tv_tishi.setVisibility(View.VISIBLE);
- }
- }
- adapter.notifyDataSetChanged();
- } catch (Exception e) {
- BitmapDescriptor point = BitmapDescriptorFactory
- .fromResource(R.drawable.point_icon);
- if (center != null) {
- oo = new MarkerOptions().position(center).
- anchor(0.5f, 0.5f).zIndex(7)
- .draggable(true).icon(point);
- aMap.addMarker(oo);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
-
- case 4:
- try {
- try {
- String date = JsonUtils.getKeyResult(msg.obj.toString(), "data");
- Gson g = new Gson();
- List<City> ll = g.fromJson(date, new TypeToken<List<City>>() {
- }.getType());
- stringTid.clear();
- cityList.clear();
- aMap.clear();
- if (ll != null && ll.size() > 0) {
- cityList.addAll(ll);
- if (center != null) {
- for (int i = 0; i < cityList.size(); i++) {
- double dwei = Double.parseDouble(list.get(i).getPoi_wei());
- double djing = Double.parseDouble(list.get(i).getPoi_jing());
- LatLng lll = new LatLng(dwei, djing);
- }
- }
- } else {
- if (center != null) {
- BitmapDescriptor point = BitmapDescriptorFactory
- .fromResource(R.drawable.point_icon);
- oo = new MarkerOptions().position(center)
- .anchor(0.5f, 0.5f).zIndex(7).icon(point)
- .draggable(false);
- aMap.addMarker(oo);
- }
- }
- } catch (Exception e) {
- BitmapDescriptor point = BitmapDescriptorFactory
- .fromResource(R.drawable.point_icon);
- oo = new MarkerOptions().position(center).
- anchor(0.5f, 0.5f).zIndex(7)
- .draggable(true).icon(point);
- aMap.addMarker(oo);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
- default:
- break;
- }
- }
- };
- private View infoWindow;
- private String zhanInfo;
- private TextView windowChargeRecordCnt;
- private View windowChargeRecordCntLine;
- private TextView windowZongjia;
- private LinearLayout windowZongjiaLayout;
- private ImageView windowRedPaperBag;
- private TextView windowLabelPublic;
- private TextView windowLabelGround;
- private TextView windowLabelFreePark;
- private ConstraintLayout windowChat;
- private LatLng markerPosition;
- private ImageView second_hand_car;
- private LinearLayout private_telephone;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- AutoLayout.getInstance().auto(this);
- setContentView(R.layout.activity_main_map);
- BarColorUtil.initStatusBarColor(MainMapActivity.this);
- m = this;
- mainMapActivity = MainMapActivity.this;
- intentFilter = new IntentFilter();
- intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
- networkChangeReceiver = new NetworkChangeReceiver();
- registerReceiver(networkChangeReceiver, intentFilter);
- EventBusUtil.register(this);
- if (!MainApplication.h5_url.equals("") && MainApplication.type.equals("PushWeb")) {
- Intent intent = new Intent(getApplicationContext(), MyWebViewActivity.class);
- intent.putExtra("url", MainApplication.h5_url);
- startActivity(intent);
- MainApplication.h5_url = "";
- MainApplication.type = "";
- }
- if (!MainApplication.h5_url.equals("") && MainApplication.type.equals("PushComment")) {
- startActivity(new Intent(getApplication(), MyMessageActivity.class));
- MainApplication.h5_url = "";
- MainApplication.type = "";
- MainApplication.mainSkip = "1";
- finish();
- }
- if (MainApplication.type.equals("PushBalance")) {
- if (MainApplication.isLogin()) {
- startActivity(new Intent(getApplication(), MyBalanceActivity.class));
- MainApplication.h5_url = "";
- MainApplication.type = "";
- MainApplication.mainSkip = "1";
- finish();
- }
- }
- if (MainApplication.type.equals("PushRanking")) {
- if (MainApplication.isLogin()) {
- startActivity(new Intent(getApplication(), RankingListActivity.class));
- MainApplication.h5_url = "";
- MainApplication.type = "";
- MainApplication.mainSkip = "1";
- finish();
- }
- }
- if (MainApplication.type.equals("PushRecharge")) {
- if (MainApplication.isLogin()) {
- startActivity(new Intent(getApplication(), AccountRechargeActivity.class));
- MainApplication.h5_url = "";
- MainApplication.type = "";
- MainApplication.mainSkip = "1";
- finish();
- }
- }
- if (MainApplication.type.equals("PushInvite")) {
- if (MainApplication.isLogin()) {
- Intent intent4 = new Intent(getApplication(), MyWebViewActivity.class);
- intent4.putExtra("url", "https://evcharge.cc/cdz/yqm.html?code=" + UserCenterActivity.getShareNo(Integer.parseInt(MainApplication.userId)) + "&phone=" + MainApplication.userPhone);
- startActivity(intent4);
- MainApplication.h5_url = "";
- MainApplication.type = "";
- MainApplication.mainSkip = "1";
- finish();
- }
- }
- if (MainApplication.type.equals("first") || MainApplication.type.equals("second") || MainApplication.type.equals("three")) {
- if (MainApplication.isLogin()) {
- long appTime4 = System.currentTimeMillis() / 1000;
- long updatetime4 = appTime4 - MainMapActivity.cha - 1;
- String token4 = String.valueOf(updatetime4);
- Intent intent4 = new Intent(getApplication(), MyWebViewActivity.class);
- String web1 = null;
- try {
- web1 = MainApplication.url + "/zhannew/basic/web/index.php/discount/redlist?userid=" + MainApplication.userId + "&token=" + URLEncoder.encode(DES3.encode(token4));
- } catch (Exception e) {
- e.printStackTrace();
- }
- intent4.putExtra("url", web1);
- startActivity(intent4);
- MainApplication.h5_url = "";
- MainApplication.type = "";
- MainApplication.mainSkip = "1";
- finish();
- }
- }
- if (MainApplication.type.equals("PushCommodity")) {
- long appTime11 = System.currentTimeMillis() / 1000;
- long updatetime1 = appTime11 - MainMapActivity.cha - 5;
- String token1 = String.valueOf(updatetime1);
- String encode_token = null;
- try {
- encode_token = DES3.encode(token1);
- } catch (Exception e) {
- e.printStackTrace();
- }
- String replace = URLEncoder.encode(encode_token);
- Intent intent11 = new Intent();
- intent11.setClass(getApplicationContext(), CreditActivity.class);
- intent11.putExtra("navColor", "#fcfcfc");
- intent11.putExtra("titleColor", "#222222");
- MainApplication.goods_type = "details";
- if (!MainApplication.isLogin()) {
- intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.h5_url);
- } else {
- intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace + "&url=" + MainApplication.h5_url);
- }
- startActivity(intent11);
- MainApplication.ad_link = "";
- overridePendingTransition(0, 0);
- CreditActivity.creditsListener = new CreditActivity.CreditsListener() {
-
- * 当点击分享按钮被点击
- * @param shareUrl 分享的地址
- * @param shareThumbnail 分享的缩略图
- * @param shareTitle 分享的标题
- * @param shareSubtitle 分享的副标题
- */
- public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
-
- ChargingShareBean chargingShareBean = new ChargingShareBean();
- chargingShareBean.setIcon(shareThumbnail);
- chargingShareBean.setTitle(shareTitle);
- chargingShareBean.setUrl(shareUrl);
- chargingShareBean.setText("");
- showSimpleBottomSheetGrid(chargingShareBean);
- }
-
- * 当点击“请先登录”按钮唤起登录时,会调用此处代码。
- * 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
- * @param webView 用于登录成功后返回到当前的webview刷新登录状态。
- * @param currentUrl 当前页面的url
- */
- public void onLoginClick(WebView webView, final String currentUrl) {
-
-
-
-
-
-
- new android.app.AlertDialog.Builder(webView.getContext())
- .setTitle("跳转登录")
- .setMessage("跳转到登录页面?")
- .setPositiveButton("是", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- MainApplication.h5_url = currentUrl;
- context.startActivity(new Intent(getApplicationContext(), LoginActivity.class));
- }
- })
- .setNegativeButton("否", null)
- .show();
- }
-
- * 当点击“复制”按钮时,触发该方法,回调获取到券码code
- * @param webView webview对象。
- * @param code 复制的券码
- */
- public void onCopyCode(WebView webView, String code) {
-
- new android.app.AlertDialog.Builder(webView.getContext())
- .setTitle("复制券码")
- .setMessage("已复制,券码为:" + code)
- .setPositiveButton("是", null)
- .setNegativeButton("否", null)
- .show();
- }
-
- * 积分商城返回首页刷新积分时,触发该方法。
- */
- public void onLocalRefresh(WebView mWebView, String credits) {
-
-
- }
- };
- }
- if (MainApplication.ad_link.equals("1")) {
- againPoint = "1";
- is_dui = getIntent().getStringExtra("is_dui");
- String url1 = getIntent().getStringExtra("shareUrl");
- if (is_dui.equals("0")) {
- Intent intent2 = new Intent(getApplication(), HomeWebActivity.class);
- intent2.putExtra("shareUrl", url1);
- intent2.putExtra("shareTitle", getIntent().getStringExtra("shareTitle"));
- intent2.putExtra("shareIcon", getIntent().getStringExtra("shareIcon"));
- intent2.putExtra("shareContent", getIntent().getStringExtra("shareContent"));
- intent2.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent2);
- MainApplication.ad_link = "";
- overridePendingTransition(0, 0);
- } else {
- long appTime11 = System.currentTimeMillis() / 1000;
- long updatetime1 = appTime11 - MainMapActivity.cha - 5;
- String token1 = String.valueOf(updatetime1);
- String encode_token = null;
- try {
- encode_token = DES3.encode(token1);
- } catch (Exception e) {
- e.printStackTrace();
- }
- String replace = URLEncoder.encode(encode_token);
- Intent intent11 = new Intent();
- intent11.setClass(getApplicationContext(), CreditActivity.class);
- intent11.putExtra("navColor", "#fcfcfc");
- intent11.putExtra("titleColor", "#222222");
- MainApplication.goods_type = "details";
- MainApplication.current_url = getIntent().getStringExtra("shareUrl");
- if (!MainApplication.isLogin()) {
- intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.current_url);
- } else {
- intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace + "&url=" + MainApplication.current_url);
- }
- startActivity(intent11);
- MainApplication.ad_link = "";
- overridePendingTransition(0, 0);
- CreditActivity.creditsListener = new CreditActivity.CreditsListener() {
-
- * 当点击分享按钮被点击
- * @param shareUrl 分享的地址
- * @param shareThumbnail 分享的缩略图
- * @param shareTitle 分享的标题
- * @param shareSubtitle 分享的副标题
- */
- public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
- ChargingShareBean chargingShareBean = new ChargingShareBean();
- chargingShareBean.setIcon(shareThumbnail);
- chargingShareBean.setTitle(shareTitle);
- chargingShareBean.setUrl(shareUrl);
- chargingShareBean.setText("");
- showSimpleBottomSheetGrid(chargingShareBean);
- }
-
- * 当点击“请先登录”按钮唤起登录时,会调用此处代码。
- * 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
- * @param webView 用于登录成功后返回到当前的webview刷新登录状态。
- * @param currentUrl 当前页面的url
- */
- public void onLoginClick(WebView webView, final String currentUrl) {
-
-
-
-
-
-
- new android.app.AlertDialog.Builder(webView.getContext())
- .setTitle("跳转登录")
- .setMessage("跳转到登录页面?")
- .setPositiveButton("是", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- MainApplication.current_url = currentUrl;
- context.startActivity(new Intent(getApplicationContext(), LoginActivity.class));
- }
- })
- .setNegativeButton("否", null)
- .show();
- }
-
- * 当点击“复制”按钮时,触发该方法,回调获取到券码code
- * @param webView webview对象。
- * @param code 复制的券码
- */
- public void onCopyCode(WebView webView, String code) {
-
- new android.app.AlertDialog.Builder(webView.getContext())
- .setTitle("复制券码")
- .setMessage("已复制,券码为:" + code)
- .setPositiveButton("是", null)
- .setNegativeButton("否", null)
- .show();
- }
-
- * 积分商城返回首页刷新积分时,触发该方法。
- */
- public void onLocalRefresh(WebView mWebView, String credits) {
-
-
- }
- };
- }
- }
- context = this;
- gestureguide = ProfileManager.getInstance().getGestureguide(getApplicationContext());
- dialog = new LoadingDialog(this);
- dialog.setCanceledOnTouchOutside(false);
- setUserData();
- setlogin();
- mMarkerView = LayoutInflater.from(this).inflate(R.layout.view_custom_marker, null);
- mMarkerView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- mMarkerViewYes = LayoutInflater.from(this).inflate(R.layout.view_custom_yes, null);
- mMarkerViewYes.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- mMarkerView1 = LayoutInflater.from(this).inflate(R.layout.view_custom_marker1, null);
- mMarkerView1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- mMarkerViewcity = LayoutInflater.from(this).inflate(R.layout.view_custom_markercity, null);
- mMarkerViewcity.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- mMarkerViewAppS = LayoutInflater.from(this).inflate(R.layout.view_custom_marker_apps, null);
- mMarkerViewAppS.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- mMarkerViewAppB = LayoutInflater.from(this).inflate(R.layout.view_custom_marker_appb, null);
- mMarkerViewAppB.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- initViews();
- getRecyclerViewData();
- File databasePath = getDatabasePath("zhan_list");
- if (databasePath.exists()) {
- eteinit("{\"fun\":\"timer\"}");
- try {
- getZhanData();
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- LogUtils.e("不存在");
- try {
- initDataBase();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- showUi(MainApplication.isMap);
- if (MainApplication.haveActivity == true) {
- List<Adin> listAdin = JsonUtils.parseToObjectList("[" + MainApplication.ad_major + "]", Adin.class);
- if (listAdin.size() > 0) {
- sav.initData(listAdin);
- rl_ad.setVisibility(View.VISIBLE);
- }
- }
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- if (login_meg.equals("")) {
- login_meg = "我知道你关注我很久了,快来注册登录吧,登录后可以在特来电、聚电科技充电桩扫码充电";
- }
- if (MainApplication.count == 2 || MainApplication.count == 24 || MainApplication.count == 44 || MainApplication.count == 64 || MainApplication.count == 84 || MainApplication.count == 104) {
- if (MainApplication.isIgnore == true) {
- new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
- .setMsg(login_meg)
- .setPositiveButton("去登录", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
- startActivity(intent);
- }
- }).setNegativeButton("忽略", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- MainApplication.isIgnore = false;
- }
- }).show();
- MobclickAgent.onEvent(context, "0041");
- }
- }
- }
- }, 2000);
- }
- private void initViews() {
- rl_charging_notice = (RelativeLayout) findViewById(R.id.rl_charging_notice);
- rl_charging_notice.setOnClickListener(this);
- tab_qa = (LinearLayout) findViewById(R.id.tab_qa);
- tab_qa.setOnClickListener(this);
- iv_guzhang = (ImageView) findViewById(R.id.iv_guzhang);
- windowName = (TextView) findViewById(R.id.window_tv_zhan_name);
- stopCost = findViewById(R.id.window_tv_stop_cost);
- windowGrade = (TextView) findViewById(R.id.window_tv_zhan_grade);
- windowCost = (TextView) findViewById(R.id.window_tv_zhan_cost);
- private_telephone = findViewById(R.id.private_telephone);
- window_tv_fast_free_num = (TextView) findViewById(R.id.window_tv_fast_free_num);
- window_tv_fast_free_label = findViewById(R.id.window_tv_fast_free_label);
- window_tv_fast_total_num = findViewById(R.id.window_tv_fast_total_num);
- window_tv_slow_free_label = findViewById(R.id.window_tv_slow_free_label);
- window_tv_slow_free_num = findViewById(R.id.window_tv_slow_free_num);
- window_tv_slow_total_num = findViewById(R.id.window_tv_slow_total_num);
- windowCommentNum = (TextView) findViewById(R.id.window_tv_comment_num);
- windowChargeRecordCnt = findViewById(R.id.window_tv_charge_record_cnt);
- windowChargeRecordCntLine = findViewById(R.id.window_tv_charge_record_cnt_line);
- windowZongjia = findViewById(R.id.window_tv_zongjia);
- windowZongjiaLayout = findViewById(R.id.window_tv_zongjia_layout);
- windowRedPaperBag = findViewById(R.id.iv_red_paper_bag);
- windowLabelPublic = findViewById(R.id.iv_label_public);
- windowLabelGround = findViewById(R.id.iv_label_ground);
- windowLabelFreePark = findViewById(R.id.iv_label_free_park);
- windowGo = (RelativeLayout) findViewById(R.id.window_rl_go);
- windowZhanDetails = (RelativeLayout) findViewById(R.id.window_rl_zhan_details);
- windowComments = (RelativeLayout) findViewById(R.id.window_rl_comment);
- windowAd = (ImageView) findViewById(R.id.window_iv_ad);
- windowGradeImg = (ImageView) findViewById(R.id.window_iv_zhan_grade);
- iv_tuijian_close = (ImageView) findViewById(R.id.iv_tuijian_close);
- iv_tuijian_tip_close = (ImageView) findViewById(R.id.iv_tuijian_tip_close);
- iv_tuijian_close.setOnClickListener(this);
- iv_tuijian_tip_close.setOnClickListener(this);
- ll_recommend = (LinearLayout) findViewById(R.id.ll_recommend);
- tv_recommend_tip = (TextView) findViewById(R.id.tv_recommend_tip);
- tv_tuijian_feedback = (TextView) findViewById(R.id.tv_tuijian_feedback);
- tv_tuijian_feedback.setOnClickListener(this);
- ll_map_control = (LinearLayout) findViewById(R.id.ll_map_control);
- windowLayout = (RelativeLayout) findViewById(R.id.window_ll_zhan);
- ll_top_right = (LinearLayout) findViewById(R.id.ll_top_right);
- iv_tuijian = (ImageView) findViewById(R.id.iv_tuijian);
- iv_route = (ImageView) findViewById(R.id.iv_route);
- second_hand_car = findViewById(R.id.second_hand_car);
- iv_tuijian.setOnClickListener(this);
- iv_route.setOnClickListener(this);
- second_hand_car.setOnClickListener(this);
- iVpoint = findViewById(R.id.iv_point);
- window_ll_zhan = (RelativeLayout) findViewById(R.id.window_ll_zhan);
- tv_search = (TextView) findViewById(R.id.tv_search);
- tv_msg_num = (TextView) findViewById(R.id.tv_msg_num);
- tv_shaixuan = (TextView) findViewById(R.id.tv_shaixuan);
- tv_shaixuan.setOnClickListener(this);
- iv_example = (ImageView) findViewById(R.id.iv_example);
- iv_example.setOnClickListener(this);
- iv_clear_address = (ImageView) findViewById(R.id.iv_clear_address);
- iv_clear_address.setOnClickListener(this);
- ll_tuijian = (LinearLayout) findViewById(R.id.ll_tuijian);
- ll_tuijian.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Log.e(TAG, "onClick: 333");
- }
- });
- ll_tuijian.setOnTouchListener(new View.OnTouchListener() {
- float mCurPosX, mCurPosY, mPosX, mPosY;
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- switch (event.getAction()) {
- case MotionEvent.ACTION_UP:
- mCurPosX = event.getX();
- mCurPosY = event.getY();
- Log.e(TAG, "onTouch: 111");
- break;
- case MotionEvent.ACTION_DOWN:
- mPosX = event.getX();
- mPosY = event.getY();
- Log.e(TAG, "onTouch: 222");
- break;
- case MotionEvent.ACTION_MOVE:
- if (mCurPosY - mPosY > 0
- && (Math.abs(mCurPosY - mPosY) > 25)) {
- Log.e(TAG, "onTouch: 向下滑動");
-
- } else if (mCurPosY - mPosY < 0
- && (Math.abs(mCurPosY - mPosY) > 25)) {
- Log.e(TAG, "onTouch: 向上滑动");
-
- }
- Log.e(TAG, "onTouch: qqqq");
- break;
- }
- return false;
- }
- });
-
- windowRedPaperBag.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent_example = new Intent(getApplicationContext(), ExampleActivity.class);
- intent_example.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent_example);
- overridePendingTransition(0, 0);
- }
- });
-
- tv_sortDistance = (TextView) findViewById(R.id.tv_sortDistance);
- tv_sortDistance.setOnClickListener(this);
- tv_sortStarLevel = (TextView) findViewById(R.id.tv_sortStarLevel);
- tv_sortStarLevel.setOnClickListener(this);
- tv_sortFreeTime = (TextView) findViewById(R.id.tv_sortFreeTime);
- tv_sortFreeTime.setOnClickListener(this);
- rl_mapList = (RelativeLayout) findViewById(R.id.rl_mapList);
- iv_roadCondition = (ImageView) findViewById(R.id.iv_roadCondition);
- iv_roadCondition.setOnClickListener(this);
- iv_yindaoye = (ImageView) findViewById(R.id.iv_yindaoye);
- iv_yindaoye.setOnClickListener(this);
- rl_grade = (RelativeLayout) findViewById(R.id.rl_grade);
- iv_grade = (ImageView) findViewById(R.id.iv_grade);
- tv_grade = (TextView) findViewById(R.id.tv_grade);
- userLogin = (TextView) findViewById(R.id.tv_userLogin);
- mTvMarkerViewNum = (TextView) mMarkerView.findViewById(R.id.tv_num);
- mTvMarkerViewNumAppS = (TextView) mMarkerViewAppS.findViewById(R.id.tv_num);
- mTvMarkerViewNumAppB = (TextView) mMarkerViewAppB.findViewById(R.id.tv_num);
- mIvMarkerBg = (ImageView) mMarkerView.findViewById(R.id.iv_icon);
- mIvMarkerAppS = (ImageView) mMarkerViewAppS.findViewById(R.id.iv_icon);
- mIvMarkerAppB = (ImageView) mMarkerViewAppB.findViewById(R.id.iv_icon);
- mTvMarkerViewNum1 = (TextView) mMarkerView1.findViewById(R.id.tv_num);
- mIvMarkerBg1 = (ImageView) mMarkerView1.findViewById(R.id.iv_icon);
- mIvMarkerBgYes = (ImageView) mMarkerViewYes.findViewById(R.id.iv_icon);
- mIvMarkerBgcity = (ImageView) mMarkerViewcity.findViewById(R.id.iv_icon);
- mTvMarkerViewNumcity = (TextView) mMarkerViewcity.findViewById(R.id.tv_num);
-
- iv_our = (ImageView) findViewById(R.id.iv_our);
-
- rl_ad = (RelativeLayout) findViewById(R.id.rl_ad);
-
- sav = (SlideAdView) findViewById(R.id.imageView8);
-
- iv_clear = (ImageView) findViewById(R.id.iv_clear);
- iv_clear.setOnClickListener(this);
- tv_citynotice = (RelativeLayout) findViewById(R.id.tv_citynotice);
- tv_citynotice.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- tv_citynotice.setVisibility(View.GONE);
- tv_notice.setVisibility(View.GONE);
- city_no = 1;
- }
- });
- ll_tab_find = (RelativeLayout) findViewById(R.id.ll_tab_find);
- ll_tab_find.setOnClickListener(this);
- tab_screen = (LinearLayout) findViewById(R.id.tab_screening);
- tab_screen.setOnClickListener(this);
- tab_me = (LinearLayout) findViewById(R.id.tab_me);
- tab_me.setOnClickListener(this);
- inBtn = (ImageView) findViewById(R.id.zoomin);
- inBtn.setOnClickListener(this);
- outBtn = (ImageView) findViewById(R.id.zoomout);
- outBtn.setOnClickListener(this);
-
- iv_list = (TextView) findViewById(R.id.iv_list);
- iv_list.setOnClickListener(this);
- SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
-
- lvZhan = (ListView) findViewById(R.id.lv_zhan_list);
- adapter = new ZhanAdapter();
-
- iv_sceen = (ImageView) findViewById(R.id.tv_person);
- iv_sceen.setOnClickListener(this);
- rl_control = (LinearLayout) findViewById(R.id.rl_control);
- tv_tishi = (TextView) findViewById(R.id.tv_tishi);
-
- tv_atCity = (TextView) findViewById(R.id.tv_switch_city);
- tv_atCity.setOnClickListener(this);
- ll_open = (LinearLayout) findViewById(R.id.ll_open);
-
- tv_num = (TextView) findViewById(R.id.tv_num);
-
- iv_refresh = (ImageView) findViewById(R.id.iv_point_again);
- iv_refresh.setOnClickListener(this);
- paoRl = (RelativeLayout) findViewById(R.id.rela_paopao);
- paoName = (TextView) findViewById(R.id.window_tv_zhan_name);
- paoName.setFocusable(true);
- paoAddress = (TextView) findViewById(R.id.tv_address);
- paoCostWay = (TextView) findViewById(R.id.window_tv_zhan_cost);
- paoDaohang = (TextView) findViewById(R.id.detail_daohang);
- paoFast = (TextView) findViewById(R.id.tv_fastNum);
- paoSlow = (TextView) findViewById(R.id.tv_slowNum);
- paoAlter = (TextView) findViewById(R.id.tv_detail_alter);
- paoTotal = (TextView) findViewById(R.id.tv_totalNum);
- paopaoAd = (ImageView) findViewById(R.id.window_iv_ad);
- tv_daohang = (TextView) findViewById(R.id.tv_daohang);
- rela = (RelativeLayout) findViewById(R.id.rela);
- ll_comment = (RelativeLayout) findViewById(R.id.window_rl_comment);
- ll_paoxiang = (RelativeLayout) findViewById(R.id.window_rl_go);
- rl_tuijian_tip = (RelativeLayout) findViewById(R.id.rl_tuijian_tip);
- rl_tuijian_tip.setOnClickListener(this);
- ll_paogo = (LinearLayout) findViewById(R.id.ll_paogo);
- tingche = (TextView) findViewById(R.id.tv_park);
- fuwu = (TextView) findViewById(R.id.tv_service);
- dian = (TextView) findViewById(R.id.tv_charge);
- rl_search = (RelativeLayout) findViewById(R.id.rl_search);
- rl_search.setOnClickListener(this);
- ll_title = (LinearLayout) findViewById(R.id.ll_title);
- if (aMap == null) {
- aMap = mapView.getMap();
- Util.setMapCustomStyleFile(aMap, getApplicationContext());
- maxZoomLevel = aMap.getMaxZoomLevel();
- minZoomLevel = aMap.getMinZoomLevel();
- MyLocationStyle myLocationStyle = new MyLocationStyle();
- myLocationStyle.myLocationIcon(BitmapDescriptorFactory
- .fromResource(R.drawable.point_icon));
- myLocationStyle.strokeColor(getResources().getColor(R.color.transparent));
- myLocationStyle.radiusFillColor(getResources().getColor(R.color.transparent));
- aMap.setMyLocationStyle(myLocationStyle);
- mUiSettings = aMap.getUiSettings();
- setUpMap();
- }
- iv_find = (ImageView) findViewById(R.id.iv_find);
- iv_main = (ImageView) findViewById(R.id.iv_main);
- iv_screening = (ImageView) findViewById(R.id.iv_screening);
- tv_main = (TextView) findViewById(R.id.tv_main);
- if (MainApplication.festival_time.equals("1")) {
- iv_screening.setImageResource(R.drawable.icon_cj2);
- iv_main.setImageResource(R.drawable.icon_cj1);
- iv_find.setImageResource(R.drawable.icon_cj3);
- tv_main.setTextColor(getResources().getColor(R.color.jieri));
- iv_list.setTextColor(getResources().getColor(R.color.white));
- ll_title.setBackgroundResource(R.color.jieri);
- tv_atCity.setTextColor(getResources().getColor(R.color.white));
- Drawable nav_up = getResources().getDrawable(R.drawable.iocn_down_white);
- nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
- tv_atCity.setCompoundDrawables(null, null, nav_up, null);
- } else if (MainApplication.festival_time.equals("2")) {
- iv_screening.setImageResource(R.drawable.icon_yx2);
- iv_main.setImageResource(R.drawable.icon_yx1);
- iv_find.setImageResource(R.drawable.icon_yx3);
- tv_main.setTextColor(getResources().getColor(R.color.jieri));
- iv_list.setTextColor(getResources().getColor(R.color.white));
- ll_title.setBackgroundResource(R.color.jieri);
- tv_atCity.setTextColor(getResources().getColor(R.color.white));
- Drawable nav_up = getResources().getDrawable(R.drawable.iocn_down_white);
- nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
- tv_atCity.setCompoundDrawables(null, null, nav_up, null);
- }
- }
- private void loadAdfloatImg(Adin adin) {
- adfloatUrl = adin.getUrl();
- Glide.with(this).load(MainApplication.url + "/zhannew/uploadfile/" + adin.getIcon()).listener(new RequestListener<Drawable>() {
- @Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- second_hand_car.setVisibility(View.GONE);
- return false;
- }
- @Override
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
- second_hand_car.setVisibility(View.VISIBLE);
- return false;
- }
- }).into(second_hand_car);
- }
-
- * 设置一些amap的属性
- */
- private void setUpMap() {
- aMap.setOnCameraChangeListener(this);
- aMap.setLocationSource(this);
- aMap.setOnMapClickListener(this);
- aMap.setOnMarkerClickListener(this);
- aMap.setInfoWindowAdapter(this);
- aMap.setOnInfoWindowClickListener(this);
- aMap.setOnMapLoadedListener(this);
- aMap.getUiSettings().setMyLocationButtonEnabled(false);
- aMap.getUiSettings().setZoomControlsEnabled(false);
- aMap.getUiSettings().setScaleControlsEnabled(true);
- aMap.getUiSettings().setRotateGesturesEnabled(false);
- aMap.setTrafficEnabled(true);
- }
- @Override
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- setIntent(intent);
- }
-
- * 方法必须重写
- */
- @Override
- protected void onResume() {
- super.onResume();
- String search_address = ProfileManager.getInstance().getSearchAddress(this);
- if (search_address.equals("")) {
- tv_search.setText("请输入地址/关键字");
- iv_clear_address.setVisibility(View.INVISIBLE);
- } else {
- tv_search.setText(search_address);
- iv_clear_address.setVisibility(View.VISIBLE);
- }
- String from = getIntent().getStringExtra("from");
- if ("search_from_activity".equals(from)) {
- searchAll();
- }
- if (FindActivity.haveFindMessage == true) {
- iVpoint.setVisibility(View.VISIBLE);
- } else {
- iVpoint.setVisibility(View.GONE);
- }
- saveTask();
- if (MainApplication.haveActivity == false) {
- if (MainApplication.isLogin() && MainApplication.isAppStart == true) {
- userChargingCheck();
- } else {
- rl_charging_notice.setVisibility(View.GONE);
- }
- getMessageNum();
- }
- if (onResumeRefresh == true) {
- try {
- getZhanData();
- } catch (Exception e) {
- e.printStackTrace();
- }
- onResumeRefresh = false;
- }
- if (ProfileManager.getInstance().getRoadCondition(getApplicationContext()) == false) {
- iv_roadCondition.setImageResource(R.drawable.icon_wulukuang_main);
- aMap.setTrafficEnabled(false);
- } else {
- iv_roadCondition.setImageResource(R.drawable.icon_youlukuang_main);
- aMap.setTrafficEnabled(true);
- }
- mapView.onResume();
- if (againPoint.equals("1") && back.equals("1")) {
- if (!isFirstLoc) {
- isFirstLoc = true;
- mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
- aMap.setLocationSource(this);
- aMap.setMyLocationEnabled(true);
- aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
- mlocationClient.startLocation();
- }
- againPoint = "";
- back = "";
- }
- detailsBack = false;
- changeButton();
- }
- private void searchAll() {
- if ("请输入地址/关键字".equals(tv_search.getText().toString())) {
- if (search_marker != null) {
- search_marker.remove();
- }
- return;
- }
- double jing = Double.valueOf(getIntent().getStringExtra("jing"));
- double wei = Double.valueOf(getIntent().getStringExtra("wei"));
- MainApplication.search_jing = jing;
- MainApplication.search_wei = wei;
- final LatLng screenCity = new LatLng(wei, jing);
- aMap = mapView.getMap();
- Util.setMapCustomStyleFile(aMap, getApplicationContext());
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
- }
- }, 500);
- if (search_marker != null) {
- search_marker.remove();
- }
- if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
- LatLng latLng = new LatLng(MainApplication.search_wei, MainApplication.search_jing);
- search_marker = aMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.icon_search_address))));
- search_marker.setPeriod(8);
- }
- ete("{\"fun\":\"timer\"}");
- }
-
- * 方法必须重写
- */
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- deactivate();
- }
-
- * 方法必须重写
- */
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- * 方法必须重写
- */
- @Override
- protected void onDestroy() {
- super.onDestroy();
- unregisterReceiver(networkChangeReceiver);
- if (mClusterOverlay != null) {
- mClusterOverlay.onDestroy();
- }
- mapView.onDestroy();
- EventBusUtil.unregister(this);
- if (null != mlocationClient) {
- mlocationClient.onDestroy();
- }
- OkHttpUtils.getInstance().cancelTag(MainMapActivity.this);
- SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
- sharedPreferencesUtil.setFileName("CurrentMarkerInfo");
- sharedPreferencesUtil.clearData();
- }
- @Override
- public void activate(OnLocationChangedListener listener) {
- mListener = listener;
- if (mlocationClient == null) {
- mlocationClient = new AMapLocationClient(this);
- mLocationOption = new AMapLocationClientOption();
-
- mlocationClient.setLocationListener(this);
-
- mLocationOption.setLocationMode(AMapLocationMode.Battery_Saving);
- mLocationOption.setInterval(1500);
-
-
- mlocationClient.setLocationOption(mLocationOption);
-
-
-
-
-
- mLocationOption.setOnceLocation(false);
-
-
- mLocationOption.setWifiScan(true);
- mlocationClient.startLocation();
- }
- }
- @Override
- public void deactivate() {
- mListener = null;
- if (mlocationClient != null) {
- mlocationClient.stopLocation();
- mlocationClient.onDestroy();
- }
- mlocationClient = null;
- }
- @Override
- public void onLocationChanged(AMapLocation amapLocation) {
- if (mListener != null && amapLocation != null) {
- if (amapLocation != null && amapLocation.getErrorCode() == 0) {
- try {
- MainApplication.atCity = amapLocation.getCity().substring(0, amapLocation.getCity().length() - 1);
- location_city = MainApplication.atCity;
- tv_atCity.setText(MainApplication.atCity);
- } catch (NullPointerException e) {
- e.printStackTrace();
- }
- ProfileManager.getInstance().setAtCity(getApplicationContext(), MainApplication.atCity);
- center = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude());
- MainApplication.center = center;
- ete("{\"fun\":\"timer\"}");
- mlocationClient.stopLocation();
- if (MainApplication.haveActivity == false) {
- getBaidu(amapLocation.getLongitude(), amapLocation.getLatitude());
- String uid;
- if (MainApplication.isLogin()) {
- uid = MainApplication.userId;
- } else {
- uid = "";
- }
- String url = "{\"fun\":\"dingwei\",\"poi_jing\":" + "\"" + String.format("%.6f", bd_lon) +
- "\"" + ",\"poi_wei\":" + "\"" + String.format("%.6f", bd_lat) + "\"" + ",\"imei\":"
- + "\"" + "android_" + Util.getUdid() + "\"" + ",\"timer\":" + "\"" + Token
- + "\"" + ",\"registration_id\":" + "\"" + MainApplication.push_id + "\""
- + ",\"userid\":" + "\"" + uid + "\"" + "}";
- eteLocation(url);
- }
- if (isFirstLoc) {
-
-
- aMap.moveCamera(CameraUpdateFactory.changeLatLng(center));
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
- }
- }, 2000);
-
- mListener.onLocationChanged(amapLocation);
- isFirstLoc = false;
- }
- } else {
- String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
- Toast.makeText(this, errText, Toast.LENGTH_SHORT).show();
- }
- }
- }
-
- public static void controlZoomShow() {
- if (aMap != null) {
- float zoom = aMap.getCameraPosition().zoom;
- Log.e(TAG, "controlZoomShow: " + zoom);
- try {
- if (zoom >= maxZoomLevel) {
- inBtn.setImageResource(R.drawable.icon_zoom_in_no);
- inBtn.setEnabled(false);
- return;
- } else {
- inBtn.setImageResource(R.drawable.icon_zoom_in_yes);
- inBtn.setEnabled(true);
- }
- if (zoom <= minZoomLevel) {
- outBtn.setImageResource(R.drawable.icon_zoom_out_no);
- outBtn.setEnabled(false);
- return;
- } else {
- outBtn.setImageResource(R.drawable.icon_zoom_out_yes);
- outBtn.setEnabled(true);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- public void eteinit(final String params) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- String host = "";
- if (MainApplication.url.contains("cdz.evcharge.cc")) {
- host = "cdz.evcharge.cc";
- } else {
- host = "59.110.68.162";
- }
- socket = new Socket(host, 9503);
-
- PrintWriter out = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(socket.getOutputStream())), true);
- out.println(params);
-
-
- BufferedReader br = new BufferedReader(new InputStreamReader(
- socket.getInputStream()));
- String msg = br.readLine();
- token = msg;
- int time = (int) (System.currentTimeMillis() / 1000);
- cha = time - Integer.parseInt(msg);
- Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
- ete2("{\"fun\":\"init\",\"timer\":" + "\"" + Token + "\"" + "}");
- MainApplication.uptime = ProfileManager.getInstance().getDataUptime(getApplicationContext());
- newUpdataZhanData(Token, MainApplication.uptime);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }).start();
- }
- private void newUpdataZhanData(String token, String uptime) {
- String url = MainApplication.url + ":9080/update_db";
- OkHttpUtils.get().url(url)
- .addParams("timer", token)
- .addParams("uptime", uptime)
- .build().execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- e.printStackTrace();
- }
- @Override
- public void onResponse(String response) {
- String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
- if ("0".equals(rtnCode)) {
- String data = JsonUtils.getKeyResult(response, "data");
- if (EmptyUtils.isNotEmpty(data)) {
- final List<UpdateZhanDataBean> list = JsonUtils.parseToObjectList(data, UpdateZhanDataBean.class);
- if (list.size() > 0) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- dealUpdateData(list);
- }
- }).start();
- }
- }
- }
- }
- });
- }
- private void dealUpdateData(List<UpdateZhanDataBean> list) {
- String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
- String uptime = "";
- try {
- SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.beginTransaction();
- try {
- for (int i = 0; i < list.size(); i++) {
- UpdateZhanDataBean bean = list.get(i);
- ContentValues cv = new ContentValues();
- cv.put("id", bean.getId());
- cv.put("status", bean.getStatus());
- cv.put("poi_jing", bean.getPoi_jing());
- cv.put("poi_wei", bean.getPoi_wei());
- cv.put("total_num", bean.getTotal_num());
- cv.put("fast_num", bean.getFast_num());
- cv.put("slow_num", bean.getSlow_num());
- cv.put("charge_cost_way", bean.getCharge_cost_way());
- cv.put("city", bean.getCity());
- cv.put("belong_attribute", bean.getBelong_attribute());
- cv.put("suit_car", bean.getSuit_car());
- cv.put("own_pay", bean.getOwn_pay());
- cv.put("supplier", bean.getSupplier());
- cv.put("stop_cost", bean.getStop_cost());
- cv.put("zhuang_num", bean.getZhuang_num());
- long mub = db.replace("zhan_list", null, cv);
- if (mub > 0) {
- uptime = bean.getUptime();
- } else {
- }
- }
- db.setTransactionSuccessful();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- db.endTransaction();
- }
- db.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (!"".equals(uptime)) {
- ProfileManager.getInstance().setDataUptime(getApplicationContext(), uptime);
- }
- }
- public void ete(final String params) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- String host = "";
- if (MainApplication.url.contains("cdz.evcharge.cc")) {
- host = "cdz.evcharge.cc";
- } else {
- host = "59.110.68.162";
- }
- socket = new Socket(host, 9503);
-
- PrintWriter out = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(socket.getOutputStream())), true);
- out.println(params);
-
-
- BufferedReader br = new BufferedReader(new InputStreamReader(
- socket.getInputStream()));
- String msg = br.readLine();
- token = msg;
- int time = (int) (System.currentTimeMillis() / 1000);
- cha = time - Integer.parseInt(msg);
- Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
- if (MainApplication.userTpye == "") {
- MainApplication.userTpye = "1";
- }
- String llon, llat, rlon, rlat;
- if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
- llon = String.valueOf(MainApplication.search_jing - 0.047414454728858857);
- llat = String.valueOf(MainApplication.search_wei + 0.047414454728858857);
- rlon = String.valueOf(MainApplication.search_jing + 0.047414454728858857);
- rlat = String.valueOf(MainApplication.search_wei - 0.041842459916509256);
- } else {
- llon = String.valueOf(center.longitude - 0.047414454728858857);
- llat = String.valueOf(center.latitude + 0.047414454728858857);
- rlon = String.valueOf(center.longitude + 0.047414454728858857);
- rlat = String.valueOf(center.latitude - 0.041842459916509256);
- }
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("fun", "zhangetlist");
- map.put("poi_lux", llon);
- map.put("poi_luy", llat);
- map.put("poi_rdx", rlon);
- map.put("poi_rdy", rlat);
- map.put("suit_car2", MainApplication.userTpye);
- map.put("status", MainApplication.mapStatus);
- map.put("charge_cost_way", "");
- map.put("belong_attribute", MainApplication.shuxing);
- map.put("speed", MainApplication.sudu);
- map.put("timer", Token);
- map.put("supplier", MainApplication.costWay);
- map.put("stop_free", MainApplication.mianStop);
- int hotel, expressway, jingdian;
- if (MainApplication.selecthotel.equals("true")) {
- MainApplication.selecthotel = "true";
- ProfileManager.getInstance().setSelecthotel(MainMapActivity.this, "true");
- hotel = 1;
- } else {
- MainApplication.selecthotel = "false";
- ProfileManager.getInstance().setSelecthotel(MainMapActivity.this, "false");
- hotel = 0;
- ;
- }
- if (MainApplication.selectexpressway.equals("true")) {
- MainApplication.selectexpressway = "true";
- ProfileManager.getInstance().setSelectExpressway(MainMapActivity.this, "true");
- expressway = 2;
- } else {
- MainApplication.selectexpressway = "false";
- ProfileManager.getInstance().setSelectExpressway(MainMapActivity.this, "false");
- expressway = 0;
- ;
- }
- if (MainApplication.selectjingdian.equals("true")) {
- MainApplication.selectjingdian = "true";
- ProfileManager.getInstance().setKeySelectjingdian(MainMapActivity.this, "true");
- jingdian = 4;
- } else {
- MainApplication.selectjingdian = "false";
- ProfileManager.getInstance().setKeySelectjingdian(MainMapActivity.this, "false");
- jingdian = 0;
- ;
- }
- int total = hotel + expressway + jingdian;
- String num;
- if (total == 0) {
- num = "";
- } else {
- num = String.valueOf(total);
- }
- map.put("zhuang_num", num);
- if (ProfileManager.getInstance().getSupport(getApplicationContext()).equals("true")) {
- map.put("own_pay", "1");
- } else {
- map.put("own_pay", "");
- }
- String socket_string = JsonUtils.mapToJson(map);
- ete1(socket_string);
- } catch (Exception e) {
- }
- }
- }).start();
- }
- private void changeButton() {
- if (MainApplication.userTpye.equals("5") && MainApplication.mapStatus.equals("4") && MainApplication.shuxing.equals("") && MainApplication.sudu.equals("0") && MainApplication.costWay.equals("") && MainApplication.mianStop.equals("")) {
- iv_sceen.setImageResource(R.drawable.icon_screen_main);
- } else {
- iv_sceen.setImageResource(R.drawable.icon_screen_main_selected);
- }
- }
- public void updateZhanData(final String params) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- String host = "";
- if (MainApplication.url.contains("cdz.evcharge.cc")) {
- host = "cdz.evcharge.cc";
- } else {
- host = "59.110.68.162";
- }
- socket = new Socket(host, 9503);
- socket.setReceiveBufferSize(1000000000);
-
- PrintWriter out = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(socket.getOutputStream())), true);
- out.println(params);
-
-
- BufferedReader br = new BufferedReader(new InputStreamReader(
- socket.getInputStream()));
- String msg = br.readLine();
- if (null != msg) {
- Log.d("msg=====update", msg);
- String maxid = JsonUtils.getKeyResult(msg, "maxid");
- Log.e(TAG, "run: max_id=" + maxid);
- if (null != maxid && Integer.parseInt(maxid) > Integer.parseInt(MainApplication.logid)) {
- MainApplication.logid = maxid;
- ProfileManager.getInstance().setLogid(getApplicationContext(), maxid);
- String data = JsonUtils.getKeyResult(msg, "data");
- Log.e("updateZhanData===data", data);
- Gson g = new Gson();
- if (null != data) {
- Log.e(TAG, "run: 有更新");
- String add = JsonUtils.getKeyResult(data, "add");
- if (null != add) {
- if (!add.equals("")) {
- List<DataRefresh> list_add = g.fromJson(add, new TypeToken<List<DataRefresh>>() {
- }.getType());
- Log.e("list_add===", list_add.size() + "");
- addData(list_add);
- } else {
- }
- }
- String up = JsonUtils.getKeyResult(data, "up");
- if (null != up) {
- List<DataRefresh> list_up = g.fromJson(up, new TypeToken<List<DataRefresh>>() {
- }.getType());
- Log.e("list_up===", list_up.size() + "");
- upData(list_up);
- } else {
- }
- String del = JsonUtils.getKeyResult(data, "del");
- if (del != null) {
- List<DataRefresh> list_del = g.fromJson(del, new TypeToken<List<DataRefresh>>() {
- }.getType());
- Log.e("list_del===", list_del.size() + "");
- if (null != del || list_del.size() > 0) {
- delData(list_del);
- } else {
- }
- }
- } else {
- }
- } else {
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }).start();
- }
- private void eteLocation(final String params) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
-
-
- {
- String host = "";
- if (MainApplication.url.contains("cdz.evcharge.cc")) {
- host = "cdz.evcharge.cc";
- } else {
- host = "59.110.68.162";
- }
- socket = new Socket(host, 9503);
- PrintWriter out = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(socket.getOutputStream())), true);
- out.println(params);
-
-
- BufferedReader br = new BufferedReader(new InputStreamReader(
- socket.getInputStream()));
- String msg = br.readLine();
- if (msg != null) {
- Message mes = new Message();
- mes.obj = msg;
- mes.what = 5;
- hand.sendMessage(mes);
- }
-
- out.close();
- br.close();
-
- socket.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }).start();
- }
- public void ete1(final String params) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
-
-
- {
- String host = "";
- if (MainApplication.url.contains("cdz.evcharge.cc")) {
- host = "cdz.evcharge.cc";
- } else {
- host = "59.110.68.162";
- }
- socket = new Socket(host, 9503);
- socket.setReceiveBufferSize(99999);
- socket.setSendBufferSize(99999);
-
- PrintWriter out = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(socket.getOutputStream())), true);
- out.println(params);
-
-
- BufferedReader br = new BufferedReader(new InputStreamReader(
- socket.getInputStream()));
- String msg = br.readLine();
- if (msg != null) {
- Message mes = new Message();
- mes.obj = msg;
- mes.what = 3;
- hand.sendMessage(mes);
- }
- out.close();
- br.close();
-
- socket.close();
- }
- } catch (Exception e) {
- }
- }
- }).start();
- }
- public void ete2(final String params) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- String host = "";
- if (MainApplication.url.contains("cdz.evcharge.cc")) {
- host = "cdz.evcharge.cc";
- } else {
- host = "59.110.68.162";
- }
- socket = new Socket(host, 9503);
-
- PrintWriter out = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(socket.getOutputStream())), true);
- out.println(params);
-
-
- BufferedReader br = new BufferedReader(new InputStreamReader(
- socket.getInputStream()));
- String msg = br.readLine();
- if (msg != null) {
- Message mes = new Message();
- mes.obj = msg;
- mes.what = 2;
- hand.sendMessage(mes);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }).start();
- }
- private void getCommentNum(final String zhan_id) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- Request request = new Request.Builder().url(MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/getcont?zhanid=" + zhan_id).build();
- Response response = null;
- try {
- response = OkHttpUtil.execute(request);
- if (response.code() == 200) {
- String json = "";
- try {
- json = response.body().string();
- Message msg = new Message();
- msg.obj = json;
- msg.what = 1;
- hand.sendMessage(msg);
- } catch (Exception e) {
- e.printStackTrace();
- Message msg = new Message();
- msg.what = 2;
- hand.sendMessage(msg);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- Message msg = new Message();
- msg.what = 2;
- hand.sendMessage(msg);
- }
- }
- }).start();
- }
- public static String getMD5(String content) {
- try {
- MessageDigest digest = MessageDigest.getInstance("MD5");
- digest.update(content.getBytes());
- return getHashString(digest);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- private static String getHashString(MessageDigest digest) {
- StringBuilder builder = new StringBuilder();
- for (byte b : digest.digest()) {
- builder.append(Integer.toHexString((b >> 4) & 0xf));
- builder.append(Integer.toHexString(b & 0xf));
- }
- return builder.toString().toLowerCase();
- }
- private Bitmap getMarkerBmpYes(int i) {
- if (i == 1) {
- mIvMarkerBgYes.setImageResource(R.drawable.icon_sgreen);
- } else if (i == 2) {
- mIvMarkerBgYes.setImageResource(R.drawable.icon_bgreen);
- } else if (i == 3) {
- mIvMarkerBgYes.setImageResource(R.drawable.icon_sorange);
- } else if (i == 4) {
- mIvMarkerBgYes.setImageResource(R.drawable.icon_borange);
- } else if (i == 5) {
- mIvMarkerBgYes.setImageResource(R.drawable.icon_sgift);
- } else if (i == 6) {
- mIvMarkerBgYes.setImageResource(R.drawable.icon_bgift);
- } else if (i == 7) {
- mIvMarkerBgYes.setImageResource(R.drawable.icon_sblue);
- } else if (i == 8) {
- mIvMarkerBgYes.setImageResource(R.drawable.icon_bblue);
- }
- Bitmap bmp = getBitmapFromView(mMarkerViewYes);
- return bmp;
- }
- private Bitmap getMarkerBmp(int num) {
- mIvMarkerBg.setImageResource(R.drawable.icon_konglog1105);
- if (num > 10) {
- mTvMarkerViewNum.setText(Integer.toString(num));
- } else {
- mTvMarkerViewNum.setText(Integer.toString(num));
- }
- Bitmap bmp = getBitmapFromView(mMarkerView);
- return bmp;
- }
- private Bitmap getMarkerApps(int num) {
- mIvMarkerAppS.setImageResource(R.drawable.icon_sapp);
- if (num > 10) {
- mTvMarkerViewNumAppS.setText(Integer.toString(num));
- } else {
- mTvMarkerViewNumAppS.setText(Integer.toString(num));
- }
- Bitmap bmp = getBitmapFromView(mMarkerViewAppS);
- return bmp;
- }
- private Bitmap getMarkerAppb(int num) {
- mIvMarkerAppB.setImageResource(R.drawable.icon_bapp);
- if (num > 10) {
- mTvMarkerViewNumAppB.setText(Integer.toString(num));
- } else {
- mTvMarkerViewNumAppB.setText(Integer.toString(num));
- }
- Bitmap bmp = getBitmapFromView(mMarkerViewAppB);
- return bmp;
- }
- private Bitmap getMarkerBmp1(int num) {
- mIvMarkerBg1.setImageResource(R.drawable.icon_konglogb);
- if (num > 10) {
- mTvMarkerViewNum1.setText(Integer.toString(num));
- } else {
- mTvMarkerViewNum1.setText(Integer.toString(num));
- }
- Bitmap bmp = getBitmapFromView(mMarkerView1);
- return bmp;
- }
- private Bitmap getMarkerBmpCity(String num) {
- String no = num;
- mIvMarkerBgcity.setImageResource(R.drawable.icon_cityno);
- mTvMarkerViewNumcity.setText(no);
- Bitmap bmp = getBitmapFromView(mMarkerViewcity);
- return bmp;
- }
- public static Bitmap getBitmapFromView(View view) {
- view.destroyDrawingCache();
- view.measure(View.MeasureSpec.makeMeasureSpec(0,
- View.MeasureSpec.UNSPECIFIED), View.MeasureSpec
- .makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
- view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
- view.setDrawingCacheEnabled(true);
- Bitmap tmp = view.getDrawingCache();
- Bitmap bitmap = tmp.copy(Bitmap.Config.ARGB_8888, false);
- tmp.recycle();
- return bitmap;
- }
- @Override
- public void onClick(View v) {
- SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
- switch (v.getId()) {
- case R.id.iv_tuijian:
- if (null != center) {
- MobclickAgent.onEvent(getApplicationContext(), "0111");
- Intent i = new Intent(getApplicationContext(), RecommendZhanActivity.class);
- i.putExtra("center_jing", String.valueOf(center.longitude));
- i.putExtra("center_wei", String.valueOf(center.latitude));
- startActivity(i);
- } else {
- ToastUtil.showToast(getApplicationContext(), "没有获取到您当前的位置,请检查网络或定位权限", Toast.LENGTH_SHORT);
- }
- MobclickAgent.onEvent(context, "0068");
- break;
- case R.id.iv_clear_address:
- tv_search.setText("请输入地址/关键字");
- iv_clear_address.setVisibility(View.INVISIBLE);
- ProfileManager.getInstance().setSearchAddress(this, "");
- MainApplication.search_jing = 0.0;
- MainApplication.search_wei = 0.0;
- ete("{\"fun\":\"timer\"}");
- if (search_marker != null) {
- search_marker.remove();
- }
- break;
- case R.id.iv_example:
- MobclickAgent.onEvent(getApplicationContext(), "0114");
- Intent intent_example = new Intent(getApplicationContext(), ExampleActivity.class);
- intent_example.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent_example);
- overridePendingTransition(0, 0);
- break;
- case R.id.iv_bg_example:
- break;
- case R.id.tv_sortDistance:
- MobclickAgent.onEvent(getApplicationContext(), "0057");
- sortTye = 1;
- tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
- tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
- tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
- tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
- if (list1.size() > 0) {
- list.clear();
- list.addAll(list1);
- adapter.notifyDataSetChanged();
- } else {
- list.clear();
- list = Util.getSortList(listt);
- adapter.notifyDataSetChanged();
- }
- break;
- case R.id.tv_sortStarLevel:
- MobclickAgent.onEvent(getApplicationContext(), "0058");
- sortTye = 2;
- tv_sortDistance.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortDistance.setBackgroundColor(getResources().getColor(R.color.white));
- tv_sortStarLevel.setTextColor(getResources().getColor(R.color.lvse));
- tv_sortStarLevel.setBackgroundResource(R.drawable.bg_lv);
- tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
- if (list2.size() > 0) {
- list.clear();
- list.addAll(list2);
- adapter.notifyDataSetChanged();
- } else {
- list.clear();
- list = Util.getSortPFList(listt);
- adapter.notifyDataSetChanged();
- }
- break;
- case R.id.tv_sortFreeTime:
- MobclickAgent.onEvent(getApplicationContext(), "0059");
- sortTye = 3;
- tv_sortDistance.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortDistance.setBackgroundColor(getResources().getColor(R.color.white));
- tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
- tv_sortFreeTime.setTextColor(getResources().getColor(R.color.lvse));
- tv_sortFreeTime.setBackgroundResource(R.drawable.bg_lv);
- if (list3.size() > 0) {
- list.clear();
- list.addAll(list3);
- adapter.notifyDataSetChanged();
- } else {
- list.clear();
- list = Util.getSortFTList(listt);
- adapter.notifyDataSetChanged();
- }
- break;
- case R.id.iv_route:
- startActivity(new Intent(getApplication(), RoutePlanShowAddressActivity.class));
- MobclickAgent.onEvent(getApplicationContext(), "0112");
- break;
- case R.id.second_hand_car:
- Intent adfloatIntent = new Intent(this, MyWebViewActivity.class);
- adfloatIntent.putExtra("url", adfloatUrl);
- startActivity(adfloatIntent);
- break;
- case R.id.iv_roadCondition:
- MobclickAgent.onEvent(getApplicationContext(), "0113");
- if (ProfileManager.getInstance().getRoadCondition(getApplicationContext()) == false) {
- iv_roadCondition.setImageResource(R.drawable.icon_youlukuang_main);
- ProfileManager.getInstance().setRoadCondition(this, true);
- aMap.setTrafficEnabled(true);
- ToastUtil.showToast(this, "实时路况已打开", Toast.LENGTH_SHORT);
- MobclickAgent.onEvent(getApplicationContext(), "0066");
- } else {
- iv_roadCondition.setImageResource(R.drawable.icon_wulukuang_main);
- ProfileManager.getInstance().setRoadCondition(this, false);
- aMap.setTrafficEnabled(false);
- ToastUtil.showToast(this, "实时路况已关闭", Toast.LENGTH_SHORT);
- MobclickAgent.onEvent(getApplicationContext(), "0067");
- }
- break;
- case R.id.zoomin:
- aMap.moveCamera(CameraUpdateFactory.zoomIn());
- controlZoomShow();
- break;
- case R.id.zoomout:
- aMap.moveCamera(CameraUpdateFactory.zoomOut());
- controlZoomShow();
- break;
-
- case R.id.iv_list:
- sharedPreferencesUtil.putBoolean("cdz_recommend_more_detail", true);
- String jing, wei;
- if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
- Log.e(TAG, "onClick: 有搜索");
- jing = String.valueOf(MainApplication.search_jing);
- wei = String.valueOf(MainApplication.search_wei);
- } else {
- Log.e(TAG, "onClick: 当前位置");
- if (null == center) {
- ToastUtil.showToast(getApplicationContext(), "请确认当前定位是否可用", Toast.LENGTH_SHORT);
- break;
- } else {
- jing = String.valueOf(center.longitude);
- wei = String.valueOf(center.latitude);
- }
- }
- if (null != jing && null != wei) {
- MobclickAgent.onEvent(getApplicationContext(), "1135");
- Intent intent = new Intent(getApplicationContext(), RecommendChargingStationActivity.class);
- intent.putExtra("center_jing", jing);
- intent.putExtra("center_wei", wei);
- startActivity(intent);
- }
- break;
-
- case R.id.iv_point_again:
- if (!isFirstLoc) {
- isFirstLoc = true;
- mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
- aMap.setLocationSource(this);
- aMap.setMyLocationEnabled(true);
- aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
- mlocationClient.startLocation();
- }
- windowLayout.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- ll_open.setVisibility(View.GONE);
- break;
-
- case R.id.tv_person:
- windowLayout.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- if (nMarker != null) {
- nMarker.hideInfoWindow();
- MarkerOptions markerOptionss = new MarkerOptions();
- if (current_chargePoint.getOwn_pay().equals("1")) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
- } else {
- if (current_chargePoint.getSuit_car().equals("特斯拉")) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
- } else {
- if (WelcomeActivity.canCost.contains(current_chargePoint.getSupplier())) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
- } else {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
- }
- }
- }
- }
- Intent intent = new Intent(getApplication(), NewScreenActivity.class);
- startActivity(intent);
- MobclickAgent.onEvent(getApplicationContext(), "0110");
- break;
- case R.id.tv_shaixuan:
- isListShow = true;
- windowLayout.setVisibility(View.GONE);
- if (null != current_chargePoint) {
- resetMarker();
- }
- MobclickAgent.onEvent(getApplicationContext(), "0110");
- Intent intentt = new Intent(getApplication(), NewScreenActivity.class);
- startActivity(intentt);
- break;
- case R.id.tv_switch_city:
- if (isListShow == false) {
- windowLayout.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- }
- if (null != current_chargePoint) {
- resetMarker();
- }
- MobclickAgent.onEvent(getApplicationContext(), "0107");
- startActivity(new Intent(getApplicationContext(), NewSelectCityActivity.class));
- if (ll_tuijian.getVisibility() == View.VISIBLE) {
- ll_tuijian.setVisibility(View.GONE);
- rl_tuijian_tip.setVisibility(View.VISIBLE);
- ll_top_right.setVisibility(View.VISIBLE);
- ll_map_control.setVisibility(View.VISIBLE);
- }
- break;
- case R.id.tab_screening:
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- if (!MainApplication.isLogin()) {
- startActivity(new Intent(getApplication(), LoginActivity.class));
- } else if (!cameraTask()) {
- EasyPermissions.requestPermissions(
- this,
- "该功能需要开启摄像头权限,是否前往开启?",
- RC_CAMERA_PERM,
- Manifest.permission.CAMERA);
- } else {
- Intent iintent = new Intent(getApplicationContext(), com.google.zxing.client.android.CaptureActivity.class);
- iintent.putExtra("url", MainApplication.url);
- iintent.putExtra("user_id", MainApplication.userId);
- iintent.putExtra("user_password", MainApplication.userPassword);
- iintent.putExtra("user_phone", ProfileManager.getInstance().getUsername(getApplicationContext()));
- LogUtils.e(ProfileManager.getInstance().getUsername(getApplicationContext()));
- iintent.putExtra("cha", MainMapActivity.cha);
- iintent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(iintent);
- overridePendingTransition(0, 0);
- if (count == 1) {
- MobclickAgent.onEvent(getApplicationContext(), "0104");
- count = 2;
- }
- }
- break;
-
- case R.id.ll_tab_find:
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- Intent intent1 = new Intent(getApplication(), FindActivity.class);
- intent1.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent1);
- overridePendingTransition(0, 0);
- if (count == 1) {
- MobclickAgent.onEvent(getApplicationContext(), "0105");
- count = 2;
- }
- break;
- case R.id.tab_qa:
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- Intent i = new Intent(getApplication(), ChatActivity.class);
- i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(i);
- overridePendingTransition(0, 0);
- if (count == 1) {
- MobclickAgent.onEvent(getApplicationContext(), "0999");
- count = 2;
- }
- break;
-
- case R.id.tab_me:
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- Intent intent2 = new Intent(getApplication(), UserCenterActivity.class);
- intent2.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent2);
- if (sav.getVisibility() == View.VISIBLE) {
- sav.setVisibility(View.GONE);
- }
- overridePendingTransition(0, 0);
- if (count == 1) {
- MobclickAgent.onEvent(getApplicationContext(), "0106");
- count = 2;
- }
- break;
- case R.id.iv_clear:
- rl_ad.setVisibility(View.GONE);
- break;
- case R.id.rl_search:
- if (isListShow == false) {
- windowLayout.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- }
- if (null != current_chargePoint) {
- resetMarker();
- }
- MobclickAgent.onEvent(getApplicationContext(), "0108");
- startActivityForResult(new Intent(getApplication(), SearchActivity.class), SEARCH_CODE);
- if (ll_tuijian.getVisibility() == View.VISIBLE) {
- ll_tuijian.setVisibility(View.GONE);
- rl_tuijian_tip.setVisibility(View.VISIBLE);
- ll_top_right.setVisibility(View.VISIBLE);
- ll_map_control.setVisibility(View.VISIBLE);
- }
- break;
- default:
- break;
- }
- }
- public void showMap() {
- if (MainApplication.isMap) {
- if (list.size() == 0) {
- ete("{\"fun\":\"timer\"}");
- }
- MainApplication.isMap = false;
-
- lvZhan.setVisibility(View.VISIBLE);
- isListShow = true;
- if (list.size() > 0) {
- rl_mapList.setVisibility(View.VISIBLE);
- tv_tishi.setVisibility(View.GONE);
- } else if (list.size() == 0) {
- rl_mapList.setVisibility(View.VISIBLE);
- tv_tishi.setVisibility(View.VISIBLE);
- }
- iv_sceen.setVisibility(View.GONE);
- iv_example.setVisibility(View.GONE);
- if (windowLayout.getVisibility() == View.VISIBLE) {
- paoShow = true;
- windowLayout.setVisibility(View.GONE);
- } else {
- rl_control.setVisibility(View.GONE);
- }
- iv_roadCondition.setVisibility(View.GONE);
- MobclickAgent.onEvent(getApplicationContext(), "0063");
- } else {
-
- MainApplication.isMap = true;
- lvZhan.setVisibility(View.GONE);
- rl_mapList.setVisibility(View.GONE);
- tv_tishi.setVisibility(View.GONE);
- if (paoShow == true && isListShow == false) {
- windowLayout.setVisibility(View.VISIBLE);
- rl_control.setVisibility(View.GONE);
- paoShow = false;
- } else {
- rl_control.setVisibility(View.VISIBLE);
- }
- isListShow = false;
- iv_sceen.setVisibility(View.VISIBLE);
- iv_example.setVisibility(View.VISIBLE);
- sortTye = 1;
- tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
- tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
- tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
- tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
- iv_roadCondition.setVisibility(View.VISIBLE);
- }
- }
- private void showUi(boolean status) {
- if (status == true) {
- lvZhan.setVisibility(View.GONE);
- rl_mapList.setVisibility(View.GONE);
- tv_tishi.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- iv_sceen.setVisibility(View.VISIBLE);
- sortTye = 1;
- tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
- tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
- tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
- tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
- tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
- iv_roadCondition.setVisibility(View.VISIBLE);
- iv_example.setVisibility(View.VISIBLE);
- } else {
- lvZhan.setVisibility(View.VISIBLE);
- if (list.size() > 0) {
- rl_mapList.setVisibility(View.VISIBLE);
- tv_tishi.setVisibility(View.GONE);
- } else if (list.size() == 0) {
- rl_mapList.setVisibility(View.VISIBLE);
- tv_tishi.setVisibility(View.VISIBLE);
- }
- rl_control.setVisibility(View.GONE);
- iv_sceen.setVisibility(View.GONE);
- if (windowLayout.getVisibility() == View.VISIBLE) {
- windowLayout.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- ll_open.setVisibility(View.GONE);
- }
- iv_roadCondition.setVisibility(View.GONE);
- iv_example.setVisibility(View.GONE);
- }
- }
- @Override
- public void onMapLoaded() {
- aMap.setMyLocationEnabled(true);
-
- aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
- aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
- }
- @Override
- public void onCameraChange(CameraPosition cameraPosition) {
- }
- @Override
- public void onCameraChangeFinish(CameraPosition cameraPosition) {
- }
- @Override
- public void onMapClick(LatLng latLng) {
- float zoom = aMap.getCameraPosition().zoom;
- aMap.moveCamera(CameraUpdateFactory.zoomTo(zoom));
- Animation animation = AnimationUtils.loadAnimation(this, R.anim.out);
- animation.setDuration(500);
- windowLayout.startAnimation(animation);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- windowLayout.setVisibility(View.GONE);
- }
- }, 500);
- SharedPreferencesUtil sharedPreferencesUtil1 = new SharedPreferencesUtil(getApplication());
- sharedPreferencesUtil1.setFileName("CurrentMarkerInfo");
- sharedPreferencesUtil1.clearData();
- rl_control.setVisibility(View.VISIBLE);
- ll_open.setVisibility(View.GONE);
- }
- @Override
- public void onWeatherLiveSearched(LocalWeatherLiveResult weatherLiveResult, int rCode) {
- if (rCode == 1000) {
- if (weatherLiveResult != null & weatherLiveResult.getLiveResult() != null) {
- LocalWeatherLive weatherlive = weatherLiveResult.getLiveResult();
- } else {
- }
- } else {
- ToastUtil.showToast(MainMapActivity.this, rCode + "", Toast.LENGTH_SHORT);
- }
- }
- @Override
- public void onWeatherForecastSearched(LocalWeatherForecastResult localWeatherForecastResult, int i) {
- if (i == 1000) {
- if (localWeatherForecastResult != null & localWeatherForecastResult.getForecastResult() != null) {
- LocalWeatherForecast weatherlive = localWeatherForecastResult.getForecastResult();
- Log.e(TAG, "onWeatherLiveSearched: " + "-------" + weatherlive.getCity() + "-------" + weatherlive.getAdCode()
- + "-------" + weatherlive.getWeatherForecast() + "-------" + weatherlive.getProvince() + "-------" + weatherlive.getReportTime());
- List<LocalDayWeatherForecast> list = weatherlive.getWeatherForecast();
- list.get(0).getDate();
- for (int a = 0; a < list.size(); a++) {
- Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDate());
- Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDayTemp());
- Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDayWeather());
- Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getNightTemp());
- Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getNightWeather());
- }
- } else {
- }
- } else {
- }
- }
- @Override
- public void onPermissionsGranted(int requestCode, List<String> perms) {
- if (requestCode == RC_CAMERA_PERM) {
- Intent iintent = new Intent(getApplicationContext(), com.google.zxing.client.android.CaptureActivity.class);
- iintent.putExtra("url", MainApplication.url);
- iintent.putExtra("user_id", MainApplication.userId);
- iintent.putExtra("user_password", MainApplication.userPassword);
- iintent.putExtra("user_phone", MainApplication.userPhone);
- iintent.putExtra("cha", MainMapActivity.cha);
- iintent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(iintent);
- overridePendingTransition(0, 0);
- }
- }
- @Override
- public void onPermissionsDenied(int requestCode, List<String> perms) {
- for (String s : perms) {
- LogUtils.e(s);
- }
- if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
- new AppSettingsDialog.Builder(MainMapActivity.this).build().show();
-
- }
- }
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
- }
- private boolean hasCameraPermission() {
- return EasyPermissions.hasPermissions(this, Manifest.permission.CAMERA);
- }
- private boolean isPermissionOK() {
- return EasyPermissions.hasPermissions(this,
- Manifest.permission.CAMERA,
- Manifest.permission.WRITE_EXTERNAL_STORAGE,
- Manifest.permission.READ_EXTERNAL_STORAGE
- );
- }
- @AfterPermissionGranted(RC_SAVE_PERM)
- public boolean saveTask() {
- if (isPermissionOK()) {
-
- return true;
- } else {
-
- return false;
- }
- }
- @AfterPermissionGranted(RC_CAMERA_PERM)
- public boolean cameraTask() {
- if (hasCameraPermission()) {
-
- return true;
- } else {
-
- return false;
- }
- }
- @Override
- public boolean onMarkerClick(Marker marker) {
- return false;
- }
-
- * 监听自定义infowindow窗口的infowindow时间回调
- * add by hyg
- *
- * @param marker
- * @return
- */
- @Override
- public View getInfoWindow(Marker marker) {
- if (infoWindow == null) {
- infoWindow = getLayoutInflater().inflate(R.layout.custom_info_window, null);
- }
- return infoWindow;
- }
- @Override
- public View getInfoContents(Marker marker) {
- return null;
- }
-
- * 自定义infowindow窗口
- * 如果想修改自定义Infow中内容,请通过view找到它并修改
- */
- public void updateInfoWindow(String text) {
- if (nMarker == null) {
- return;
- }
- if (infoWindow == null) {
- return;
- }
- infoWindow.findViewById(R.id.infoWindowNavigate).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- MobclickAgent.onEvent(getApplicationContext(), "1120");
- infoViewNavigate();
- }
- });
- TextView distance = infoWindow.findViewById(R.id.distance);
- distance.setText(text);
- }
-
- * 点击自定义气泡,进行导航操作
- * add by hyg
- *
- * @param marker
- */
- @Override
- public void onInfoWindowClick(Marker marker) {
- }
- public class ZhanAdapter extends BaseAdapter {
- @Override
- public int getCount() {
- if (list.size() > 30) {
- return 30;
- } else {
- return list.size();
- }
- }
- @Override
- public Object getItem(int position) {
- return list.get(position);
- }
- @Override
- public long getItemId(int position) {
- return position;
- }
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- ViewHolder viewHolder = null;
- if (convertView == null) {
- convertView = LayoutInflater.from(getApplication()).inflate(
- R.layout.item_zhandian, null);
- viewHolder = new ViewHolder();
- viewHolder.item_zhan_name = (TextView) convertView.findViewById(R.id.item_zhan_name);
- viewHolder.item_zhan_go = (TextView) convertView.findViewById(R.id.item_zhan_go);
- viewHolder.item_zhan_distance = (TextView) convertView.findViewById(R.id.item_zhan_distance);
- viewHolder.item_zhan_cost = (TextView) convertView.findViewById(R.id.item_zhan_cost);
- viewHolder.item_fast_num = (TextView) convertView.findViewById(R.id.item_fast_num);
- viewHolder.item_fastable = (TextView) convertView.findViewById(R.id.item_fastable);
- viewHolder.item_fastable_num = (TextView) convertView.findViewById(R.id.item_fastable_num);
- viewHolder.item_slowable = (TextView) convertView.findViewById(R.id.item_slowable);
- viewHolder.item_slowable_num = (TextView) convertView.findViewById(R.id.item_slowable_num);
- viewHolder.item_slow_num = (TextView) convertView.findViewById(R.id.item_slow_num);
- viewHolder.item_grade_pic = (ImageView) convertView.findViewById(R.id.item_grade_pic);
- viewHolder.item_layout = (LinearLayout) convertView.findViewById(R.id.item_layout);
- convertView.setTag(viewHolder);
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
- if (list.size() > 0) {
- viewHolder.item_zhan_name.setText(list.get(position).getZhan_name());
- if (list.get(position).getStar_level().equals("") || list.get(position).getStar_level().equals("0")) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_0xing);
- } else {
- String star_level = list.get(position).getStar_level().toString();
- double d;
- d = Double.parseDouble(star_level);
- String grade = String.format("%.1f", d);
- if (d > 0 && d < 1) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_05xing);
- } else if (d >= 1 && d < 1.5) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_1xing);
- } else if (d >= 1.5 && d < 2) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_15xing);
- } else if (d >= 2 && d < 2.5) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_2xing);
- } else if (d >= 2.5 && d < 3) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_25xing);
- } else if (d >= 3 && d < 3.5) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_3xing);
- } else if (d >= 3.5 && d < 4) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_35xing);
- } else if (d >= 4 && d < 4.5) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_4xing);
- } else if (d >= 4.5 && d < 5) {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_45xing);
- } else {
- viewHolder.item_grade_pic.setImageResource(R.drawable.icon_5xing);
- }
- }
- if (list.get(position).getOwn_pay().equals("1")) {
- viewHolder.item_zhan_cost.setText("可使用本APP扫码支付");
- } else {
- if (list.get(position).getCharge_cost_way2().equals("")) {
- viewHolder.item_zhan_cost.setText("暂无");
- } else {
- if (list.get(position).getCharge_cost_way2().equals("微信支付")) {
- viewHolder.item_zhan_cost.setText(list.get(position).getCharge_cost_way2());
- } else {
- viewHolder.item_zhan_cost.setText(list.get(position).getCharge_cost_way2() + "支付");
- }
- }
- }
- String fast = list.get(position).getFast_num();
- String slow = list.get(position).getSlow_num();
- String acNum = null, dcNum = null, acableNum = null, dcableNum = null;
- acNum = list.get(position).getAcNum();
- dcNum = list.get(position).getDcNum();
- acableNum = list.get(position).getAcableNum();
- dcableNum = list.get(position).getDcableNum();
- if (null != acableNum && null != acNum
- && null != dcableNum && null != dcNum && !acableNum.equals("")
- && !acNum.equals("") && !dcableNum.equals("") && !dcNum.equals("")) {
- viewHolder.item_fast_num.setText(dcNum);
- viewHolder.item_fastable_num.setText(dcableNum);
- viewHolder.item_fastable.setVisibility(View.VISIBLE);
- viewHolder.item_fastable_num.setVisibility(View.VISIBLE);
- viewHolder.item_slow_num.setText(acNum);
- viewHolder.item_slowable_num.setText(acableNum);
- viewHolder.item_slowable.setVisibility(View.VISIBLE);
- viewHolder.item_slowable_num.setVisibility(View.VISIBLE);
- } else {
- viewHolder.item_fast_num.setText(fast);
- viewHolder.item_fastable.setVisibility(View.GONE);
- viewHolder.item_fastable_num.setVisibility(View.GONE);
- viewHolder.item_slow_num.setText(slow);
- viewHolder.item_slowable.setVisibility(View.GONE);
- viewHolder.item_slowable_num.setVisibility(View.GONE);
- }
- if ("0m".equals(list.get(position).getDistance())) {
- viewHolder.item_zhan_distance.setText("未知");
- } else {
- viewHolder.item_zhan_distance.setText(list.get(position).getDistance());
- }
- viewHolder.item_zhan_go.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- MobclickAgent.onEvent(getApplicationContext(), "0060");
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
- !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", gd_jing + "");
- intent.putExtra("stop_wei", gd_wei + "");
- startActivity(intent);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", list.get(position).getZhan_name());
- map.put("CostWay", list.get(position).getCharge_cost_way());
- map.put("City", list.get(position).getCity());
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- } else {
- if (center != null) {
- LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
- popupWindow = new PopupWindow(popupWindowView,
- ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
- true);
- popupWindow.setBackgroundDrawable(new BitmapDrawable());
-
- popupWindow.setAnimationStyle(R.style.popupAnimation);
- LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
- if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- ll_tvTwo.setVisibility(View.GONE);
- }
- LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
- ll_tvOne.setVisibility(View.GONE);
- }
- cancleButton = (Button) popupWindowView
- .findViewById(R.id.cancleButton);
- cancleButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- popupWindow.dismiss();
- }
- });
- tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
- tvThree.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", gd_jing + "");
- intent.putExtra("stop_wei", gd_wei + "");
- startActivity(intent);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", list.get(position).getZhan_name());
- map.put("CostWay", list.get(position).getCharge_cost_way());
- map.put("City", list.get(position).getCity());
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- }
- });
- tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
- tvOne.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = null;
- double dwei = Double.parseDouble(list.get(position).getPoi_wei());
- double djing = Double.parseDouble(list.get(position).getPoi_jing());
- getBaidu(center.longitude, center.latitude);
- try {
- String s = "intent://map/direction?" +
- "origin=" + bd_lat + "," + bd_lon + "&" +
- "destination=" + dwei + "," + djing +
- "&mode=driving&" +
- "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
- intent = Intent.getIntent(s);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", list.get(position).getZhan_name());
- map.put("CostWay", list.get(position).getCharge_cost_way());
- map.put("City", list.get(position).getCity());
- MobclickAgent.onEvent(context, "0031", map);
- map.clear();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- startActivity(intent);
- popupWindow.dismiss();
- }
- });
- tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
- tvTwo.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- try {
- getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
- Intent intent4 = new Intent("android.intent.action.VIEW",
- 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"));
- intent4.setPackage("com.autonavi.minimap");
- startActivity(intent4);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", list.get(position).getZhan_name());
- map.put("CostWay", list.get(position).getCharge_cost_way());
- map.put("City", list.get(position).getCity());
- MobclickAgent.onEvent(context, "0032", map);
- map.clear();
- } catch (Exception e) {
- e.printStackTrace();
- Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
- }
- }
- });
- popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
- } else {
- Toast.makeText(getApplication(),
- "没有定位到您的当前位置", Toast.LENGTH_SHORT)
- .show();
- }
- }
- }
- });
- }
- return convertView;
- }
- class ViewHolder {
- TextView item_zhan_name, item_zhan_go, item_zhan_distance, item_zhan_cost, item_fast_num, item_fastable, item_fastable_num,
- item_slowable, item_slowable_num, item_slow_num;
- ImageView item_grade_pic;
- LinearLayout item_layout;
- }
- }
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
-
- if (windowLayout.getVisibility() == View.VISIBLE) {
- Animation animation = AnimationUtils.loadAnimation(this, R.anim.out);
- animation.setDuration(500);
- windowLayout.startAnimation(animation);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- windowLayout.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- }
- }, 500);
- return false;
- }
- if ((System.currentTimeMillis() - exitTime) > 2000) {
- Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
- exitTime = System.currentTimeMillis();
- } else {
- if (MainMapActivity.mainMapActivity != null) {
- MainMapActivity.mainMapActivity.finish();
- }
- SharedPreferences mySharedPreferences = getSharedPreferences("showdialog",
- Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor1 = mySharedPreferences.edit();
- editor1.clear();
- ProfileManager.getInstance().setSearchAddress(this, "");
- ActivityUtils.finishAllActivities();
- android.os.Process.killProcess(android.os.Process.myPid());
- }
- }
- return true;
- }
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (isListShow == false) {
- windowLayout.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- }
- if (requestCode == SEARCH_CODE && resultCode == 101) {
- double jing = Double.valueOf(data.getStringExtra("jing"));
- double wei = Double.valueOf(data.getStringExtra("wei"));
- MainApplication.search_jing = jing;
- MainApplication.search_wei = wei;
- final LatLng screenCity = new LatLng(wei, jing);
- aMap = mapView.getMap();
- Util.setMapCustomStyleFile(aMap, getApplicationContext());
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
- }
- }, 500);
- if (search_marker != null) {
- search_marker.remove();
- }
- if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
- LatLng latLng = new LatLng(MainApplication.search_wei, MainApplication.search_jing);
- search_marker = aMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.icon_search_address))));
- search_marker.setPeriod(8);
- }
- ete("{\"fun\":\"timer\"}");
- } else if (requestCode == SEARCH_CODE && resultCode == 102) {
- double jing = Double.valueOf(data.getStringExtra("jing"));
- double wei = Double.valueOf(data.getStringExtra("wei"));
- final LatLng screenCity = new LatLng(wei, jing);
- aMap = mapView.getMap();
- Util.setMapCustomStyleFile(aMap, getApplicationContext());
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
- }
- }, 500);
- }
- }
- private void dialogup() {
- int code = Integer.parseInt(now_versionCode);
- if (code - getVersionCode(getApplication()) > 0) {
- new AlertDialogUpdate(MainMapActivity.this).builder()
- .setTitle("更新提示 " + now_versionName)
- .setMsg(title.trim())
- .setPositiveButton("更新", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent();
- intent.setAction("android.intent.action.VIEW");
- Uri content_url = Uri.parse("http://cdz.evcharge.cc/app/app.apk");
- intent.setData(content_url);
- startActivity(intent);
- }
- }).setNegativeButton("忽略", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- }
- }).show();
- }
- }
- private void showProgressWindow() {
- updateDialog = new UpdateDialog(MainMapActivity.this);
- updateDialog.builder().setMsg("").setCancelable(false).show();
- }
- private void dialogup_other() {
- int code = Integer.parseInt(now_versionCode);
- if (code - getVersionCode(getApplication()) > 0) {
- alterDialog = new AlertDialogUpdate(MainMapActivity.this);
- alterDialog.builder()
- .setTitle("更新提示 " + now_versionName)
- .setMsg(title.trim())
- .setPositiveButton("更新", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showProgressWindow();
- ToastUtil.showToast(getApplicationContext(), "正在下载中", Toast.LENGTH_SHORT);
- OkHttpUtils.get().url("http://cdz.evcharge.cc/app/app.apk").build()
- .execute(new FileCallBack(Environment.getExternalStorageDirectory().getAbsolutePath(), "cdz_install") {
- @Override
- public void inProgress(final float progress, long total) {
- NumberFormat numberFormat = NumberFormat.getInstance();
-
- numberFormat.setMaximumFractionDigits(2);
- String format = numberFormat.format(progress * 100);
- Message message = new Message();
- message.what = 0x01;
- Bundle bundle = new Bundle();
- bundle.putString("format", format + "%");
- LogUtils.e("当前:" + format);
- if (!format.contains(".")) {
- bundle.putString("progress", format + ".");
- } else {
- bundle.putString("progress", format);
- }
- message.setData(bundle);
- myHandler.sendMessage(message);
- }
- @Override
- public void onError(Call call, Exception e) {
- }
- @Override
- public void onResponse(File response) {
- String path = getDatabasePath("zhan_list").getPath();
- com.blankj.utilcode.util.LogUtils.e(path);
- AppUtils.cleanAppData(path);
- Intent intent = new Intent();
- intent.setAction(android.content.Intent.ACTION_VIEW);
- Uri uri;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- Uri contentUri = FileProvider.getUriForFile(context,
- context.getApplicationContext().getPackageName() + ".provider",
- response);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
- } else {
- uri = Uri.fromFile(response);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setDataAndType(uri, "application/vnd.android.package-archive");
- }
- context.startActivity(intent);
- android.os.Process.killProcess(android.os.Process.myPid());
- }
- });
- }
- }).setNegativeButton("退出", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- SharedPreferences mySharedPreferences = getSharedPreferences("showdialog",
- Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor1 = mySharedPreferences.edit();
- editor1.clear();
- finish();
- ProfileManager.getInstance().setSearchAddress(getApplicationContext(), "");
- android.os.Process.killProcess(android.os.Process.myPid());
- }
- }).setCancelable(false).show();
- }
- }
- public static int getVersionCode(Context context)
- {
- try {
- PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
- return pi.versionCode;
- } catch (PackageManager.NameNotFoundException e) {
-
- e.printStackTrace();
- return 0;
- }
- }
- public void getVersion() {
- try {
- PackageManager manager = getApplication().getPackageManager();
- PackageInfo info = manager.getPackageInfo(getApplication().getPackageName(), 0);
- app_version = info.versionName;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private void getPingLun() {
- new Thread(new Runnable() {
- @Override
- public void run() {
- String url = null;
- try {
- url = MainApplication.url + "/zhannew/basic/web/index.php/tpmember/commentcount?userid=" + MainApplication.userId;
- } catch (Exception e) {
- e.printStackTrace();
- }
- submitPingLun(url);
- }
- }).start();
- }
- private void submitPingLun(String sms) {
- Request request = new Request.Builder().url(sms).build();
- Response response = null;
- try {
- if (request == null) {
- Message msg = new Message();
- msg.what = 5;
- hand.sendMessage(msg);
- return;
- }
- response = OkHttpUtil.execute(request);
- if (response.code() == 200) {
- String json = "";
- try {
- json = response.body().string();
- Message msg = new Message();
- msg.obj = json;
- msg.what = 17;
- hand.sendMessage(msg);
- } catch (Exception e) {
- e.printStackTrace();
- Message msg = new Message();
- msg.what = 5;
- hand.sendMessage(msg);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- Message msg = new Message();
- msg.what = 5;
- hand.sendMessage(msg);
- }
- }
-
- private void getMessage() {
- new Thread(new Runnable() {
- @Override
- public void run() {
- long appTime1 = System.currentTimeMillis() / 1000;
- String token = String.valueOf(appTime1);
- String url = null;
- if (MainApplication.msgTime.equals("0")) {
- MainApplication.firstOpenTime = token;
- ProfileManager.getInstance().setFirstOpenTime(getApplicationContext(), token);
- MainApplication.msgTime = token;
- ProfileManager.getInstance().setSystemMsgTime(getApplicationContext(), token);
- }
- try {
- url = MainApplication.url + "/zhannew/basic/web/index.php/zhangonggao/release?timer=" + MainApplication.msgTime;
- } catch (Exception e) {
- e.printStackTrace();
- }
- submitMessage(url);
- }
- }).start();
- }
- private void submitMessage(String sms) {
- Request request = new Request.Builder().url(sms).build();
- Response response = null;
- try {
- if (request == null) {
- Message msg = new Message();
- msg.what = 5;
- hand.sendMessage(msg);
- return;
- }
- response = OkHttpUtil.execute(request);
- if (response.code() == 200) {
- String json = "";
- try {
- json = response.body().string();
- Message msg = new Message();
- msg.obj = json;
- msg.what = 7;
- hand.sendMessage(msg);
- } catch (Exception e) {
- e.printStackTrace();
- Message msg = new Message();
- msg.what = 5;
- hand.sendMessage(msg);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- Message msg = new Message();
- msg.what = 5;
- hand.sendMessage(msg);
- }
- }
- public void MainMapp() {
- eteCityTime("{\"fun\":\"timer\"}");
- clickMarker = false;
- SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
- sharedPreferencesUtil.setFileName("CurrentMarkerInfo");
- sharedPreferencesUtil.clearData();
- }
- public void eteCityTime(final String params) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- String host = "";
- if (MainApplication.url.contains("cdz.evcharge.cc")) {
- host = "cdz.evcharge.cc";
- } else {
- host = "59.110.68.162";
- }
- socket = new Socket(host, 9503);
-
- PrintWriter out = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(socket.getOutputStream())), true);
- out.println(params);
-
-
- BufferedReader br = new BufferedReader(new InputStreamReader(
- socket.getInputStream()));
- String msg = br.readLine();
- token = msg;
- int time = (int) (System.currentTimeMillis() / 1000);
- cha = time - Integer.parseInt(msg);
- Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
- 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 + "\"" + "}";
- if (MainApplication.userTpye == "") {
- MainApplication.userTpye = "1";
- }
- eteCity("{\"fun\":\"getcity\",\"suit_car2\":" + "\"" + MainApplication.userTpye + "\"" + ",\"status\":" + "\"" + MainApplication.mapStatus + "\"" + ",\"charge_cost_way\":" + "\"" + MainApplication.costWay + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + "}");
- } catch (Exception e) {
- }
- }
- }).start();
- }
- public void eteCity(final String params) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- String host = "";
- if (MainApplication.url.contains("cdz.evcharge.cc")) {
- host = "cdz.evcharge.cc";
- } else {
- host = "59.110.68.162";
- }
- socket = new Socket(host, 9503);
-
- PrintWriter out = new PrintWriter(new BufferedWriter(
- new OutputStreamWriter(socket.getOutputStream())), true);
- out.println(params);
-
-
- BufferedReader br = new BufferedReader(new InputStreamReader(
- socket.getInputStream()));
- String msg = br.readLine();
- if (msg != null) {
- Message mes = new Message();
- mes.obj = msg;
- mes.what = 4;
- hand.sendMessage(mes);
- }
-
- out.close();
- br.close();
-
- socket.close();
- } catch (Exception e) {
- }
- }
- }).start();
- }
-
- private void setlogin() {
- if (TextUtils
- .isEmpty(ProfileManager.getInstance().getId(getApplication()))) {
- if (MainApplication.userNickname.equals("")) {
- } else {
- }
- MainApplication.sql = ProfileManager.getInstance().getSQL(this);
- } else {
- MainApplication.userPhone = ProfileManager.getInstance().getUsername(getApplication());
- MainApplication.userId = ProfileManager.getInstance().getUserid(getApplication());
- MainApplication.userIcon = ProfileManager.getInstance().getUsericon(getApplication());
- MainApplication.userNickname = ProfileManager.getInstance().getNickname(getApplication());
- MainApplication.sql = ProfileManager.getInstance().getSQL(getApplication());
- if (!MainApplication.userId.equals("")) {
- getPingLun();
- }
- }
- }
- private boolean isAvilible(Context context, String packageName) {
-
- final PackageManager packageManager = context.getPackageManager();
-
- List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
-
- List<String> packageNames = new ArrayList<String>();
-
- if (packageInfos != null) {
- for (int i = 0; i < packageInfos.size(); i++) {
- String packName = packageInfos.get(i).packageName;
- packageNames.add(packName);
- }
- }
-
- return packageNames.contains(packageName);
- }
- private void getGaode(Double jing, Double wei) {
- double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
- double gg_lon;
- double gg_lat;
- double x = jing - 0.0065, y = wei - 0.006;
- double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
- double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
- gg_lon = z * Math.cos(theta);
- gd_jing = String.valueOf(gg_lon);
- gg_lat = z * Math.sin(theta);
- gd_wei = String.valueOf(gg_lat);
- }
- private void getBaidu(Double jing, Double wei) {
- double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
- double x = jing;
- double y = wei;
- double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
- double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
- bd_lon = z * Math.cos(theta) + 0.0065;
- bd_lat = z * Math.sin(theta) + 0.006;
- }
- private void getBaidu1(Double jing, Double wei) {
- double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
- double x = jing;
- double y = wei;
- double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
- double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
- bd_jing = z * Math.cos(theta) + 0.0065;
- bd_wei = z * Math.sin(theta) + 0.006;
- }
- private void getBeginGaode(Double jing, Double wei) {
- double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
- double gg_lon;
- double gg_lat;
- double x = jing - 0.0065, y = wei - 0.006;
- double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
- double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
- gg_lon = z * Math.cos(theta);
- bg_jing = String.valueOf(gg_lon);
- gg_lat = z * Math.sin(theta);
- bg_wei = String.valueOf(gg_lat);
- }
- private void setUserData() {
- if (!ProfileManager.getInstance().getGuide(this)) {
- MainApplication.messageToken = "0";
- MainApplication.userTpye = "1";
- ProfileManager.getInstance().setGuide(this, true);
- MainApplication.sql = ProfileManager.getInstance().getSQL(this);
- MainApplication.sudu = ProfileManager.getInstance().getSudu(this);
- } else {
- MainApplication.userTpye = ProfileManager.getInstance().getTpey(this);
- MainApplication.mapStatus = ProfileManager.getInstance().getMapstatus(this);
- MainApplication.costWay = ProfileManager.getInstance().getCostway(this);
- MainApplication.map = ProfileManager.getInstance().getMap(this);
- MainApplication.shuxing = ProfileManager.getInstance().getShuxing(this);
- MainApplication.sudu = ProfileManager.getInstance().getSudu(this);
- MainApplication.atCity = ProfileManager.getInstance().getAtCity(this);
- MainApplication.sql = ProfileManager.getInstance().getSQL(this);
- MainApplication.support = ProfileManager.getInstance().getSupport(this);
- MainApplication.freestop = ProfileManager.getInstance().getFreeStop(this);
- MainApplication.selecthotel = ProfileManager.getInstance().getSelectHotel(this);
- MainApplication.selectexpressway = ProfileManager.getInstance().getSelectExpressway(this);
- MainApplication.selectjingdian = ProfileManager.getInstance().getSelectJingdian(this);
- MainApplication.logid = ProfileManager.getInstance().getLogid(this);
- MainApplication.messageToken = ProfileManager.getInstance().getKeyMessageToken(this);
- }
- }
- private void userChargingCheck() {
- OkHttpUtils.get().url(UrlConstants.USER_CHARGING_CHECK_URL)
- .addParams(ChargingConstants.USERID, MainApplication.userId)
- .addParams(ChargingConstants.PWD, MainApplication.userPassword)
- .build().connTimeOut(10000).readTimeOut(10000).execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- }
- @Override
- public void onResponse(final String response) {
- LogUtils.e(response);
- if (EmptyUtils.isNotEmpty(response)) {
- String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
- if ("306".equals(rtnCode)) {
- LogUtils.e("有订单");
- rl_charging_notice.setVisibility(View.VISIBLE);
- if (firstCheck) {
- if (isStatusBack == false) {
- String data = JsonUtils.getKeyResult(response, "data");
- String orderid = JsonUtils.getKeyResult(data, "orderId");
- Intent intent = new Intent(getApplicationContext(), ChargingStatusActivity.class);
- intent.putExtra(ChargingConstants.ORDERID, orderid);
- startActivity(intent);
- }
- firstCheck = false;
- }
- rl_charging_notice.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- String data = JsonUtils.getKeyResult(response, "data");
- String orderid = JsonUtils.getKeyResult(data, "orderId");
- Intent intent = new Intent(getApplicationContext(), ChargingStatusActivity.class);
- intent.putExtra(ChargingConstants.ORDERID, orderid);
- startActivity(intent);
- }
- });
- } else {
- LogUtils.e("没有订单");
- rl_charging_notice.setVisibility(View.GONE);
- MainApplication.isAppStart = false;
- ProfileManager.getInstance().setAppStart(getApplicationContext(), MainApplication.isAppStart);
- }
- }
- }
- });
- }
- private void getZhanListData(int level) {
- aMap.clear();
- ZhanDBHelper dbHelper = new ZhanDBHelper(this);
- try {
- dbHelper.createDataBase();
- SQLiteDatabase db = dbHelper.getWritableDatabase();
- db.beginTransaction();
- String sql = "";
- if (level == 3) {
- 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";
- } else if (level == 2) {
- 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";
- }
- Cursor cursor = db.rawQuery(sql, null);
- ZhanDB zhan_db;
- while (cursor.moveToNext()) {
- zhan_db = new ZhanDB();
- zhan_db.setCnt(cursor.getString(cursor.getColumnIndex("cnt")));
- zhan_db.setPjing2(cursor.getString(cursor.getColumnIndex("pjing2")));
- zhan_db.setPwei2(cursor.getString(cursor.getColumnIndex("pwei2")));
- list_db.add(zhan_db);
- }
- cursor.close();
- db.endTransaction();
- db.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- private void delData(List<DataRefresh> list_del) {
- String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
- try {
- SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.beginTransaction();
- try {
- for (int i = 0; i < list_del.size(); i++) {
- String[] args = {String.valueOf(list_del.get(i).getId())};
- int mub = db.delete("zhan_list", "id=?", args);
- if (mub > 0) {
- } else {
- }
- }
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- db.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private void addData(List<DataRefresh> list_add) {
- String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
- try {
- SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.beginTransaction();
- try {
- for (int i = 0; i < list_add.size(); i++) {
- ContentValues cv = new ContentValues();
- cv.put("id", list_add.get(i).getId());
- cv.put("status", list_add.get(i).getStatus());
- cv.put("poi_jing", list_add.get(i).getPoi_jing());
- cv.put("poi_wei", list_add.get(i).getPoi_wei());
- cv.put("total_num", list_add.get(i).getTotal_num());
- cv.put("fast_num", list_add.get(i).getFast_num());
- cv.put("slow_num", list_add.get(i).getSlow_num());
- cv.put("charge_cost_way", list_add.get(i).getCharge_cost_way());
- cv.put("belong_attribute", list_add.get(i).getBelong_attribute());
- cv.put("suit_car", list_add.get(i).getSuit_car());
- cv.put("own_pay", list_add.get(i).getOwn_pay());
- cv.put("city", list_add.get(i).getCity());
- cv.put("supplier", list_add.get(i).getSupplier());
- long mub = db.insert("zhan_list", null, cv);
- if (mub > 0) {
- Log.e(TAG, "添加成功");
- } else {
- Log.e(TAG, "添加失败---" + list_add.get(i).getId());
- }
- }
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- db.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private void upData(List<DataRefresh> list_up) {
- String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
- try {
- SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
- db.beginTransaction();
- try {
- for (int i = 0; i < list_up.size(); i++) {
- String[] args = {String.valueOf(list_up.get(i).getId())};
- ContentValues cv = new ContentValues();
- cv.put("id", list_up.get(i).getId());
- cv.put("status", list_up.get(i).getStatus());
- cv.put("poi_jing", list_up.get(i).getPoi_jing());
- cv.put("poi_wei", list_up.get(i).getPoi_wei());
- cv.put("total_num", list_up.get(i).getTotal_num());
- cv.put("fast_num", list_up.get(i).getFast_num());
- cv.put("slow_num", list_up.get(i).getSlow_num());
- cv.put("charge_cost_way", list_up.get(i).getCharge_cost_way());
- cv.put("belong_attribute", list_up.get(i).getBelong_attribute());
- cv.put("suit_car", list_up.get(i).getSuit_car());
- cv.put("own_pay", list_up.get(i).getOwn_pay());
- cv.put("city", list_up.get(i).getCity());
- cv.put("supplier", list_up.get(i).getSupplier());
- long mub = db.update("zhan_list", cv, "id=?", args);
- if (mub > 0) {
- Log.e(TAG, "up成功");
- } else {
- Log.e(TAG, "up失败---" + list_up.get(i).getId());
- }
- }
- db.setTransactionSuccessful();
- } finally {
- db.endTransaction();
- }
- db.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public String getAssetsCacheFile(Context context, String fileName) throws Exception {
- File cacheFile = new File(context.getCacheDir(), fileName);
- try {
- InputStream inputStream = context.getAssets().open(fileName);
- try {
- FileOutputStream outputStream = new FileOutputStream(cacheFile);
- try {
- byte[] buf = new byte[1024];
- int len;
- while ((len = inputStream.read(buf)) > 0) {
- outputStream.write(buf, 0, len);
- }
- } finally {
- outputStream.close();
- }
- } finally {
- inputStream.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- getZhanData();
- return cacheFile.getAbsolutePath();
- }
- class NetworkChangeReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
- if (null != networkInfo && networkInfo.isAvailable()) {
- } else {
- Toast.makeText(context, "当前网络不可用", Toast.LENGTH_SHORT).show();
- }
- }
- }
- private void getZhanData() throws Exception {
- if (zhan_lists != null) {
- zhan_lists.clear();
- }
- if (mClusterOverlay != null) {
- mClusterOverlay.onDestroy();
- }
- DaoMaster daoMaster = new DaoMaster(SQLiteDatabase.openOrCreateDatabase(getDatabasePath("zhan_list"), null));
- DaoSession mDaoSession = daoMaster.newSession();
- zhan_listDao = mDaoSession.getZhan_listDao();
- zhan_lists = zhan_listDao.queryRaw("where status = ? " + MainApplication.sql, new String[]{"4"});
- if (onResumeRefresh == true) {
- ToastUtil.showToast(getApplicationContext(), "共" + zhan_lists.size() + "个符合条件的站点", Toast.LENGTH_SHORT);
- }
- new Thread() {
- public void run() {
- List<ClusterItem> items = new ArrayList<ClusterItem>();
- if (zhan_lists != null && zhan_lists.size() > 0) {
- for (int i = 0; i < zhan_lists.size(); i++) {
- String jing = zhan_lists.get(i).getPoi_jing();
- String wei = zhan_lists.get(i).getPoi_wei();
- if (jing != null && !jing.equals("") && !wei.equals("") && wei != null) {
- int position_jing = jing.length() - jing.indexOf(".") - 1;
- int position_wei = wei.length() - wei.indexOf(".") - 1;
- LatLng ll;
- if (position_jing > 13 || position_wei > 13) {
- ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
- } else {
- double dwei = Double.parseDouble(wei);
- double djing = Double.parseDouble(jing);
- getGaode(djing, dwei);
- ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
- }
- if (null != String.valueOf(ll.longitude) && null != String.valueOf(ll.latitude)) {
- if (null != zhan_lists) {
- zhan_lists.get(i).setPoi_jing(String.valueOf(ll.longitude));
- zhan_lists.get(i).setPoi_wei(String.valueOf(ll.latitude));
- }
- }
- }
- }
- }
- for (int i = 0; i < zhan_lists.size(); i++) {
- if (null != zhan_lists.get(i).getPoi_jing() && null != zhan_lists.get(i).getPoi_wei()) {
- double lat, lon;
- if (zhan_lists.get(i).getPoi_wei().equals("") || zhan_lists.get(i).getPoi_wei() == null) {
- lat = 0.00;
- } else {
- lat = Double.parseDouble(zhan_lists.get(i).getPoi_wei());
- }
- if (zhan_lists.get(i).getPoi_jing().equals("") || zhan_lists.get(i).getPoi_jing() == null) {
- lon = 0.00;
- } else {
- lon = Double.parseDouble(zhan_lists.get(i).getPoi_jing());
- }
- LatLng latLng = new LatLng(lat, lon, false);
- RegionItem regionItem = new RegionItem(latLng, "test" + i);
-
- regionItem.setChargePoint(zhan_lists.get(i));
- items.add(regionItem);
- }
- }
- mClusterOverlay = new ClusterOverlay(aMap, items, dp2px(getApplicationContext(), clusterRadius), getApplicationContext());
- mClusterOverlay.setClusterRenderer(MainMapActivity.this);
- mClusterOverlay.setOnClusterClickListener(MainMapActivity.this);
- }
- }.start();
- }
- private void showMapMarker() {
- List<ClusterItem> items = new ArrayList<ClusterItem>();
- for (int i = 0; i < zhan_lists.size(); i++) {
- if (null != zhan_lists.get(i).getPoi_jing() && null != zhan_lists.get(i).getPoi_wei()) {
- double lat, lon;
- if (zhan_lists.get(i).getPoi_wei().equals("") || zhan_lists.get(i).getPoi_wei() == null) {
- lat = 0.00;
- } else {
- lat = Double.parseDouble(zhan_lists.get(i).getPoi_wei());
- }
- if (zhan_lists.get(i).getPoi_jing().equals("") || zhan_lists.get(i).getPoi_jing() == null) {
- lon = 0.00;
- } else {
- lon = Double.parseDouble(zhan_lists.get(i).getPoi_jing());
- }
- LatLng latLng = new LatLng(lat, lon, false);
- RegionItem regionItem = new RegionItem(latLng, "test" + i);
-
- regionItem.setChargePoint(zhan_lists.get(i));
- items.add(regionItem);
- }
- }
- mClusterOverlay = new ClusterOverlay(aMap, items, dp2px(getApplicationContext(), clusterRadius), getApplicationContext());
- mClusterOverlay.setClusterRenderer(MainMapActivity.this);
- mClusterOverlay.setOnClusterClickListener(MainMapActivity.this);
- }
- private void initDataBase() throws IOException {
- File databasePath = getDatabasePath("zhan_list");
- databasePath.getParentFile().mkdirs();
- databasePath.createNewFile();
- InputStream inputStream = getAssets().open("zhan_list.db");
- FileOutputStream fileOutputStream = new FileOutputStream(databasePath);
- byte[] buf = new byte[1024 * 10];
- int length = 0;
- while ((length = inputStream.read(buf)) != -1) {
- fileOutputStream.write(buf, 0, length);
- fileOutputStream.flush();
- }
- inputStream.close();
- fileOutputStream.close();
- eteinit("{\"fun\":\"timer\"}");
- try {
- getZhanData();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @Override
- public Drawable getDrawAble(int clusterNum) {
- int radius = dp2px(getApplicationContext(), 60);
- if (clusterNum == 1) {
- Drawable bitmapDrawable = mBackDrawAbles.get(1);
- if (bitmapDrawable == null) {
- bitmapDrawable =
- getApplication().getResources().getDrawable(
- R.drawable.icon_sorange);
- mBackDrawAbles.put(1, bitmapDrawable);
- }
- return bitmapDrawable;
- } else if (clusterNum > 1 && clusterNum < 999) {
- Drawable bitmapDrawable = mBackDrawAbles.get(2);
- if (bitmapDrawable == null) {
- bitmapDrawable =
- getApplication().getResources().getDrawable(
- R.drawable.icon_marker1_999);
- mBackDrawAbles.put(2, bitmapDrawable);
- }
- return bitmapDrawable;
- } else if (clusterNum > 1000) {
- Drawable bitmapDrawable = mBackDrawAbles.get(3);
- if (bitmapDrawable == null) {
- bitmapDrawable =
- getApplication().getResources().getDrawable(
- R.drawable.icon_marker1000);
- mBackDrawAbles.put(3, bitmapDrawable);
- }
- return bitmapDrawable;
- } else {
- Drawable bitmapDrawable = mBackDrawAbles.get(4);
- if (bitmapDrawable == null) {
- bitmapDrawable =
- getApplication().getResources().getDrawable(
- R.drawable.icon_marker1_999);
- mBackDrawAbles.put(4, bitmapDrawable);
- }
- return bitmapDrawable;
- }
- }
- private Bitmap drawCircle(int radius, int color) {
- Bitmap bitmap = BitmapFactory.decodeResource(MainApplication.context.getResources(), R.drawable.icon_newmarker4);
- Bitmap bitmap1 = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), false);
- return bitmap1;
- }
-
- * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
- */
- public int dp2px(Context context, float dpValue) {
- final float scale = context.getResources().getDisplayMetrics().density;
- return (int) (dpValue * scale + 0.5f);
- }
- @Override
- public void onClick(Marker marker, List<ClusterItem> clusterItems) {
- LatLngBounds.Builder builder = new LatLngBounds.Builder();
- for (ClusterItem clusterItem : clusterItems) {
- builder.include(clusterItem.getPosition());
- }
-
- if (clusterItems.size() == 1) {
- MobclickAgent.onEvent(context, "0102");
- Log.e(TAG, "onClick: !!" + "!!");
- rl_control.setVisibility(View.GONE);
- moveRefresh = false;
- ClusterItem clusterItem = clusterItems.get(0);
- markerPosition = clusterItem.getPosition();
- RegionItem regionItem = (RegionItem) clusterItems.get(0);
- zhan_list chargePoint = regionItem.getChargePoint();
- String own_pay = chargePoint.getOwn_pay();
- String supplier = chargePoint.getSupplier();
- String suit_car = chargePoint.getSuit_car();
- if (null != own_pay && own_pay.equals("1")) {
- marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig1));
- } else {
- if (null != suit_car && suit_car.equals("特斯拉")) {
- marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig3));
- } else {
- if (null != supplier && WelcomeActivity.canCost.contains(supplier)) {
- marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig2));
- } else {
- marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig3));
- }
- }
- }
- if (nMarker != null && current_chargePoint.getId() != chargePoint.getId()) {
- MarkerOptions markerOptionss = new MarkerOptions();
- if (null != current_chargePoint.getOwn_pay() && current_chargePoint.getOwn_pay().equals("1")) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
- } else {
- if (null != current_chargePoint.getSuit_car() && current_chargePoint.getSuit_car().equals("特斯拉")) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
- } else {
- if (null != current_chargePoint.getSupplier() && WelcomeActivity.canCost.contains(current_chargePoint.getSupplier())) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
- } else {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
- }
- }
- }
- nMarker = aMap.addMarker(markerOptionss);
- }
- Long zhan_id = ((RegionItem) clusterItem).getChargePoint().getId();
- nMarker = marker;
- zhanInfo = null;
-
- nMarker.showInfoWindow();
- current_chargePoint = chargePoint;
- dialog.show();
- if (null != marker.getPosition()) {
- getSingleZhanInfo(String.valueOf(zhan_id), marker.getPosition());
- }
- } else {
- LatLngBounds latLngBounds = builder.build();
- aMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 0));
- }
- }
- private void clickMarkAndMove(int adHeight) {
- if (markerPosition == null) {
- return;
- }
- float zoom = aMap.getCameraPosition().zoom;
- int width = mapView.getMeasuredWidth();
- int height = mapView.getMeasuredHeight();
- if (height > 1122) {
- Point point = aMap.getProjection().toScreenLocation(markerPosition);
- int y = point.y - (height - 1122) - DensityUtil.dip2px(getApplicationContext(), adHeight);
- aMap.moveCamera(CameraUpdateFactory.scrollBy(point.x - width / 2, y));
- } else {
- aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(markerPosition, zoom));
- }
- }
- private void getSingleZhanInfo(String zhan_id, final LatLng ll) {
- String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/zhan-info2?zhan_id=" + zhan_id + "&version=" + MainApplication.current_code;
- OkHttpUtils.get().url(url).build().execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- }
- @Override
- public void onResponse(String response) {
- Log.e(TAG, "onResponse: " + response);
- dialog.cancel();
- String info = JsonUtils.getKeyResult(response, "info");
- Log.e(TAG, "onResponse: info=" + info);
- String info_decode = "";
- try {
- info_decode = DES3S.decode(info);
- } catch (Exception e) {
- e.printStackTrace();
- }
- Log.e(TAG, "onResponse: info_decode=" + info_decode);
- if (null != info_decode && !info_decode.equals("")) {
- showInfoWindow(info_decode, ll);
- }
- }
- });
- }
- private void showInfoWindow(String info, final LatLng ll) {
- zhanInfo = info;
- final String id = JsonUtils.getKeyResult(info, "id");
- getCommentNum(id);
- zhanGrade(id);
- final String zhan_name = JsonUtils.getKeyResult(info, "zhan_name");
- String stop_cost = JsonUtils.getKeyResult(info, "stop_cost");
- String own_pay = JsonUtils.getKeyResult(info, "own_pay");
- String charge_cost_way2 = JsonUtils.getKeyResult(info, "charge_cost_way2");
- final String charge_cost_way = JsonUtils.getKeyResult(info, "charge_cost_way");
- String other_cost = JsonUtils.getKeyResult(info, "other_cost");
- String charge_cost = JsonUtils.getKeyResult(info, "charge_cost");
- String total_num = JsonUtils.getKeyResult(info, "total_num");
- String slow_num = JsonUtils.getKeyResult(info, "slow_num");
- String fast_num = JsonUtils.getKeyResult(info, "fast_num");
- String remind = JsonUtils.getKeyResult(info, "remind");
- String charge_record_cnt = JsonUtils.getKeyResult(info, "charge_record_cnt");
- String zongjia = JsonUtils.getKeyResult(info, "zongjia");
- String belong_attribute = JsonUtils.getKeyResult(info, "belong_attribute");
- String park_location = JsonUtils.getKeyResult(info, "park_location");
- final String city = JsonUtils.getKeyResult(info, "city");
- final String poi_jing = JsonUtils.getKeyResult(info, "poi_jing");
- final String poi_wei = JsonUtils.getKeyResult(info, "poi_wei");
- final String fenshi_is = JsonUtils.getKeyResult(info, "fenshi_is");
- final String telephone = JsonUtils.getKeyResult(info, "telephone");
- TextView fenshi_info_textview = findViewById(R.id.fenshi_info_textview);
- fenshi_info_textview.setText("");
- if ("1".equals(fenshi_is)) {
- final String fenshi_info = JsonUtils.getKeyResult(info, "fenshi_info");
- ArrayList<PileData.FenshiInfoBean> fenshiList = (ArrayList<PileData.FenshiInfoBean>) JsonUtils.parseToObjectList(fenshi_info, PileData.FenshiInfoBean.class);
- if (fenshiList.size() == 1) {
- fenshi_info_textview.setText("全天价格统一");
- } else {
- Calendar calendar = Calendar.getInstance();
- int hours = calendar.get(Calendar.HOUR_OF_DAY);
- int minutes = calendar.get(Calendar.MINUTE);
- int totalMinutes = hours * 60 + minutes;
- for (PileData.FenshiInfoBean bean : fenshiList) {
- if (bean.getStartTotalMinutes() > totalMinutes) {
- double service_free = 0;
- double charge_free = 0;
- try {
- service_free = Double.valueOf(bean.getService_free());
- charge_free = Double.valueOf(bean.getCharge_free());
- } catch (Exception e) {
- e.printStackTrace();
- }
- fenshi_info_textview.setText(String.format("%s开始 %.2f元/度", bean.getStart(), service_free + charge_free));
- break;
- }
- }
- }
- } else {
- double totalPrice = 0;
- try {
- totalPrice = Double.valueOf(zongjia);
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (totalPrice != 0) {
- fenshi_info_textview.setText("全天价格统一");
- }
- }
- if (belong_attribute != null && belong_attribute.contains("私人")) {
- private_telephone.setVisibility(View.VISIBLE);
- private_telephone.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
- .setMsg(zhan_name + " " + telephone)
- .setPositiveButton("呼叫", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent();
- intent.setAction("android.intent.action.CALL");
- intent.addCategory("android.intent.category.DEFAULT");
- intent.setData(Uri.parse("tel:" + telephone));
- startActivity(intent);
- }
- }).setNegativeButton("取消", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- }
- }).show();
- }
- });
- } else {
- private_telephone.setVisibility(View.GONE);
- }
-
-
-
- if (remind.equals("0")) {
- if ("1".equals(own_pay)) {
- iv_guzhang.setVisibility(View.VISIBLE);
- iv_guzhang.setImageResource(R.drawable.icon_is_cost);
- } else {
- iv_guzhang.setVisibility(View.GONE);
- }
- } else if (remind.equals("2")) {
- iv_guzhang.setVisibility(View.VISIBLE);
- iv_guzhang.setImageResource(R.drawable.icon_rest);
- } else {
- iv_guzhang.setVisibility(View.VISIBLE);
- iv_guzhang.setImageResource(R.drawable.icon_guzhang_window);
- }
- windowName.setText(zhan_name);
- if (stop_cost != null && !stop_cost.equals("")) {
- stopCost.setVisibility(View.VISIBLE);
- stopCost.setText("停车费:" + stop_cost);
- } else {
- stopCost.setVisibility(View.GONE);
- }
- if (center != null) {
- String wei = poi_wei;
- String jing = poi_jing;
- int position_jing = jing.length() - jing.indexOf(".") - 1;
- int position_wei = wei.length() - wei.indexOf(".") - 1;
- LatLng latLng;
- if (position_jing > 13 || position_wei > 13) {
- latLng = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
- } else {
- double dwei = Double.parseDouble(wei);
- double djing = Double.parseDouble(jing);
- getGaode(djing, dwei);
- latLng = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
- }
-
- double d = AMapUtils.calculateLineDistance(center, latLng);
- if ("0m".equals(Util.getDistance(d))) {
- updateInfoWindow("未知距离");
- } else {
- String text = Util.getDistance(d);
- updateInfoWindow("距您 " + text);
- }
- }
- if (charge_record_cnt != null) {
- int count = Integer.parseInt(charge_record_cnt);
-
- if (count == 0) {
- windowChargeRecordCnt.setText("");
- windowChargeRecordCntLine.setVisibility(View.GONE);
- } else {
- windowChargeRecordCntLine.setVisibility(View.VISIBLE);
- if (count < 1000) {
- windowChargeRecordCnt.setText(count + "次充电");
- } else if (count < 10000) {
- windowChargeRecordCnt.setText(count / 1000 + "k+次充电");
- } else {
- windowChargeRecordCnt.setText(count / 10000 + "w+次充电");
- }
- }
- } else {
- windowChargeRecordCnt.setText("");
- windowChargeRecordCntLine.setVisibility(View.GONE);
- }
- if (zongjia != null) {
- double zongjiaValue = Double.parseDouble(zongjia);
- if (zongjiaValue == 0) {
- windowZongjiaLayout.setVisibility(View.GONE);
- } else {
- windowZongjiaLayout.setVisibility(View.VISIBLE);
- windowZongjia.setText(String.format("%.2f", zongjiaValue));
- }
- } else {
- windowZongjiaLayout.setVisibility(View.GONE);
- }
-
- windowRedPaperBag.setVisibility("1".equals(own_pay) ? View.VISIBLE : View.GONE);
- windowLabelPublic.setText(belong_attribute);
- windowLabelGround.setText("0".equals(park_location) ? "地下" : "地上");
- windowLabelFreePark.setVisibility(stop_cost.contains("免费") ? View.VISIBLE : View.GONE);
- String acNum = null, dcNum = null, acableNum = null, dcableNum = null;
- if (null != JsonUtils.getKeyResult(info, "acNum")) {
- acNum = JsonUtils.getKeyResult(info, "acNum");
- dcNum = JsonUtils.getKeyResult(info, "dcNum");
- acableNum = JsonUtils.getKeyResult(info, "acableNum");
- dcableNum = JsonUtils.getKeyResult(info, "dcableNum");
- }
- if (null != acableNum && null != acNum
- && null != dcableNum && null != dcNum) {
- window_tv_fast_free_num.setText(dcableNum);
- window_tv_fast_total_num.setText("/" + dcNum);
- window_tv_fast_free_label.setVisibility(View.VISIBLE);
- window_tv_fast_total_num.setVisibility(View.VISIBLE);
- window_tv_slow_free_num.setText(acableNum);
- window_tv_slow_total_num.setText("/" + acNum);
- window_tv_slow_free_label.setVisibility(View.VISIBLE);
- window_tv_slow_total_num.setVisibility(View.VISIBLE);
- } else {
- if (fast_num.equals("")) {
- window_tv_fast_free_num.setText("0");
- } else {
- window_tv_fast_free_num.setText(fast_num);
- }
- window_tv_fast_free_label.setVisibility(View.GONE);
- window_tv_fast_total_num.setVisibility(View.GONE);
- if (slow_num.equals("")) {
- window_tv_slow_free_num.setText("0");
- } else {
- window_tv_slow_free_num.setText(slow_num);
- }
- window_tv_slow_free_label.setVisibility(View.GONE);
- window_tv_slow_total_num.setVisibility(View.GONE);
- }
-
- if (own_pay.equals("1")) {
- windowCost.setText("可使用本APP扫码支付");
- } else {
- if (charge_cost_way2.equals("")) {
- windowCost.setText("暂无");
- } else {
- windowCost.setText(charge_cost_way2);
- }
- }
- windowZhanDetails.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
- intent.putExtra("zhan_id", id);
- intent.putExtra("poi_jing", poi_jing);
- intent.putExtra("poi_wei", poi_wei);
- startActivity(intent);
- MainMapActivity.isR = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("type", "详情");
- MobclickAgent.onEvent(context, "0102", map);
- map.clear();
- }
- });
- windowLayout.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View view, MotionEvent motionEvent) {
- switch (motionEvent.getAction()) {
- case MotionEvent.ACTION_DOWN:
- mPosX = motionEvent.getX();
- mPosY = motionEvent.getY();
- mCurPosX = 0;
- mCurPosY = 0;
- break;
- case MotionEvent.ACTION_MOVE:
- mCurPosX = motionEvent.getX();
- mCurPosY = motionEvent.getY();
- break;
- case MotionEvent.ACTION_UP:
- if (mCurPosY != 0 && mCurPosY > mPosY && Math.abs(mCurPosY - mPosY) > 25) {
-
- if (nMarker != null) {
- nMarker.hideInfoWindow();
- if (current_chargePoint.getOwn_pay().equals("1")) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
- } else {
- if (current_chargePoint.getSuit_car().equals("特斯拉")) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
- } else {
- if (WelcomeActivity.canCost.contains(current_chargePoint.getSupplier())) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
- } else {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
- }
- }
- }
- }
-
- Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out);
- animation.setDuration(500);
- windowLayout.startAnimation(animation);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- windowLayout.setVisibility(View.GONE);
- rl_control.setVisibility(View.VISIBLE);
- }
- }, 500);
- } else if (mCurPosY != 0 && mCurPosY < mPosY && Math.abs(mCurPosY - mPosY) > 25) {
- System.out.println("up");
- } else if (mCurPosX != 0 && mCurPosX > mPosX && Math.abs(mCurPosX - mPosX) > 25) {
- System.out.println("right");
- } else if (mCurPosX != 0 && mCurPosX < mPosX && Math.abs(mCurPosX - mPosX) > 25) {
- System.out.println("left");
- } else {
- Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
- intent.putExtra("zhan_id", id);
- intent.putExtra("poi_jing", poi_jing);
- intent.putExtra("poi_wei", poi_wei);
- startActivity(intent);
- MainMapActivity.isR = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("type", "详情");
- MobclickAgent.onEvent(context, "0102", map);
- map.clear();
- }
- break;
- }
- return true;
- }
- });
- windowComments.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
- intent.putExtra("zhan_id", id);
- intent.putExtra("poi_jing", poi_jing);
- intent.putExtra("poi_wei", poi_wei);
- MainApplication.details_flag = "3";
- startActivity(intent);
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("type", "评论");
- MobclickAgent.onEvent(context, "0102", map);
- map.clear();
- }
- });
-
- if (MainApplication.list_addetail != null) {
- Random random = new Random();
- final int result = random.nextInt(MainApplication.list_addetail.size());
- Picasso.with(MainApplication.context)
- .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + MainApplication.list_addetail.get(result).getImg())
- .into(windowAd);
- windowAd.setVisibility(View.VISIBLE);
- clickMarkAndMove(0);
- windowAd.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- MobclickAgent.onEvent(context, "0052");
- if (MainApplication.list_addetail.get(result).getIs_dui().equals("1")) {
- long appTime11 = System.currentTimeMillis() / 1000;
- long updatetime1 = appTime11 - MainMapActivity.cha - 5;
- String token1 = String.valueOf(updatetime1);
- String encode_token = null;
- try {
- encode_token = DES3.encode(token1);
- } catch (Exception e) {
- e.printStackTrace();
- }
- String replace = URLEncoder.encode(encode_token);
- Intent intent11 = new Intent();
- intent11.setClass(getApplicationContext(), CreditActivity.class);
- intent11.putExtra("navColor", "#fcfcfc");
- intent11.putExtra("titleColor", "#222222");
- MainApplication.goods_type = "details";
- MainApplication.current_url = MainApplication.list_addetail.get(result).getUrl();
- if (!MainApplication.isLogin()) {
- intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.current_url);
- } else {
- intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace + "&url=" + MainApplication.current_url);
- }
- startActivity(intent11);
- overridePendingTransition(0, 0);
- CreditActivity.creditsListener = new CreditActivity.CreditsListener() {
-
- * 当点击分享按钮被点击
- * @param shareUrl 分享的地址
- * @param shareThumbnail 分享的缩略图
- * @param shareTitle 分享的标题
- * @param shareSubtitle 分享的副标题
- */
- public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
-
- ChargingShareBean chargingShareBean = new ChargingShareBean();
- chargingShareBean.setIcon(shareThumbnail);
- chargingShareBean.setTitle(shareTitle);
- chargingShareBean.setUrl(shareUrl);
- chargingShareBean.setText("");
- showSimpleBottomSheetGrid(chargingShareBean);
- }
-
- * 当点击“请先登录”按钮唤起登录时,会调用此处代码。
- * 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。
- * @param webView 用于登录成功后返回到当前的webview刷新登录状态。
- * @param currentUrl 当前页面的url
- */
- public void onLoginClick(WebView webView, final String currentUrl) {
-
-
-
-
-
-
- new android.app.AlertDialog.Builder(webView.getContext())
- .setTitle("跳转登录")
- .setMessage("跳转到登录页面?")
- .setPositiveButton("是", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- MainApplication.current_url = currentUrl;
- context.startActivity(new Intent(getApplicationContext(), LoginActivity.class));
- }
- })
- .setNegativeButton("否", null)
- .show();
- }
-
- * 当点击“复制”按钮时,触发该方法,回调获取到券码code
- * @param webView webview对象。
- * @param code 复制的券码
- */
- public void onCopyCode(WebView webView, String code) {
-
- new android.app.AlertDialog.Builder(webView.getContext())
- .setTitle("复制券码")
- .setMessage("已复制,券码为:" + code)
- .setPositiveButton("是", null)
- .setNegativeButton("否", null)
- .show();
- }
-
- * 积分商城返回首页刷新积分时,触发该方法。
- */
- public void onLocalRefresh(WebView mWebView, String credits) {
-
-
- }
- };
- } else {
- Intent intent145 = new Intent(getApplication(), MyWebViewActivity.class);
- String url = MainApplication.list_addetail.get(result).getUrl();
- if (EmptyUtils.isNotEmpty(url)) {
- if (url.contains("?")) {
- url = MainApplication.list_addetail.get(result).getUrl() + "&cdzshareid=" + MainApplication.list_addetail.get(result).getId();
- } else {
- url = MainApplication.list_addetail.get(result).getUrl() + "?cdzshareid=" + MainApplication.list_addetail.get(result).getId();
- }
- intent145.putExtra("url", url);
- startActivity(intent145);
- }
- }
- }
- });
- } else {
- windowAd.setVisibility(View.GONE);
- clickMarkAndMove(65);
- }
-
- final String finalRemind = remind;
- windowGo.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- infoViewNavigate();
- }
- });
- Animation animation = AnimationUtils.loadAnimation(this, R.anim.in);
- animation.setDuration(500);
- windowLayout.startAnimation(animation);
- windowLayout.setVisibility(View.VISIBLE);
- SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
- boolean showedExampleActivity = sharedPreferencesUtil.hasKey("cdz_showed_example_activity");
- if (!showedExampleActivity) {
- Intent pIntent = new Intent(getApplicationContext(), ExampleActivity.class);
- pIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(pIntent);
- overridePendingTransition(0, 0);
- }
- }
-
- * 点击气泡进行导航
- * add by hyg
- */
- private void infoViewNavigate() {
- if (zhanInfo == null) {
- return;
- }
- if (nMarker == null) {
- return;
- }
- final LatLng ll = nMarker.getPosition();
- final String id = JsonUtils.getKeyResult(zhanInfo, "id");
- final String zhan_name = JsonUtils.getKeyResult(zhanInfo, "zhan_name");
- String stop_cost = JsonUtils.getKeyResult(zhanInfo, "stop_cost");
- String own_pay = JsonUtils.getKeyResult(zhanInfo, "own_pay");
- String charge_cost_way2 = JsonUtils.getKeyResult(zhanInfo, "charge_cost_way2");
- final String charge_cost_way = JsonUtils.getKeyResult(zhanInfo, "charge_cost_way");
- String other_cost = JsonUtils.getKeyResult(zhanInfo, "other_cost");
- String charge_cost = JsonUtils.getKeyResult(zhanInfo, "charge_cost");
- String total_num = JsonUtils.getKeyResult(zhanInfo, "total_num");
- String slow_num = JsonUtils.getKeyResult(zhanInfo, "slow_num");
- String fast_num = JsonUtils.getKeyResult(zhanInfo, "fast_num");
- String remind = JsonUtils.getKeyResult(zhanInfo, "remind");
- final String city = JsonUtils.getKeyResult(zhanInfo, "city");
- final String poi_jing = JsonUtils.getKeyResult(zhanInfo, "poi_jing");
- final String poi_wei = JsonUtils.getKeyResult(zhanInfo, "poi_wei");
- String belongAttribute = JsonUtils.getKeyResult(zhanInfo, "belong_attribute");
- HashMap<String, String> mapp = new HashMap<String, String>();
- mapp.put("type", "导航");
- MobclickAgent.onEvent(context, "0102", mapp);
- mapp.clear();
- if (remind.equals("0")) {
- if (belongAttribute.contains("私人")) {
- new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
- .setMsg("该站为私人站点,建议\n先联系桩主后再前往")
- .setPositiveButton("继续", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") && !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- if (null == center) {
- ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT);
- } else {
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", ll.longitude + "");
- intent.putExtra("stop_wei", ll.latitude + "");
- startActivity(intent);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- }
- } else {
- if (center != null) {
- LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
- popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, true);
- popupWindow.setBackgroundDrawable(new BitmapDrawable());
-
- popupWindow.setAnimationStyle(R.style.popupAnimation);
- LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
- if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- ll_tvTwo.setVisibility(View.GONE);
- }
- LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
- ll_tvOne.setVisibility(View.GONE);
- }
- cancleButton = (Button) popupWindowView.findViewById(R.id.cancleButton);
- cancleButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- popupWindow.dismiss();
- }
- });
- tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
- tvThree.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", ll.longitude + "");
- intent.putExtra("stop_wei", ll.latitude + "");
- startActivity(intent);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- }
- });
- tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
- tvOne.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = null;
- int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1;
- int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1;
- if (position_jing > 13 || position_wei > 13) {
- getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei));
- } else {
- bd_jing = Double.parseDouble(poi_jing);
- bd_wei = Double.parseDouble(poi_wei);
- }
- getBaidu(center.longitude, center.latitude);
- try {
- 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";
- intent = Intent.getIntent(s);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0031", map);
- map.clear();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- startActivity(intent);
- popupWindow.dismiss();
- }
- });
- tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
- tvTwo.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- try {
- 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"));
- intent4.setPackage("com.autonavi.minimap");
- startActivity(intent4);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0032", map);
- map.clear();
- } catch (Exception e) {
- e.printStackTrace();
- Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
- }
- }
- });
- popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
- } else {
- Toast.makeText(getApplication(), "没有定位到您的当前位置", Toast.LENGTH_SHORT).show();
- }
- }
- }
- }).setNegativeButton("取消", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- }
- }).show();
- } else {
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") && !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- if (null == center) {
- ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT);
- } else {
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", ll.longitude + "");
- intent.putExtra("stop_wei", ll.latitude + "");
- startActivity(intent);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- }
- } else {
- if (center != null) {
- LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
- popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, true);
- popupWindow.setBackgroundDrawable(new BitmapDrawable());
-
- popupWindow.setAnimationStyle(R.style.popupAnimation);
- LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
- if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- ll_tvTwo.setVisibility(View.GONE);
- }
- LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
- ll_tvOne.setVisibility(View.GONE);
- }
- cancleButton = (Button) popupWindowView.findViewById(R.id.cancleButton);
- cancleButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- popupWindow.dismiss();
- }
- });
- tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
- tvThree.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", ll.longitude + "");
- intent.putExtra("stop_wei", ll.latitude + "");
- startActivity(intent);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- }
- });
- tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
- tvOne.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = null;
- int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1;
- int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1;
- if (position_jing > 13 || position_wei > 13) {
- getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei));
- } else {
- bd_jing = Double.parseDouble(poi_jing);
- bd_wei = Double.parseDouble(poi_wei);
- }
- getBaidu(center.longitude, center.latitude);
- try {
- 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";
- intent = Intent.getIntent(s);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0031", map);
- map.clear();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- startActivity(intent);
- popupWindow.dismiss();
- }
- });
- tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
- tvTwo.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- try {
- 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"));
- intent4.setPackage("com.autonavi.minimap");
- startActivity(intent4);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0032", map);
- map.clear();
- } catch (Exception e) {
- e.printStackTrace();
- Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
- }
- }
- });
- popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
- } else {
- Toast.makeText(getApplication(), "没有定位到您的当前位置", Toast.LENGTH_SHORT).show();
- }
- }
- }
- } else if (remind.equals("2")) {
- new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
- .setTitle("暂时未营业")
- .setMsg("该站点当前不在营业时间\n" + "可能无法正常充电,是否继续前往")
- .setPositiveButton("继续", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
- !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", ll.longitude + "");
- intent.putExtra("stop_wei", ll.latitude + "");
- startActivity(intent);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- } else {
- if (center != null) {
- LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
- popupWindow = new PopupWindow(popupWindowView,
- ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
- true);
- popupWindow.setBackgroundDrawable(new BitmapDrawable());
-
- popupWindow.setAnimationStyle(R.style.popupAnimation);
- LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
- if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- ll_tvTwo.setVisibility(View.GONE);
- }
- LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
- ll_tvOne.setVisibility(View.GONE);
- }
- cancleButton = (Button) popupWindowView
- .findViewById(R.id.cancleButton);
- cancleButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- popupWindow.dismiss();
- }
- });
- tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
- tvThree.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", ll.longitude + "");
- intent.putExtra("stop_wei", ll.latitude + "");
- startActivity(intent);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- }
- });
- tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
- tvOne.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = null;
- int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1;
- int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1;
- if (position_jing > 13 || position_wei > 13) {
- getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei));
- } else {
- bd_jing = Double.parseDouble(poi_jing);
- bd_wei = Double.parseDouble(poi_wei);
- }
- getBaidu(center.longitude, center.latitude);
- try {
- 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";
- intent = Intent.getIntent(s);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0031", map);
- map.clear();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- startActivity(intent);
- popupWindow.dismiss();
- }
- });
- tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
- tvTwo.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- try {
- 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"));
- intent4.setPackage("com.autonavi.minimap");
- startActivity(intent4);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0032", map);
- map.clear();
- } catch (Exception e) {
- e.printStackTrace();
- Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
- }
- }
- });
- popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
- } else {
- ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT);
- }
- }
- }
- }).setNegativeButton("取消", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- }
- }).show();
- } else {
- new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
- .setTitle("站点故障")
- .setMsg("该站点充电桩均为离线或故障\n" + "可能无法正常充电,是否继续前往")
- .setPositiveButton("继续", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
- !isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", ll.longitude + "");
- intent.putExtra("stop_wei", ll.latitude + "");
- startActivity(intent);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- } else {
- if (center != null) {
- LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- popupWindowView = inflater1.inflate(R.layout.item_selectmap, null);
- popupWindow = new PopupWindow(popupWindowView,
- ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
- true);
- popupWindow.setBackgroundDrawable(new BitmapDrawable());
-
- popupWindow.setAnimationStyle(R.style.popupAnimation);
- LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo);
- if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
- ll_tvTwo.setVisibility(View.GONE);
- }
- LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne);
- if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) {
- ll_tvOne.setVisibility(View.GONE);
- }
- cancleButton = (Button) popupWindowView
- .findViewById(R.id.cancleButton);
- cancleButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- popupWindow.dismiss();
- }
- });
- tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree);
- tvThree.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
- intent.putExtra("start_jing", center.longitude + "");
- intent.putExtra("start_wei", center.latitude + "");
- intent.putExtra("stop_jing", ll.longitude + "");
- intent.putExtra("stop_wei", ll.latitude + "");
- startActivity(intent);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0033", map);
- map.clear();
- }
- });
- tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne);
- tvOne.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = null;
- int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1;
- int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1;
- if (position_jing > 13 || position_wei > 13) {
- getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei));
- } else {
- bd_jing = Double.parseDouble(poi_jing);
- bd_wei = Double.parseDouble(poi_wei);
- }
- getBaidu(center.longitude, center.latitude);
- try {
- 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";
- intent = Intent.getIntent(s);
- detailsBack = true;
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0031", map);
- map.clear();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- startActivity(intent);
- popupWindow.dismiss();
- }
- });
- tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
- tvTwo.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- try {
- 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"));
- intent4.setPackage("com.autonavi.minimap");
- startActivity(intent4);
- detailsBack = true;
- popupWindow.dismiss();
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("Name", zhan_name);
- map.put("CostWay", charge_cost_way);
- map.put("City", city);
- MobclickAgent.onEvent(context, "0032", map);
- map.clear();
- } catch (Exception e) {
- e.printStackTrace();
- Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show();
- }
- }
- });
- popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
- } else {
- ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT);
- }
- }
- }
- }).setNegativeButton("取消", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- }
- }).show();
- }
- }
- private void zhanGrade(String zhan_id) {
- long appTime1 = System.currentTimeMillis() / 1000;
- long updatetime = appTime1 - MainMapActivity.cha - 3;
- String token = String.valueOf(updatetime);
- String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanstar/getstar" +
- "?supplier=星星充电&timer=" + token + "&ver=1.0&zhan_id=" + zhan_id + "&sign="
- + Md5Util.md5("supplier=星星充电&timer=" + token + "&zhan_id=" + zhan_id + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a");
- OkHttpUtils.get()
- .url(url)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- }
- @Override
- public void onResponse(String response) {
- if (null != response) {
- String code = JsonUtils.getKeyResult(response, "code");
- String star_num = JsonUtils.getKeyResult(response, "star_level");
- if (star_num.equals("") || star_num.equals("0")) {
- windowGrade.setText("暂无评分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_0xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else {
- String star_level = star_num;
- double d;
- d = Double.parseDouble(star_level);
- String grade = String.format("%.1f", d);
- if (d > 0 && d < 1) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_05xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else if (d >= 1 && d < 1.5) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_1xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else if (d >= 1.5 && d < 2) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_15xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else if (d >= 2 && d < 2.5) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_2xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else if (d >= 2.5 && d < 3) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_25xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else if (d >= 3 && d < 3.5) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_3xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else if (d >= 3.5 && d < 4) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_35xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- } else if (d >= 4 && d < 4.5) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_4xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else if (d >= 4.5 && d < 5) {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_45xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- } else {
- windowGrade.setText(grade + "分");
- Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_5xing);
- rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight());
- windowGrade.setCompoundDrawables(rightDrawable, null, null, null);
- windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6));
- }
- }
- }
- }
- });
- }
- private void resetMarker() {
- if (nMarker != null) {
- nMarker.hideInfoWindow();
- if (current_chargePoint.getOwn_pay().equals("1")) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1));
- } else {
- if (current_chargePoint.getSuit_car().equals("特斯拉")) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
- } else {
- if (WelcomeActivity.canCost.contains(MainMapActivity.current_chargePoint.getSupplier())) {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
- } else {
- nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
- }
- }
- }
- }
- }
- private void getShareIntegral() {
- String url = MainApplication.url + "/zhannew/basic/web/index.php/member/insert-task?userid=" + MainApplication.userId;
- OkHttpUtils.get().url(url).build().execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- }
- @Override
- public void onResponse(String response) {
- Log.e(TAG, "onResponse: getShareIntegral=" + response);
- String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
- if (rtnCode.equals("01")) {
- } else {
- }
- }
- });
- }
- private void getMessageNum() {
- long appTime1 = System.currentTimeMillis() / 1000;
- String token = String.valueOf(appTime1);
- if (MainApplication.msgTime.equals("0")) {
- MainApplication.firstOpenTime = token;
- ProfileManager.getInstance().setFirstOpenTime(getApplicationContext(), token);
- MainApplication.msgTime = token;
- ProfileManager.getInstance().setSystemMsgTime(getApplicationContext(), token);
- }
- String url = MainApplication.url + "/zhannew/basic/web/index.php/question/center?user_id=" +
- MainApplication.userId + "&timer=" + MainApplication.msgTime + "&phone=" + MainApplication.userPhone
- + "&password=" + MainApplication.userPassword;
- OkHttpUtils.get().tag(MainMapActivity.this).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- }
- @Override
- public void onResponse(String response) {
- String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
- if ("01".equals(rtnCode)) {
- String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
- question_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "question_unread"));
- comment_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "comment_unread"));
- system_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "system_unread"));
- total_unread = question_unread + comment_unread + system_unread;
- if (total_unread > 0) {
- tv_msg_num.setVisibility(View.VISIBLE);
- tv_msg_num.setText(total_unread + "");
- } else {
- tv_msg_num.setVisibility(View.GONE);
- }
- }
- }
- });
- }
-
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void handleEvent(BaseEvent event) {
- if (event.getType().equals(BaseConstants.EVENT_SELECT_CITY)) {
- String locationCity = MainApplication.getInstance().getmCurrentCity();
- tv_atCity.setText(locationCity);
- MainApplication.atCity = locationCity;
- final LatLng cityLatLng = new LatLng(event.getPoi_lat(), event.getPoi_lon());
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(cityLatLng, 14.0f));
- }
- }, 500);
- } else {
- if (!isFirstLoc) {
- isFirstLoc = true;
- mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
- aMap.setLocationSource(this);
- aMap.setMyLocationEnabled(true);
- aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
- mlocationClient.setLocationListener(this);
- mlocationClient.startLocation();
- }
- }
- }
- private void showSimpleBottomSheetGrid(final ChargingShareBean chargingShareBean) {
- final int TAG_SHARE_WECHAT_FRIEND = 0;
- final int TAG_SHARE_WECHAT_MOMENT = 1;
- final int TAG_SHARE_QQ = 2;
- QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(MainMapActivity.this);
- QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
- .addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
- .addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
- .setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() {
- @Override
- public void onClick(QMUIBottomSheet dialog, View itemView) {
- dialog.dismiss();
- int tag = (int) itemView.getTag();
- switch (tag) {
- case TAG_SHARE_WECHAT_FRIEND:
- share(Wechat.NAME, chargingShareBean);
- break;
- case TAG_SHARE_WECHAT_MOMENT:
- share(WechatMoments.NAME, chargingShareBean);
- break;
- case TAG_SHARE_QQ:
- share(QQ.NAME, chargingShareBean);
- break;
- }
- }
- }).build();
- build.show();
- }
- private void share(final String name, ChargingShareBean chargingShareBean) {
- Platform.ShareParams paramsToShare = new Platform.ShareParams();
- paramsToShare.setText(chargingShareBean.getText());
- paramsToShare.setTitle(chargingShareBean.getTitle());
- paramsToShare.setTitleUrl(chargingShareBean.getUrl());
- paramsToShare.setUrl(chargingShareBean.getUrl());
- paramsToShare.setImageUrl(chargingShareBean.getIcon());
- paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
- Platform platform = ShareSDK.getPlatform(name);
- platform.setPlatformActionListener(new PlatformActionListener() {
- @Override
- public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
- if (MainApplication.isLogin()) {
- getShareIntegral();
- }
- }
- @Override
- public void onError(Platform platform, int i, Throwable throwable) {
- LogUtils.e(throwable.getMessage());
- }
- @Override
- public void onCancel(Platform platform, int i) {
- }
- });
- platform.share(paramsToShare);
- }
- private void getRecyclerViewData() {
- String findDate = ProfileManager.getInstance().getFindDate(MainMapActivity.this);
- if (EmptyUtils.isEmpty(findDate)) {
- findDate = String.valueOf(System.currentTimeMillis() / 1000);
- ProfileManager.getInstance().setFindDate(MainMapActivity.this, findDate);
- }
- String url = MainApplication.url + "/zhannew/basic/web/index.php/discovery/menu-list";
- OkHttpUtils.get().url(url).addParams("timer", findDate).build().execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- }
- @Override
- public void onResponse(String response) {
- if (EmptyUtils.isNotEmpty(response)) {
- String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
- if ("01".equals(rtnCode)) {
- String data = JsonUtils.getKeyResult(response, "data");
- List<FindData> list = JsonUtils.parseToObjectList(data, FindData.class);
- if (list.size() > 0) {
- for (FindData findData : list) {
- if (findData.getUnread().equals("0")) {
- FindActivity.haveFindMessage = true;
- iVpoint.setVisibility(View.VISIBLE);
- return;
- }
- }
- }
- }
- }
- }
- });
- }
- private void loadDmpData() {
- OkHttpUtils.get().url(MainApplication.url + "/zhannew/xd_url.php").build().connTimeOut(3000).readTimeOut(3000)
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- e.printStackTrace();
- }
- @Override
- public void onResponse(String response) {
- String show_url = JsonUtils.getKeyResult(response, "show_url");
- String click_url = JsonUtils.getKeyResult(response, "click_url");
- uploadDmp(show_url);
- sav.setClick_url(click_url);
- }
- });
- }
- private void uploadDmp(String url) {
- url = Util.generateDmpUrl(url);
- OkHttpUtils.get().url(url).build().connTimeOut(3000).readTimeOut(3000)
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e) {
- e.printStackTrace();
- }
- @Override
- public void onResponse(String response) {
- }
- });
- }
- }
|