├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── 190.gif ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── chs │ │ └── filterdemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── chs │ │ │ └── filterdemo │ │ │ ├── FilterFragment.java │ │ │ ├── FilterFragmentTwo.java │ │ │ └── MainActivity.java │ └── res │ │ ├── anim │ │ ├── left_in.xml │ │ ├── left_out.xml │ │ ├── right_in.xml │ │ └── right_out.xml │ │ ├── drawable │ │ ├── shape_patrol_corners_blue.xml │ │ ├── shape_patrol_corners_blue_confirm.xml │ │ └── shape_patrol_corners_gray.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── fragment_department_select.xml │ │ └── fragment_patrol_filter.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── patrol_back.png │ │ ├── patrol_drop_down.png │ │ ├── patrol_heading.png │ │ └── patrol_next_arrow.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── chs │ └── filterdemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FilterDemo 2 | 3 | Android仿京东筛选 4 | 5 | [Android仿京东筛选](http://blog.csdn.net/mingyunxiaohai/article/details/52893695) 6 | 7 | ![](https://github.com/chsmy/FilterDemo/blob/master/app/190.gif) -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/190.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chsmy/FilterDemo/566dcbcbdac6f873d5d9040b91d5eb0d57c97c6a/app/190.gif -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.0" 6 | defaultConfig { 7 | applicationId "com.chs.filterdemo" 8 | minSdkVersion 18 9 | targetSdkVersion 24 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:24.2.1' 28 | testCompile 'junit:junit:4.12' 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\AndroidTools\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/chs/filterdemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.chs.filterdemo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.chs.filterdemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/chs/filterdemo/FilterFragment.java: -------------------------------------------------------------------------------- 1 | package com.chs.filterdemo; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentManager; 7 | import android.support.v4.app.FragmentTransaction; 8 | import android.support.v4.widget.DrawerLayout; 9 | import android.text.TextUtils; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.FrameLayout; 14 | import android.widget.ImageView; 15 | import android.widget.RelativeLayout; 16 | import android.widget.TextView; 17 | 18 | /** 19 | * 作者:chs on 2016/10/10 10:07 20 | * 邮箱:657083984@qq.com 21 | */ 22 | 23 | public class FilterFragment extends Fragment { 24 | private DrawerLayout mDrawerLayout; 25 | private FrameLayout mDrawerContent; 26 | private RelativeLayout rl_department; 27 | private ImageView iv_back; 28 | private TextView department_selected; 29 | @Nullable 30 | @Override 31 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 32 | View view = inflater.inflate(R.layout.fragment_patrol_filter, null); 33 | initView(view); 34 | initEvent(); 35 | return view; 36 | } 37 | 38 | private void initEvent() { 39 | rl_department.setOnClickListener(new View.OnClickListener() { 40 | @Override 41 | public void onClick(View v) { 42 | showNext(); 43 | } 44 | }); 45 | iv_back.setOnClickListener(new View.OnClickListener() { 46 | @Override 47 | public void onClick(View v) { 48 | mDrawerLayout.closeDrawer(mDrawerContent); 49 | } 50 | }); 51 | } 52 | 53 | private void initView(View view) { 54 | String departmentName = getArguments().getString("departmentName"); 55 | mDrawerLayout = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout); 56 | mDrawerContent = (FrameLayout) getActivity().findViewById(R.id.drawer_content); 57 | rl_department = (RelativeLayout) view.findViewById(R.id.rl_department); 58 | iv_back = (ImageView) view.findViewById(R.id.iv_back); 59 | department_selected = (TextView) view.findViewById(R.id.department_selected); 60 | if(!TextUtils.isEmpty(departmentName)){ 61 | department_selected.setText(departmentName); 62 | department_selected.setTextColor(getResources().getColor(R.color.blue_text)); 63 | } 64 | } 65 | 66 | 67 | private void showNext() { 68 | Fragment fragment = new FilterFragmentTwo(); 69 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); 70 | FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); 71 | fragmentTransaction.setCustomAnimations(R.anim.right_in, R.anim.left_out, R.anim.left_in, R.anim.right_out); 72 | fragmentTransaction.replace(R.id.drawer_content, fragment); 73 | fragmentTransaction.addToBackStack(null); 74 | fragmentTransaction.commitAllowingStateLoss(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/chs/filterdemo/FilterFragmentTwo.java: -------------------------------------------------------------------------------- 1 | package com.chs.filterdemo; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.AdapterView; 10 | import android.widget.ArrayAdapter; 11 | import android.widget.ImageView; 12 | import android.widget.ListView; 13 | 14 | /** 15 | * 作者:chs on 2016/10/22 16:01 16 | * 邮箱:657083984@qq.com 17 | */ 18 | 19 | public class FilterFragmentTwo extends Fragment { 20 | private ListView lv_department; 21 | private ImageView iv_back; 22 | private String departmentName = ""; 23 | String[] list; 24 | @Nullable 25 | @Override 26 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 27 | View view = inflater.inflate(R.layout.fragment_department_select, null); 28 | initView(view); 29 | return view; 30 | } 31 | 32 | private void initView(View view) { 33 | lv_department = (ListView) view.findViewById(R.id.lv_department); 34 | iv_back = (ImageView) view.findViewById(R.id.iv_back); 35 | list = new String[10]; 36 | for(int i = 0;i<10;i++){ 37 | list[i] = "部门"+i; 38 | } 39 | ArrayAdapter arrayAdapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1,list); 40 | lv_department.setAdapter(arrayAdapter); 41 | 42 | 43 | iv_back.setOnClickListener(new View.OnClickListener() { 44 | @Override 45 | public void onClick(View v) { 46 | // showNext(); 47 | getActivity().getSupportFragmentManager().popBackStackImmediate(); 48 | } 49 | }); 50 | 51 | lv_department.setOnItemClickListener(new AdapterView.OnItemClickListener() { 52 | @Override 53 | public void onItemClick(AdapterView parent, View view, int position, long id) { 54 | departmentName = list[position]; 55 | // showNext(); 56 | getActivity().getSupportFragmentManager().popBackStackImmediate(); 57 | } 58 | }); 59 | } 60 | // private void showNext() { 61 | // Fragment fragment = new FilterFragment(); 62 | // Bundle bundle = new Bundle(); 63 | // bundle.putString("departmentName",departmentName); 64 | // fragment.setArguments(bundle); 65 | // FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); 66 | // FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); 67 | // fragmentTransaction.setCustomAnimations(R.anim.left_in, R.anim.right_out, R.anim.right_in, R.anim.left_out); 68 | // fragmentTransaction.replace(R.id.drawer_content, fragment); 69 | // fragmentTransaction.commitAllowingStateLoss(); 70 | // } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/chs/filterdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.chs.filterdemo; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.widget.DrawerLayout; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.view.View; 9 | import android.widget.FrameLayout; 10 | import android.widget.TextView; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | private TextView tv_filter; 14 | private DrawerLayout mDrawerLayout; 15 | private FrameLayout mDrawerContent; 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_main); 20 | initView(); 21 | initEvent(); 22 | } 23 | 24 | private void initEvent() { 25 | tv_filter.setOnClickListener(new View.OnClickListener() { 26 | @Override 27 | public void onClick(View v) { 28 | mDrawerLayout.openDrawer(mDrawerContent); 29 | } 30 | }); 31 | } 32 | 33 | private void initView() { 34 | tv_filter = (TextView) findViewById(R.id.tv_filter); 35 | mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 36 | mDrawerContent = (FrameLayout) findViewById(R.id.drawer_content); 37 | 38 | Fragment fragment = new FilterFragment(); 39 | FragmentManager fragmentManager = getSupportFragmentManager(); 40 | Bundle bundle = new Bundle(); 41 | bundle.putString("departmentName",""); 42 | fragment.setArguments(bundle); 43 | fragmentManager.beginTransaction().replace(R.id.drawer_content, fragment).commit(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/res/anim/left_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/anim/left_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/anim/right_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/anim/right_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_patrol_corners_blue.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_patrol_corners_blue_confirm.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_patrol_corners_gray.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 19 | 20 | 30 | 31 | 32 | 36 | 37 | 38 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_department_select.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 21 | 22 | 27 | 28 | 32 | 40 | 47 | 48 |