浏览代码

优化接口列表

316044749 7 年之前
父节点
当前提交
894e2f4d2b

+ 5 - 0
app/src/main/AndroidManifest.xml

@@ -41,6 +41,7 @@
 
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
+
         </activity>
 
         <!--登陆-->
@@ -132,6 +133,10 @@
         <activity android:name=".activity.CourseDetailActivity"
             android:screenOrientation="portrait"/>
 
+        <!--机构列表-->
+        <activity android:name=".activity.OrgListActivity"
+            android:screenOrientation="portrait"/>
+
         <!--定位服务-->
         <meta-data android:name="com.amap.api.v2.apikey" android:value="45fb5d8b52ba4f9f214bfb4fdaf81a72"/>
         <service android:name="com.amap.api.location.APSService"/>

+ 26 - 0
app/src/main/java/com/ynstkz/shitu/android/activity/OrgListActivity.java

@@ -0,0 +1,26 @@
+package com.ynstkz.shitu.android.activity;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+
+import com.ynstkz.shitu.android.R;
+import com.ynstkz.shitu.android.base.TitleBarActivity;
+
+/**
+ * 作者:fuchangle on 2018/3/7 17:08
+ */
+
+public class OrgListActivity extends TitleBarActivity{
+
+    @Override
+    public View onCreateView(String name, Context context, AttributeSet attrs) {
+        return super.onCreateView(name, context, attrs);
+    }
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.activity_org_list;
+    }
+
+}

文件差异内容过多而无法显示
+ 18 - 92
app/src/main/java/com/ynstkz/shitu/android/bean/OrgRecommendListBean.java


+ 35 - 8
app/src/main/java/com/ynstkz/shitu/android/fragment/HomeFragment.java

@@ -7,12 +7,16 @@ import android.os.Handler;
 import android.os.Message;
 import android.support.v4.view.ViewCompat;
 import android.support.v4.view.ViewPager;
+import android.text.TextUtils;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.util.TypedValue;
+import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.ScrollView;
@@ -26,6 +30,7 @@ import com.google.gson.Gson;
 import com.ynstkz.shitu.android.R;
 import com.ynstkz.shitu.android.activity.LocationSelectActivity;
 import com.ynstkz.shitu.android.activity.OrgDetailActivity;
+import com.ynstkz.shitu.android.activity.OrgListActivity;
 import com.ynstkz.shitu.android.adapter.HomeBannerAdapter;
 import com.ynstkz.shitu.android.adapter.OrgNavigationGridAdapter;
 import com.ynstkz.shitu.android.base.BaseFragment;
@@ -70,6 +75,10 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
     LinearLayout llLocationSelect;
     @Bind(R.id.ll_org_main)
     LinearLayout llOrgMain;
+    @Bind(R.id.edit_search)
+    EditText editSearch;
+    @Bind(R.id.iv_org_more)
+    TextView ivOrgMore;
 
 
     private List<HomeBannerBean.DataBean> listBanner;
@@ -127,6 +136,23 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
             }
         });
 
+        //搜索
+        editSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+            @Override
+            public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
+                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
+                    String searchKey = editSearch.getText().toString().trim();
+                    if(!TextUtils.isEmpty(searchKey)){
+                        Intent intent = new Intent(getActivity(), OrgListActivity.class);
+                        intent.putExtra("searchKey", searchKey);
+                        startActivity(intent);
+                    } else {
+                        showToast("搜索关键字不能为空");
+                    }
+                }
+                return false;
+            }
+        });
     }
 
     /**
@@ -186,11 +212,11 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
 //        });
 
         int[] icons = new int[]{R.drawable.org_xueqian, R.drawable.org_chudeng, R.drawable.org_zhongdeng,
-            R.drawable.org_gaodeng, R.drawable.org_chengren, R.drawable.org_peixun, R.drawable.org_chuguo, R.drawable.org_other};
+                R.drawable.org_gaodeng, R.drawable.org_chengren, R.drawable.org_peixun, R.drawable.org_chuguo, R.drawable.org_other};
         String[] labs = getResources().getStringArray(R.array.org_navigation);
 
         List<CourseNavigationBean> listCourseNavigation = new ArrayList<>();
-        for(int i=0; i<8; i++){
+        for (int i = 0; i < 8; i++) {
             CourseNavigationBean courseNavigationBean = new CourseNavigationBean();
             courseNavigationBean.setIcon_ids(icons[i]);
             courseNavigationBean.setLab(labs[i]);
@@ -206,7 +232,7 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
      */
     private void getOrgRecommendList(String location) {
 
-        RequestGroup.getAgencyRecommendList(pageNumber+"", "25", location, new Callback() {
+        RequestGroup.getAgencyRecommendList(pageNumber + "", "25", location, new Callback() {
             @Override
             public Object parseNetworkResponse(Response response, int id) throws Exception {
                 return new Gson().fromJson(response.body().string(), OrgRecommendListBean.class);
@@ -244,14 +270,14 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
     /**
      * 设置推荐列表数据
      */
-    private void setOrgListData(List<OrgItemBean> listOrg){
-        if(listOrg == null || listOrg.size() == 0){
+    private void setOrgListData(List<OrgItemBean> listOrg) {
+        if (listOrg == null || listOrg.size() == 0) {
             return;
         }
-        if(pageNumber == 1){
+        if (pageNumber == 1) {
             llOrgMain.removeAllViews();
         }
-        for(int i=0; i<listOrg.size(); i++){
+        for (int i = 0; i < listOrg.size(); i++) {
             View view = LayoutInflater.from(getActivity()).inflate(R.layout.item_org_list, null);
             ImageView iv_headPic = view.findViewById(R.id.iv_headPic);
             TextView tv_memberName = view.findViewById(R.id.tv_memberName);
@@ -262,6 +288,7 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
             Glide.with(getActivity()).load(orgItemBean.getHeadPic()).into(iv_headPic);
             tv_memberName.setText(orgItemBean.getMemberName());
             rb_score.setProgress(orgItemBean.getScore() * 2);
+            tv_regaddress.setText(orgItemBean.getAddress());
             llOrgMain.addView(view);
 
             /**
@@ -369,7 +396,7 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
 
     @Override
     public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) {
-        pageNumber ++;
+        pageNumber++;
         getOrgRecommendList(longitude + "," + latitude);
     }
 

+ 2 - 1
app/src/main/java/com/ynstkz/shitu/android/fragment/NearbyFragment.java

@@ -39,7 +39,7 @@ import okhttp3.Response;
  * 作者:fuchangle on 2018/1/29 11:43
  */
 
-public class NearbyFragment extends BaseFragment implements PullToRefreshBase.OnRefreshListener2<ListView>{
+public class OrgListFragment extends BaseFragment implements PullToRefreshBase.OnRefreshListener2<ListView>{
 
     @Bind(R.id.tv_location)
     TextView tvLocation;
@@ -114,6 +114,7 @@ public class NearbyFragment extends BaseFragment implements PullToRefreshBase.On
             @Override
             public void onError(Call call, Exception e, int id) {
                 showToast(getString(R.string.error_msg));
+                pullToRefresh.onRefreshComplete();
             }
 
             @Override

二进制
app/src/main/res/drawable-xxhdpi/search_icon.png


+ 1 - 1
app/src/main/res/layout/activity_home.xml

@@ -18,7 +18,7 @@
 
         <fragment
             android:id="@+id/fm_nearby"
-            android:name="com.ynstkz.shitu.android.fragment.NearbyFragment"
+            android:name="com.ynstkz.shitu.android.fragment.OrgListFragment"
             android:layout_width="match_parent"
             android:layout_height="match_parent"/>
 

+ 15 - 0
app/src/main/res/layout/activity_org_list.xml

@@ -0,0 +1,15 @@
+<?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:orientation="vertical">
+
+    <include layout="@layout/view_title"/>
+
+    <fragment
+        android:id="@+id/fm_nearby"
+        android:name="com.ynstkz.shitu.android.fragment.OrgListFragment"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+
+</LinearLayout>

+ 4 - 1
app/src/main/res/layout/item_org_list.xml

@@ -57,9 +57,12 @@
 
                 <TextView
                     android:id="@+id/tv_regaddress"
-                    android:layout_width="wrap_content"
+                    android:layout_width="@dimen/company_200dp"
                     android:layout_height="wrap_content"
                     android:layout_alignParentRight="true"
+                    android:maxLines="1"
+                    android:ellipsize="end"
+                    android:gravity="right"
                     android:text="未名湖"/>
 
 

+ 25 - 1
app/src/main/res/layout/view_home_title.xml

@@ -35,7 +35,31 @@
         android:layout_weight="4"
         android:layout_height="@dimen/company_35dp"
         android:background="@drawable/shape_search_bg"
-        android:layout_gravity="center">
+        android:layout_gravity="center_vertical"
+        android:orientation="horizontal"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:paddingLeft="@dimen/company_10dp"
+        android:paddingRight="@dimen/company_10dp">
+
+        <ImageView
+            android:layout_width="@dimen/company_15dp"
+            android:layout_height="@dimen/company_15dp"
+            android:background="@drawable/search_icon"
+            android:layout_gravity="center_vertical"/>
+
+        <EditText
+            android:id="@+id/edit_search"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:hint="机构/学校/家教名称"
+            android:layout_marginLeft="@dimen/company_5dp"
+            android:imeOptions="actionSearch"
+            android:singleLine="true"
+            android:textColor="@color/color_999"
+            android:textSize="@dimen/company_12sp"
+            android:textCursorDrawable="@color/main_color"
+            android:background="@null"/>
 
     </LinearLayout>