objects) {
+ mContext = context;
+ mInflater = LayoutInflater.from(context);
+ mResource = mDropDownResource = resource;
+ mObjects = objects;
+ mFieldId = textViewResourceId;
+ }
+
+ public void add(T object) {
+ synchronized (mLock) {
+ if (mOriginalValues != null) {
+ mOriginalValues.add(object);
+ } else {
+ mObjects.add(object);
+ }
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+
+ /**
+ * Adds the specified Collection at the end of the array.
+ *
+ * @param collection The Collection to add at the end of the array.
+ */
+ public void addAll(Collection extends T> collection) {
+ synchronized (mLock) {
+ if (mOriginalValues != null) {
+ mOriginalValues.addAll(collection);
+ } else {
+ mObjects.addAll(collection);
+ }
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+
+ /**
+ * Adds the specified items at the end of the array.
+ *
+ * @param items The items to add at the end of the array.
+ */
+ public void addAll(T... items) {
+ synchronized (mLock) {
+ if (mOriginalValues != null) {
+ Collections.addAll(mOriginalValues, items);
+ } else {
+ Collections.addAll(mObjects, items);
+ }
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+
+ /**
+ * Inserts the specified object at the specified index in the array.
+ *
+ * @param object The object to insert into the array.
+ * @param index The index at which the object must be inserted.
+ */
+ public void insert(T object, int index) {
+ synchronized (mLock) {
+ if (mOriginalValues != null) {
+ mOriginalValues.add(index, object);
+ } else {
+ mObjects.add(index, object);
+ }
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+
+ /**
+ * Removes the specified object from the array.
+ *
+ * @param object The object to remove.
+ */
+ public void remove(T object) {
+ synchronized (mLock) {
+ if (mOriginalValues != null) {
+ mOriginalValues.remove(object);
+ } else {
+ mObjects.remove(object);
+ }
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+
+ /**
+ * Remove all elements from the list.
+ */
+ public void clear() {
+ synchronized (mLock) {
+ if (mOriginalValues != null) {
+ mOriginalValues.clear();
+ } else {
+ mObjects.clear();
+ }
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+
+ /**
+ * Sorts the content of this adapter using the specified comparator.
+ *
+ * @param comparator The comparator used to sort the objects contained
+ * in this adapter.
+ */
+ public void sort(Comparator super T> comparator) {
+ synchronized (mLock) {
+ if (mOriginalValues != null) {
+ Collections.sort(mOriginalValues, comparator);
+ } else {
+ Collections.sort(mObjects, comparator);
+ }
+ }
+ if (mNotifyOnChange) notifyDataSetChanged();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void notifyDataSetChanged() {
+ super.notifyDataSetChanged();
+ mNotifyOnChange = true;
+ }
+
+ /**
+ * Control whether methods that change the list ({@link #add},
+ * {@link #insert}, {@link #remove}, {@link #clear}) automatically call
+ * {@link #notifyDataSetChanged}. If set to false, caller must
+ * manually call notifyDataSetChanged() to have the changes
+ * reflected in the attached view.
+ *
+ * The default is true, and calling notifyDataSetChanged()
+ * resets the flag to true.
+ *
+ * @param notifyOnChange if true, modifications to the list will
+ * automatically call {@link
+ * #notifyDataSetChanged}
+ */
+ public void setNotifyOnChange(boolean notifyOnChange) {
+ mNotifyOnChange = notifyOnChange;
+ }
+
+ /**
+ * Returns the context associated with this array adapter. The context is used
+ * to create views from the resource passed to the constructor.
+ *
+ * @return The Context associated with this adapter.
+ */
+ public Context getContext() {
+ return mContext;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCount() {
+ return mObjects.size();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public T getItem(int position) {
+ return mObjects.get(position);
+ }
+
+ /**
+ * Returns the position of the specified item in the array.
+ *
+ * @param item The item to retrieve the position of.
+ * @return The position of the specified item.
+ */
+ public int getPosition(T item) {
+ return mObjects.indexOf(item);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getItemId(int position) {
+ return position;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public View getView(int position, View convertView, ViewGroup parent) {
+ return createViewFromResource(mInflater, position, convertView, parent, mResource);
+ }
+
+ private View createViewFromResource(LayoutInflater inflater, int position, View convertView,
+ ViewGroup parent, int resource) {
+ View view;
+ TextView text;
+
+ if (convertView == null) {
+ view = inflater.inflate(resource, parent, false);
+ } else {
+ view = convertView;
+ }
+
+ try {
+ if (mFieldId == 0) {
+ // If no custom field is assigned, assume the whole resource is a TextView
+ text = (TextView) view;
+ } else {
+ // Otherwise, find the TextView field within the layout
+ text = (TextView) view.findViewById(mFieldId);
+ }
+ } catch (ClassCastException e) {
+ throw new IllegalStateException(
+ "ArrayAdapter requires the resource ID to be a TextView", e);
+ }
+
+ T item = getItem(position);
+ if (item instanceof CharSequence) {
+ text.setText((CharSequence) item);
+ } else {
+ text.setText(item.toString());
+ }
+
+ return view;
+ }
+
+ /**
+ *
Sets the layout resource to create the drop down views.
+ *
+ * @param resource the layout resource defining the drop down views
+ * @see #getDropDownView(int, View, ViewGroup)
+ */
+ public void setDropDownViewResource(@LayoutRes int resource) {
+ this.mDropDownResource = resource;
+ }
+
+ /**
+ * Sets the {@link Resources.Theme} against which drop-down views are
+ * inflated.
+ *
+ * By default, drop-down views are inflated against the theme of the
+ * {@link Context} passed to the adapter's constructor.
+ *
+ * @param theme the theme against which to inflate drop-down views or
+ * {@code null} to use the theme from the adapter's context
+ * @see #getDropDownView(int, View, ViewGroup)
+ */
+ @Override
+ public void setDropDownViewTheme(Resources.Theme theme) {
+ if (theme == null) {
+ mDropDownInflater = null;
+ } else if (theme == mInflater.getContext().getTheme()) {
+ mDropDownInflater = mInflater;
+ }
+// else {
+// final Context context = new ContextThemeWrapper(mContext, theme);
+// mDropDownInflater = LayoutInflater.from(context);
+// }
+ }
+
+ @Override
+ public Resources.Theme getDropDownViewTheme() {
+ return mDropDownInflater == null ? null : mDropDownInflater.getContext().getTheme();
+ }
+
+ @Override
+ public View getDropDownView(int position, View convertView, ViewGroup parent) {
+ final LayoutInflater inflater = mDropDownInflater == null ? mInflater : mDropDownInflater;
+ return createViewFromResource(inflater, position, convertView, parent, mDropDownResource);
+ }
+
+
+ public Filter getFilter() {
+ if (mFilter == null) {
+ mFilter = new ArrayFilter();
+ }
+ return mFilter;
+ }
+
+ private class ArrayFilter extends Filter {
+ @Override
+ protected FilterResults performFiltering(CharSequence prefix) {
+ FilterResults results = new FilterResults();
+
+ if (mOriginalValues == null) {
+ synchronized (mLock) {
+ mOriginalValues = new ArrayList(mObjects);
+ }
+ }
+
+ if (prefix == null || prefix.length() == 0) {
+ ArrayList list;
+ synchronized (mLock) {
+ list = new ArrayList(mOriginalValues);
+ }
+ results.values = list;
+ results.count = list.size();
+ } else {
+ String prefixString = prefix.toString().toLowerCase();
+
+ ArrayList values;
+ synchronized (mLock) {
+ values = new ArrayList(mOriginalValues);
+ }
+
+ final int count = values.size();
+ final ArrayList newValues = new ArrayList();
+
+ for (int i = 0; i < count; i++) {
+ final T value = values.get(i);
+ final String valueText = value.toString().toLowerCase();
+
+ // First match against the whole, non-splitted value
+ if (valueText.startsWith(prefixString)) {
+ newValues.add(value);
+ } else {
+ final String[] words = valueText.split(" ");
+ final int wordCount = words.length;
+
+ // Start at index 0, in case valueText starts with space(s)
+ for (int k = 0; k < wordCount; k++) {
+ if (words[k].contains(prefixString)) {
+ newValues.add(value);
+ break;
+ }
+ }
+ }
+ }
+
+ results.values = newValues;
+ results.count = newValues.size();
+ }
+
+ return results;
+ }
+
+ @Override
+ protected void publishResults(CharSequence constraint, FilterResults results) {
+ //noinspection unchecked
+ mObjects = (List) results.values;
+ if (results.count > 0) {
+ notifyDataSetChanged();
+ } else {
+ notifyDataSetInvalidated();
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/shunzhi/parent/adapter/MyThemedSpinnerAdapter.java b/app/src/main/java/com/shunzhi/parent/adapter/MyThemedSpinnerAdapter.java
new file mode 100644
index 0000000..4e5de5f
--- /dev/null
+++ b/app/src/main/java/com/shunzhi/parent/adapter/MyThemedSpinnerAdapter.java
@@ -0,0 +1,15 @@
+package com.shunzhi.parent.adapter;
+
+import android.content.res.Resources;
+import android.support.annotation.Nullable;
+import android.widget.SpinnerAdapter;
+
+/**
+ * Created by Administrator on 2016/7/5.
+ */
+public interface MyThemedSpinnerAdapter extends SpinnerAdapter {
+ @Nullable
+ Resources.Theme getDropDownViewTheme();
+ void setDropDownViewTheme(@Nullable Resources.Theme theme);
+}
+
diff --git a/app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java b/app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java
index 08d4e29..aa53369 100644
--- a/app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java
+++ b/app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java
@@ -60,6 +60,9 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre
AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_PWD, loginPwd);
RetrofitCreateHelper.getInstance().setAuthorization(jsonObject.get("access_token").getAsString());
getUserInfo(loginName, 0, "");
+ //fixme 新增历史登录账号
+ AppContext.getInstance().setHistroyUser(loginName);
+
} else {
ToastUtils.showToast(jsonObject.get("error").getAsString());
}
@@ -173,7 +176,7 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre
if (currentBean.getStudentClass() != null && currentBean.getStudentClass().size() > 0) {
AppConfig.getAppConfig(mIView.getBindActivity()).set(AppConfig.ISBINDING, "1");
- }else{
+ } else {
AppConfig.getAppConfig(mIView.getBindActivity()).set(AppConfig.ISBINDING, "0");
}
diff --git a/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java b/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
index 914cf9f..7507d1f 100644
--- a/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
+++ b/app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
@@ -12,6 +12,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -25,19 +26,27 @@ import com.share.mvpsdk.utils.ToastUtils;
import com.shunzhi.parent.AppConfig;
import com.shunzhi.parent.AppContext;
import com.shunzhi.parent.R;
+import com.shunzhi.parent.adapter.MyArrayAdapter;
import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract;
import com.shunzhi.parent.presenter.loginandregister.LoginAndRegisterPresenter;
import com.shunzhi.parent.ui.MainActivity;
import com.shunzhi.parent.ui.activity.LoginAndRegistActivity;
import com.shunzhi.parent.views.MyProcessDialog;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+import java.util.ArrayList;
+import java.util.List;
+
public class LoginAndRegistFragment extends BaseMVPCompatFragment
implements LoginAndRegisterContract.ILoginView, View.OnClickListener {
public RoundedImageView roundedImageView;
- public EditText phoneNumber, idCode, password, et_password_new;
- public TextView get_idCode, loginAndRegister, tv_info, tv_goto, tv_goto_zhuce, tv_goto_mima,center_title;
+ public EditText idCode, password, et_password_new;
+ AutoCompleteTextView phoneNumber;
+ public TextView get_idCode, loginAndRegister, tv_info, tv_goto, tv_goto_zhuce, tv_goto_mima, center_title;
public LinearLayout phoneLayout, idCodeLayout, passwordLayout, main_login, passwordLayout_new;
public ImageView img_eye, img_eye_new, back_top;
public static String typepage;
@@ -100,7 +109,6 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment list = new ArrayList<>();
+ for (int i = 0; i < ja.length(); i++) {
+ list.add(ja.optString(i));
+ }
+ MyArrayAdapter adapter = new MyArrayAdapter(getActivity(), R.layout.simple_dropdown_item_1line, list);
+ phoneNumber.setAdapter(adapter);
+ phoneNumber.setThreshold(1);
+ phoneNumber.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ phoneNumber.showDropDown();
+ }
+ });
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+
@Override
- public void getUserInfo(int type,String message) {
+ public void getUserInfo(int type, String message) {
progressDialog.dismiss();
if (type == 0) {
startActivity(new Intent().setClass(getActivity(), MainActivity.class));
@@ -173,11 +205,11 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
@@ -142,12 +162,13 @@
android:background="@color/bottomline" />
+
+ android:orientation="vertical"
+ android:visibility="gone">
@@ -222,13 +243,14 @@
android:textSize="@dimen/sp_16" />
+
+ android:orientation="horizontal"
+ android:visibility="gone">
+
+ android:layout_weight="1" />
+
+
+
--
libgit2 0.21.0