充电桩app代码

UserCenterActivity.java 68KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  1. package com.electric.chargingpile.activity;
  2. import android.Manifest;
  3. import android.app.Activity;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.content.SharedPreferences;
  9. import android.graphics.Bitmap;
  10. import android.graphics.BitmapFactory;
  11. import android.graphics.Canvas;
  12. import android.graphics.Paint;
  13. import android.graphics.PorterDuff;
  14. import android.graphics.PorterDuffXfermode;
  15. import android.net.ConnectivityManager;
  16. import android.net.NetworkInfo;
  17. import android.net.Uri;
  18. import android.os.Bundle;
  19. import android.os.Environment;
  20. import android.os.Handler;
  21. import android.os.Message;
  22. import android.os.Process;
  23. import androidx.annotation.NonNull;
  24. import android.util.Log;
  25. import android.view.KeyEvent;
  26. import android.view.View;
  27. import android.view.WindowManager;
  28. import android.widget.FrameLayout;
  29. import android.widget.ImageView;
  30. import android.widget.LinearLayout;
  31. import android.widget.RelativeLayout;
  32. import android.widget.TextView;
  33. import android.widget.Toast;
  34. import android.widget.ToggleButton;
  35. import com.amap.api.services.weather.LocalDayWeatherForecast;
  36. import com.amap.api.services.weather.LocalWeatherForecast;
  37. import com.amap.api.services.weather.LocalWeatherForecastResult;
  38. import com.amap.api.services.weather.LocalWeatherLive;
  39. import com.amap.api.services.weather.LocalWeatherLiveResult;
  40. import com.amap.api.services.weather.WeatherSearch;
  41. import com.amap.api.services.weather.WeatherSearchQuery;
  42. import com.blankj.utilcode.util.ActivityUtils;
  43. import com.blankj.utilcode.util.BarUtils;
  44. import com.electric.chargingpile.R;
  45. import com.electric.chargingpile.application.MainApplication;
  46. import com.electric.chargingpile.data.Adin;
  47. import com.electric.chargingpile.data.CarOwnerCertificateBean;
  48. import com.electric.chargingpile.entity.CarSeriesEntity;
  49. import com.electric.chargingpile.manager.ProfileManager;
  50. import com.electric.chargingpile.util.DES3;
  51. import com.electric.chargingpile.util.JsonUtils;
  52. import com.electric.chargingpile.util.LoadingDialog;
  53. import com.electric.chargingpile.util.NetUtil;
  54. import com.electric.chargingpile.util.OkHttpUtil;
  55. import com.electric.chargingpile.util.PicassoUtil;
  56. import com.electric.chargingpile.util.Util;
  57. import com.electric.chargingpile.view.AlertDialogTwo;
  58. import com.electric.chargingpile.view.ObservableScrollView;
  59. import com.electric.chargingpile.view.RoundImageView;
  60. import com.electric.chargingpile.view.ScrollViewListener;
  61. import com.electric.chargingpile.view.SignInDialog;
  62. import com.google.android.gms.appindexing.Action;
  63. import com.google.android.gms.appindexing.AppIndex;
  64. import com.google.android.gms.common.api.GoogleApiClient;
  65. import com.google.gson.Gson;
  66. import com.squareup.okhttp.Request;
  67. import com.squareup.okhttp.Response;
  68. import com.squareup.picasso.Picasso;
  69. import com.umeng.analytics.MobclickAgent;
  70. import com.zhy.http.okhttp.OkHttpUtils;
  71. import com.zhy.http.okhttp.callback.StringCallback;
  72. import com.zhy.http.okhttp.request.RequestCall;
  73. import org.json.JSONException;
  74. import org.json.JSONObject;
  75. import java.io.File;
  76. import java.io.FileOutputStream;
  77. import java.io.IOException;
  78. import java.io.InputStream;
  79. import java.net.HttpURLConnection;
  80. import java.net.MalformedURLException;
  81. import java.net.URL;
  82. import java.net.URLEncoder;
  83. import java.util.List;
  84. import okhttp3.Call;
  85. import pub.devrel.easypermissions.AfterPermissionGranted;
  86. import pub.devrel.easypermissions.AppSettingsDialog;
  87. import pub.devrel.easypermissions.EasyPermissions;
  88. //import cn.sharesdk.framework.Platform;
  89. //import cn.sharesdk.framework.PlatformActionListener;
  90. //import cn.sharesdk.framework.ShareSDK;
  91. //import cn.sharesdk.onekeyshare.OnekeyShare;
  92. public class UserCenterActivity extends Activity implements View.OnClickListener,
  93. ScrollViewListener, WeatherSearch.OnWeatherSearchListener, EasyPermissions.PermissionCallbacks {
  94. private static final String TAG = "UserCenterActivity";
  95. private IntentFilter intentFilter;
  96. private Bitmap download_bmp;
  97. private NetworkChangeReceiver networkChangeReceiver;
  98. private ImageView iv_back, iv_message, iv_qiandao, iv_share_prompt, iv_find, iv_main, iv_screening, iv_point;
  99. private RelativeLayout rl_addZhan, rl_collection, rl_more,
  100. rl_offline, rl_shop, rl_message, rl_feedback, rl_shareNo, rl_offline_upload, rl_chongzhi, rl_myaccount, rl_yue, rl_chongdianbi, rl_hongbao, rl_car_owner_certificate, rl_publish_price;
  101. private ToggleButton mTogBtn;
  102. private TextView tv_exit, userLogin, userRegister, chongdianbi, yue, hongbao, tv_our;
  103. private LinearLayout ll_userLogin;
  104. private RelativeLayout ll_noLogin, rl_myaq, ll_tab_find;
  105. private TextView show_userPoints, show_userName, tv_msg_num, tv_msg_num1;
  106. private ImageView iv_gift, usermore, bg_icon, default_icon, iv_rank, iv_tishi, iv_usermore, iv_yue, iv_hongbao, iv_chongdianbi, iv_paihang, iv_qiandao_default, iv_paihang_default;
  107. private RoundImageView userIcon;
  108. private RelativeLayout llPerson, rl_sirenzhuang;
  109. private String integral, integral2;
  110. private LinearLayout tab_main, tab_hot, tab_claim, tab_me, tab_scan, tab_qa;
  111. static Bitmap bitmap = null;
  112. private Bitmap bm = null;
  113. private FrameLayout fl_icon;
  114. private long exitTime = 0;
  115. private String shareNo;
  116. private RelativeLayout ll_btn, rl_shezhi;
  117. private ObservableScrollView sv;
  118. private Activity activity;
  119. private int zhanMessageNum = 0, commentNum = 0;
  120. String name;
  121. Bitmap target;
  122. private ImageView iv_our;
  123. private WeatherSearchQuery mquery;
  124. private WeatherSearchQuery mquery1;
  125. private WeatherSearch mweathersearch;
  126. private WeatherSearch mweathersearch1;
  127. private String now_temperature = "", now_weather = "", temperature = "";
  128. // String imageUrl = MainApplication.userIcon;
  129. Bitmap usericonbt;
  130. private LoadingDialog loadDialog;
  131. private TextView tv_qaNum, tv_messageNum;
  132. private static final int RC_CAMERA_PERM = 123;
  133. private Handler handler = new Handler() {
  134. // 主线程通过这个方法处理消息
  135. @Override
  136. public void handleMessage(Message msg) {
  137. switch (msg.what) {
  138. case 3:
  139. Toast.makeText(getApplication(), "服务器处理错误", Toast.LENGTH_SHORT).show();
  140. break;
  141. case 17:
  142. try {
  143. JSONObject jsonObject = new JSONObject(msg.obj.toString());
  144. String pingLunNum = jsonObject.getString("rtnMsg");
  145. Log.d("pingLunNum+++", pingLunNum);
  146. MainMapActivity.have_pinglun = Integer.parseInt(pingLunNum);
  147. Log.d("pinglun===yonghu", MainMapActivity.have_message + "");
  148. } catch (JSONException e) {
  149. e.printStackTrace();
  150. }
  151. break;
  152. default:
  153. break;
  154. }
  155. }
  156. };
  157. /**
  158. * ATTENTION: This was auto-generated to implement the App Indexing API.
  159. * See https://g.co/AppIndexing/AndroidStudio for more information.
  160. */
  161. private GoogleApiClient client;
  162. private ImageView chat_share_bar;
  163. private TextView car_owner_certificate_label;
  164. //把一个url的网络图片变成一个本地的BitMap
  165. public Bitmap returnBitMap(final String url) {
  166. new Thread(new Runnable() {
  167. @Override
  168. public void run() {
  169. URL myFileUrl = null;
  170. Bitmap bitmap = null;
  171. try {
  172. myFileUrl = new URL(url);
  173. } catch (MalformedURLException e) {
  174. e.printStackTrace();
  175. }
  176. try {
  177. HttpURLConnection conn = (HttpURLConnection) myFileUrl
  178. .openConnection();
  179. conn.setDoInput(true);
  180. conn.connect();
  181. InputStream is = conn.getInputStream();
  182. bitmap = BitmapFactory.decodeStream(is);
  183. is.close();
  184. } catch (IOException e) {
  185. e.printStackTrace();
  186. }
  187. }
  188. }).start();
  189. return bitmap;
  190. }
  191. @Override
  192. protected void onCreate(Bundle savedInstanceState) {
  193. super.onCreate(savedInstanceState);
  194. setContentView(R.layout.activity_user_center);
  195. intentFilter = new IntentFilter();
  196. intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
  197. networkChangeReceiver = new NetworkChangeReceiver();
  198. registerReceiver(networkChangeReceiver, intentFilter);
  199. //透明状态栏
  200. getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  201. initView();
  202. activity = this;
  203. if (MainApplication.isLogin()) {
  204. getPingLun();
  205. }
  206. // ATTENTION: This was auto-generated to implement the App Indexing API.
  207. // See https://g.co/AppIndexing/AndroidStudio for more information.
  208. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
  209. }
  210. Handler hand = new Handler() {
  211. public void handleMessage(Message msg) {
  212. switch (msg.what) {
  213. case 2:
  214. try {
  215. saveBitmap(bm);
  216. setIcon();
  217. } catch (Exception e) {
  218. e.printStackTrace();
  219. }
  220. break;
  221. default:
  222. break;
  223. }
  224. }
  225. ;
  226. };
  227. private void initView() {
  228. loadDialog = new LoadingDialog(this);
  229. loadDialog.setCanceledOnTouchOutside(false);
  230. mquery = new WeatherSearchQuery(MainMapActivity.location_city, WeatherSearchQuery.WEATHER_TYPE_FORECAST);
  231. mweathersearch = new WeatherSearch(this);
  232. mweathersearch.setOnWeatherSearchListener(this);
  233. mweathersearch.setQuery(mquery);
  234. mweathersearch.searchWeatherAsyn(); //异步搜索
  235. mquery1 = new WeatherSearchQuery(MainMapActivity.location_city, WeatherSearchQuery.WEATHER_TYPE_LIVE);
  236. mweathersearch1 = new WeatherSearch(this);
  237. mweathersearch1.setOnWeatherSearchListener(this);
  238. mweathersearch1.setQuery(mquery1);
  239. mweathersearch1.searchWeatherAsyn(); //异步搜索
  240. sv = (ObservableScrollView) findViewById(R.id.sv);
  241. sv.setScrollViewListener(this);
  242. iv_qiandao = (ImageView) findViewById(R.id.iv_qiandao);
  243. iv_qiandao.setOnClickListener(this);
  244. rl_shezhi = findViewById(R.id.rl_shezhi);
  245. int statusBarHeight = BarUtils.getStatusBarHeight();
  246. rl_shezhi.setTranslationY(statusBarHeight);
  247. tv_qaNum = (TextView) findViewById(R.id.tv_qaNum);
  248. tv_messageNum = (TextView) findViewById(R.id.tv_messageNum);
  249. tab_qa = (LinearLayout) findViewById(R.id.tab_qa);
  250. tab_qa.setOnClickListener(this);
  251. iv_qiandao_default = (ImageView) findViewById(R.id.iv_qiandao_default);
  252. iv_gift = (ImageView) findViewById(R.id.iv_gift);
  253. iv_qiandao_default.setOnClickListener(this);
  254. iv_gift.setOnClickListener(this);
  255. iv_paihang = (ImageView) findViewById(R.id.iv_paihang);
  256. iv_paihang.setOnClickListener(this);
  257. iv_paihang_default = (ImageView) findViewById(R.id.iv_paihang_default);
  258. iv_paihang_default.setOnClickListener(this);
  259. rl_sirenzhuang = (RelativeLayout) findViewById(R.id.rl_sirenzhuang);
  260. rl_sirenzhuang.setOnClickListener(this);
  261. iv_share_prompt = (ImageView) findViewById(R.id.iv_share_prompt);
  262. tv_msg_num = (TextView) findViewById(R.id.tv_msg_num);
  263. rl_myaq = (RelativeLayout) findViewById(R.id.rl_myaq);
  264. rl_myaq.setOnClickListener(this);
  265. iv_yue = (ImageView) findViewById(R.id.iv_yue);
  266. iv_hongbao = (ImageView) findViewById(R.id.iv_hongbao);
  267. iv_chongdianbi = (ImageView) findViewById(R.id.iv_chongdianbi);
  268. yue = (TextView) findViewById(R.id.tv_yue);
  269. iv_message = (ImageView) findViewById(R.id.iv_have_message);
  270. ll_tab_find = (RelativeLayout) findViewById(R.id.ll_tab_find);
  271. ll_tab_find.setOnClickListener(this);
  272. chongdianbi = (TextView) findViewById(R.id.tv_chongdianbi);
  273. hongbao = (TextView) findViewById(R.id.tv_hongbao);
  274. ll_btn = (RelativeLayout) findViewById(R.id.ll_btn);
  275. iv_point = findViewById(R.id.iv_point);
  276. iv_our = (ImageView) findViewById(R.id.iv_our);
  277. rl_collection = (RelativeLayout) findViewById(R.id.rl_collection);
  278. rl_collection.setOnClickListener(this);
  279. rl_message = (RelativeLayout) findViewById(R.id.rl_message);
  280. rl_message.setOnClickListener(this);
  281. rl_shareNo = (RelativeLayout) findViewById(R.id.rl_shareNo);
  282. rl_shareNo.setOnClickListener(this);
  283. rl_offline_upload = (RelativeLayout) findViewById(R.id.rl_offline_upload);
  284. rl_offline_upload.setOnClickListener(this);
  285. chat_share_bar = findViewById(R.id.chat_share_bar);
  286. chat_share_bar.setOnClickListener(this);
  287. rl_car_owner_certificate = findViewById(R.id.rl_car_owner_certificate);
  288. rl_car_owner_certificate.setOnClickListener(this);
  289. rl_publish_price = findViewById(R.id.rl_publish_price);
  290. rl_publish_price.setOnClickListener(this);
  291. rl_chongzhi = (RelativeLayout) findViewById(R.id.rl_chongzhi);
  292. rl_chongzhi.setOnClickListener(this);
  293. rl_myaccount = (RelativeLayout) findViewById(R.id.rl_myaccount);
  294. rl_myaccount.setOnClickListener(this);
  295. rl_chongdianbi = (RelativeLayout) findViewById(R.id.rl_chongdianbi);
  296. rl_chongdianbi.setOnClickListener(this);
  297. rl_hongbao = (RelativeLayout) findViewById(R.id.rl_hongbao);
  298. rl_hongbao.setOnClickListener(this);
  299. rl_yue = (RelativeLayout) findViewById(R.id.rl_yue);
  300. rl_yue.setOnClickListener(this);
  301. tab_main = (LinearLayout) findViewById(R.id.tab_main);
  302. tab_main.setOnClickListener(this);
  303. tab_hot = (LinearLayout) findViewById(R.id.tab_hot);
  304. tab_hot.setOnClickListener(this);
  305. tab_claim = (LinearLayout) findViewById(R.id.tab_claim);
  306. tab_claim.setOnClickListener(this);
  307. tab_scan = (LinearLayout) findViewById(R.id.tab_screening);
  308. tab_scan.setOnClickListener(this);
  309. iv_find = (ImageView) findViewById(R.id.iv_find);
  310. iv_main = (ImageView) findViewById(R.id.iv_main);
  311. iv_screening = (ImageView) findViewById(R.id.iv_screening);
  312. tv_our = (TextView) findViewById(R.id.tv_our);
  313. //整个用户banner布局
  314. llPerson = (RelativeLayout) findViewById(R.id.ll_person);
  315. llPerson.setOnClickListener(this);
  316. car_owner_certificate_label = findViewById(R.id.car_owner_certificate_label);
  317. //登陆按钮
  318. userLogin = (TextView) findViewById(R.id.userLogin);
  319. userLogin.setOnClickListener(this);
  320. //注册按钮
  321. userRegister = (TextView) findViewById(R.id.userRegister);
  322. userRegister.setOnClickListener(this);
  323. //包含登陆按钮和注册按钮的线性布局
  324. ll_userLogin = (LinearLayout) findViewById(R.id.ll_userLogin);
  325. //未登录状态头像显示
  326. ll_noLogin = (RelativeLayout) findViewById(R.id.ll_noLogin);
  327. //显示用户积分
  328. // show_userPoints = (TextView) findViewById(R.id.show_userPoints);
  329. //显示用户名
  330. show_userName = (TextView) findViewById(R.id.show_username);
  331. //用户详情信息图标
  332. usermore = (ImageView) findViewById(R.id.iv_usermore);
  333. //用户头像
  334. userIcon = (RoundImageView) findViewById(R.id.user);
  335. // if (!MainApplication.userIcon.equals("")) {
  336. // PicassoUtil.loadingNetImage(getApplication(), MainApplication.userIcon, userIcon);
  337. // }
  338. bg_icon = (ImageView) findViewById(R.id.bg_icon);
  339. // iv_rank = (ImageView) findViewById(R.id.iv_rank);
  340. iv_usermore = (ImageView) findViewById(R.id.iv_usermore);
  341. iv_usermore.setOnClickListener(this);
  342. if (MainMapActivity.total_unread > 0) {
  343. tv_msg_num.setVisibility(View.VISIBLE);
  344. tv_msg_num.setText(MainMapActivity.total_unread + "");
  345. if (MainMapActivity.question_unread > 0) {
  346. tv_qaNum.setVisibility(View.VISIBLE);
  347. tv_qaNum.setText(MainMapActivity.question_unread + "");
  348. } else {
  349. tv_qaNum.setVisibility(View.GONE);
  350. }
  351. if (MainMapActivity.system_unread + MainMapActivity.comment_unread > 0) {
  352. tv_messageNum.setVisibility(View.VISIBLE);
  353. tv_messageNum.setText(MainMapActivity.system_unread + MainMapActivity.comment_unread + "");
  354. } else {
  355. tv_messageNum.setVisibility(View.GONE);
  356. }
  357. } else {
  358. tv_msg_num.setVisibility(View.GONE);
  359. tv_qaNum.setVisibility(View.GONE);
  360. tv_messageNum.setVisibility(View.GONE);
  361. }
  362. // iv_tishi = (ImageView) findViewById(R.id.iv_tishi);
  363. // iv_tishi.setOnClickListener(this);
  364. //默认头像
  365. // setIcon();
  366. // PicassoUtil.loadingNetImage(UserCenterActivity.this, MainApplication.userIcon, userIcon);
  367. set_loginShow();
  368. }
  369. private void getSharePrompt(String user_id) {
  370. OkHttpUtils.get().url("http://123.57.6.131/zhannew/basic/web/index.php/present/index")
  371. .addParams("user_id", user_id)
  372. .build().execute(new StringCallback() {
  373. @Override
  374. public void onError(Call call, Exception e) {
  375. }
  376. @Override
  377. public void onResponse(String response) {
  378. String status = JsonUtils.getKeyResult(response, "status");
  379. // Log.e("status===",status);
  380. if (status.equals("1")) {
  381. iv_share_prompt.setVisibility(View.VISIBLE);
  382. } else {
  383. iv_share_prompt.setVisibility(View.GONE);
  384. }
  385. }
  386. });
  387. }
  388. private void setIcon() {
  389. // if (!MainApplication.userIcon.equals("")&&!MainApplication.userIcon.equals("V")){
  390. // new Thread(new Runnable() {
  391. // @Override
  392. // public void run() {
  393. // Log.e("1234","22222222");
  394. // bm = ImageLoader.getInstance().loadImageSync(MainApplication.userIcon);
  395. // if (bm != null) {
  396. // Message mes = new Message();
  397. // mes.obj = bm;
  398. // mes.what = 2;
  399. // hand.sendMessage(mes);
  400. // }
  401. // }
  402. // }).start();
  403. // }
  404. if (MainApplication.userIcon.equals("V")) {
  405. // Log.e("1111", "11111");
  406. usericonbt = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + File.separator + "d1ev/usericon");
  407. userIcon.setImageBitmap(usericonbt);
  408. } else if (MainApplication.userIcon.equals("")) {
  409. // Log.e("2222", "22222");
  410. userIcon.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.icon_face2_0));
  411. } else {
  412. // Log.e("3333", "33333");
  413. // userIcon.setImageBitmap(bm);
  414. if (!MainApplication.userIcon.equals("")) {
  415. // Glide.with(MainApplication.context)
  416. // .load(MainApplication.userIcon)
  417. // .error(R.drawable.icon_face2_0)
  418. // .placeholder(R.drawable.icon_face2_0)
  419. // .into(userIcon);
  420. PicassoUtil.loadingNetImage(getApplication(), MainApplication.userIcon, userIcon);
  421. }
  422. }
  423. }
  424. public void saveBitmap(Bitmap mBitmap) {
  425. String dir_path = Environment.getExternalStorageDirectory() + File.separator + "d1ev/";
  426. File directory = new File(dir_path);
  427. File f = new File(dir_path, "usericon");
  428. try {
  429. if (!directory.exists()) {
  430. directory.mkdir();//没有目录先创建目录
  431. }
  432. f.createNewFile();
  433. } catch (IOException e) {
  434. // TODO Auto-generated catch block
  435. }
  436. FileOutputStream fOut = null;
  437. try {
  438. fOut = new FileOutputStream(f);
  439. } catch (Exception e) {
  440. e.printStackTrace();
  441. }
  442. mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
  443. try {
  444. fOut.flush();
  445. } catch (IOException e) {
  446. e.printStackTrace();
  447. }
  448. try {
  449. fOut.close();
  450. } catch (IOException e) {
  451. e.printStackTrace();
  452. }
  453. }
  454. @Override
  455. public boolean onKeyDown(int keyCode, KeyEvent event) {
  456. if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
  457. if ((System.currentTimeMillis() - exitTime) > 2000) {
  458. Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
  459. exitTime = System.currentTimeMillis();
  460. } else {
  461. if (MainMapActivity.mainMapActivity != null) {
  462. MainMapActivity.mainMapActivity.finish();
  463. }
  464. SharedPreferences mySharedPreferences = getSharedPreferences("showdialog",
  465. Activity.MODE_PRIVATE);
  466. SharedPreferences.Editor editor1 = mySharedPreferences.edit();
  467. editor1.clear();
  468. ProfileManager.getInstance().setSearchAddress(this, "");
  469. ActivityUtils.finishAllActivities();
  470. // finish();
  471. // System.exit(0);
  472. Process.killProcess(Process.myPid());
  473. }
  474. return true;
  475. }
  476. return super.onKeyDown(keyCode, event);
  477. }
  478. // public void saveBitmap() {
  479. // Log.e("@@@", "保存图片");
  480. // File f = new File("/sdcard/d1ev/", "usericon");
  481. // if (f.exists()) {
  482. // f.delete();
  483. // }
  484. // try {
  485. // FileOutputStream out = new FileOutputStream(f);
  486. // bm.compress(Bitmap.CompressFormat.PNG, 90, out);
  487. // out.flush();
  488. // out.close();
  489. // Log.i("@@@", "已经保存");
  490. // } catch (FileNotFoundException e) {
  491. //// TODO Auto-generated catch block
  492. // e.printStackTrace();
  493. // } catch (IOException e) {
  494. //// TODO Auto-generated catch block
  495. // e.printStackTrace();
  496. // }
  497. // }
  498. private void set_loginShow() {
  499. if (MainApplication.isLogin()) {
  500. // if (!MainApplication.userIcon.equals("")){
  501. // PicassoUtil.loadingNetImage(UserCenterActivity.this, MainApplication.userIcon, userIcon);
  502. // }else {
  503. //
  504. // SharedPreferences sharedPreferences= getSharedPreferences("userInfo",
  505. // Activity.MODE_PRIVATE);
  506. //
  507. // String userphoto = sharedPreferences.getString("userphoto","");
  508. // Log.e("!!!",userphoto);
  509. // userIcon.setImageBitmap(base64ToBitmap(userphoto));
  510. // }
  511. ////
  512. setIcon();
  513. // bg_icon.setVisibility(View.VISIBLE);
  514. // iv_tishi.setVisibility(View.VISIBLE);
  515. // createCircleImage(returnBitMap(imageUrl),15);
  516. // userIcon.setImageBitmap(target);
  517. userIcon.setVisibility(View.VISIBLE);
  518. // fl_icon.setVisibility(View.VISIBLE);
  519. ll_btn.setVisibility(View.VISIBLE);
  520. ll_btn.setEnabled(true);
  521. ll_btn.setOnClickListener(new View.OnClickListener() {
  522. @Override
  523. public void onClick(View v) {
  524. MobclickAgent.onEvent(getApplicationContext(), "0802");
  525. MobclickAgent.onEvent(getApplicationContext(), "1093");
  526. // startActivity(new Intent(getApplicationContext(), PersonalPageActivity.class));
  527. // startActivity(new Intent(getApplicationContext(), UserInfoActivity.class));
  528. startActivity(new Intent(getApplicationContext(), UserPageActivity.class));
  529. }
  530. });
  531. ll_userLogin.setVisibility(View.INVISIBLE);
  532. ll_noLogin.setVisibility(View.INVISIBLE);
  533. iv_yue.setVisibility(View.GONE);
  534. iv_chongdianbi.setVisibility(View.GONE);
  535. iv_hongbao.setVisibility(View.GONE);
  536. yue.setVisibility(View.VISIBLE);
  537. hongbao.setVisibility(View.VISIBLE);
  538. chongdianbi.setVisibility(View.VISIBLE);
  539. show_userName.setVisibility(View.VISIBLE);
  540. // iv_rank.setVisibility(View.GONE);
  541. if (!ProfileManager.getInstance().getNickname(getApplication()).equals("")) {
  542. sp();
  543. MainApplication.userNickname = ProfileManager.getInstance().getNickname(getApplication());
  544. show_userName.setText(MainApplication.userNickname);
  545. } else {
  546. show_userName.setText(Util.handlePhone(ProfileManager.getInstance()
  547. .getUsername(getApplication())));
  548. }
  549. // show_userPoints.setVisibility(View.VISIBLE);
  550. // default_icon.setVisibility(View.GONE);
  551. // usermore.setVisibility(View.VISIBLE);
  552. // tv_exit.setVisibility(View.VISIBLE);
  553. MainApplication.userPhone = ProfileManager.getInstance().getUsername(getApplication());
  554. MainApplication.userId = ProfileManager.getInstance().getUserid(getApplication());
  555. // MainApplication.userIcon = ProfileManager.getInstance().getUsericon(getApplication());
  556. } else {
  557. iv_gift.setImageResource(R.drawable.icon_qiandaohavegift);
  558. ll_btn.setVisibility(View.GONE);
  559. llPerson.setEnabled(false);
  560. ll_userLogin.setVisibility(View.VISIBLE);
  561. ll_noLogin.setVisibility(View.VISIBLE);
  562. iv_yue.setVisibility(View.VISIBLE);
  563. iv_hongbao.setVisibility(View.VISIBLE);
  564. iv_chongdianbi.setVisibility(View.VISIBLE);
  565. yue.setVisibility(View.INVISIBLE);
  566. hongbao.setVisibility(View.INVISIBLE);
  567. chongdianbi.setVisibility(View.INVISIBLE);
  568. show_userName.setVisibility(View.INVISIBLE);
  569. // show_userPoints.setVisibility(View.INVISIBLE);
  570. // usermore.setVisibility(View.INVISIBLE);
  571. // iv_rank.setVisibility(View.GONE);
  572. // tv_exit.setVisibility(View.GONE);
  573. // iv_tishi.setVisibility(View.GONE);
  574. // default_icon.setVisibility(View.VISIBLE);
  575. bg_icon.setVisibility(View.INVISIBLE);
  576. userIcon.setVisibility(View.GONE);
  577. // fl_icon.setVisibility(View.GONE);
  578. }
  579. }
  580. private void sp() {
  581. SharedPreferences mySharedPreferences = getSharedPreferences("userInfo",
  582. Activity.MODE_PRIVATE);
  583. name = mySharedPreferences.getString("nickname", "");
  584. }
  585. @Override
  586. public void onClick(View v) {
  587. switch (v.getId()) {
  588. case R.id.rl_myaq:
  589. if (!MainApplication.isLogin()) {
  590. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  591. startActivity(new Intent(getApplication(), LoginActivity.class));
  592. } else {
  593. MobclickAgent.onEvent(getApplicationContext(), "0812");
  594. startActivityForResult(new Intent(getApplicationContext(), MyQAActivity.class), 2);
  595. }
  596. break;
  597. case R.id.iv_qiandao:
  598. MobclickAgent.onEvent(getApplicationContext(), "0803");
  599. startActivity(new Intent(getApplication(), MemberCenterActivity.class));
  600. break;
  601. case R.id.iv_qiandao_default: // 会员中心
  602. if (!MainApplication.isLogin()) {
  603. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  604. startActivity(new Intent(getApplication(), LoginActivity.class));
  605. }
  606. break;
  607. case R.id.iv_gift:
  608. if (!MainApplication.isLogin()) {
  609. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  610. startActivity(new Intent(getApplication(), LoginActivity.class));
  611. } else {
  612. MobclickAgent.onEvent(getApplicationContext(), "0805");
  613. // startActivity(new Intent(getApplication(), WebQianDaoActivity.class));
  614. // MobclickAgent.onEvent(getApplicationContext(), "0015");
  615. signIn();
  616. }
  617. break;
  618. case R.id.ll_tab_find:
  619. MobclickAgent.onEvent(getApplicationContext(), "0105");
  620. Intent intent = new Intent(getApplication(), FindActivity.class);
  621. intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  622. startActivity(intent);
  623. finish();
  624. overridePendingTransition(0, 0);
  625. break;
  626. case R.id.tab_main:
  627. Intent ii = new Intent(getApplication(), MainMapActivity.class);
  628. ii.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  629. startActivity(ii);
  630. MobclickAgent.onEvent(getApplicationContext(), "0118");
  631. finish();
  632. overridePendingTransition(0, 0);
  633. break;
  634. case R.id.tab_screening:
  635. if (!MainApplication.isLogin()) {
  636. startActivity(new Intent(getApplication(), LoginActivity.class));
  637. } else if (!cameraTask()) {
  638. EasyPermissions.requestPermissions(
  639. this,
  640. "该功能需要开启摄像头权限,是否前往开启?",
  641. RC_CAMERA_PERM,
  642. Manifest.permission.CAMERA);
  643. } else {
  644. Intent iintent = new Intent(getApplicationContext(), com.google.zxing.client.android.CaptureActivity.class);
  645. iintent.putExtra("url", MainApplication.url);
  646. iintent.putExtra("user_id", MainApplication.userId);
  647. iintent.putExtra("user_password", MainApplication.userPassword);
  648. iintent.putExtra("user_phone", MainApplication.userPhone);
  649. iintent.putExtra("cha", MainMapActivity.cha);
  650. iintent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  651. startActivity(iintent);
  652. overridePendingTransition(0, 0);
  653. MobclickAgent.onEvent(getApplicationContext(), "0104");
  654. }
  655. break;
  656. case R.id.tab_qa:
  657. MobclickAgent.onEvent(getApplicationContext(), "0999");
  658. Intent intent7 = new Intent(getApplication(), ChatActivity.class);
  659. intent7.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  660. startActivity(intent7);
  661. finish();
  662. overridePendingTransition(0, 0);
  663. break;
  664. case R.id.iv_back:
  665. break;
  666. case R.id.iv_paihang: // 排行榜
  667. startActivity(new Intent(getApplicationContext(), RankingListActivity.class));
  668. MobclickAgent.onEvent(getApplicationContext(), "0804");
  669. break;
  670. case R.id.iv_paihang_default: // 排行榜
  671. startActivity(new Intent(getApplicationContext(), RankingListActivity.class));
  672. MobclickAgent.onEvent(getApplicationContext(), "0804");
  673. break;
  674. case R.id.rl_shareNo:
  675. if (!MainApplication.isLogin()) {
  676. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  677. startActivity(new Intent(getApplication(), LoginActivity.class));
  678. } else {
  679. Intent intent4 = new Intent(getApplication(), MyWebViewActivity.class);
  680. intent4.putExtra("url", "http://evcharge.cc/cdz/yqm.html?code=" +
  681. getShareNo(Integer.parseInt(MainApplication.userId)) + "&phone=" + MainApplication.userPhone + "&ver=" + Math.random());
  682. startActivity(intent4);
  683. MobclickAgent.onEvent(getApplicationContext(), "0811");
  684. }
  685. break;
  686. case R.id.rl_collection:
  687. startActivity(new Intent(getApplication(), MyCollectActivity.class));
  688. MobclickAgent.onEvent(getApplicationContext(), "0815");
  689. break;
  690. case R.id.rl_car_owner_certificate: // 车主认证
  691. if (!MainApplication.isLogin()) {
  692. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  693. startActivity(new Intent(getApplication(), LoginActivity.class));
  694. } else {
  695. loadDialog.show();
  696. getCarOwnerCertificateList("certificate");
  697. }
  698. break;
  699. case R.id.rl_publish_price: // 发表成交价
  700. if (!MainApplication.isLogin()) {
  701. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  702. startActivity(new Intent(getApplication(), LoginActivity.class));
  703. } else {
  704. loadDialog.show();
  705. getCarOwnerCertificateList("price");
  706. }
  707. break;
  708. case R.id.rl_chongzhi:
  709. if (!MainApplication.isLogin()) {
  710. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  711. startActivity(new Intent(getApplication(), LoginActivity.class));
  712. } else {
  713. startActivity(new Intent(getApplication(), AccountRechargeActivity.class));
  714. MobclickAgent.onEvent(getApplicationContext(), "0810");
  715. }
  716. break;
  717. case R.id.rl_hongbao:
  718. if (!MainApplication.isLogin()) {
  719. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  720. startActivity(new Intent(getApplication(), LoginActivity.class));
  721. } else {
  722. long appTime4 = System.currentTimeMillis() / 1000;
  723. long updatetime4 = appTime4 - MainMapActivity.cha - 1;
  724. String token4 = String.valueOf(updatetime4);
  725. Intent intent4 = new Intent(getApplication(), MyWebViewActivity.class);
  726. String web1 = null;
  727. try {
  728. web1 = MainApplication.url + "/zhannew/basic/web/index.php/discount/redlist?userid=" + MainApplication.userId + "&token=" + URLEncoder.encode(DES3.encode(token4));
  729. } catch (Exception e) {
  730. e.printStackTrace();
  731. }
  732. intent4.putExtra("url", web1);
  733. startActivity(intent4);
  734. MobclickAgent.onEvent(getApplicationContext(), "0808");
  735. }
  736. break;
  737. case R.id.rl_chongdianbi:
  738. if (!MainApplication.isLogin()) {
  739. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  740. startActivity(new Intent(getApplication(), LoginActivity.class));
  741. } else {
  742. startActivity(new Intent(getApplication(), ChargingCoinsActivity.class));
  743. MobclickAgent.onEvent(getApplicationContext(), "0809");
  744. }
  745. break;
  746. case R.id.rl_yue:
  747. if (!MainApplication.isLogin()) {
  748. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  749. startActivity(new Intent(getApplication(), LoginActivity.class));
  750. } else {
  751. startActivity(new Intent(getApplication(), MyBalanceActivity.class));
  752. MobclickAgent.onEvent(getApplicationContext(), "0807");
  753. }
  754. break;
  755. case R.id.rl_myaccount:
  756. if (!MainApplication.isLogin()) {
  757. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  758. startActivity(new Intent(getApplication(), LoginActivity.class));
  759. } else {
  760. startActivity(new Intent(getApplication(), MyAccountActivity.class));
  761. MobclickAgent.onEvent(getApplicationContext(), "0806");
  762. }
  763. break;
  764. case R.id.rl_feedback:
  765. startActivity(new Intent(getApplication(), FeedbackActivity.class));
  766. break;
  767. case R.id.rl_message:
  768. startActivityForResult(new Intent(getApplication(), MyMessageActivity.class), 1);
  769. MobclickAgent.onEvent(getApplicationContext(), "0814");
  770. break;
  771. case R.id.rl_offline_upload:
  772. startActivity(new Intent(getApplication(), OfflineMapActivity.class));
  773. MobclickAgent.onEvent(getApplicationContext(), "0816");
  774. break;
  775. case R.id.chat_share_bar: // 聊聊入口
  776. MobclickAgent.onEvent(getApplicationContext(), "1123");
  777. Intent i = new Intent(getApplicationContext(), ChatActivity.class);//聊聊页面
  778. i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  779. startActivity(i);
  780. break;
  781. case R.id.iv_usermore:
  782. startActivity(new Intent(getApplication(), UserCenterMoreActivity.class));
  783. MobclickAgent.onEvent(getApplicationContext(), "0817");
  784. break;
  785. case R.id.userLogin:
  786. startActivity(new Intent(getApplication(), LoginActivity.class));
  787. break;
  788. case R.id.userRegister:
  789. startActivity(new Intent(getApplication(), RegisterActivity.class));
  790. break;
  791. case R.id.rl_sirenzhuang:
  792. if (!MainApplication.isLogin()) {
  793. Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
  794. startActivity(new Intent(getApplication(), LoginActivity.class));
  795. } else {
  796. MobclickAgent.onEvent(getApplicationContext(), "0813");
  797. startActivity(new Intent(this, PrivateZhaungListActivity.class));
  798. }
  799. break;
  800. }
  801. }
  802. private Bitmap createCircleImage(Bitmap source, int min) {
  803. final Paint paint = new Paint();
  804. paint.setAntiAlias(true);
  805. target = Bitmap.createBitmap(min, min, Bitmap.Config.ARGB_8888);
  806. /**
  807. * 产生一个同样大小的画布
  808. */
  809. Canvas canvas = new Canvas(target);
  810. /**
  811. * 首先绘制圆形
  812. */
  813. canvas.drawCircle(min / 2, min / 2, min / 2, paint);
  814. /**
  815. * 使用SRC_IN,参考上面的说明
  816. */
  817. paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
  818. /**
  819. * 绘制图片
  820. */
  821. canvas.drawBitmap(source, 0, 0, paint);
  822. return target;
  823. }
  824. private void getIntegration() {
  825. if (!NetUtil.CheckNetwork(this)) {
  826. Toast.makeText(this, "请检查网络", Toast.LENGTH_SHORT).show();
  827. return;
  828. }
  829. new Thread(new Runnable() {
  830. @Override
  831. public void run() {
  832. String url = "";
  833. try {
  834. url = MainApplication.url + "/zhannew/basic/web/index.php/tpmember/getintegral_v2?" +
  835. "user_id=" + MainApplication.userId + "&password=" + URLEncoder.encode(MainApplication.userPassword);
  836. } catch (Exception e) {
  837. e.printStackTrace();
  838. }
  839. submit(url);
  840. }
  841. }).start();
  842. }
  843. private void submit(String sms) {
  844. Request request = new Request.Builder().url(sms).build();
  845. Response response = null;
  846. try {
  847. if (request == null) {
  848. Message msg = new Message();
  849. msg.what = 3;
  850. handler.sendMessage(msg);
  851. return;
  852. }
  853. response = OkHttpUtil.execute(request);
  854. if (response.code() == 200) {
  855. String json = "";
  856. try {
  857. json = response.body().string();
  858. Message msg = new Message();
  859. msg.obj = json;
  860. msg.what = 2;
  861. handler.sendMessage(msg);
  862. } catch (Exception e) {
  863. e.printStackTrace();
  864. Message msg = new Message();
  865. msg.what = 3;
  866. handler.sendMessage(msg);
  867. }
  868. }
  869. } catch (Exception e) {
  870. e.printStackTrace();
  871. Message msg = new Message();
  872. msg.what = 3;
  873. handler.sendMessage(msg);
  874. }
  875. }
  876. @Override
  877. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  878. //先判断是哪个页面返回过来的
  879. switch (requestCode) {
  880. case 3:
  881. //再判断返回过来的情况,是成功还是失败还是其它的什么……
  882. case 1:
  883. getMessageNum();
  884. break;
  885. case 2:
  886. getMessageNum();
  887. break;
  888. }
  889. }
  890. private void getMessageNum() {
  891. long appTime1 = System.currentTimeMillis() / 1000;
  892. String token = String.valueOf(appTime1);
  893. if (MainApplication.msgTime.equals("0")) {
  894. MainApplication.firstOpenTime = token;
  895. ProfileManager.getInstance().setFirstOpenTime(getApplicationContext(), token);
  896. MainApplication.msgTime = token;
  897. ProfileManager.getInstance().setSystemMsgTime(getApplicationContext(), token);
  898. }
  899. String url = MainApplication.url + "/zhannew/basic/web/index.php/question/center?user_id=" +
  900. MainApplication.userId + "&timer=" + MainApplication.msgTime + "&phone=" + MainApplication.userPhone
  901. + "&password=" + MainApplication.userPassword;
  902. OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
  903. @Override
  904. public void onError(Call call, Exception e) {
  905. }
  906. @Override
  907. public void onResponse(String response) {
  908. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  909. if ("01".equals(rtnCode)) {
  910. String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
  911. MainMapActivity.question_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "question_unread"));
  912. MainMapActivity.comment_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "comment_unread"));
  913. MainMapActivity.system_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "system_unread"));
  914. MainMapActivity.total_unread = MainMapActivity.question_unread + MainMapActivity.comment_unread + MainMapActivity.system_unread;
  915. if (MainMapActivity.total_unread > 0) {
  916. tv_msg_num.setVisibility(View.VISIBLE);
  917. tv_msg_num.setText(MainMapActivity.total_unread + "");
  918. if (MainMapActivity.question_unread > 0) {
  919. tv_qaNum.setVisibility(View.VISIBLE);
  920. tv_qaNum.setText(MainMapActivity.question_unread + "");
  921. } else {
  922. tv_qaNum.setVisibility(View.GONE);
  923. }
  924. if (MainMapActivity.system_unread + MainMapActivity.comment_unread > 0) {
  925. tv_messageNum.setVisibility(View.VISIBLE);
  926. tv_messageNum.setText(MainMapActivity.system_unread + MainMapActivity.comment_unread + "");
  927. } else {
  928. tv_messageNum.setVisibility(View.GONE);
  929. }
  930. } else {
  931. tv_msg_num.setVisibility(View.GONE);
  932. tv_qaNum.setVisibility(View.GONE);
  933. tv_messageNum.setVisibility(View.GONE);
  934. }
  935. }
  936. }
  937. });
  938. }
  939. private void getCarOwnerCertificateList(String from) {
  940. long tokenTime = System.currentTimeMillis() / 1000 - MainMapActivity.cha - 1;
  941. String token = null;
  942. try {
  943. token = DES3.encode(String.valueOf(tokenTime));
  944. token = URLEncoder.encode(token, "UTF-8");
  945. } catch (Exception e) {
  946. e.printStackTrace();
  947. }
  948. String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token;
  949. OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
  950. @Override
  951. public void onError(Call call, Exception e) {
  952. e.printStackTrace();
  953. loadDialog.dismiss();
  954. Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
  955. }
  956. @Override
  957. public void onResponse(String response) {
  958. loadDialog.dismiss();
  959. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  960. if ("01".equals(rtnCode)) {
  961. String data = JsonUtils.getKeyResult(response, "data");
  962. List<CarOwnerCertificateBean> list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
  963. if ("price".equals(from)) {
  964. if (list.size() == 0) {
  965. new AlertDialogTwo(UserCenterActivity.this).builder()
  966. .setMsg("您还没有认证车主,认证车主可获双倍奖励哦。")
  967. .setPositiveButton("继续发表", new View.OnClickListener() {
  968. @Override
  969. public void onClick(View v) {
  970. Intent intent = new Intent(getApplication(), MyWebViewActivity.class);
  971. intent.putExtra("url", "https://www.d1ev.com/special/models/wap/webView/index.html");
  972. startActivity(intent);
  973. }
  974. }).setNegativeButton("去认证", new View.OnClickListener() {
  975. @Override
  976. public void onClick(View v) {
  977. startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
  978. }
  979. }).show();
  980. } else {
  981. Intent intent = new Intent(getApplication(), MyWebViewActivity.class);
  982. intent.putExtra("url", "https://www.d1ev.com/special/models/wap/webView/index.html");
  983. startActivity(intent);
  984. }
  985. } else if ("certificate".equals(from)) {
  986. if (list.size() == 0) {
  987. startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
  988. } else {
  989. Intent intent = new Intent(getApplication(), CarOwnerCertificateListActivity.class);
  990. intent.putExtra("data", data);
  991. startActivity(intent);
  992. }
  993. } else if ("init".equals(from)) {
  994. boolean certificated = false;
  995. String chexing = "";
  996. for (CarOwnerCertificateBean bean : list) {
  997. if (bean.getStatus() == 1 && bean.getMain() == 1) {
  998. certificated = true;
  999. chexing = bean.getChexing();
  1000. break;
  1001. }
  1002. }
  1003. if (certificated) {
  1004. Gson gson = new Gson();
  1005. CarSeriesEntity carSeriesEntity = gson.fromJson(chexing, CarSeriesEntity.class);
  1006. car_owner_certificate_label.setText(carSeriesEntity.getSeriesName());
  1007. } else {
  1008. car_owner_certificate_label.setText("认证车主获取充电优惠");
  1009. }
  1010. }
  1011. } else {
  1012. String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
  1013. Toast.makeText(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT).show();
  1014. }
  1015. }
  1016. });
  1017. }
  1018. @Override
  1019. protected void onResume() {
  1020. if (FindActivity.haveFindMessage == true) {
  1021. iv_point.setVisibility(View.VISIBLE);
  1022. } else {
  1023. iv_point.setVisibility(View.GONE);
  1024. }
  1025. set_loginShow();
  1026. if (MainApplication.isLogin()) {
  1027. new Handler().postDelayed(new Runnable() {
  1028. @Override
  1029. public void run() {
  1030. getUserIntegral();
  1031. }
  1032. }, 300);
  1033. }
  1034. super.onResume();
  1035. MobclickAgent.onResume(this);
  1036. if (MainApplication.isLogin()) {
  1037. if (!"".equals(MainApplication.userIcon)) {
  1038. Picasso.with(UserCenterActivity.this)
  1039. .load(MainApplication.userIcon)
  1040. .placeholder(R.drawable.icon_face2_0)
  1041. .error(R.drawable.icon_face2_0)
  1042. .into(userIcon);
  1043. } else {
  1044. userIcon.setImageResource(R.drawable.icon_face2_0);
  1045. }
  1046. }
  1047. if (MainApplication.isLogin()) {
  1048. getCarOwnerCertificateList("init");
  1049. }
  1050. }
  1051. @Override
  1052. public void onWeatherLiveSearched(LocalWeatherLiveResult localWeatherLiveResult, int rCode) {
  1053. if (rCode == 1000) {
  1054. if (localWeatherLiveResult != null & localWeatherLiveResult.getLiveResult() != null) {
  1055. LocalWeatherLive weatherlive = localWeatherLiveResult.getLiveResult();
  1056. now_temperature = weatherlive.getTemperature();
  1057. } else {
  1058. }
  1059. } else {
  1060. }
  1061. }
  1062. @Override
  1063. public void onWeatherForecastSearched(LocalWeatherForecastResult localWeatherForecastResult, int i) {
  1064. if (i == 1000) {
  1065. if (localWeatherForecastResult != null & localWeatherForecastResult.getForecastResult() != null) {
  1066. LocalWeatherForecast weatherlive = localWeatherForecastResult.getForecastResult();
  1067. // Log.e(TAG, "onWeatherLiveSearched: " + "-------" + weatherlive.getCity() + "-------" + weatherlive.getAdCode()
  1068. // + "-------" + weatherlive.getWeatherForecast().get(1)..getWeatherForecast() + "-------" + weatherlive.getProvince() + "-------" + weatherlive.getReportTime());
  1069. List<LocalDayWeatherForecast> list = weatherlive.getWeatherForecast();
  1070. if (list.size() > 1) {
  1071. temperature = list.get(0).getDayTemp() + "~" + list.get(0).getNightTemp();
  1072. if (list.get(0).getNightWeather().equals(list.get(0).getDayWeather())) {
  1073. now_weather = list.get(0).getDayWeather();
  1074. } else {
  1075. now_weather = list.get(0).getDayWeather() + "转" + list.get(0).getNightWeather();
  1076. }
  1077. }
  1078. } else {
  1079. }
  1080. } else {
  1081. }
  1082. }
  1083. private void getPingLun() {
  1084. new Thread(new Runnable() {
  1085. @Override
  1086. public void run() {
  1087. String url = null;
  1088. try {
  1089. url = MainApplication.url + "/zhannew/basic/web/index.php/tpmember/commentcount?userid=" + MainApplication.userId;
  1090. } catch (Exception e) {
  1091. e.printStackTrace();
  1092. }
  1093. submitPingLun(url);
  1094. }
  1095. }).start();
  1096. }
  1097. private void submitPingLun(String sms) {
  1098. Request request = new Request.Builder().url(sms).build();
  1099. Response response = null;
  1100. try {
  1101. if (request == null) {
  1102. Message msg = new Message();
  1103. msg.what = 3;
  1104. handler.sendMessage(msg);
  1105. return;
  1106. }
  1107. response = OkHttpUtil.execute(request);
  1108. if (response.code() == 200) {
  1109. String json = "";
  1110. try {
  1111. json = response.body().string();
  1112. Message msg = new Message();
  1113. msg.obj = json;
  1114. msg.what = 17;
  1115. handler.sendMessage(msg);
  1116. } catch (Exception e) {
  1117. e.printStackTrace();
  1118. Message msg = new Message();
  1119. msg.what = 3;
  1120. handler.sendMessage(msg);
  1121. }
  1122. }
  1123. } catch (Exception e) {
  1124. e.printStackTrace();
  1125. Message msg = new Message();
  1126. msg.what = 3;
  1127. handler.sendMessage(msg);
  1128. }
  1129. }
  1130. @Override
  1131. protected void onPause() {
  1132. super.onPause();
  1133. MobclickAgent.onPause(this);
  1134. }
  1135. @Override
  1136. public void onStart() {
  1137. super.onStart();
  1138. // ATTENTION: This was auto-generated to implement the App Indexing API.
  1139. // See https://g.co/AppIndexing/AndroidStudio for more information.
  1140. client.connect();
  1141. Action viewAction = Action.newAction(
  1142. Action.TYPE_VIEW, // TODO: choose an action type.
  1143. "UserCenter Page", // TODO: Define a title for the content shown.
  1144. // TODO: If you have web page content that matches this app activity's content,
  1145. // make sure this auto-generated web page URL is correct.
  1146. // Otherwise, set the URL to null.
  1147. Uri.parse("http://host/path"),
  1148. // TODO: Make sure this auto-generated app URL is correct.
  1149. Uri.parse("android-app://com.electric.chargingpile/http/host/path")
  1150. );
  1151. AppIndex.AppIndexApi.start(client, viewAction);
  1152. }
  1153. @Override
  1154. public void onStop() {
  1155. super.onStop();
  1156. // ATTENTION: This was auto-generated to implement the App Indexing API.
  1157. // See https://g.co/AppIndexing/AndroidStudio for more information.
  1158. Action viewAction = Action.newAction(
  1159. Action.TYPE_VIEW, // TODO: choose an action type.
  1160. "UserCenter Page", // TODO: Define a title for the content shown.
  1161. // TODO: If you have web page content that matches this app activity's content,
  1162. // make sure this auto-generated web page URL is correct.
  1163. // Otherwise, set the URL to null.
  1164. Uri.parse("http://host/path"),
  1165. // TODO: Make sure this auto-generated app URL is correct.
  1166. Uri.parse("android-app://com.electric.chargingpile/http/host/path")
  1167. );
  1168. AppIndex.AppIndexApi.end(client, viewAction);
  1169. client.disconnect();
  1170. }
  1171. public static String getShareNo(int no) {
  1172. final int wordsLength = 26;
  1173. int sus = no;// 商
  1174. int mo;// 模
  1175. int i = 1;// 循环的次数
  1176. StringBuilder sb = new StringBuilder();
  1177. char[] array = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
  1178. 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
  1179. 'V', 'W', 'X', 'Y', 'Z'};
  1180. while (sus > 0) {
  1181. System.out.println();
  1182. mo = sus % wordsLength;
  1183. sus = sus / wordsLength;
  1184. System.err.println("第" + i + "次循环, " + "商sus= " + sus
  1185. + " 模 mo= " + mo);
  1186. sb.append(array[mo]);
  1187. i++;
  1188. }
  1189. System.err.println(sb.toString());
  1190. // tv_shareno.setText(sb.toString());
  1191. return sb.toString();
  1192. }
  1193. @Override
  1194. public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) {
  1195. if (scrollView == sv) {
  1196. // Toast.makeText(getApplicationContext(),"开始滑动",Toast.LENGTH_SHORT).show();
  1197. } else {
  1198. }
  1199. }
  1200. @Override
  1201. public void onPermissionsGranted(int requestCode, List<String> perms) {
  1202. Intent iintent = new Intent(getApplicationContext(), com.google.zxing.client.android.CaptureActivity.class);
  1203. iintent.putExtra("url", MainApplication.url);
  1204. iintent.putExtra("user_id", MainApplication.userId);
  1205. iintent.putExtra("user_password", MainApplication.userPassword);
  1206. iintent.putExtra("user_phone", ProfileManager.getInstance().getUsername(getApplicationContext()));
  1207. iintent.putExtra("cha", MainMapActivity.cha);
  1208. iintent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  1209. startActivity(iintent);
  1210. overridePendingTransition(0, 0);
  1211. }
  1212. @Override
  1213. public void onPermissionsDenied(int requestCode, List<String> perms) {
  1214. if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
  1215. // TODO add by hyg20200525
  1216. new AppSettingsDialog.Builder(UserCenterActivity.this).build().show();
  1217. // new AppSettingsDialog.Builder(UserCenterActivity.this,
  1218. // "该功能需要开启摄像头权限,是否前往开启??").build().show();
  1219. }
  1220. }
  1221. @Override
  1222. public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  1223. super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  1224. EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
  1225. }
  1226. private boolean hasCameraPermission() {
  1227. return EasyPermissions.hasPermissions(this, Manifest.permission.CAMERA);
  1228. }
  1229. @AfterPermissionGranted(RC_CAMERA_PERM)
  1230. public boolean cameraTask() {
  1231. if (hasCameraPermission()) {
  1232. // Have permission, do the thing!
  1233. // Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
  1234. return true;
  1235. } else {
  1236. // Ask for one permission
  1237. // EasyPermissions.requestPermissions(
  1238. // this,
  1239. // "该功能需要开启摄像头权限,是否前往开启?",
  1240. // RC_CAMERA_PERM,
  1241. // Manifest.permission.CAMERA);
  1242. return false;
  1243. }
  1244. }
  1245. class NetworkChangeReceiver extends BroadcastReceiver {
  1246. @Override
  1247. public void onReceive(Context context, Intent intent) {
  1248. ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  1249. NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
  1250. if (null != networkInfo && networkInfo.isAvailable()) {
  1251. } else {
  1252. Toast.makeText(context, "当前网络不可用", Toast.LENGTH_SHORT).show();
  1253. }
  1254. }
  1255. }
  1256. @Override
  1257. protected void onDestroy() {
  1258. super.onDestroy();
  1259. unregisterReceiver(networkChangeReceiver);
  1260. }
  1261. private void getUserIntegral() {
  1262. String replace = null;
  1263. try {
  1264. long appTime1 = System.currentTimeMillis() / 1000;
  1265. long updatetime = appTime1 - MainMapActivity.cha - 3;
  1266. String token = String.valueOf(updatetime);
  1267. String encode_token = DES3.encode(token);
  1268. replace = URLEncoder.encode(encode_token);
  1269. } catch (Exception e) {
  1270. e.printStackTrace();
  1271. }
  1272. String url = MainApplication.url + "/zhannew/basic/web/index.php/member/get-score?id=" + MainApplication.userId +
  1273. "&phone=" + MainApplication.userPhone + "&password=" + URLEncoder.encode(MainApplication.userPassword) + "&token=" + replace;
  1274. RequestCall call = OkHttpUtils.get().url(url).build();
  1275. call.execute(new StringCallback() {
  1276. @Override
  1277. public void onError(Call call, Exception e) {
  1278. }
  1279. @Override
  1280. public void onResponse(String response) {
  1281. // Log.e(TAG, "onResponse:getUserIntegral= "+response );
  1282. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  1283. if (null != rtnCode && rtnCode.equals("01")) {
  1284. String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
  1285. String count_score = JsonUtils.getKeyResult(rtnMsg, "count_score");
  1286. String money = JsonUtils.getKeyResult(rtnMsg, "money");
  1287. String hongbao1 = JsonUtils.getKeyResult(rtnMsg, "hongbao");
  1288. String sign = JsonUtils.getKeyResult(rtnMsg, "sign");
  1289. if (sign.equals("01")) {
  1290. iv_gift.setImageResource(R.drawable.icon_signined);
  1291. } else {
  1292. iv_gift.setImageResource(R.drawable.icon_qiandaohavegift);
  1293. }
  1294. if (null != count_score && !count_score.equals("")) {
  1295. chongdianbi.setText(count_score);
  1296. }
  1297. if (null != money && !money.equals("")) {
  1298. yue.setText(money);
  1299. }
  1300. if (null != hongbao1 && !hongbao1.equals("")) {
  1301. hongbao.setText(hongbao1);
  1302. }
  1303. String grow_score_info = JsonUtils.getKeyResult(rtnMsg, "grow_score_info");
  1304. String name = JsonUtils.getKeyResult(grow_score_info, "name");
  1305. if (name != null) {
  1306. if (name.equals("普通")) {
  1307. iv_qiandao.setImageResource(R.drawable.icon_center_putong);
  1308. } else if (name.equals("青铜")) {
  1309. iv_qiandao.setImageResource(R.drawable.icon_center_qingtong);
  1310. } else if (name.equals("白银")) {
  1311. iv_qiandao.setImageResource(R.drawable.icon_center_baiyin);
  1312. } else if (name.equals("黄金")) {
  1313. iv_qiandao.setImageResource(R.drawable.icon_center_huangjin);
  1314. } else if (name.equals("铂金")) {
  1315. iv_qiandao.setImageResource(R.drawable.icon_senter_bojin);
  1316. } else if (name.equals("钻石")) {
  1317. iv_qiandao.setImageResource(R.drawable.icon_center_zuanshi);
  1318. }
  1319. }
  1320. } else {
  1321. ProfileManager.getInstance().setUsername(getApplicationContext(), "");
  1322. MainApplication.userPhone = "";
  1323. Toast.makeText(getApplicationContext(), "登录已失效,请重新登录", Toast.LENGTH_SHORT).show();
  1324. startActivity(new Intent(getApplicationContext(), LoginActivity.class));
  1325. }
  1326. }
  1327. });
  1328. }
  1329. private void signIn() {
  1330. String replace = null;
  1331. try {
  1332. long appTime1 = System.currentTimeMillis() / 1000;
  1333. long updatetime = appTime1 - MainMapActivity.cha - 3;
  1334. String token = String.valueOf(updatetime);
  1335. String encode_token = DES3.encode(token);
  1336. replace = URLEncoder.encode(encode_token);
  1337. } catch (Exception e) {
  1338. e.printStackTrace();
  1339. }
  1340. String url = MainApplication.url + "/zhannew/basic/web/index.php/checkin/sign?phone=" + MainApplication.userPhone +
  1341. "&password=" + URLEncoder.encode(MainApplication.userPassword) + "&token=" + replace + "&city=" + MainMapActivity.location_city;
  1342. OkHttpUtils.get().url(url).build().execute(new StringCallback() {
  1343. @Override
  1344. public void onError(Call call, Exception e) {
  1345. }
  1346. @Override
  1347. public void onResponse(String response) {
  1348. // Log.e(TAG, "onResponse: signIn "+response );
  1349. // {"rtnCode":"01","rtnMsg":{"score":"10","log_day":"1"}}
  1350. String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
  1351. if (rtnCode.equals("01")) {
  1352. getUserIntegral();
  1353. iv_gift.setImageResource(R.drawable.icon_signined);
  1354. String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
  1355. String log_day = JsonUtils.getKeyResult(rtnMsg, "log_day");
  1356. String score = JsonUtils.getKeyResult(rtnMsg, "plusScore");
  1357. String third = "", second = "", first = "";
  1358. int length = log_day.length();
  1359. char words[] = log_day.toCharArray();
  1360. if (length == 1) {
  1361. third = "";
  1362. second = "";
  1363. first = String.valueOf(words[0]);
  1364. } else if (length == 2) {
  1365. third = "";
  1366. second = String.valueOf(words[0]);
  1367. first = String.valueOf(words[1]);
  1368. } else if (length == 3) {
  1369. third = String.valueOf(words[0]);
  1370. second = String.valueOf(words[1]);
  1371. first = String.valueOf(words[2]);
  1372. }
  1373. // String weather = JsonUtils.getKeyResult(rtnMsg,"weather");
  1374. //// Log.e(TAG, "onResponse: weather="+weather );
  1375. // String status = JsonUtils.getKeyResult(weather,"status");
  1376. //// Log.e(TAG, "onResponse: status="+status );
  1377. // String results = JsonUtils.getKeyResult(weather,"results");
  1378. //// Log.e(TAG, "onResponse: results="+results );
  1379. // try {
  1380. // JSONArray jsArray = new JSONArray(results);
  1381. //// if (jsArray.length() >1) {
  1382. // String s = jsArray.getString(0);
  1383. // Log.e(TAG, "onResponse: s=" + s);
  1384. // String pm25 = JsonUtils.getKeyResult(s, "pm25");//*
  1385. // Log.e(TAG, "onResponse: pm25=" + pm25);
  1386. // String weather_data = JsonUtils.getKeyResult(s, "weather_data");
  1387. // Log.e(TAG, "onResponse: weather_data=" + weather_data);
  1388. // List<WeatherResults.WeatherDataBean> list = JsonUtils.parseToObjectList(weather_data, WeatherResults.WeatherDataBean.class);
  1389. // String now_weather = list.get(0).getWeather();//*
  1390. // String temperature = list.get(0).getTemperature();//*
  1391. // temperature = temperature.replace(" ", "");
  1392. // temperature = temperature.substring(0, temperature.length() - 1);
  1393. // String date = list.get(0).getDate();
  1394. // String now_temperature = date.substring(date.length() - 4, date.length() - 2);//*
  1395. // Log.e(TAG, "onResponse: now_weather=" + now_weather + "--temperature=" + temperature + "--now_temperature=" + now_temperature);
  1396. if (activity == null || activity.isFinishing()) {
  1397. return;
  1398. } else {
  1399. showDialog(third, second, first, score, now_temperature, now_weather, temperature, MainMapActivity.location_city);
  1400. }
  1401. }
  1402. }
  1403. });
  1404. }
  1405. private void showDialog(String third, String second, String first, String score, String now_temperature, String now_weather, String temperature, String city) {
  1406. SignInDialog signInDialog = new SignInDialog(this);
  1407. signInDialog.builder()
  1408. .setCancelable(true)
  1409. .setTitle(third, second, first, score, city)
  1410. .setWeatherUI(now_temperature, now_weather, temperature)
  1411. .show();
  1412. }
  1413. }