is() / 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().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"); MainMapActivity.question_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "question_unread")); MainMapActivity.comment_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "comment_unread")); MainMapActivity.system_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "system_unread")); MainMapActivity.total_unread = MainMapActivity.question_unread + MainMapActivity.comment_unread + MainMapActivity.system_unread; if (MainMapActivity.total_unread > 0) { tv_msg_num.setVisibility(View.VISIBLE); tv_msg_num.setText(MainMapActivity.total_unread + ""); if (MainMapActivity.question_unread > 0) { tv_qaNum.setVisibility(View.VISIBLE); tv_qaNum.setText(MainMapActivity.question_unread + ""); } else { tv_qaNum.setVisibility(View.GONE); } if (MainMapActivity.system_unread + MainMapActivity.comment_unread > 0) { tv_messageNum.setVisibility(View.VISIBLE); tv_messageNum.setText(MainMapActivity.system_unread + MainMapActivity.comment_unread + ""); } else { tv_messageNum.setVisibility(View.GONE); } } else { tv_msg_num.setVisibility(View.GONE); tv_qaNum.setVisibility(View.GONE); tv_messageNum.setVisibility(View.GONE); } } } }); } private void getCarOwnerCertificateList(String from) { long tokenTime = System.currentTimeMillis() / 1000 - MainMapActivity.cha - 1; String token = null; try { token = DES3.encode(String.valueOf(tokenTime)); token = URLEncoder.encode(token, "UTF-8"); } catch (Exception e) { e.printStackTrace(); } String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId + "&order=1" + "&token=" + token; Log.e(TAG, "getCarOwnerCertificateList: "+url); OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() { @Override public void onError(Call call, Exception e) { e.printStackTrace(); loadDialog.dismiss(); Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } @Override public void onResponse(String response) { loadDialog.dismiss(); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if ("01".equals(rtnCode)) { String data = JsonUtils.getKeyResult(response, "data"); List<CarOwnerCertificateBean> list =new ArrayList<>(); try{ list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class); }catch (com.alibaba.fastjson.JSONException e){ } if ("price".equals(from)) { if (list.size() == 0) { new AlertDialogTwo(UserCenterActivity.this).builder() .setMsg("您还没有认证车主,认证车主可获双倍奖励哦。") .setPositiveButton("继续发表", new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), MyWebViewActivity.class); intent.putExtra("url", "https://www.d1ev.com/special/models/wap/webView/index.html"); startActivity(intent); } }).setNegativeButton("去认证", new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class)); } }).show(); } else { Intent intent = new Intent(getApplication(), MyWebViewActivity.class); intent.putExtra("url", "https://www.d1ev.com/special/models/wap/webView/index.html"); startActivity(intent); } } else if ("certificate".equals(from)) { if (list.size() == 0) { startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class)); } else { boolean isType=false ; for (int i = 0; i < list.size(); i++) { if (list.get(i).getStatus()!= 2){ //不等于2 则表示为认证车型 isType=true; } } if (isType){ Intent intent = new Intent(getApplication(), CarOwnerCertificateListActivity.class); intent.putExtra("data", data); startActivity(intent); }else{ startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class)); } } } else if ("init".equals(from)) { boolean certificated = false; boolean isCertifiedOwner=true;//是否是已通过认证车主 boolean isVerified=true;//是否是已认证车主 String chexing = ""; Gson gson = new Gson(); for (CarOwnerCertificateBean bean : list) { if (bean.getStatus() == 1 && bean.getMain() == 1 &&isCertifiedOwner) { certificated = true; chexing = bean.getChexing(); isCertifiedOwner=false; } if (bean.getStatus() != 2 && isVerified){ MainApplication.userCertifiedModel=bean.getChexing(); isVerified=false; } } if (certificated) { CarSeriesEntity carSeriesEntity = gson.fromJson(chexing, CarSeriesEntity.class); car_owner_certificate_label.setText(carSeriesEntity.getSeriesName()); MainApplication.userCertifiedModel=carSeriesEntity.getSeriesName(); } else { car_owner_certificate_label.setText("认证车主获取充电优惠"); } } } else { String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg"); Toast.makeText(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT).show(); } } }); } @Override protected void onResume() { if (FindActivity.haveFindMessage == true) { iv_point.setVisibility(View.VISIBLE); } else { iv_point.setVisibility(View.GONE); } set_loginShow(); if (MainApplication.isLogin()) { new Handler().postDelayed(new Runnable() { @Override public void run() { getUserIntegral(); } }, 300); } super.onResume(); MobclickAgent.onResume(this); if (MainApplication.isLogin()) { if (!"".equals(MainApplication.userIcon)) { Picasso.with(UserCenterActivity.this) .load(MainApplication.userIcon) .placeholder(R.drawable.icon_user1118) .error(R.drawable.icon_user1118) .into(userIcon); } else { userIcon.setImageResource(R.drawable.icon_user1118); } } if (MainApplication.isLogin()) { getCarOwnerCertificateList("init"); } } @Override public void onWeatherLiveSearched(LocalWeatherLiveResult localWeatherLiveResult, int rCode) { if (rCode == 1000) { if (localWeatherLiveResult != null & localWeatherLiveResult.getLiveResult() != null) { LocalWeatherLive weatherlive = localWeatherLiveResult.getLiveResult(); now_temperature = weatherlive.getTemperature(); } else { } } else { } } @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().get(1)..getWeatherForecast() + "-------" + weatherlive.getProvince() + "-------" + weatherlive.getReportTime()); List<LocalDayWeatherForecast> list = weatherlive.getWeatherForecast(); if (list.size() > 1) { temperature = list.get(0).getDayTemp() + "~" + list.get(0).getNightTemp(); if (list.get(0).getNightWeather().equals(list.get(0).getDayWeather())) { now_weather = list.get(0).getDayWeather(); } else { now_weather = list.get(0).getDayWeather() + "转" + list.get(0).getNightWeather(); } } } else { } } else { } } 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 = 3; handler.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; handler.sendMessage(msg); } catch (Exception e) { e.printStackTrace(); Message msg = new Message(); msg.what = 3; handler.sendMessage(msg); } } } catch (Exception e) { e.printStackTrace(); Message msg = new Message(); msg.what = 3; handler.sendMessage(msg); } } @Override protected void onPause() { super.onPause(); MobclickAgent.onPause(this); } @Override public void onStart() { super.onStart(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client.connect(); Action viewAction = Action.newAction( Action.TYPE_VIEW, // TODO: choose an action type. "UserCenter Page", // TODO: Define a title for the content shown. // TODO: If you have web page content that matches this app activity's content, // make sure this auto-generated web page URL is correct. // Otherwise, set the URL to null. Uri.parse("http://host/path"), // TODO: Make sure this auto-generated app URL is correct. Uri.parse("android-app://com.electric.chargingpile/http/host/path") ); AppIndex.AppIndexApi.start(client, viewAction); } @Override public void onStop() { super.onStop(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. Action viewAction = Action.newAction( Action.TYPE_VIEW, // TODO: choose an action type. "UserCenter Page", // TODO: Define a title for the content shown. // TODO: If you have web page content that matches this app activity's content, // make sure this auto-generated web page URL is correct. // Otherwise, set the URL to null. Uri.parse("http://host/path"), // TODO: Make sure this auto-generated app URL is correct. Uri.parse("android-app://com.electric.chargingpile/http/host/path") ); AppIndex.AppIndexApi.end(client, viewAction); client.disconnect(); } public static String getShareNo(int no) { final int wordsLength = 26; int sus = no;// 商 int mo;// 模 int i = 1;// 循环的次数 StringBuilder sb = new StringBuilder(); char[] array = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; while (sus > 0) { System.out.println(); mo = sus % wordsLength; sus = sus / wordsLength; System.err.println("第" + i + "次循环, " + "商sus= " + sus + " 模 mo= " + mo); sb.append(array[mo]); i++; } System.err.println(sb.toString()); // tv_shareno.setText(sb.toString()); return sb.toString(); } @Override public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) { if (scrollView == sv) { // Toast.makeText(getApplicationContext(),"开始滑动",Toast.LENGTH_SHORT).show(); } else { } } @Override public void onPermissionsGranted(int requestCode, List<String> perms) { 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())); 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) { if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) { // TODO add by hyg20200525 new AppSettingsDialog.Builder(UserCenterActivity.this).build().show(); // new AppSettingsDialog.Builder(UserCenterActivity.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); } @AfterPermissionGranted(RC_CAMERA_PERM) public boolean cameraTask() { if (hasCameraPermission()) { // Have permission, do the thing! // Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show(); return true; } else { // Ask for one permission // EasyPermissions.requestPermissions( // this, // "该功能需要开启摄像头权限,是否前往开启?", // RC_CAMERA_PERM, // Manifest.permission.CAMERA); return false; } } 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(); } } } @Override protected void onDestroy() { super.onDestroy(); unregisterReceiver(networkChangeReceiver); } private void getUserIntegral() { String replace = null; try { long appTime1 = System.currentTimeMillis() / 1000; long updatetime = appTime1 - MainMapActivity.cha - 3; String token = String.valueOf(updatetime); String encode_token = DES3.encode(token); replace = URLEncoder.encode(encode_token); } catch (Exception e) { e.printStackTrace(); } String url = MainApplication.url + "/zhannew/basic/web/index.php/member/get-score?id=" + MainApplication.userId + "&phone=" + MainApplication.userPhone + "&password=" + URLEncoder.encode(MainApplication.userPassword) + "&token=" + replace; RequestCall call = OkHttpUtils.get().url(url).build(); call.execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { // Log.e(TAG, "onResponse:getUserIntegral= "+response ); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if (null != rtnCode && rtnCode.equals("01")) { String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg"); String count_score = JsonUtils.getKeyResult(rtnMsg, "count_score"); String money = JsonUtils.getKeyResult(rtnMsg, "money"); String hongbao1 = JsonUtils.getKeyResult(rtnMsg, "hongbao"); String sign = JsonUtils.getKeyResult(rtnMsg, "sign"); if (sign.equals("01")) { iv_gift.setImageResource(R.drawable.icon_signined); } else { iv_gift.setImageResource(R.drawable.icon_qiandaohavegift); } if (null != count_score && !count_score.equals("")) { chongdianbi.setText(count_score); } if (null != money && !money.equals("")) { yue.setText(money); } if (null != hongbao1 && !hongbao1.equals("")) { hongbao.setText(hongbao1); } String grow_score_info = JsonUtils.getKeyResult(rtnMsg, "grow_score_info"); String name = JsonUtils.getKeyResult(grow_score_info, "name"); if (name != null) { if (name.equals("普通")) { iv_qiandao.setImageResource(R.drawable.icon_center_putong); } else if (name.equals("青铜")) { iv_qiandao.setImageResource(R.drawable.icon_center_qingtong); } else if (name.equals("白银")) { iv_qiandao.setImageResource(R.drawable.icon_center_baiyin); } else if (name.equals("黄金")) { iv_qiandao.setImageResource(R.drawable.icon_center_huangjin); } else if (name.equals("铂金")) { iv_qiandao.setImageResource(R.drawable.icon_senter_bojin); } else if (name.equals("钻石")) { iv_qiandao.setImageResource(R.drawable.icon_center_zuanshi); } } } else { ProfileManager.getInstance().setUsername(getApplicationContext(), ""); MainApplication.userPhone = ""; Toast.makeText(getApplicationContext(), "登录已失效,请重新登录", Toast.LENGTH_SHORT).show(); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); } } }); } private void signIn() { String replace = null; try { long appTime1 = System.currentTimeMillis() / 1000; long updatetime = appTime1 - MainMapActivity.cha - 3; String token = String.valueOf(updatetime); String encode_token = DES3.encode(token); replace = URLEncoder.encode(encode_token); } catch (Exception e) { e.printStackTrace(); } String url = MainApplication.url + "/zhannew/basic/web/index.php/checkin/sign?phone=" + MainApplication.userPhone + "&password=" + URLEncoder.encode(MainApplication.userPassword) + "&token=" + replace + "&city=" + MainMapActivity.location_city; 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: signIn "+response ); // {"rtnCode":"01","rtnMsg":{"score":"10","log_day":"1"}} String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if (rtnCode.equals("01")) { getUserIntegral(); iv_gift.setImageResource(R.drawable.icon_signined); String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg"); String log_day = JsonUtils.getKeyResult(rtnMsg, "log_day"); String score = JsonUtils.getKeyResult(rtnMsg, "plusScore"); String third = "", second = "", first = ""; int length = log_day.length(); char words[] = log_day.toCharArray(); if (length == 1) { third = ""; second = ""; first = String.valueOf(words[0]); } else if (length == 2) { third = ""; second = String.valueOf(words[0]); first = String.valueOf(words[1]); } else if (length == 3) { third = String.valueOf(words[0]); second = String.valueOf(words[1]); first = String.valueOf(words[2]); } // String weather = JsonUtils.getKeyResult(rtnMsg,"weather"); //// Log.e(TAG, "onResponse: weather="+weather ); // String status = JsonUtils.getKeyResult(weather,"status"); //// Log.e(TAG, "onResponse: status="+status ); // String results = JsonUtils.getKeyResult(weather,"results"); //// Log.e(TAG, "onResponse: results="+results ); // try { // JSONArray jsArray = new JSONArray(results); //// if (jsArray.length() >1) { // String s = jsArray.getString(0); // Log.e(TAG, "onResponse: s=" + s); // String pm25 = JsonUtils.getKeyResult(s, "pm25");//* // Log.e(TAG, "onResponse: pm25=" + pm25); // String weather_data = JsonUtils.getKeyResult(s, "weather_data"); // Log.e(TAG, "onResponse: weather_data=" + weather_data); // List<WeatherResults.WeatherDataBean> list = JsonUtils.parseToObjectList(weather_data, WeatherResults.WeatherDataBean.class); // String now_weather = list.get(0).getWeather();//* // String temperature = list.get(0).getTemperature();//* // temperature = temperature.replace(" ", ""); // temperature = temperature.substring(0, temperature.length() - 1); // String date = list.get(0).getDate(); // String now_temperature = date.substring(date.length() - 4, date.length() - 2);//* // Log.e(TAG, "onResponse: now_weather=" + now_weather + "--temperature=" + temperature + "--now_temperature=" + now_temperature); if (activity == null || activity.isFinishing()) { return; } else { showDialog(third, second, first, score, now_temperature, now_weather, temperature, MainMapActivity.location_city); } } } }); } public void requestWebLink(){ String url = MainApplication.url + "/zhannew/basic/web/index.php/discovery/cheyouqun"; 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: signIn "+response ); // {"rtnCode":"01","rtnMsg":{"score":"10","log_day":"1"}} String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if (rtnCode.equals("01")) { String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg"); mUrl = JsonUtils.getKeyResult(response, "data"); } } }); } private void showDialog(String third, String second, String first, String score, String now_temperature, String now_weather, String temperature, String city) { SignInDialog signInDialog = new SignInDialog(this); signInDialog.builder() .setCancelable(true) .setTitle(third, second, first, score, city) .setWeatherUI(now_temperature, now_weather, temperature) .show(); } } Vernita Rosenbaum - Gogs: Go Git Service
Vernita Rosenbaum discount-copy-paper0489