Repository: Bigkoo/EasySideBar
Branch: master
Commit: afe9c698aef2
Files: 59
Total size: 83.2 KB
Directory structure:
gitextract_f_jovrni/
├── .gitignore
├── .idea/
│ ├── compiler.xml
│ ├── copyright/
│ │ └── profiles_settings.xml
│ ├── encodings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ ├── runConfigurations.xml
│ └── vcs.xml
├── README.md
├── app/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── demo/
│ │ └── ExampleInstrumentedTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── demo/
│ │ │ └── MainActivity.java
│ │ └── res/
│ │ ├── layout/
│ │ │ └── activity_main.xml
│ │ ├── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── values-w820dp/
│ │ └── dimens.xml
│ └── test/
│ └── java/
│ └── com/
│ └── demo/
│ └── ExampleUnitTest.java
├── build.gradle
├── easysidebar/
│ ├── .gitignore
│ ├── build.gradle
│ ├── libs/
│ │ └── pinyin4j-2.5.0.jar
│ ├── proguard-rules.pro
│ └── src/
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── esaysidebar/
│ │ │ ├── EasySideBarBuilder.java
│ │ │ ├── activity/
│ │ │ │ ├── GridCityAdapter.java
│ │ │ │ ├── MyGridView.java
│ │ │ │ ├── SortAdapter.java
│ │ │ │ └── SortCityActivity.java
│ │ │ ├── bean/
│ │ │ │ └── CitySortModel.java
│ │ │ ├── lib/
│ │ │ │ ├── EasySideBar.java
│ │ │ │ └── EditTextWithDel.java
│ │ │ └── utils/
│ │ │ ├── PinyinComparator.java
│ │ │ └── PinyinUtils.java
│ │ └── res/
│ │ ├── drawable/
│ │ │ ├── edit_background.xml
│ │ │ ├── select_btn_white_gray.xml
│ │ │ └── selector_btn_press.xml
│ │ ├── layout/
│ │ │ ├── activity_sort_city.xml
│ │ │ ├── gridview_item.xml
│ │ │ ├── headview_hotcity.xml
│ │ │ ├── headview_loaction.xml
│ │ │ └── item_select_city.xml
│ │ ├── values/
│ │ │ ├── arrays.xml
│ │ │ ├── color.xml
│ │ │ ├── drawables.xml
│ │ │ └── strings.xml
│ │ └── values-w820dp/
│ │ └── dimens.xml
│ └── test/
│ └── java/
│ └── com/
│ └── demo/
│ └── ExampleUnitTest.java
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
================================================
FILE: .idea/compiler.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
================================================
FILE: .idea/copyright/profiles_settings.xml
================================================
<component name="CopyrightManager">
<settings default="" />
</component>
================================================
FILE: .idea/encodings.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
================================================
FILE: .idea/gradle.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/easysidebar" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
================================================
FILE: .idea/misc.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
================================================
FILE: .idea/modules.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/EasySideBar.iml" filepath="$PROJECT_DIR$/EasySideBar.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/easysidebar/easysidebar.iml" filepath="$PROJECT_DIR$/easysidebar/easysidebar.iml" />
</modules>
</component>
</project>
================================================
FILE: .idea/runConfigurations.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
================================================
FILE: .idea/vcs.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
================================================
FILE: README.md
================================================
# EasySideBar
一款按字母排序的库,已封装好城市数据,可定制化强,也可以下载源代码用Module的形式引入自己改一改来使用,也可稍做改造定制成通讯录。欢迎Star、提建议、提Issue。

## **使用步骤:**
### 1.添加Jcenter仓库 Gradle依赖:
```java
compile 'com.contrarywind:EasySideBar:1.1.0'
```
## 2.在Activity中添加如下代码:
```java
//热门城市数据 ,不添加数据的时候会隐藏该布局
ArrayList<String> hotCityList = new ArrayList<>();
hotCityList.add("北京");
hotCityList.add("上海");
hotCityList.add("广州");
hotCityList.add("深圳");
hotCityList.add("杭州");
hotCityList.add("成都");
hotCityList.add("厦门");
hotCityList.add("天津");
hotCityList.add("武汉");
hotCityList.add("长沙");
//初始化以及配置
new EasySideBarBuilder(MainActivity.this)
.setTitle("城市选择")
/*.setIndexColor(Color.BLUE)*/
.setIndexColor(0xFF0095EE)
/*.isLazyRespond(true) //懒加载模式*/
.setHotCityList(hotCityList)//热门城市列表
.setIndexItems(mIndexItems)//索引字母
.setLocationCity("广州")//定位城市
.setMaxOffset(60)//索引的最大偏移量
.start();
```
## 3.在Activity中重写onActivityResult方法,接收回调数据:
```java
//resultCode 是使用封装好的EasySideBarBuilder.CODE_SIDEREQUEST
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case EasySideBarBuilder.CODE_SIDEREQUEST:
if (data!=null){
String city = data.getStringExtra("selected");
Toast.makeText(this,"选择的城市:"+city,Toast.LENGTH_SHORT).show();
}
break;
default:
break;
}
}
```
## Thanks
- [WaveSideBar](https://github.com/gjiazhe/WaveSideBar)
# License
```
Copyright 2014 Bigkoo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
================================================
FILE: app/.gitignore
================================================
/build
================================================
FILE: app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.easysidebar"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
testCompile 'junit:junit:4.12'
compile project(path: ':easysidebar')
}
================================================
FILE: app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in F:\Android-studio\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: app/src/androidTest/java/com/demo/ExampleInstrumentedTest.java
================================================
package com.demo;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.easysidebar", appContext.getPackageName());
}
}
================================================
FILE: app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.demo.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: app/src/main/java/com/demo/MainActivity.java
================================================
package com.demo;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.esaysidebar.EasySideBarBuilder;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
private final String[] mIndexItems = {"定位","热门"};//头部额外的索引
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
Button btn_sure = (Button)findViewById(R.id.btn_sure);
btn_sure.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ArrayList<String> hotCityList = new ArrayList<>();
hotCityList.add("北京");
hotCityList.add("上海");
hotCityList.add("广州");
hotCityList.add("深圳");
hotCityList.add("杭州");
hotCityList.add("成都");
hotCityList.add("厦门");
hotCityList.add("天津");
hotCityList.add("武汉");
hotCityList.add("长沙");
new EasySideBarBuilder(MainActivity.this)
.setTitle("城市选择")
/*.setIndexColor(Color.BLUE)*/
.setIndexColor(0xFF0095EE)
/* .isLazyRespond(true) //懒加载模式*/
.setHotCityList(hotCityList)//热门城市列表
.setIndexItems(mIndexItems)//索引字母
.setLocationCity("广州")//定位城市
.setMaxOffset(60)//索引的最大偏移量
.start();
}
});
}
//数据回调
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case EasySideBarBuilder.CODE_SIDEREQUEST:
if (data!=null){
String city = data.getStringExtra("selected");
Toast.makeText(this,"选择的城市:"+city,Toast.LENGTH_SHORT).show();
}
break;
default:
break;
}
}
}
================================================
FILE: app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<Button
android:id="@+id/btn_sure"
android:text="打开选择页面"
android:padding="10dp"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
================================================
FILE: app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">EasySideBar</string>
</resources>
================================================
FILE: app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: app/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: app/src/test/java/com/demo/ExampleUnitTest.java
================================================
package com.demo;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.novoda:bintray-release:0.4.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: easysidebar/.gitignore
================================================
/build
================================================
FILE: easysidebar/build.gradle
================================================
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.novoda.bintray-release'//添加插件
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionName "1.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
allprojects {
tasks.withType(Javadoc) {//兼容中文字符
options{
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
}
}
publish {
userOrg = 'contrarywind'//bintray.com 用户名/组织名 user/org name
groupId = 'com.contrarywind'//JCenter上显示的路径 path
artifactId = 'EasySideBar'//项目名称 project name
publishVersion = '1.0.1'//版本号 version code
desc = 'this is a sidebar for android'//项目描述 description
website = 'https://github.com/Bigkoo/EasySideBar' //项目网址链接 link
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
}
================================================
FILE: easysidebar/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in F:\Android-studio\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: easysidebar/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.esaysidebar">
<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">
<activity android:name="com.esaysidebar.activity.SortCityActivity"
android:windowSoftInputMode = "adjustPan"/>
</application>
</manifest>
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/EasySideBarBuilder.java
================================================
package com.esaysidebar;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import com.esaysidebar.activity.SortCityActivity;
import java.util.ArrayList;
/**
* TODO<建造器>
*
* @author: 小嵩
* @date: 2017/3/9 12:24
*/
public class EasySideBarBuilder {
private Context mContext;
public static final int CODE_SIDEREQUEST = 0x00000011; // ActivityForResult回调值
private String mtitleText;
private boolean isLazyRespond;
private String[] indexItems;
private String LocationCity;
private int indexColor= 0xFF666666;//默认索引文字颜色
private int maxOffset = 80;
private ArrayList<String> HotCityList;//热门城市列表
public EasySideBarBuilder(Context context) {
this.mContext = context;
}
public EasySideBarBuilder setTitle(String titleText){
this.mtitleText = titleText;
return this;
}
public EasySideBarBuilder isLazyRespond(boolean isLazyRespond){
this.isLazyRespond = isLazyRespond;
return this;
}
public EasySideBarBuilder setIndexItems(String[] indexItems){
this.indexItems = indexItems;
return this;
}
public EasySideBarBuilder setLocationCity(String LocationCity){
this.LocationCity = LocationCity;
return this;
}
public EasySideBarBuilder setIndexColor(int indexColor){
this.indexColor = indexColor;
return this;
}
public EasySideBarBuilder setMaxOffset(int maxOffset){
this.maxOffset = maxOffset;
return this;
}
public EasySideBarBuilder setHotCityList(ArrayList<String> HotCityList){
this.HotCityList = HotCityList;
return this;
}
public void start(){
Activity activity = (Activity) mContext;
Intent intent = new Intent(mContext, SortCityActivity.class);
intent.putExtra("titleText",mtitleText);
intent.putExtra("isLazyRespond",isLazyRespond);
intent.putExtra("indexItems",indexItems);
intent.putExtra("LocationCity",LocationCity);
intent.putExtra("indexColor",indexColor);
intent.putExtra("maxOffset",maxOffset);
intent.putStringArrayListExtra("HotCityList",HotCityList);
activity.startActivityForResult(intent,CODE_SIDEREQUEST);
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/activity/GridCityAdapter.java
================================================
package com.esaysidebar.activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.esaysidebar.R;
import java.util.List;
/**
* @TODO<按字母排序的选择页面- 热门城市列表适配器>
* @author 小嵩
* @date 2016-8-12 11:24:12
*/
public class GridCityAdapter extends ArrayAdapter<String> {
/**
* 需要渲染的item布局文件
*/
private int resource;
public GridCityAdapter(Context context, int textViewResourceId, List<String> objects) {
super(context, textViewResourceId, objects);
resource = textViewResourceId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout layout = null;
if (convertView == null) {
layout = (LinearLayout) LayoutInflater.from(getContext()).inflate(resource, null);
} else {
layout = (LinearLayout) convertView;
}
TextView name = (TextView) layout.findViewById(R.id.tv_city);
name.setText(getItem(position));
return layout;
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/activity/MyGridView.java
================================================
package com.esaysidebar.activity;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;
/**
* 自定义GridView,解决ScrollView嵌套Grideview只显示一行半
*/
public class MyGridView extends GridView {
public MyGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public MyGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyGridView(Context context) {
super(context);
}
/**
* 其中onMeasure函数决定了组件显示的高度与宽度;
* makeMeasureSpec函数中第一个函数决定布局空间的大小,第二个参数是布局模式
* MeasureSpec.AT_MOST的意思就是子控件需要多大的控件就扩展到多大的空间
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/activity/SortAdapter.java
================================================
package com.esaysidebar.activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.esaysidebar.R;
import com.esaysidebar.bean.CitySortModel;
import java.util.List;
public class SortAdapter extends BaseAdapter {
private List<CitySortModel> list = null;
private Context mContext;
public SortAdapter(Context mContext, List<CitySortModel> list) {
this.mContext = mContext;
this.list = list;
}
/**
* 当ListView数据发生变化时,调用此方法来更新ListView
*
* @param list
*/
public void updateListView(List<CitySortModel> list) {
this.list = list;
notifyDataSetChanged();
}
public int getCount() {
return this.list.size();
}
public Object getItem(int position) {
return list.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View view, ViewGroup arg2) {
ViewHolder viewHolder = null;
final CitySortModel mContent = list.get(position);
if (view == null) {
viewHolder = new ViewHolder();
view = LayoutInflater.from(mContext).inflate(R.layout.item_select_city, null);
viewHolder.tvTitle = (TextView) view.findViewById(R.id.tv_city_name);
view.setTag(viewHolder);
viewHolder.tvLetter = (TextView) view.findViewById(R.id.tv_catagory);
} else {
viewHolder = (ViewHolder) view.getTag();
}
int section = getSectionForPosition(position);
if (position == getPositionForSection(section)) {
viewHolder.tvLetter.setVisibility(View.VISIBLE);
viewHolder.tvLetter.setText(mContent.getSortLetters());
} else {
viewHolder.tvLetter.setVisibility(View.GONE);
}
viewHolder.tvTitle.setText(this.list.get(position).getName());
return view;
}
final static class ViewHolder {
TextView tvLetter;
TextView tvTitle;
}
public int getSectionForPosition(int position) {
return list.get(position).getSortLetters().charAt(0);
}
public int getPositionForSection(int section) {
for (int i = 0; i < getCount(); i++) {
String sortStr = list.get(i).getSortLetters();
char firstChar = sortStr.toUpperCase().charAt(0);
if (firstChar == section) {
return i;
}
}
return -1;
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/activity/SortCityActivity.java
================================================
package com.esaysidebar.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.esaysidebar.EasySideBarBuilder;
import com.esaysidebar.R;
import com.esaysidebar.bean.CitySortModel;
import com.esaysidebar.lib.EasySideBar;
import com.esaysidebar.utils.PinyinComparator;
import com.esaysidebar.utils.PinyinUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SortCityActivity extends Activity {
private ListView sortListView;
private EasySideBar sideBar;
private TextView mTvTitle;
private TextView mTvLoaction,tv_label_location,tv_label_hot;
private ImageView iv_back;
private SortAdapter adapter;
private GridCityAdapter cityAdapter;//热门城市的适配器
private EditText mEtCityName;
private List<CitySortModel> SourceDateList;//内容数据源
private List<String> HotCityList;//热门城市列表
private String titleText;//标题
private boolean isLazyRespond;//是否为懒加载
private String[] indexItems;//头部的索引值
private String LocationCity;//定位城市
private int indexColor;//索引文字颜色
private int maxOffset;//滑动特效 最大偏移量
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sort_city);
titleText = getIntent().getExtras().getString("titleText");
isLazyRespond = getIntent().getExtras().getBoolean("isLazyRespond");
indexItems = getIntent().getExtras().getStringArray("indexItems");
LocationCity = getIntent().getExtras().getString("LocationCity");
HotCityList = getIntent().getStringArrayListExtra("HotCityList");
if (HotCityList==null){
HotCityList = new ArrayList<>();
}
indexColor = getIntent().getIntExtra("indexColor",0xFF666666);//索引颜色
maxOffset = getIntent().getIntExtra("maxOffset",80);
initViews();
}
private void initViews() {
mEtCityName = (EditText) findViewById(R.id.et_search);
sideBar = (EasySideBar) findViewById(R.id.sidebar);
mTvTitle = (TextView) findViewById(R.id.tv_title);
sortListView = (ListView) findViewById(R.id.country_lvcountry);
iv_back = (ImageView) findViewById(R.id.iv_back);
sortListView.addHeaderView(initLocationHeadView());
sortListView.addHeaderView(initHotHeadView());
initSideBar();
initEvents();
setAdapter();
}
private void setAdapter() {
SourceDateList = filledData(getResources().getStringArray(R.array.provinces));
Collections.sort(SourceDateList, new PinyinComparator());
adapter = new SortAdapter(this, SourceDateList);
sortListView.setAdapter(adapter);
}
private void initEvents() {
//设置右侧触摸监听, (此处还需要优化)
sideBar.setOnSelectIndexItemListener(new EasySideBar.OnSelectIndexItemListener() {
@Override
public void onSelectIndexItem(int index, String value) {
//该字母首次出现的位置
int position = adapter.getPositionForSection(value.charAt(0));
if (position != -1) {
sortListView.setSelection(position + sortListView.getHeaderViewsCount());
}else {//未匹配到索引内容
for (int i= 0; i<indexItems.length;i++){//匹配头部索引
if (value.equals(indexItems[i])){
sortListView.setSelection(i);
}
}
}
}
});
//ListView的点击事件
sortListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String city = ((CitySortModel) adapter.getItem(position - 1)).getName();
SentDataForResult(city);
}
});
//根据输入框输入值的改变来过滤搜索
mEtCityName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//当输入框里面的值为空,更新为原来的列表,否则为过滤数据列表
filterData(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});
iv_back.setOnClickListener(new View.OnClickListener() {//点击 finish 掉页面
@Override
public void onClick(View v) {
SortCityActivity.this.finish();
}
});
}
private void initSideBar() {//初始化sidebar
//标题栏初始化
if (!TextUtils.isEmpty(titleText)){
mTvTitle.setVisibility(View.VISIBLE);
mTvTitle.setText(titleText);
}else {
mTvTitle.setVisibility(View.GONE);
}
sideBar.setLazyRespond(isLazyRespond);
sideBar.setTextColor(indexColor);
sideBar.setMaxOffset(maxOffset);
}
private View initHotHeadView() {
View headView = getLayoutInflater().inflate(R.layout.headview_hotcity, null);
GridView mGvCity = (GridView) headView.findViewById(R.id.gv_hot_city);
/* mTvLoaction =(TextView) headView.findViewById(R.id.tv_location_city);
tv_label_location =(TextView) headView.findViewById(R.id.tv_label_location);*/
tv_label_hot =(TextView) headView.findViewById(R.id.tv_label_hot);
if (HotCityList.size()<=0){//热门城市
tv_label_hot.setVisibility(View.GONE);
}else {
tv_label_hot.setVisibility(View.VISIBLE);
}
/* if (TextUtils.isEmpty(LocationCity)){//定位城市
mTvLoaction.setVisibility(View.GONE);
tv_label_location.setVisibility(View.GONE);
} else {
tv_label_location.setVisibility(View.VISIBLE);
mTvLoaction.setVisibility(View.VISIBLE);
mTvLoaction.setText(LocationCity);//设置定位城市
mTvLoaction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SentDataForResult(LocationCity);
}
});
}*/
cityAdapter = new GridCityAdapter(this, R.layout.gridview_item, HotCityList);
mGvCity.setAdapter(cityAdapter);
mGvCity.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
//选中的 Gird city
SentDataForResult(HotCityList.get(i));
}
});
return headView;
}
private View initLocationHeadView() {
View headView = getLayoutInflater().inflate(R.layout.headview_loaction, null);
mTvLoaction =(TextView) headView.findViewById(R.id.tv_location_city);
tv_label_location =(TextView) headView.findViewById(R.id.tv_label_location);
if (TextUtils.isEmpty(LocationCity)){//定位城市
mTvLoaction.setVisibility(View.GONE);
tv_label_location.setVisibility(View.GONE);
} else {
tv_label_location.setVisibility(View.VISIBLE);
mTvLoaction.setVisibility(View.VISIBLE);
mTvLoaction.setText(LocationCity);//设置定位城市
mTvLoaction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SentDataForResult(LocationCity);
}
});
}
return headView;
}
private void SentDataForResult(String city) {
Intent mIntent = new Intent();
mIntent.putExtra("selected", city);
SortCityActivity.this.setResult(EasySideBarBuilder.CODE_SIDEREQUEST, mIntent);
SortCityActivity.this.finish();
}
/**
* 根据输入框中的值来过滤数据并更新ListView
*
* @param filterStr
*/
private void filterData(String filterStr) {
List<CitySortModel> mSortList = new ArrayList<>();
if (TextUtils.isEmpty(filterStr)) {
mSortList = SourceDateList;
} else {
mSortList.clear();
for (CitySortModel sortModel : SourceDateList) {
String name = sortModel.getName();
/* name.toUpperCase().indexOf(filterStr.toString().toUpperCase()) != -1*/
if (name.toUpperCase().contains(filterStr.toString().toUpperCase()) || PinyinUtils.getPingYin(name).toUpperCase().startsWith(filterStr.toString().toUpperCase())) {
mSortList.add(sortModel);
}
}
}
// 根据a-z进行排序
Collections.sort(mSortList, new PinyinComparator());
adapter.updateListView(mSortList);
}
private List<CitySortModel> filledData(String[] date) {//获取数据,并根据拼音分类,添加index
List<CitySortModel> mSortList = new ArrayList<>();
ArrayList<String> indexString = new ArrayList<>();//索引字母数组
boolean isGarbled = false;
for (int i = 0; i < date.length; i++) {
CitySortModel sortModel = new CitySortModel();
sortModel.setName(date[i]);
String pinyin = PinyinUtils.getPingYin(date[i]);
String sortString = pinyin.substring(0, 1).toUpperCase();
if (sortString.matches("[A-Z]")) {
sortModel.setSortLetters(sortString.toUpperCase());
if (!indexString.contains(sortString)) {
indexString.add(sortString);
}
}else{
sortModel.setSortLetters("#");
isGarbled = true;
}
mSortList.add(sortModel);
}
Collections.sort(indexString);
if (isGarbled){//出现乱码,将其添加到索引
indexString.add("#");
}
String[] IndexList = Concat(indexItems,indexString.toArray(new String[indexString.size()]));
sideBar.setIndexItems(IndexList); //只显示有内容部分的字母index
return mSortList;
}
private String[] Concat(String[] a,String[] b) {//合并两个数组
String[] mIndexItems = new String[a.length + b.length];
System.arraycopy(a, 0, mIndexItems, 0, a.length);
System.arraycopy(b, 0, mIndexItems, a.length, b.length);
return mIndexItems;
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/bean/CitySortModel.java
================================================
package com.esaysidebar.bean;
public class CitySortModel {
private String name;//显示的数据
private String sortLetters;//显示数据拼音的首字母
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSortLetters() {
return sortLetters;
}
public void setSortLetters(String sortLetters) {
this.sortLetters = sortLetters;
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/lib/EasySideBar.java
================================================
package com.esaysidebar.lib;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import static android.R.attr.width;
/**
* @TODO<WaveSideBar>
* @author 小嵩
* @date 2017-3-9 10:37:24
*/
public class EasySideBar extends View {
private final static int DEFAULT_TEXT_SIZE = 14; // sp
private final static int DEFAULT_MAX_OFFSET = 80; //dp
private final static String[] DEFAULT_INDEX_ITEMS = {"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", "#"};
private String[] mIndexItems;
/**
* the index in {@link #mIndexItems} of the current selected index item,
* it's reset to -1 when the finger up
*/
private int mCurrentIndex = -1;
/**
* Y coordinate of the point where finger is touching,
* the baseline is top of {@link #mStartTouchingArea}
* it's reset to -1 when the finger up
*/
private float mCurrentY = -1;
private Paint mPaint;
private int mTextColor;
private float mTextSize;
private int MaxHeight;
private int MaxWidth;
/**
* the Height of each index item
*/
private float mIndexItemHeight;
/**
* offset of the current selected index item
*/
private float mMaxOffset;
/**
* {@link #mStartTouching} will be set to true when {@link MotionEvent#ACTION_DOWN}
* happens in this area, and the side bar should start working.
*/
private RectF mStartTouchingArea = new RectF();
/**
* Height and width of {@link #mStartTouchingArea}
*/
private float mBarHeight;
private float mBarWidth;
/**
* Flag that the finger is starting touching.
* If true, it means the {@link MotionEvent#ACTION_DOWN} happened but
* {@link MotionEvent#ACTION_UP} not yet.
*/
private boolean mStartTouching = false;
/**
* if true, the {@link OnSelectIndexItemListener#onSelectIndexItem(int,String)}
* will not be called until the finger up.
* if false, it will be called when the finger down, up and move.
*/
private boolean mLazyRespond = false;
/**
* the position of the side bar, default is {@link #POSITION_RIGHT}.
* You can set it to {@link #POSITION_LEFT} for people who use phone with left hand.
*/
private int mSideBarPosition;
public static final int POSITION_RIGHT = 0;
public static final int POSITION_LEFT = 1;
/**
* the alignment of items, default is {@link #TEXT_ALIGN_CENTER}.
*/
private int mTextAlignment;
public static final int TEXT_ALIGN_CENTER = 0;
public static final int TEXT_ALIGN_LEFT = 1;
public static final int TEXT_ALIGN_RIGHT = 2;
/**
* observe the current selected index item
*/
private OnSelectIndexItemListener onSelectIndexItemListener;
/**
* the baseline of the first index item text to draw
*/
private float mFirstItemBaseLineY;
/**
* for {@link #dp2px(int)} and {@link #sp2px(int)}
*/
private DisplayMetrics mDisplayMetrics;
public EasySideBar(Context context) {
this(context, null);
}
public EasySideBar(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public EasySideBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mDisplayMetrics = context.getResources().getDisplayMetrics();
mTextColor = Color.GRAY;
mMaxOffset = dp2px(DEFAULT_MAX_OFFSET);
mSideBarPosition = POSITION_RIGHT;
mTextAlignment = TEXT_ALIGN_CENTER;
/*TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.WaveSideBar);
mLazyRespond = typedArray.getBoolean(R.styleable.WaveSideBar_sidebar_lazy_respond, false);
mTextColor = typedArray.getColor(R.styleable.WaveSideBar_sidebar_text_color, Color.GRAY);
mMaxOffset = typedArray.getDimension(R.styleable.WaveSideBar_sidebar_max_offset, dp2px(DEFAULT_MAX_OFFSET));
mSideBarPosition = typedArray.getInt(R.styleable.WaveSideBar_sidebar_position, POSITION_RIGHT);
mTextAlignment = typedArray.getInt(R.styleable.WaveSideBar_sidebar_text_alignment, TEXT_ALIGN_CENTER);
typedArray.recycle();*/
mTextSize = sp2px(DEFAULT_TEXT_SIZE);
mIndexItems = DEFAULT_INDEX_ITEMS;
initPaint();
}
private void initPaint() {
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(mTextColor);
mPaint.setTextSize(mTextSize);
switch (mTextAlignment) {
case TEXT_ALIGN_CENTER: mPaint.setTextAlign(Paint.Align.CENTER); break;
case TEXT_ALIGN_LEFT: mPaint.setTextAlign(Paint.Align.LEFT); break;
case TEXT_ALIGN_RIGHT: mPaint.setTextAlign(Paint.Align.RIGHT); break;
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
MaxHeight = MeasureSpec.getSize(heightMeasureSpec);
MaxWidth = MeasureSpec.getSize(widthMeasureSpec);
Paint.FontMetrics fontMetrics = mPaint.getFontMetrics();
mIndexItemHeight = fontMetrics.bottom - fontMetrics.top;
mBarHeight = mIndexItems.length * mIndexItemHeight;
while (mBarHeight >= MaxHeight){
mTextSize--;
mPaint.setTextSize(mTextSize);
fontMetrics = mPaint.getFontMetrics();
mIndexItemHeight = fontMetrics.bottom - fontMetrics.top;
mBarHeight = mIndexItems.length * mIndexItemHeight;
}
// calculate the width of the longest text as the width of side bar
for (String indexItem : mIndexItems) {
mBarWidth = Math.max(mBarWidth, mPaint.measureText(indexItem));
}
float areaLeft = (mSideBarPosition == POSITION_LEFT) ? 0 : (MaxWidth - mBarWidth - getPaddingRight());
float areaRight = (mSideBarPosition == POSITION_LEFT) ? (getPaddingLeft() + areaLeft + mBarWidth) : width;
float areaTop = MaxHeight /2 - mBarHeight/2;
float areaBottom = areaTop + mBarHeight;
mStartTouchingArea.set(
areaLeft,
areaTop,
areaRight,
areaBottom);
// the baseline Y of the first item' text to draw
mFirstItemBaseLineY = (MaxHeight /2 - mIndexItems.length*mIndexItemHeight/2)
+ (mIndexItemHeight/2 - (fontMetrics.descent-fontMetrics.ascent)/2)
- fontMetrics.ascent;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// draw each item
for (int i = 0; i < mIndexItems.length; i++) {
float baseLineY = mFirstItemBaseLineY + mIndexItemHeight*i;
// calculate the scale factor of the item to draw
float scale = getItemScale(i);
int alphaScale = (i == mCurrentIndex) ? (255) : (int) (255 * (1-scale));
mPaint.setAlpha(alphaScale);
mPaint.setTextSize(mTextSize + mTextSize*scale);
float baseLineX = 0f;
if (mSideBarPosition == POSITION_LEFT) {
switch (mTextAlignment) {
case TEXT_ALIGN_CENTER:
baseLineX = getPaddingLeft() + mBarWidth/2 + mMaxOffset*scale;
break;
case TEXT_ALIGN_LEFT:
baseLineX = getPaddingLeft() + mMaxOffset*scale;
break;
case TEXT_ALIGN_RIGHT:
baseLineX = getPaddingLeft() + mBarWidth + mMaxOffset*scale;
break;
}
} else {
switch (mTextAlignment) {
case TEXT_ALIGN_CENTER:
baseLineX = getWidth() - getPaddingRight() - mBarWidth/2 - mMaxOffset*scale;
break;
case TEXT_ALIGN_RIGHT:
baseLineX = getWidth() - getPaddingRight() - mMaxOffset*scale;
break;
case TEXT_ALIGN_LEFT:
baseLineX = getWidth() - getPaddingRight() - mBarWidth - mMaxOffset*scale;
break;
}
}
// draw
canvas.drawText(
mIndexItems[i], //item text to draw
baseLineX, //baseLine X
baseLineY, // baseLine Y
mPaint);
}
// reset paint
mPaint.setAlpha(255);
mPaint.setTextSize(mTextSize);
}
/**
* calculate the scale factor of the item to draw
*
* @param index the index of the item in array {@link #mIndexItems}
* @return the scale factor of the item to draw
*/
private float getItemScale(int index) {
float scale = 0;
if (mCurrentIndex != -1) {
float distance = Math.abs(mCurrentY - (mIndexItemHeight*index+mIndexItemHeight/2)) / mIndexItemHeight;
scale = 1 - distance*distance/16;
scale = Math.max(scale, 0);
}
return scale;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mIndexItems.length == 0) {
return super.onTouchEvent(event);
}
float eventY = event.getY();
float eventX = event.getX();
mCurrentIndex = getSelectedIndex(eventY);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (mStartTouchingArea.contains(eventX, eventY)) {
mStartTouching = true;
if (!mLazyRespond && onSelectIndexItemListener != null) {
onSelectIndexItemListener.onSelectIndexItem(mCurrentIndex,mIndexItems[mCurrentIndex]);
}
invalidate();
return true;
} else {
mCurrentIndex = -1;
return false;
}
case MotionEvent.ACTION_MOVE:
if (mStartTouching && !mLazyRespond && onSelectIndexItemListener != null) {
onSelectIndexItemListener.onSelectIndexItem(mCurrentIndex,mIndexItems[mCurrentIndex]);
}
invalidate();
return true;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (mLazyRespond && onSelectIndexItemListener != null) {
onSelectIndexItemListener.onSelectIndexItem(mCurrentIndex,mIndexItems[mCurrentIndex]);
}
mCurrentIndex = -1;
mStartTouching = false;
invalidate();
return true;
}
return super.onTouchEvent(event);
}
private int getSelectedIndex(float eventY) {
mCurrentY = eventY - (getHeight()/2 - mBarHeight /2);
if (mCurrentY <= 0) {
return 0;
}
int index = (int) (mCurrentY / this.mIndexItemHeight);
if (index >= this.mIndexItems.length) {
index = this.mIndexItems.length - 1;
}
return index;
}
private float dp2px(int dp) {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, this.mDisplayMetrics);
}
private float sp2px(int sp) {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, this.mDisplayMetrics);
}
//Customize
public void setIndexItems(String[] indexItems) {
this.mIndexItems = indexItems;
requestLayout();
}
public void setTextColor(int color) {
this.mTextColor = color;
mPaint.setColor(color);
invalidate();
}
public void setPosition(int position) {
if (position != POSITION_RIGHT && position != POSITION_LEFT) {
throw new IllegalArgumentException("the position must be POSITION_RIGHT or POSITION_LEFT");
}
mSideBarPosition = position;
requestLayout();
}
public void setMaxOffset(int offset) {
mMaxOffset = dp2px(offset);
invalidate();
}
public void setLazyRespond(boolean lazyRespond) {
mLazyRespond = lazyRespond;
}
public void setTextAlign(int align) {
if (mTextAlignment == align) {
return;
}
switch (align) {
case TEXT_ALIGN_CENTER: mPaint.setTextAlign(Paint.Align.CENTER); break;
case TEXT_ALIGN_LEFT: mPaint.setTextAlign(Paint.Align.LEFT); break;
case TEXT_ALIGN_RIGHT: mPaint.setTextAlign(Paint.Align.RIGHT); break;
default:
throw new IllegalArgumentException(
"the alignment must be TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT or TEXT_ALIGN_RIGHT");
}
mTextAlignment = align;
invalidate();
}
public void setOnSelectIndexItemListener(OnSelectIndexItemListener onSelectIndexItemListener) {
this.onSelectIndexItemListener = onSelectIndexItemListener;
}
public interface OnSelectIndexItemListener {
void onSelectIndexItem(int index, String indexValue);
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/lib/EditTextWithDel.java
================================================
package com.esaysidebar.lib;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.EditText;
import com.esaysidebar.R;
/**
* @author: xiaolijuan
* @projectName: SelectCityDome
* @date: 2016-03-01
* @time: 15:59
*/
public class EditTextWithDel extends EditText {
private final static String TAG = "EditTextWithDel";
private Drawable imgInable;
private Drawable imgAble;
private Context mContext;
public EditTextWithDel(Context context) {
super(context);
mContext = context;
init();
}
public EditTextWithDel(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
init();
}
public EditTextWithDel(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
init();
}
private void init() {
imgAble = mContext.getResources().getDrawable(
R.mipmap.icon_delete_gray);
addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
setDrawable();
}
});
setDrawable();
}
private void setDrawable() {
if (length() < 1) {
setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
} else {
setCompoundDrawablesWithIntrinsicBounds(null, null, imgAble, null);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (imgAble != null && event.getAction() == MotionEvent.ACTION_UP) {
int eventX = (int) event.getRawX();
int eventY = (int) event.getRawY();
Log.e(TAG, "eventX = " + eventX + "; eventY = " + eventY);
Rect rect = new Rect();
getGlobalVisibleRect(rect);
rect.left = rect.right - 50;
if (rect.contains(eventX, eventY))
setText("");
}
return super.onTouchEvent(event);
}
@Override
protected void finalize() throws Throwable {
super.finalize();
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/utils/PinyinComparator.java
================================================
package com.esaysidebar.utils;
import com.esaysidebar.bean.CitySortModel;
import java.util.Comparator;
/**
* 用来对ListView中的数据根据A-Z进行排序,前面两个if判断主要是将不是以汉字开头的数据放在后面
*/
public class PinyinComparator implements Comparator<CitySortModel> {
public int compare(CitySortModel o1, CitySortModel o2) {
//这里主要是用来对ListView里面的数据根据ABCDEFG...来排序
if (o1.getSortLetters().equals("@") || o2.getSortLetters().equals("#")) {
return -1;
} else if (o1.getSortLetters().equals("#") || o2.getSortLetters().equals("@")) {
return 1;
} else {
return o1.getSortLetters().compareTo(o2.getSortLetters());
}
}
}
================================================
FILE: easysidebar/src/main/java/com/esaysidebar/utils/PinyinUtils.java
================================================
package com.esaysidebar.utils;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
/**
* @author:
* @description:
* @projectName: SelectCityDome
* @date: 2016-03-01
* @time: 15:45
*/
public class PinyinUtils {
/**
*
* @param chines
* @return
*/
public static String getAlpha(String chines) {
String pinyinName = "";
char[] nameChar = chines.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (int i = 0; i < nameChar.length; i++) {
if (nameChar[i] > 128) {
try {
pinyinName += PinyinHelper.toHanyuPinyinStringArray(
nameChar[i], defaultFormat)[0].charAt(0);
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pinyinName += nameChar[i];
}
}
return pinyinName;
}
/**
*
* string's chinese to pinying ,english string no change
*
* @param inputString
* @return
*/
public static String getPingYin(String inputString) {
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
format.setVCharType(HanyuPinyinVCharType.WITH_V);
String output = "";
if (inputString != null && inputString.length() > 0
&& !"null".equals(inputString)) {
char[] input = inputString.trim().toCharArray();
try {
for (int i = 0; i < input.length; i++) {
if (Character.toString(input[i]).matches(
"[\\u4E00-\\u9FA5]+")) {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(
input[i], format);
output += temp[0];
} else
output += Character.toString(input[i]);
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
return "*";
}
return output;
}
/**
*c
*
* @param chines
* @return
*/
public static String converterToFirstSpell(String chines) {
String pinyinName = "";
char[] nameChar = chines.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (int i = 0; i < nameChar.length; i++) {
if (nameChar[i] > 128) {
try {
pinyinName += PinyinHelper.toHanyuPinyinStringArray(
nameChar[i], defaultFormat)[0].charAt(0);
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pinyinName += nameChar[i];
}
}
return pinyinName;
}
}
================================================
FILE: easysidebar/src/main/res/drawable/edit_background.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#F0F0F0" />
<stroke
android:width="1dp"
android:color="#DEDEDE" />
</shape>
================================================
FILE: easysidebar/src/main/res/drawable/select_btn_white_gray.xml
================================================
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--白色-蓝色 点击状态选择器-->
<item android:state_pressed="false">
<shape>
<solid android:color="@color/color_background" />
<corners android:radius="4dp" />
</shape>
</item>
<item android:state_pressed="true">
<shape>
<solid android:color="@color/color_background_gray" />
<corners android:radius="4dp" />
<stroke
android:width="0.8dp"
android:color="@color/color_gray_transparent" />
</shape>
</item>
</selector>
================================================
FILE: easysidebar/src/main/res/drawable/selector_btn_press.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/common_gray_transparent" android:state_pressed="true"/>
<item android:drawable="@drawable/common_white"/>
</selector>
================================================
FILE: easysidebar/src/main/res/layout/activity_sort_city.xml
================================================
<?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:background="@color/color_background"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="46dp"
android:background="#0088CC">
<ImageView
android:id="@+id/iv_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/ic_back"
android:padding="12dp"/>
<TextView
android:id="@+id/tv_title"
android:text="标题"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="10dp"
android:textColor="#EEEEEE"/>
</RelativeLayout>
<com.esaysidebar.lib.EditTextWithDel
android:id="@+id/et_search"
android:hint="请输入城市名或拼音查询"
android:maxLines="1"
android:paddingLeft="10dp"
android:textSize="15dp"
android:textColorHint="@android:color/darker_gray"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:background="@drawable/edit_background"
android:layout_width="match_parent"
android:layout_height="40dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/country_lvcountry"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:divider="@null"
android:scrollbars="none" />
<com.esaysidebar.lib.EasySideBar
android:id="@+id/sidebar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</LinearLayout>
================================================
FILE: easysidebar/src/main/res/layout/gridview_item.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_city"
android:gravity="center"
android:background="@drawable/select_btn_white_gray"
android:layout_width="match_parent"
android:paddingLeft="4dp"
android:layout_margin="5dp"
android:paddingRight="4dp"
android:textColor="#979797"
android:layout_height="38dp" />
</LinearLayout>
================================================
FILE: easysidebar/src/main/res/layout/headview_hotcity.xml
================================================
<?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="wrap_content"
android:orientation="vertical"
android:background="@color/color_background_gray"
xmlns:tools="http://schemas.android.com/tools">
<!-- <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_label_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_margin="10dp"
android:text="当前定位城市"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_location_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="广州"
android:textSize="14dp"
android:layout_marginLeft="10dp"
android:gravity="center"
android:drawableLeft="@mipmap/ic_location"
android:drawablePadding="4dp"
android:layout_marginBottom="10dp"
android:padding="10dp"
android:background="@drawable/selector_btn_press"/>
</LinearLayout>-->
<TextView
android:id="@+id/tv_label_hot"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:gravity="center_vertical"
android:layout_marginLeft="16dp"
android:text="热门城市"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
<com.esaysidebar.activity.MyGridView
android:id="@+id/gv_hot_city"
android:layout_width="match_parent"
android:layout_marginRight="20dp"
android:layout_marginLeft="10dp"
android:numColumns="3"
android:horizontalSpacing="10dp"
android:verticalSpacing="5dp"
android:listSelector="@android:color/transparent"
tools:listitem="@layout/gridview_item"
android:layout_height="match_parent" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#E0E0E0" />
<!--<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:gravity="center_vertical"
android:layout_marginLeft="16dp"
android:text="主要城市"
android:textColor="@android:color/black"
android:textSize="14sp" />-->
</LinearLayout>
================================================
FILE: easysidebar/src/main/res/layout/headview_loaction.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_background_gray">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_label_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_margin="10dp"
android:text="当前定位城市"
android:textColor="@android:color/darker_gray"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_location_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="广州"
android:textSize="14dp"
android:layout_marginLeft="10dp"
android:gravity="center"
android:drawableLeft="@mipmap/ic_location"
android:drawablePadding="4dp"
android:layout_marginBottom="10dp"
android:padding="10dp"
android:background="@drawable/selector_btn_press"/>
</LinearLayout>
</LinearLayout>
================================================
FILE: easysidebar/src/main/res/layout/item_select_city.xml
================================================
<?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="wrap_content"
android:orientation="vertical"
android:background="@color/color_background">
<TextView
android:id="@+id/tv_catagory"
android:layout_width="38dp"
android:layout_height="38dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:background="@drawable/edit_background"
android:gravity="center"
android:text="A"
android:textColor="#7E7B80"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_city_name"
android:layout_width="match_parent"
android:layout_height="43dp"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:text="CityName"
android:textColor="#7E7B80"
android:textSize="16sp"
android:background="@drawable/selector_btn_press"/>
<View
android:layout_marginRight="30dp"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginLeft="12dp"
android:background="#7E7B80" />
</LinearLayout>
================================================
FILE: easysidebar/src/main/res/values/arrays.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string-array name="provinces">
<item>%#S乱码</item>
<item>北京市</item>
<item>天津市</item>
<item>上海市</item>
<item>重庆市</item>
<item>石家庄</item>
<item>唐山市</item>
<item>秦皇岛</item>
<item>邯郸市</item>
<item>邢台市</item>
<item>保定市</item>
<item>张家口</item>
<item>承德市</item>
<item>沧州市</item>
<item>廊坊市</item>
<item>衡水市</item>
<item>太原市</item>
<item>大同市</item>
<item>阳泉市</item>
<item>长治市</item>
<item>晋城市</item>
<item>朔州市</item>
<item>晋中市</item>
<item>运城市</item>
<item>忻州市</item>
<item>临汾市</item>
<item>吕梁市</item>
<item>南京市</item>
<item>无锡市</item>
<item>徐州市</item>
<item>常州市</item>
<item>苏州市</item>
<item>南通市</item>
<item>连云港</item>
<item>淮安市</item>
<item>盐城市</item>
<item>扬州市</item>
<item>镇江市</item>
<item>泰州市</item>
<item>宿迁市</item>
<item>杭州市</item>
<item>宁波市</item>
<item>温州市</item>
<item>嘉兴市</item>
<item>湖州市</item>
<item>绍兴市</item>
<item>金华市</item>
<item>衢州市</item>
<item>舟山市</item>
<item>台州市</item>
<item>丽水市</item>
<item>合肥市</item>
<item>芜湖市</item>
<item>蚌埠市</item>
<item>淮南市</item>
<item>马鞍山</item>
<item>淮北市</item>
<item>铜陵市</item>
<item>安庆市</item>
<item>黄山市</item>
<item>滁州市</item>
<item>阜阳市</item>
<item>宿州市</item>
<item>巢湖市</item>
<item>六安市</item>
<item>毫州市</item>
<item>池州市</item>
<item>宣城市</item>
<item>福州市</item>
<item>厦门市</item>
<item>莆田市</item>
<item>三明市</item>
<item>泉州市</item>
<item>漳州市</item>
<item>南平市</item>
<item>龙岩市</item>
<item>宁德市</item>
<item>南昌市</item>
<item>景德镇</item>
<item>萍乡市</item>
<item>九江市</item>
<item>新余市</item>
<item>鹰潭市</item>
<item>赣州市</item>
<item>吉安市</item>
<item>宜春市</item>
<item>抚州市</item>
<item>上饶市</item>
<item>济南市</item>
<item>青岛市</item>
<item>淄博市</item>
<item>枣庄市</item>
<item>东营市</item>
<item>烟台市</item>
<item>潍坊市</item>
<item>济宁市</item>
<item>泰安市</item>
<item>威海市</item>
<item>日照市</item>
<item>莱芜市</item>
<item>临沂市</item>
<item>德州市</item>
<item>聊城市</item>
<item>滨州市</item>
<item>菏泽市</item>
<item>郑州市</item>
<item>开封市</item>
<item>洛阳市</item>
<item>平顶山</item>
<item>安阳市</item>
<item>鹤壁市</item>
<item>新乡市</item>
<item>焦作市</item>
<item>濮阳市</item>
<item>许昌市</item>
<item>漯河市</item>
<item>三门峡</item>
<item>南阳市</item>
<item>商丘市</item>
<item>信阳市</item>
<item>周口市</item>
<item>驻马店</item>
<item>武汉市</item>
<item>黄石市</item>
<item>十堰市</item>
<item>宜昌市</item>
<item>襄樊市</item>
<item>鄂州市</item>
<item>荆门市</item>
<item>孝感市</item>
<item>荆州市</item>
<item>黄冈市</item>
<item>咸宁市</item>
<item>随州市</item>
<item>神农架</item>
<item>恩施土家族苗族自治州</item>
<item>长沙市</item>
<item>株洲市</item>
<item>湘潭市</item>
<item>衡阳市</item>
<item>邵阳市</item>
<item>岳阳市</item>
<item>常德市</item>
<item>张家界</item>
<item>益阳市</item>
<item>永州市</item>
<item>怀化市</item>
<item>娄底市</item>
<item>郴州市</item>
<item>湘西土家族苗族自治州</item>
<item>广州市</item>
<item>韶关市</item>
<item>深圳市</item>
<item>珠海市</item>
<item>汕头市</item>
<item>佛山市</item>
<item>江门市</item>
<item>湛江市</item>
<item>茂名市</item>
<item>肇庆市</item>
<item>惠州市</item>
<item>梅州市</item>
<item>汕尾市</item>
<item>河源市</item>
<item>阳江市</item>
<item>清远市</item>
<item>东莞市</item>
<item>中山市</item>
<item>潮州市</item>
<item>揭阳市</item>
<item>云浮市</item>
<item>沈阳市</item>
<item>大连市</item>
<item>鞍山市</item>
<item>抚顺市</item>
<item>本溪市</item>
<item>丹东市</item>
<item>锦州市</item>
<item>营口市</item>
<item>阜新市</item>
<item>辽阳市</item>
<item>盘锦市</item>
<item>铁岭市</item>
<item>朝阳市</item>
<item>葫芦岛</item>
<item>长春市</item>
<item>吉林市</item>
<item>四平市</item>
<item>辽源市</item>
<item>通化市</item>
<item>白山市</item>
<item>松原市</item>
<item>白城市</item>
<item>延边朝鲜族自治区市</item>
<item>哈尔滨</item>
<item>齐齐哈尔市</item>
<item>鸡西市</item>
<item>鹤岗市</item>
<item>双鸭山</item>
<item>大庆市</item>
<item>伊春市</item>
<item>佳木斯</item>
<item>七台河</item>
<item>牡丹江</item>
<item>黑河市</item>
<item>绥化市</item>
<item>大兴安岭地区</item>
<item>南宁市</item>
<item>柳州市</item>
<item>桂林市</item>
<item>梧州市</item>
<item>北海市</item>
<item>防城港</item>
<item>钦州市</item>
<item>贵港市</item>
<item>玉林市</item>
<item>百色市</item>
<item>贺州市</item>
<item>河池市</item>
<item>来宾市</item>
<item>崇左市</item>
<item>海口市</item>
<item>三亚市</item>
<item>台北市</item>
<item>台南市</item>
<item>高雄市</item>
<item>成都市</item>
<item>自贡市</item>
<item>攀枝花</item>
<item>泸州市</item>
<item>德阳市</item>
<item>绵阳市</item>
<item>广元市</item>
<item>遂宁市</item>
<item>内江市</item>
<item>乐山市</item>
<item>南充市</item>
<item>眉山市</item>
<item>宜宾市</item>
<item>广安市</item>
<item>达州市</item>
<item>雅安市</item>
<item>巴中市</item>
<item>资阳市</item>
<item>阿坝藏族羌族自治州</item>
<item>甘孜藏族自治州</item>
<item>凉山彝族自治州</item>
<item>贵阳市</item>
<item>六盘水</item>
<item>遵义市</item>
<item>安顺市</item>
<item>铜仁地</item>
<item>黔西南布依族苗族自治州</item>
<item>毕节地</item>
<item>黔东南苗族侗族自治州</item>
<item>黔南布依族苗族自治州</item>
<item>昆明市</item>
<item>曲靖市</item>
<item>玉溪市</item>
<item>宝山市</item>
<item>邵通市</item>
<item>丽江市</item>
<item>思茅市</item>
<item>临沧市</item>
<item>楚雄彝族自治州</item>
<item>红河哈尼族彝族自治州</item>
<item>文山壮族苗族自治州</item>
<item>西双版纳傣族自治州</item>
<item>大理白族自治州</item>
<item>德宏傣族景颇族自治州</item>
<item>怒江傈僳族自治州</item>
<item>迪庆藏族自治州</item>
<item>拉萨市</item>
<item>西安市</item>
<item>铜川市</item>
<item>宝鸡市</item>
<item>咸阳市</item>
<item>渭南市</item>
<item>延安市</item>
<item>汉中市</item>
<item>榆林市</item>
<item>安康市</item>
<item>商洛市</item>
<item>兰州市</item>
<item>嘉峪关</item>
<item>金昌市</item>
<item>白银市</item>
<item>天水市</item>
<item>武威市</item>
<item>张掖市</item>
<item>平凉市</item>
<item>酒泉市</item>
<item>庆阳市</item>
<item>定西市</item>
<item>西宁市</item>
<item>海东地区</item>
<item>海北藏族自治州</item>
<item>黄南藏族自治州市</item>
<item>海南藏族自治州</item>
<item>果洛藏族自治州</item>
<item>玉树藏族自治州</item>
<item>海西蒙古族藏族自治州</item>
<item>银川市</item>
<item>石嘴山</item>
<item>吴忠市</item>
<item>固原市</item>
<item>中卫市</item>
<item>呼和浩特市</item>
<item>包头市</item>
<item>乌海市</item>
<item>赤峰市</item>
<item>通辽市</item>
<item>鄂尔多斯市</item>
<item>呼伦贝尔市</item>
<item>巴彦卓尔市</item>
<item>乌兰察布市</item>
<item>兴安盟</item>
<item>乌鲁木齐市</item>
<item>克拉玛依市</item>
<item>吐鲁番地区</item>
<item>哈密地区</item>
<item>昌吉回族自治州</item>
<item>博尔塔拉蒙古自治州</item>
<item>巴音郭楞蒙古自治州</item>
<item>阿克苏地区</item>
<item>克孜勒苏柯尔克孜自治州</item>
<item>喀什地区</item>
<item>和田地区</item>
<item>伊犁哈萨克自治州</item>
<item>塔城地区</item>
<item>阿勒泰地区</item>
<item>石河子市</item>
<item>阿拉尔市</item>
<item>香港特别行政区</item>
<item>澳门特别行政区</item>
</string-array>
</resources>
================================================
FILE: easysidebar/src/main/res/values/color.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 公用的背景颜色 -->
<color name="color_background">#F9F9F9</color>
<color name="color_background_gray">#F0F0F0</color>
<color name="color_gray_transparent">#88AAAAAA</color>
<color name="color_transparent">#00000000</color>
</resources>
================================================
FILE: easysidebar/src/main/res/values/drawables.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="common_white" type="drawable">@color/color_background</item>
<item name="common_transparent" type="drawable">@color/color_transparent</item>
<item name="common_gray_transparent" type="drawable">@color/color_gray_transparent</item>
</resources>
================================================
FILE: easysidebar/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">EasySideBarLibrary</string>
</resources>
================================================
FILE: easysidebar/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: easysidebar/src/test/java/com/demo/ExampleUnitTest.java
================================================
package com.demo;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
================================================
FILE: gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: settings.gradle
================================================
include ':app', ':easysidebar'
gitextract_f_jovrni/ ├── .gitignore ├── .idea/ │ ├── compiler.xml │ ├── copyright/ │ │ └── profiles_settings.xml │ ├── encodings.xml │ ├── gradle.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── demo/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── demo/ │ │ │ └── MainActivity.java │ │ └── res/ │ │ ├── layout/ │ │ │ └── activity_main.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ └── test/ │ └── java/ │ └── com/ │ └── demo/ │ └── ExampleUnitTest.java ├── build.gradle ├── easysidebar/ │ ├── .gitignore │ ├── build.gradle │ ├── libs/ │ │ └── pinyin4j-2.5.0.jar │ ├── proguard-rules.pro │ └── src/ │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── esaysidebar/ │ │ │ ├── EasySideBarBuilder.java │ │ │ ├── activity/ │ │ │ │ ├── GridCityAdapter.java │ │ │ │ ├── MyGridView.java │ │ │ │ ├── SortAdapter.java │ │ │ │ └── SortCityActivity.java │ │ │ ├── bean/ │ │ │ │ └── CitySortModel.java │ │ │ ├── lib/ │ │ │ │ ├── EasySideBar.java │ │ │ │ └── EditTextWithDel.java │ │ │ └── utils/ │ │ │ ├── PinyinComparator.java │ │ │ └── PinyinUtils.java │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── edit_background.xml │ │ │ ├── select_btn_white_gray.xml │ │ │ └── selector_btn_press.xml │ │ ├── layout/ │ │ │ ├── activity_sort_city.xml │ │ │ ├── gridview_item.xml │ │ │ ├── headview_hotcity.xml │ │ │ ├── headview_loaction.xml │ │ │ └── item_select_city.xml │ │ ├── values/ │ │ │ ├── arrays.xml │ │ │ ├── color.xml │ │ │ ├── drawables.xml │ │ │ └── strings.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ └── test/ │ └── java/ │ └── com/ │ └── demo/ │ └── ExampleUnitTest.java ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle
SYMBOL INDEX (90 symbols across 14 files)
FILE: app/src/androidTest/java/com/demo/ExampleInstrumentedTest.java
class ExampleInstrumentedTest (line 17) | @RunWith(AndroidJUnit4.class)
method useAppContext (line 19) | @Test
FILE: app/src/main/java/com/demo/MainActivity.java
class MainActivity (line 14) | public class MainActivity extends AppCompatActivity {
method onCreate (line 17) | @Override
method initView (line 26) | private void initView() {
method onActivityResult (line 60) | @Override
FILE: app/src/test/java/com/demo/ExampleUnitTest.java
class ExampleUnitTest (line 12) | public class ExampleUnitTest {
method addition_isCorrect (line 13) | @Test
FILE: easysidebar/src/main/java/com/esaysidebar/EasySideBarBuilder.java
class EasySideBarBuilder (line 18) | public class EasySideBarBuilder {
method EasySideBarBuilder (line 31) | public EasySideBarBuilder(Context context) {
method setTitle (line 35) | public EasySideBarBuilder setTitle(String titleText){
method isLazyRespond (line 39) | public EasySideBarBuilder isLazyRespond(boolean isLazyRespond){
method setIndexItems (line 43) | public EasySideBarBuilder setIndexItems(String[] indexItems){
method setLocationCity (line 47) | public EasySideBarBuilder setLocationCity(String LocationCity){
method setIndexColor (line 51) | public EasySideBarBuilder setIndexColor(int indexColor){
method setMaxOffset (line 55) | public EasySideBarBuilder setMaxOffset(int maxOffset){
method setHotCityList (line 59) | public EasySideBarBuilder setHotCityList(ArrayList<String> HotCityList){
method start (line 64) | public void start(){
FILE: easysidebar/src/main/java/com/esaysidebar/activity/GridCityAdapter.java
class GridCityAdapter (line 21) | public class GridCityAdapter extends ArrayAdapter<String> {
method GridCityAdapter (line 27) | public GridCityAdapter(Context context, int textViewResourceId, List<S...
method getView (line 32) | @Override
FILE: easysidebar/src/main/java/com/esaysidebar/activity/MyGridView.java
class MyGridView (line 10) | public class MyGridView extends GridView {
method MyGridView (line 12) | public MyGridView(Context context, AttributeSet attrs, int defStyle) {
method MyGridView (line 16) | public MyGridView(Context context, AttributeSet attrs) {
method MyGridView (line 20) | public MyGridView(Context context) {
method onMeasure (line 29) | @Override
FILE: easysidebar/src/main/java/com/esaysidebar/activity/SortAdapter.java
class SortAdapter (line 16) | public class SortAdapter extends BaseAdapter {
method SortAdapter (line 20) | public SortAdapter(Context mContext, List<CitySortModel> list) {
method updateListView (line 30) | public void updateListView(List<CitySortModel> list) {
method getCount (line 35) | public int getCount() {
method getItem (line 39) | public Object getItem(int position) {
method getItemId (line 43) | public long getItemId(int position) {
method getView (line 47) | public View getView(final int position, View view, ViewGroup arg2) {
class ViewHolder (line 76) | final static class ViewHolder {
method getSectionForPosition (line 81) | public int getSectionForPosition(int position) {
method getPositionForSection (line 85) | public int getPositionForSection(int section) {
FILE: easysidebar/src/main/java/com/esaysidebar/activity/SortCityActivity.java
class SortCityActivity (line 28) | public class SortCityActivity extends Activity {
method onCreate (line 47) | @Override
method initViews (line 66) | private void initViews() {
method setAdapter (line 82) | private void setAdapter() {
method initEvents (line 90) | private void initEvents() {
method initSideBar (line 151) | private void initSideBar() {//初始化sidebar
method initHotHeadView (line 166) | private View initHotHeadView() {
method initLocationHeadView (line 212) | private View initLocationHeadView() {
method SentDataForResult (line 236) | private void SentDataForResult(String city) {
method filterData (line 249) | private void filterData(String filterStr) {
method filledData (line 268) | private List<CitySortModel> filledData(String[] date) {//获取数据,并根据拼音分类,...
method Concat (line 300) | private String[] Concat(String[] a,String[] b) {//合并两个数组
FILE: easysidebar/src/main/java/com/esaysidebar/bean/CitySortModel.java
class CitySortModel (line 3) | public class CitySortModel {
method getName (line 8) | public String getName() {
method setName (line 12) | public void setName(String name) {
method getSortLetters (line 16) | public String getSortLetters() {
method setSortLetters (line 20) | public void setSortLetters(String sortLetters) {
FILE: easysidebar/src/main/java/com/esaysidebar/lib/EasySideBar.java
class EasySideBar (line 21) | public class EasySideBar extends View {
method EasySideBar (line 117) | public EasySideBar(Context context) {
method EasySideBar (line 121) | public EasySideBar(Context context, AttributeSet attrs) {
method EasySideBar (line 125) | public EasySideBar(Context context, AttributeSet attrs, int defStyleAt...
method initPaint (line 149) | private void initPaint() {
method onMeasure (line 161) | @Override
method onDraw (line 206) | @Override
method getItemScale (line 267) | private float getItemScale(int index) {
method onTouchEvent (line 277) | @Override
method getSelectedIndex (line 322) | private int getSelectedIndex(float eventY) {
method dp2px (line 335) | private float dp2px(int dp) {
method sp2px (line 339) | private float sp2px(int sp) {
method setIndexItems (line 348) | public void setIndexItems(String[] indexItems) {
method setTextColor (line 353) | public void setTextColor(int color) {
method setPosition (line 359) | public void setPosition(int position) {
method setMaxOffset (line 368) | public void setMaxOffset(int offset) {
method setLazyRespond (line 373) | public void setLazyRespond(boolean lazyRespond) {
method setTextAlign (line 377) | public void setTextAlign(int align) {
method setOnSelectIndexItemListener (line 393) | public void setOnSelectIndexItemListener(OnSelectIndexItemListener onS...
type OnSelectIndexItemListener (line 397) | public interface OnSelectIndexItemListener {
method onSelectIndexItem (line 398) | void onSelectIndexItem(int index, String indexValue);
FILE: easysidebar/src/main/java/com/esaysidebar/lib/EditTextWithDel.java
class EditTextWithDel (line 22) | public class EditTextWithDel extends EditText {
method EditTextWithDel (line 28) | public EditTextWithDel(Context context) {
method EditTextWithDel (line 34) | public EditTextWithDel(Context context, AttributeSet attrs, int defSty...
method EditTextWithDel (line 40) | public EditTextWithDel(Context context, AttributeSet attrs) {
method init (line 46) | private void init() {
method setDrawable (line 67) | private void setDrawable() {
method onTouchEvent (line 76) | @Override
method finalize (line 91) | @Override
FILE: easysidebar/src/main/java/com/esaysidebar/utils/PinyinComparator.java
class PinyinComparator (line 10) | public class PinyinComparator implements Comparator<CitySortModel> {
method compare (line 12) | public int compare(CitySortModel o1, CitySortModel o2) {
FILE: easysidebar/src/main/java/com/esaysidebar/utils/PinyinUtils.java
class PinyinUtils (line 18) | public class PinyinUtils {
method getAlpha (line 24) | public static String getAlpha(String chines) {
method getPingYin (line 52) | public static String getPingYin(String inputString) {
method converterToFirstSpell (line 86) | public static String converterToFirstSpell(String chines) {
FILE: easysidebar/src/test/java/com/demo/ExampleUnitTest.java
class ExampleUnitTest (line 12) | public class ExampleUnitTest {
method addition_isCorrect (line 13) | @Test
Condensed preview — 59 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (97K chars).
[
{
"path": ".gitignore",
"chars": 118,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n"
},
{
"path": ".idea/compiler.xml",
"chars": 686,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"CompilerConfiguration\">\n <resourceExt"
},
{
"path": ".idea/copyright/profiles_settings.xml",
"chars": 74,
"preview": "<component name=\"CopyrightManager\">\n <settings default=\"\" />\n</component>"
},
{
"path": ".idea/encodings.xml",
"chars": 159,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"Encoding\">\n <file url=\"PROJECT\" chars"
},
{
"path": ".idea/gradle.xml",
"chars": 683,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"GradleSettings\">\n <option name=\"linke"
},
{
"path": ".idea/misc.xml",
"chars": 2644,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"EntryPointsManager\">\n <entry_points v"
},
{
"path": ".idea/modules.xml",
"chars": 488,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"ProjectModuleManager\">\n <modules>\n "
},
{
"path": ".idea/runConfigurations.xml",
"chars": 564,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"RunConfigurationProducerService\">\n <o"
},
{
"path": ".idea/vcs.xml",
"chars": 180,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n <component name=\"VcsDirectoryMappings\">\n <mapping dire"
},
{
"path": "README.md",
"chars": 2539,
"preview": "# EasySideBar\n一款按字母排序的库,已封装好城市数据,可定制化强,也可以下载源代码用Module的形式引入自己改一改来使用,也可稍做改造定制成通讯录。欢迎Star、提建议、提Issue。\n\n users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "settings.gradle",
"chars": 31,
"preview": "include ':app', ':easysidebar'\n"
}
]
// ... and 2 more files (download for full content)
About this extraction
This page contains the full source code of the Bigkoo/EasySideBar GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 59 files (83.2 KB), approximately 24.0k tokens, and a symbol index with 90 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.