Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

将library和demo不能正常导入修改 #24

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

18 changes: 17 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 37 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

现在使用比较多的类似美团等APP的城市选择界面.

2步即可实现,就是这么简单粗暴!
3步即可实现,就是这么简单粗暴!

# Gif

Expand All @@ -20,7 +20,7 @@
# Install

目前没上传,只能
下载library手动导入.
下载library(citypicker)手动导入.

# Usage

Expand All @@ -43,19 +43,33 @@
cityPickerFragment.updateLocateState(LocateState.SUCCESS, location.replaceAll("市", ""));
```

### Step3
添加到清单文件中,修改软键盘模式。添加高德地图的key
```
<activity
android:name=".CityPickerActivity"
android:theme="@style/CityPicker.NoActionBar"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan"/>

<meta-data android:name="com.amap.api.v2.apikey" android:value="your key"/>
```


# 例子

```
/**
* 引用例子
*/
public class DemoActivity extends AppCompatActivity {

Toolbar toolbar;

FrameLayout flCityPickerContainer;
public class CityPickerActivity extends AppCompatActivity {

private FrameLayout flCityPickerContainer;
private CityPickerFragment cityPickerFragment;
//声明AMapLocationClient类对象
public AMapLocationClient mLocationClient = null;
//声明定位回调监听器
public AMapLocationListener mLocationListener;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand All @@ -64,45 +78,44 @@ public class DemoActivity extends AppCompatActivity {
initView();
}


protected void initView() {

   //这里
       cityPickerFragment = new CityPickerFragment();
private void initView() {
cityPickerFragment = new CityPickerFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.fl_activity_city_picker_container, cityPickerFragment).commit();
.add(R.id.fl_activity_city_container, cityPickerFragment).commit();
initLocationListener();
//初始化定位
mLocationClient = new AMapLocationClient(getApplicationContext());
//设置定位回调监听
mLocationClient.setLocationListener(mLocationListener);
//启动定位
mLocationClient.startLocation();

}

//定位
LocationManager.startSingleLocation(new IMapLocationListener() {
private void initLocationListener() {
mLocationListener = new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {

if (aMapLocation.getErrorCode() == 0) {
String city = aMapLocation.getCity();
String district = aMapLocation.getDistrict();
String location = StringUtils.extractLocation(city, district);

Toast.makeText(CityPickerActivity.this,city,Toast.LENGTH_SHORT).show();
//定位成功,更新状态
cityPickerFragment.updateLocateState(LocateState.SUCCESS, location.replaceAll("市", ""));
} else {
cityPickerFragment.updateLocateState(LocateState.FAILED, null);

}


}
});
};
}

@Override
protected void onDestroy() {
super.onDestroy();

//销毁定位
LocationManager.stopSingleLocation();
mLocationClient.stopLocation();
}
}


```
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

Expand Down
170 changes: 85 additions & 85 deletions citypicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,89 +31,89 @@ dependencies {
compile files('libs/AMap_Location_V3.2.0_20161205.jar')
}

apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
//apply plugin: 'com.github.dcendents.android-maven'
//apply plugin: 'com.jfrog.bintray'
//
//version = "1.1"
//
//def siteUrl = 'https://github.com/zaaach/CityPicker.git'
//def gitUrl = '[email protected]:zaaach/CityPicker.git'
//
//group = "com.zaaach"
//install {
// repositories.mavenInstaller {
// pom {
// project {
// packaging 'aar'
// name 'CityPicker'
// description 'a nice city picker library for android.'
// url siteUrl
//
// licenses {
// license {
// name 'The Apache Software License, Version 2.0'
// url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
// }
// }
//
// developers {
// developer {
// id 'zaaach'
// name 'zaaach'
// email '[email protected]'
// }
// }
//
// scm {
// connection gitUrl
// developerConnection gitUrl
// url siteUrl
// }
// }
// }
// }
//}

version = "1.1"

def siteUrl = 'https://github.com/zaaach/CityPicker.git'
def gitUrl = '[email protected]:zaaach/CityPicker.git'

group = "com.zaaach"
install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
name 'CityPicker'
description 'a nice city picker library for android.'
url siteUrl

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id 'zaaach'
name 'zaaach'
email '[email protected]'
}
}

scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}

// 生成jar包的task
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
// 生成jarDoc的task
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options.encoding "UTF-8"
options.charSet 'UTF-8'
options.author true
options.version true
failOnError false
}
// 生成javaDoc的jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}

//上传传到Jcenter
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

configurations = ['archives']
pkg {
repo = "maven"
userOrg= "zaaach"
name = "CityPicker"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}
//// 生成jar包的task
//task sourcesJar(type: Jar) {
// from android.sourceSets.main.java.srcDirs
// classifier = 'sources'
//}
//// 生成jarDoc的task
//task javadoc(type: Javadoc) {
// source = android.sourceSets.main.java.srcDirs
// classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
// options.encoding "UTF-8"
// options.charSet 'UTF-8'
// options.author true
// options.version true
// failOnError false
//}
//// 生成javaDoc的jar
//task javadocJar(type: Jar, dependsOn: javadoc) {
// classifier = 'javadoc'
// from javadoc.destinationDir
//}
//artifacts {
// archives javadocJar
// archives sourcesJar
//}
//
////上传传到Jcenter
//Properties properties = new Properties()
//properties.load(project.rootProject.file('local.properties').newDataInputStream())
//bintray {
// user = properties.getProperty("bintray.user")
// key = properties.getProperty("bintray.apikey")
//
// configurations = ['archives']
// pkg {
// repo = "maven"
// userOrg= "zaaach"
// name = "CityPicker"
// websiteUrl = siteUrl
// vcsUrl = gitUrl
// licenses = ["Apache-2.0"]
// publish = true
// }
//}
Loading