Commit ebc4d466 by gao.chao

位置页

parent c0611b2a
...@@ -10,6 +10,26 @@ android { ...@@ -10,6 +10,26 @@ android {
versionName "1.0" versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
signingConfigs {
debug {
keyAlias 'mayiguide'
keyPassword 'mayi888'
storeFile file('keyStore.jks')
storePassword 'mayi888'
v1SigningEnabled true
v2SigningEnabled true
}
release {
keyAlias 'mayiguide'
keyPassword 'mayi888'
storeFile file('keyStore.jks')
storePassword 'mayi888'
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled false
......
...@@ -24,6 +24,12 @@ ...@@ -24,6 +24,12 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="d78a6d571c700f3ad33f374d81fed6a2" />
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
......
package com.mayi.demo; package com.mayi.demo;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.View; import android.view.View;
import com.mayi.fastdevelop.base.BaseActivity; import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.commonpage.WebActivity; import com.mayi.fastdevelop.commonpage.WebActivity;
import com.mayi.fastdevelop.commonpage.zxing.BaseScanActivity; import com.mayi.fastdevelop.commonpage.amap.MapLocationActivity;
import com.mayi.fastdevelop.comnon.Key;
import com.mayi.fastdevelop.comnon.RequestCode;
import com.mayi.fastdevelop.util.ToastUtil;
import com.mayi.fastdevelop.util.ToolUtils; import com.mayi.fastdevelop.util.ToolUtils;
import com.mayi.fastdevelop.view.OnMultiClickListener; import com.mayi.fastdevelop.view.OnMultiClickListener;
...@@ -58,5 +63,22 @@ public class PageActivity extends BaseActivity { ...@@ -58,5 +63,22 @@ public class PageActivity extends BaseActivity {
gotoActivity(StartActivity.class); gotoActivity(StartActivity.class);
} }
}); });
findViewById(R.id.b7).setOnClickListener(new OnMultiClickListener() {
@Override
public void onMultiClick(View v) {
Intent intent = new Intent(PageActivity.this, MapLocationActivity.class);
startActivityForResult(intent, RequestCode.MAP_LOCATION_ACTIVITY_RESULTCODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode== RequestCode.MAP_LOCATION_ACTIVITY_RESULTCODE){
if (resultCode== Activity.RESULT_OK){
showToast(data.getStringExtra(Key.AVTIVITY_RESULT));
}
}
super.onActivityResult(requestCode, resultCode, data);
} }
} }
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="起屏页" /> android:text="起屏页" />
<Button
android:id="@+id/b7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="搜索地址页" />
</LinearLayout> </LinearLayout>
......
...@@ -26,6 +26,11 @@ android { ...@@ -26,6 +26,11 @@ android {
dependencies { dependencies {
api fileTree(include: ['*.jar'], dir: 'libs') api fileTree(include: ['*.jar'], dir: 'libs')
//高德地图
api 'com.amap.api:location:latest.integration'
api 'com.amap.api:search:latest.integration'
api 'com.amap.api:3dmap:latest.integration'
api 'com.yanzhenjie:permission:2.0.0-rc12'//权限申请 api 'com.yanzhenjie:permission:2.0.0-rc12'//权限申请
api 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'//下拉刷新,加载更多 api 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3'//下拉刷新,加载更多
api 'com.youth.banner:banner:1.4.10' //图片轮播控件 api 'com.youth.banner:banner:1.4.10' //图片轮播控件
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<application> <application>
<activity android:name=".commonpage.amap.MapLocationActivity" />
<activity android:name=".commonpage.WebActivity" /> <activity android:name=".commonpage.WebActivity" />
<!-- 解决 Android N 7.0 上 报错:android.os.FileUriExposedException --> <!-- 解决 Android N 7.0 上 报错:android.os.FileUriExposedException -->
......
package com.mayi.fastdevelop.commonpage; package com.mayi.fastdevelop.commonpage;
import android.Manifest; import android.Manifest;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
...@@ -23,6 +24,7 @@ import android.webkit.JavascriptInterface; ...@@ -23,6 +24,7 @@ import android.webkit.JavascriptInterface;
import com.mayi.fastdevelop.R; import com.mayi.fastdevelop.R;
import com.mayi.fastdevelop.base.BaseActivity; import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.commonpage.amap.MapLocationActivity;
import com.mayi.fastdevelop.comnon.Key; import com.mayi.fastdevelop.comnon.Key;
import com.mayi.fastdevelop.comnon.RequestCode; import com.mayi.fastdevelop.comnon.RequestCode;
import com.mayi.fastdevelop.util.BitmapUtil; import com.mayi.fastdevelop.util.BitmapUtil;
...@@ -30,11 +32,15 @@ import com.mayi.fastdevelop.util.DialogUtils; ...@@ -30,11 +32,15 @@ import com.mayi.fastdevelop.util.DialogUtils;
import com.mayi.fastdevelop.util.SpUtil; import com.mayi.fastdevelop.util.SpUtil;
import com.mayi.fastdevelop.view.CustomTitleBar; import com.mayi.fastdevelop.view.CustomTitleBar;
import com.mayi.fastdevelop.view.dialog.BaseDialog; import com.mayi.fastdevelop.view.dialog.BaseDialog;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback; import com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback;
import com.tencent.smtt.export.external.interfaces.WebResourceError;
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
import com.tencent.smtt.sdk.ValueCallback; import com.tencent.smtt.sdk.ValueCallback;
import com.tencent.smtt.sdk.WebChromeClient; import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebSettings; import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView; import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -93,6 +99,22 @@ public class WebActivity extends BaseActivity { ...@@ -93,6 +99,22 @@ public class WebActivity extends BaseActivity {
uploadPicture(); uploadPicture();
} }
}); });
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {//处理网页加载失败时
super.onReceivedError(view, errorCode, description, failingUrl);
Throwable thr = new Throwable("web加载错误: errorCode" + errorCode + " \ndescription=" + description + " \nfailingUrl=" + failingUrl);
CrashReport.postCatchedException(thr);
}
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {//处理网页加载失败时
super.onReceivedError(view, request, error);
Throwable thr = new Throwable("web加载错误: errorCode" + error.getErrorCode() + " \ndescription=" + error.getDescription() + " \nfailingUrl=" + request.getUrl());
CrashReport.postCatchedException(thr);
}
});
initView(); initView();
} }
...@@ -262,7 +284,10 @@ public class WebActivity extends BaseActivity { ...@@ -262,7 +284,10 @@ public class WebActivity extends BaseActivity {
* @param parameter * @param parameter
*/ */
public void goPage(String pageName, String parameter) { public void goPage(String pageName, String parameter) {
if (TextUtils.equals(pageName, "MapLocation")) {//地图定位页面
Intent intent = new Intent(this, MapLocationActivity.class);
startActivityForResult(intent, RequestCode.MAP_LOCATION_ACTIVITY_RESULTCODE);
}
} }
private void initWebView() { private void initWebView() {
...@@ -310,7 +335,11 @@ public class WebActivity extends BaseActivity { ...@@ -310,7 +335,11 @@ public class WebActivity extends BaseActivity {
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RequestCode.REQUEST_CODE_ALBUM || requestCode == RequestCode.REQUEST_CODE_CAMERA) { if (requestCode==RequestCode.MAP_LOCATION_ACTIVITY_RESULTCODE){
if (resultCode== Activity.RESULT_OK){
showToast(data.getStringExtra(Key.AVTIVITY_RESULT));
}
}else if (requestCode == RequestCode.REQUEST_CODE_ALBUM || requestCode == RequestCode.REQUEST_CODE_CAMERA) {
if (uploadMessage == null && uploadMessageAboveL == null) { if (uploadMessage == null && uploadMessageAboveL == null) {
return; return;
} }
...@@ -364,4 +393,5 @@ public class WebActivity extends BaseActivity { ...@@ -364,4 +393,5 @@ public class WebActivity extends BaseActivity {
}; };
asyncTask.execute(); asyncTask.execute();
} }
} }
package com.mayi.fastdevelop.commonpage.amap;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.amap.api.services.core.PoiItem;
import com.mayi.fastdevelop.R;
import java.util.ArrayList;
import java.util.List;
public class SearchResultAdapter extends BaseAdapter {
private List<PoiItem> data;
private Context context;
private int selectedPosition = 0;
public SearchResultAdapter(Context context) {
this.context = context;
data = new ArrayList<>();
}
public void setData(List<PoiItem> data) {
this.data = data;
}
public void setSelectedPosition(int selectedPosition) {
this.selectedPosition = selectedPosition;
}
public int getSelectedPosition() {
return selectedPosition;
}
@Override
public int getCount() {
return data.size();
}
@Override
public PoiItem getItem(int position) {
return data.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.view_holder_result, parent, false);
viewHolder = new ViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.bindView(position);
return convertView;
}
class ViewHolder {
TextView textTitle;
TextView textSubTitle;
ImageView imageCheck;
public ViewHolder(View view) {
textTitle = view.findViewById(R.id.text_title);
textSubTitle = view.findViewById(R.id.text_title_sub);
imageCheck = view.findViewById(R.id.image_check);
}
public void bindView(int position) {
if (position >= data.size())
return;
PoiItem poiItem = data.get(position);
textTitle.setText(poiItem.getTitle());
textSubTitle.setText(poiItem.getCityName() + poiItem.getAdName() + poiItem.getSnippet());
imageCheck.setVisibility(position == selectedPosition ? View.VISIBLE : View.INVISIBLE);
textSubTitle.setVisibility((position == 0 && poiItem.getPoiId().equals("regeo")) ? View.GONE : View.VISIBLE);
}
}
}
package com.mayi.fastdevelop.comnon; package com.mayi.fastdevelop.comnon;
public class Key { public class Key {
/* 保存下载ID的key */
public static final String ANT_DOWNLOAD_ID = "ant_download_id"; public static final String ANT_DOWNLOAD_ID = "ant_download_id";
/* avtivity返回上级页面结果 */
public static final String AVTIVITY_RESULT = "avtivity_result";
/* 用户信息 */ /* 用户信息 */
public static final String USER_INFO = "userinfo"; public static final String USER_INFO = "userinfo";
/*是否首次登录*/ /*是否首次登录*/
......
...@@ -5,4 +5,6 @@ public class RequestCode { ...@@ -5,4 +5,6 @@ public class RequestCode {
public static final int REQUEST_CODE_PERMISSION_CAMERA = 0x01; public static final int REQUEST_CODE_PERMISSION_CAMERA = 0x01;
public static final int REQUEST_CODE_CAMERA = 0x02; public static final int REQUEST_CODE_CAMERA = 0x02;
public static final int REQUEST_CODE_ALBUM = 0x03; public static final int REQUEST_CODE_ALBUM = 0x03;
/* 地图定位页面 返回 resultcode*/
public static final int MAP_LOCATION_ACTIVITY_RESULTCODE = 0x04;
} }
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#f6f6f6"/>
<corners android:radius="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.mayi.fastdevelop.view.CustomTitleBar
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="@dimen/im_dp_40" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal">
<AutoCompleteTextView
android:id="@+id/keyWord"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_weight="1"
android:background="@drawable/bg_edit_contact_search"
android:completionThreshold="1"
android:dropDownVerticalOffset="1.0dip"
android:focusable="true"
android:hint="请输入关键字"
android:imeOptions="actionDone"
android:inputType="text|textAutoComplete"
android:maxLength="20"
android:paddingLeft="@dimen/im_dp_10"
android:paddingRight="@dimen/im_dp_10"
android:singleLine="true"
android:textColor="#000000"
android:textColorHint="#C0C0C0"
android:textSize="14sp" />
</LinearLayout>
<com.amap.api.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="220dp" />
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/map"
android:layout_weight="1"
android:cacheColorHint="#00000000"
android:divider="@android:color/darker_gray"
android:dividerHeight="1px" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/online_user_list_item_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_marginTop="20dip"
android:padding="@dimen/im_dp_2"
android:textColor="#898989"
android:textSize="15sp" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/text_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="title"
android:textSize="15sp" />
<TextView
android:id="@+id/text_title_sub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="sub_title"
android:textColor="@android:color/darker_gray"
android:textSize="13sp" />
</LinearLayout>
<ImageView
android:id="@+id/image_check"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginLeft="8dp"
android:src="@mipmap/icon_affirm_selected" />
</LinearLayout>
\ No newline at end of file
<resources> <resources>
<string name="app_name">fastDevelop</string>
<string name="save_img_failed_2">图片地址异常,保存图片失败!</string> <string name="save_img_failed_2">图片地址异常,保存图片失败!</string>
<string name="save_img_success">保存图片成功!</string> <string name="save_img_success">保存图片成功!</string>
<string name="save_img_failed">保存图片失败!</string> <string name="save_img_failed">保存图片失败!</string>
...@@ -19,4 +18,6 @@ ...@@ -19,4 +18,6 @@
<string name="scan_tips">将二维码放入框内,即可自动扫描</string> <string name="scan_tips">将二维码放入框内,即可自动扫描</string>
<string name="open_light">打开闪光灯</string> <string name="open_light">打开闪光灯</string>
<string name="close_light">关闭闪光灯</string> <string name="close_light">关闭闪光灯</string>
<string name="position">位置</string>
<string name="send">发送</string>
</resources> </resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment