浏览代码

添加定位、手机号登陆UI,忘记密码UI

316044749 7 年之前
父节点
当前提交
1c4b7d937b

+ 1 - 0
app/build.gradle

@@ -42,6 +42,7 @@ dependencies {
     compile 'com.jakewharton:butterknife:7.0.1'
     compile 'com.github.bumptech.glide:glide:3.7.0'
     compile 'com.muddzdev:styleabletoast:2.0.1'
+    compile 'org.greenrobot:eventbus:3.1.1'
     //导航
     compile 'com.amap.api:navi-3dmap:5.6.0_3dmap5.7.0'
     //定位

+ 9 - 1
app/src/main/AndroidManifest.xml

@@ -55,8 +55,16 @@
         <activity android:name=".activity.LoginPhoneCodeActivity"
             android:screenOrientation="portrait"/>
 
+        <!--找回密码-->
+        <activity android:name=".activity.FindPasswordActivity"
+            android:screenOrientation="portrait"/>
+
+        <!--找回密码 - 确认-->
+        <activity android:name=".activity.FindPasswordAffirmActivity"
+            android:screenOrientation="portrait"/>
+
         <!--定位服务-->
-        <meta-data android:name="com.ynstkz.shitu.android.demo" android:value="a78b553a67f68d1d980f908eb1f034a8"/>
+        <meta-data android:name="com.amap.api.v2.apikey" android:value="45fb5d8b52ba4f9f214bfb4fdaf81a72"/>
         <service android:name="com.amap.api.location.APSService"/>
 
     </application>

+ 87 - 0
app/src/main/java/com/ynstkz/shitu/android/activity/FindPasswordActivity.java

@@ -0,0 +1,87 @@
+package com.ynstkz.shitu.android.activity;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.ynstkz.shitu.android.R;
+import com.ynstkz.shitu.android.base.TitleBarActivity;
+import com.ynstkz.shitu.android.utils.StatusBarUtil;
+
+import butterknife.Bind;
+
+/**
+ * 忘记密码
+ * 作者:fuchangle on 2018/2/8 12:06
+ */
+
+public class FindPasswordActivity extends TitleBarActivity {
+
+    @Bind(R.id.iv_cancel)
+    ImageView ivCancel;
+    @Bind(R.id.tv_login)
+    TextView tvLogin;
+    @Bind(R.id.edit_phone_number)
+    EditText editPhoneNumber;
+    @Bind(R.id.edit_password)
+    EditText editVerifycode;
+    @Bind(R.id.tv_verifycode)
+    TextView tvVerifycode;
+    @Bind(R.id.btn_next)
+    Button btnNext;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        StatusBarUtil.setTransparent(this);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            setStatusBarColor(this, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+        }
+        initView();
+        initData();
+        setListener();
+    }
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.activity_register;
+    }
+
+    private void initView() {
+
+    }
+
+    private void initData() {
+
+    }
+
+    private void setListener() {
+        //关闭
+        ivCancel.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                finish();
+            }
+        });
+        //登陆
+        tvLogin.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                startActivity(new Intent(FindPasswordActivity.this, LoginActivity.class));
+            }
+        });
+        //修改密码
+        btnNext.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                startActivity(new Intent(FindPasswordActivity.this, FindPasswordAffirmActivity.class));
+            }
+        });
+    }
+}

+ 25 - 0
app/src/main/java/com/ynstkz/shitu/android/activity/FindPasswordAffirmActivity.java

@@ -0,0 +1,25 @@
+package com.ynstkz.shitu.android.activity;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+
+import com.ynstkz.shitu.android.R;
+import com.ynstkz.shitu.android.base.TitleBarActivity;
+
+/**
+ * 作者:fuchangle on 2018/2/8 17:56
+ */
+
+public class FindPasswordAffirmActivity extends TitleBarActivity{
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
+    protected int getLayoutId() {
+        return R.layout.activity_findpassword_affirm;
+    }
+
+}

+ 8 - 8
app/src/main/java/com/ynstkz/shitu/android/activity/HomeActivity.java

@@ -20,8 +20,11 @@ import com.amap.api.location.AMapLocationClientOption;
 import com.amap.api.location.AMapLocationListener;
 import com.ynstkz.shitu.android.R;
 import com.ynstkz.shitu.android.base.TitleBarActivity;
+import com.ynstkz.shitu.android.event.LocationChangedEvent;
 import com.ynstkz.shitu.android.fragment.ConfirmationDialogFragment;
 
+import org.greenrobot.eventbus.EventBus;
+
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
@@ -66,7 +69,6 @@ public class HomeActivity extends TitleBarActivity implements AMapLocationListen
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setSwipeBackEnable(false);
-        ButterKnife.bind(this);
         initView();
         initData();
         setListener();
@@ -165,13 +167,11 @@ public class HomeActivity extends TitleBarActivity implements AMapLocationListen
         if (amapLocation != null) {
             if (amapLocation.getErrorCode() == 0) {
                 //定位成功回调信息,设置相关消息
-                amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
-                amapLocation.getLatitude();//获取纬度
-                amapLocation.getLongitude();//获取经度
-                amapLocation.getAccuracy();//获取精度信息
-                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                Date date = new Date(amapLocation.getTime());
-                df.format(date);//定位时间
+//                amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
+//                amapLocation.getLatitude();//获取纬度
+//                amapLocation.getLongitude();//获取经度
+//                amapLocation.getAccuracy();//获取精度信息
+                EventBus.getDefault().post(new LocationChangedEvent(amapLocation));
             } else {
                 //显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
                 Log.e("AmapError", "location Error, ErrCode:"

+ 7 - 1
app/src/main/java/com/ynstkz/shitu/android/activity/LoginActivity.java

@@ -46,7 +46,6 @@ public class LoginActivity extends TitleBarActivity {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
             setStatusBarColor(this, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
         }
-        ButterKnife.bind(this);
         initView();
         initData();
         setListener();
@@ -87,5 +86,12 @@ public class LoginActivity extends TitleBarActivity {
                 startActivity(new Intent(LoginActivity.this, LoginPhoneCodeActivity.class));
             }
         });
+        //找回密码
+        tvForgetPw.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                startActivity(new Intent(LoginActivity.this, FindPasswordActivity.class));
+            }
+        });
     }
 }

+ 65 - 1
app/src/main/java/com/ynstkz/shitu/android/activity/LoginPhoneCodeActivity.java

@@ -1,19 +1,42 @@
 package com.ynstkz.shitu.android.activity;
 
+import android.content.Intent;
 import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
 
 import com.ynstkz.shitu.android.R;
 import com.ynstkz.shitu.android.base.TitleBarActivity;
 import com.ynstkz.shitu.android.utils.StatusBarUtil;
 
+import butterknife.Bind;
+import butterknife.ButterKnife;
+
 /**
  * 作者:fuchangle on 2018/2/7 15:02
  */
 
-public class LoginPhoneCodeActivity extends TitleBarActivity{
+public class LoginPhoneCodeActivity extends TitleBarActivity {
+
+    @Bind(R.id.iv_cancel)
+    ImageView ivCancel;
+    @Bind(R.id.tv_register)
+    TextView tvRegister;
+    @Bind(R.id.tv_login)
+    TextView tvLogin;
+    @Bind(R.id.edit_username)
+    EditText editUsername;
+    @Bind(R.id.edit_verification_code)
+    EditText editVerificationCode;
+    @Bind(R.id.tv_forget_pw)
+    TextView tvForgetPw;
+    @Bind(R.id.btn_login)
+    Button btnLogin;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -22,10 +45,51 @@ public class LoginPhoneCodeActivity extends TitleBarActivity{
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
             setStatusBarColor(this, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
         }
+        initView();
+        initData();
+        setListener();
     }
 
     @Override
     protected int getLayoutId() {
         return R.layout.activity_login_phonecode;
     }
+
+    private void initView(){
+
+    }
+
+    private void initData(){
+
+    }
+
+    private void setListener(){
+        //关闭
+        ivCancel.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                finish();
+            }
+        });
+        //注册
+        tvRegister.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                startActivity(new Intent(LoginPhoneCodeActivity.this, RegisterActivity.class));
+            }
+        });
+        //普通登陆
+        tvLogin.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                startActivity(new Intent(LoginPhoneCodeActivity.this, LoginActivity.class));
+            }
+        });
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        ButterKnife.unbind(this);
+    }
 }

+ 0 - 1
app/src/main/java/com/ynstkz/shitu/android/activity/RegisterActivity.java

@@ -41,7 +41,6 @@ public class RegisterActivity extends TitleBarActivity {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
             setStatusBarColor(this, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
         }
-        ButterKnife.bind(this);
         initView();
         initData();
         setListener();

+ 3 - 0
app/src/main/java/com/ynstkz/shitu/android/base/TitleBarActivity.java

@@ -9,6 +9,8 @@ import android.widget.TextView;
 import com.ynstkz.shitu.android.R;
 import com.ynstkz.shitu.android.utils.StatusBarUtil;
 
+import butterknife.ButterKnife;
+
 /**
  * 作者:fuchangle on 2018/1/27 22:25
  */
@@ -21,6 +23,7 @@ public abstract class TitleBarActivity extends BaseActivity{
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(getLayoutId());
+        ButterKnife.bind(this);
         StatusBarUtil.setColorNoTranslucent(this, getResources().getColor(R.color.colorPrimary));
         mToolbarTitle = (TextView)findViewById(R.id.tv_title);
         if (mToolbarTitle != null) {

+ 24 - 0
app/src/main/java/com/ynstkz/shitu/android/event/LocationChangedEvent.java

@@ -0,0 +1,24 @@
+package com.ynstkz.shitu.android.event;
+
+import com.amap.api.location.AMapLocation;
+
+/**
+ * 作者:fuchangle on 2018/2/8 15:42
+ */
+
+public class LocationChangedEvent {
+
+    private AMapLocation amapLocation;
+
+    public LocationChangedEvent(AMapLocation amapLocation) {
+        this.amapLocation = amapLocation;
+    }
+
+    public AMapLocation getAmapLocation() {
+        return amapLocation;
+    }
+
+    public void setAmapLocation(AMapLocation amapLocation) {
+        this.amapLocation = amapLocation;
+    }
+}

+ 17 - 0
app/src/main/java/com/ynstkz/shitu/android/fragment/HomeFragment.java

@@ -13,6 +13,11 @@ import com.common.library.pulltorefresh.PullToRefreshBase;
 import com.common.library.pulltorefresh.PullToRefreshScrollView;
 import com.ynstkz.shitu.android.R;
 import com.ynstkz.shitu.android.base.BaseFragment;
+import com.ynstkz.shitu.android.event.LocationChangedEvent;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
 
 import butterknife.Bind;
 import butterknife.ButterKnife;
@@ -48,6 +53,7 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
     }
 
     private void initView() {
+        EventBus.getDefault().register(this);
         svMain.setOnRefreshListener(this);
     }
 
@@ -71,6 +77,11 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
         });
     }
 
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMessageEvent(LocationChangedEvent event) {
+        tvLocation.setText(event.getAmapLocation().getDistrict());
+    }
+
     @Override
     public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) {
         showToast(getActivity(), "onPullDownToRefresh");
@@ -80,4 +91,10 @@ public class HomeFragment extends BaseFragment implements PullToRefreshBase.OnRe
     public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) {
         showToast(getActivity(), "onPullUpToRefresh");
     }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        EventBus.getDefault().unregister(this);
+    }
 }

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

@@ -1,25 +1,63 @@
 package com.ynstkz.shitu.android.fragment;
 
 import android.os.Bundle;
-import android.support.annotation.Nullable;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.TextView;
 
 import com.ynstkz.shitu.android.R;
 import com.ynstkz.shitu.android.base.BaseFragment;
+import com.ynstkz.shitu.android.event.LocationChangedEvent;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import butterknife.Bind;
+import butterknife.ButterKnife;
 
 /**
  * 附近
  * 作者:fuchangle on 2018/1/29 11:43
  */
 
-public class NearbyFragment extends BaseFragment{
+public class NearbyFragment extends BaseFragment {
+
+    @Bind(R.id.tv_location)
+    TextView tvLocation;
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.fm_nearby, null);
+        ButterKnife.bind(this, view);
+        initView();
+        initData();
+        setListener();
         return view;
     }
 
+    private void initView(){
+        EventBus.getDefault().register(this);
+    }
+
+    private void initData(){
+
+    }
+
+    private void setListener(){
+
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMessageEvent(LocationChangedEvent event) {
+        tvLocation.setText(event.getAmapLocation().getDistrict());
+    }
+
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+        ButterKnife.unbind(this);
+        EventBus.getDefault().unregister(this);
+    }
 }

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


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


+ 98 - 0
app/src/main/res/layout/activity_findpassword_affirm.xml

@@ -0,0 +1,98 @@
+<?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"
+    android:background="@color/white">
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingLeft="@dimen/company_15dp"
+        android:paddingTop="@dimen/company_15dp"
+        android:paddingRight="@dimen/company_15dp">
+
+        <ImageView
+            android:id="@+id/iv_cancel"
+            android:layout_width="@dimen/company_20dp"
+            android:layout_height="@dimen/company_20dp"
+            android:src="@drawable/login_cancel_icon" />
+
+        <TextView
+            android:id="@+id/tv_register"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentRight="true"
+            android:text="登录"
+            android:textColor="@color/main_color"
+            android:textSize="@dimen/company_18sp" />
+
+    </RelativeLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/company_30dp"
+        android:gravity="center_horizontal"
+        android:orientation="vertical">
+
+        <ImageView
+            android:layout_width="62dp"
+            android:layout_height="62dp"
+            android:src="@drawable/logo" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/company_6dp"
+            android:text="仕  途  网"
+            android:textColor="@color/main_color"
+            android:textSize="@dimen/company_18sp"
+            android:textStyle="bold" />
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:paddingLeft="@dimen/company_15dp"
+        android:paddingTop="@dimen/company_15dp"
+        android:paddingRight="@dimen/company_15dp">
+
+        <EditText
+            android:id="@+id/edit_password"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/company_50dp"
+            android:layout_marginTop="@dimen/company_10dp"
+            android:background="@drawable/shapre_default_edit_bg"
+            android:hint="请输入密码"
+            android:maxLines="1"
+            android:textCursorDrawable="@null"
+            android:textSize="@dimen/company_14sp" />
+
+        <EditText
+            android:id="@+id/edit_password_again"
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/company_50dp"
+            android:layout_marginTop="@dimen/company_20dp"
+            android:background="@drawable/shapre_default_edit_bg"
+            android:hint="请再输入一次密码"
+            android:inputType="textPassword"
+            android:maxLines="1"
+            android:textCursorDrawable="@null"
+            android:textSize="@dimen/company_14sp" />
+
+    </LinearLayout>
+
+    <Button
+        android:id="@+id/btn_submit"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/company_50dp"
+        android:layout_marginTop="@dimen/company_20dp"
+        android:background="@drawable/shape_default_btn_bg"
+        android:textColor="@color/white"
+        android:textSize="@dimen/company_16sp"
+        android:text="确定"/>
+
+</LinearLayout>

+ 26 - 8
app/src/main/res/layout/activity_register.xml

@@ -71,17 +71,35 @@
             android:textCursorDrawable="@null"
             android:textSize="@dimen/company_14sp" />
 
-        <EditText
-            android:id="@+id/edit_password"
+        <RelativeLayout
             android:layout_width="match_parent"
             android:layout_height="@dimen/company_50dp"
             android:layout_marginTop="@dimen/company_20dp"
-            android:background="@drawable/shapre_default_edit_bg"
-            android:hint="请输入登陆密码"
-            android:inputType="textPassword"
-            android:maxLines="1"
-            android:textCursorDrawable="@null"
-            android:textSize="@dimen/company_14sp" />
+            android:background="@drawable/shapre_default_edit_bg">
+
+            <EditText
+                android:id="@+id/edit_password"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:hint="请输入验证码"
+                android:inputType="textPassword"
+                android:maxLines="1"
+                android:layout_toLeftOf="@+id/tv_verifycode"
+                android:textCursorDrawable="@null"
+                android:textSize="@dimen/company_14sp"
+                android:background="@null"/>
+
+            <TextView
+                android:id="@+id/tv_verifycode"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_alignParentRight="true"
+                android:textSize="@dimen/company_14sp"
+                android:textColor="@color/main_color"
+                android:text="获取手机验证码"/>
+
+        </RelativeLayout>
 
     </LinearLayout>
 

+ 11 - 0
app/src/main/res/layout/fm_nearby.xml

@@ -4,4 +4,15 @@
     android:layout_height="match_parent"
     android:orientation="vertical">
 
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="?attr/actionBarSize"
+        android:orientation="vertical">
+
+        <include layout="@layout/view_home_title"/>
+
+    </LinearLayout>
+
+
+
 </LinearLayout>

+ 7 - 8
app/src/main/res/layout/view_home_title.xml

@@ -15,8 +15,8 @@
         <ImageView
             android:layout_width="@dimen/company_20dp"
             android:layout_height="@dimen/company_20dp"
-            android:background="@mipmap/ic_launcher"
-            />
+            android:src="@drawable/location_icon"
+            android:layout_marginRight="@dimen/company_5dp"/>
 
         <TextView
             android:id="@+id/tv_location"
@@ -31,24 +31,23 @@
 
     <LinearLayout
         android:layout_width="0dp"
-        android:layout_weight="7"
+        android:layout_weight="4"
         android:layout_height="@dimen/company_35dp"
         android:background="@drawable/shape_search_bg"
         android:layout_gravity="center">
 
-
     </LinearLayout>
 
     <LinearLayout
         android:layout_width="0dp"
-        android:layout_weight="2"
+        android:layout_weight="1"
         android:layout_height="match_parent"
         android:gravity="center">
 
         <ImageView
-            android:layout_width="@dimen/company_40dp"
-            android:layout_height="@dimen/company_40dp"
-            android:background="@mipmap/ic_launcher"/>
+            android:layout_width="@dimen/company_25dp"
+            android:layout_height="@dimen/company_25dp"
+            android:src="@drawable/people_server_icon"/>
 
     </LinearLayout>