Commit 2f8fe45ce66afcca5b7f54604738f648f228bb78
Exists in
yxb_dev
and in
1 other branch
no message
Showing
15 changed files
with
866 additions
and
44 deletions
Show diff stats
.idea/runConfigurations.xml
| @@ -1,12 +0,0 @@ | @@ -1,12 +0,0 @@ | ||
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<project version="4"> | ||
| 3 | - <component name="RunConfigurationProducerService"> | ||
| 4 | - <option name="ignoredProducers"> | ||
| 5 | - <set> | ||
| 6 | - <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> | ||
| 7 | - <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> | ||
| 8 | - <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> | ||
| 9 | - </set> | ||
| 10 | - </option> | ||
| 11 | - </component> | ||
| 12 | -</project> | ||
| 13 | \ No newline at end of file | 0 | \ No newline at end of file |
No preview for this file type
| @@ -0,0 +1,172 @@ | @@ -0,0 +1,172 @@ | ||
| 1 | +#!/usr/bin/env sh | ||
| 2 | + | ||
| 3 | +############################################################################## | ||
| 4 | +## | ||
| 5 | +## Gradle start up script for UN*X | ||
| 6 | +## | ||
| 7 | +############################################################################## | ||
| 8 | + | ||
| 9 | +# Attempt to set APP_HOME | ||
| 10 | +# Resolve links: $0 may be a link | ||
| 11 | +PRG="$0" | ||
| 12 | +# Need this for relative symlinks. | ||
| 13 | +while [ -h "$PRG" ] ; do | ||
| 14 | + ls=`ls -ld "$PRG"` | ||
| 15 | + link=`expr "$ls" : '.*-> \(.*\)$'` | ||
| 16 | + if expr "$link" : '/.*' > /dev/null; then | ||
| 17 | + PRG="$link" | ||
| 18 | + else | ||
| 19 | + PRG=`dirname "$PRG"`"/$link" | ||
| 20 | + fi | ||
| 21 | +done | ||
| 22 | +SAVED="`pwd`" | ||
| 23 | +cd "`dirname \"$PRG\"`/" >/dev/null | ||
| 24 | +APP_HOME="`pwd -P`" | ||
| 25 | +cd "$SAVED" >/dev/null | ||
| 26 | + | ||
| 27 | +APP_NAME="Gradle" | ||
| 28 | +APP_BASE_NAME=`basename "$0"` | ||
| 29 | + | ||
| 30 | +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
| 31 | +DEFAULT_JVM_OPTS="" | ||
| 32 | + | ||
| 33 | +# Use the maximum available, or set MAX_FD != -1 to use that value. | ||
| 34 | +MAX_FD="maximum" | ||
| 35 | + | ||
| 36 | +warn () { | ||
| 37 | + echo "$*" | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +die () { | ||
| 41 | + echo | ||
| 42 | + echo "$*" | ||
| 43 | + echo | ||
| 44 | + exit 1 | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +# OS specific support (must be 'true' or 'false'). | ||
| 48 | +cygwin=false | ||
| 49 | +msys=false | ||
| 50 | +darwin=false | ||
| 51 | +nonstop=false | ||
| 52 | +case "`uname`" in | ||
| 53 | + CYGWIN* ) | ||
| 54 | + cygwin=true | ||
| 55 | + ;; | ||
| 56 | + Darwin* ) | ||
| 57 | + darwin=true | ||
| 58 | + ;; | ||
| 59 | + MINGW* ) | ||
| 60 | + msys=true | ||
| 61 | + ;; | ||
| 62 | + NONSTOP* ) | ||
| 63 | + nonstop=true | ||
| 64 | + ;; | ||
| 65 | +esac | ||
| 66 | + | ||
| 67 | +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||
| 68 | + | ||
| 69 | +# Determine the Java command to use to start the JVM. | ||
| 70 | +if [ -n "$JAVA_HOME" ] ; then | ||
| 71 | + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
| 72 | + # IBM's JDK on AIX uses strange locations for the executables | ||
| 73 | + JAVACMD="$JAVA_HOME/jre/sh/java" | ||
| 74 | + else | ||
| 75 | + JAVACMD="$JAVA_HOME/bin/java" | ||
| 76 | + fi | ||
| 77 | + if [ ! -x "$JAVACMD" ] ; then | ||
| 78 | + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | ||
| 79 | + | ||
| 80 | +Please set the JAVA_HOME variable in your environment to match the | ||
| 81 | +location of your Java installation." | ||
| 82 | + fi | ||
| 83 | +else | ||
| 84 | + JAVACMD="java" | ||
| 85 | + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
| 86 | + | ||
| 87 | +Please set the JAVA_HOME variable in your environment to match the | ||
| 88 | +location of your Java installation." | ||
| 89 | +fi | ||
| 90 | + | ||
| 91 | +# Increase the maximum file descriptors if we can. | ||
| 92 | +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then | ||
| 93 | + MAX_FD_LIMIT=`ulimit -H -n` | ||
| 94 | + if [ $? -eq 0 ] ; then | ||
| 95 | + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | ||
| 96 | + MAX_FD="$MAX_FD_LIMIT" | ||
| 97 | + fi | ||
| 98 | + ulimit -n $MAX_FD | ||
| 99 | + if [ $? -ne 0 ] ; then | ||
| 100 | + warn "Could not set maximum file descriptor limit: $MAX_FD" | ||
| 101 | + fi | ||
| 102 | + else | ||
| 103 | + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | ||
| 104 | + fi | ||
| 105 | +fi | ||
| 106 | + | ||
| 107 | +# For Darwin, add options to specify how the application appears in the dock | ||
| 108 | +if $darwin; then | ||
| 109 | + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | ||
| 110 | +fi | ||
| 111 | + | ||
| 112 | +# For Cygwin, switch paths to Windows format before running java | ||
| 113 | +if $cygwin ; then | ||
| 114 | + APP_HOME=`cygpath --path --mixed "$APP_HOME"` | ||
| 115 | + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | ||
| 116 | + JAVACMD=`cygpath --unix "$JAVACMD"` | ||
| 117 | + | ||
| 118 | + # We build the pattern for arguments to be converted via cygpath | ||
| 119 | + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | ||
| 120 | + SEP="" | ||
| 121 | + for dir in $ROOTDIRSRAW ; do | ||
| 122 | + ROOTDIRS="$ROOTDIRS$SEP$dir" | ||
| 123 | + SEP="|" | ||
| 124 | + done | ||
| 125 | + OURCYGPATTERN="(^($ROOTDIRS))" | ||
| 126 | + # Add a user-defined pattern to the cygpath arguments | ||
| 127 | + if [ "$GRADLE_CYGPATTERN" != "" ] ; then | ||
| 128 | + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | ||
| 129 | + fi | ||
| 130 | + # Now convert the arguments - kludge to limit ourselves to /bin/sh | ||
| 131 | + i=0 | ||
| 132 | + for arg in "$@" ; do | ||
| 133 | + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | ||
| 134 | + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | ||
| 135 | + | ||
| 136 | + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | ||
| 137 | + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | ||
| 138 | + else | ||
| 139 | + eval `echo args$i`="\"$arg\"" | ||
| 140 | + fi | ||
| 141 | + i=$((i+1)) | ||
| 142 | + done | ||
| 143 | + case $i in | ||
| 144 | + (0) set -- ;; | ||
| 145 | + (1) set -- "$args0" ;; | ||
| 146 | + (2) set -- "$args0" "$args1" ;; | ||
| 147 | + (3) set -- "$args0" "$args1" "$args2" ;; | ||
| 148 | + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
| 149 | + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
| 150 | + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
| 151 | + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
| 152 | + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
| 153 | + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
| 154 | + esac | ||
| 155 | +fi | ||
| 156 | + | ||
| 157 | +# Escape application args | ||
| 158 | +save () { | ||
| 159 | + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done | ||
| 160 | + echo " " | ||
| 161 | +} | ||
| 162 | +APP_ARGS=$(save "$@") | ||
| 163 | + | ||
| 164 | +# Collect all arguments for the java command, following the shell quoting and substitution rules | ||
| 165 | +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" | ||
| 166 | + | ||
| 167 | +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong | ||
| 168 | +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then | ||
| 169 | + cd "$(dirname "$0")" | ||
| 170 | +fi | ||
| 171 | + | ||
| 172 | +exec "$JAVACMD" "$@" |
| @@ -0,0 +1,84 @@ | @@ -0,0 +1,84 @@ | ||
| 1 | +@if "%DEBUG%" == "" @echo off | ||
| 2 | +@rem ########################################################################## | ||
| 3 | +@rem | ||
| 4 | +@rem Gradle startup script for Windows | ||
| 5 | +@rem | ||
| 6 | +@rem ########################################################################## | ||
| 7 | + | ||
| 8 | +@rem Set local scope for the variables with windows NT shell | ||
| 9 | +if "%OS%"=="Windows_NT" setlocal | ||
| 10 | + | ||
| 11 | +set DIRNAME=%~dp0 | ||
| 12 | +if "%DIRNAME%" == "" set DIRNAME=. | ||
| 13 | +set APP_BASE_NAME=%~n0 | ||
| 14 | +set APP_HOME=%DIRNAME% | ||
| 15 | + | ||
| 16 | +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
| 17 | +set DEFAULT_JVM_OPTS= | ||
| 18 | + | ||
| 19 | +@rem Find java.exe | ||
| 20 | +if defined JAVA_HOME goto findJavaFromJavaHome | ||
| 21 | + | ||
| 22 | +set JAVA_EXE=java.exe | ||
| 23 | +%JAVA_EXE% -version >NUL 2>&1 | ||
| 24 | +if "%ERRORLEVEL%" == "0" goto init | ||
| 25 | + | ||
| 26 | +echo. | ||
| 27 | +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
| 28 | +echo. | ||
| 29 | +echo Please set the JAVA_HOME variable in your environment to match the | ||
| 30 | +echo location of your Java installation. | ||
| 31 | + | ||
| 32 | +goto fail | ||
| 33 | + | ||
| 34 | +:findJavaFromJavaHome | ||
| 35 | +set JAVA_HOME=%JAVA_HOME:"=% | ||
| 36 | +set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
| 37 | + | ||
| 38 | +if exist "%JAVA_EXE%" goto init | ||
| 39 | + | ||
| 40 | +echo. | ||
| 41 | +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
| 42 | +echo. | ||
| 43 | +echo Please set the JAVA_HOME variable in your environment to match the | ||
| 44 | +echo location of your Java installation. | ||
| 45 | + | ||
| 46 | +goto fail | ||
| 47 | + | ||
| 48 | +:init | ||
| 49 | +@rem Get command-line arguments, handling Windows variants | ||
| 50 | + | ||
| 51 | +if not "%OS%" == "Windows_NT" goto win9xME_args | ||
| 52 | + | ||
| 53 | +:win9xME_args | ||
| 54 | +@rem Slurp the command line arguments. | ||
| 55 | +set CMD_LINE_ARGS= | ||
| 56 | +set _SKIP=2 | ||
| 57 | + | ||
| 58 | +:win9xME_args_slurp | ||
| 59 | +if "x%~1" == "x" goto execute | ||
| 60 | + | ||
| 61 | +set CMD_LINE_ARGS=%* | ||
| 62 | + | ||
| 63 | +:execute | ||
| 64 | +@rem Setup the command line | ||
| 65 | + | ||
| 66 | +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
| 67 | + | ||
| 68 | +@rem Execute Gradle | ||
| 69 | +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% | ||
| 70 | + | ||
| 71 | +:end | ||
| 72 | +@rem End local scope for the variables with windows NT shell | ||
| 73 | +if "%ERRORLEVEL%"=="0" goto mainEnd | ||
| 74 | + | ||
| 75 | +:fail | ||
| 76 | +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
| 77 | +rem the _cmd.exe /c_ return code! | ||
| 78 | +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
| 79 | +exit /b 1 | ||
| 80 | + | ||
| 81 | +:mainEnd | ||
| 82 | +if "%OS%"=="Windows_NT" endlocal | ||
| 83 | + | ||
| 84 | +:omega |
| @@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
| 1 | +## This file must *NOT* be checked into Version Control Systems, | ||
| 2 | +# as it contains information specific to your local configuration. | ||
| 3 | +# | ||
| 4 | +# Location of the SDK. This is only used by Gradle. | ||
| 5 | +# For customization when using a Version Control System, please read the | ||
| 6 | +# header note. | ||
| 7 | +#Thu May 24 14:51:19 GMT+08:00 2018 | ||
| 8 | +ndk.dir=D\:\\work_yxb\\Android\\Sdk\\ndk-bundle | ||
| 9 | +sdk.dir=D\:\\work_yxb\\Android\\Sdk |
app/src/main/java/com/shunzhi/parent/AppConfig.java
| @@ -13,6 +13,7 @@ import java.io.File; | @@ -13,6 +13,7 @@ import java.io.File; | ||
| 13 | */ | 13 | */ |
| 14 | 14 | ||
| 15 | public class AppConfig { | 15 | public class AppConfig { |
| 16 | + public static final String SYSTEM_INIT_FILE_NAME = "shunzhi_sysini"; | ||
| 16 | //保存键值对 | 17 | //保存键值对 |
| 17 | public static String SCHOOL_ID = "school_id"; | 18 | public static String SCHOOL_ID = "school_id"; |
| 18 | public static String LOGIN_NAME = "login_name"; | 19 | public static String LOGIN_NAME = "login_name"; |
| @@ -27,6 +28,7 @@ public class AppConfig { | @@ -27,6 +28,7 @@ public class AppConfig { | ||
| 27 | public static String ISBINDING = "isbinding"; | 28 | public static String ISBINDING = "isbinding"; |
| 28 | public static String CURRCHILDJSONSTR = ""; | 29 | public static String CURRCHILDJSONSTR = ""; |
| 29 | public static String DISTRICT="district"; | 30 | public static String DISTRICT="district"; |
| 31 | + public static String LOGINHISTORY = "login_history"; | ||
| 30 | 32 | ||
| 31 | 33 | ||
| 32 | public static boolean ISLOGIN = false; | 34 | public static boolean ISLOGIN = false; |
app/src/main/java/com/shunzhi/parent/AppContext.java
| @@ -26,6 +26,8 @@ import com.shunzhi.parent.ui.MainActivity; | @@ -26,6 +26,8 @@ import com.shunzhi.parent.ui.MainActivity; | ||
| 26 | 26 | ||
| 27 | import org.greenrobot.greendao.database.Database; | 27 | import org.greenrobot.greendao.database.Database; |
| 28 | import org.greenrobot.greendao.database.DatabaseOpenHelper; | 28 | import org.greenrobot.greendao.database.DatabaseOpenHelper; |
| 29 | +import org.json.JSONArray; | ||
| 30 | +import org.json.JSONException; | ||
| 29 | 31 | ||
| 30 | import timber.log.Timber; | 32 | import timber.log.Timber; |
| 31 | 33 | ||
| @@ -36,6 +38,8 @@ import timber.log.Timber; | @@ -36,6 +38,8 @@ import timber.log.Timber; | ||
| 36 | public class AppContext extends GlobalApplication { | 38 | public class AppContext extends GlobalApplication { |
| 37 | private static AppContext appContext; | 39 | private static AppContext appContext; |
| 38 | 40 | ||
| 41 | + private SharedPreferences sysInitSharedPreferences; | ||
| 42 | + | ||
| 39 | public final static int LOCATION_CITYNAME = 0x00; | 43 | public final static int LOCATION_CITYNAME = 0x00; |
| 40 | 44 | ||
| 41 | public String cityName = "", district = ""; | 45 | public String cityName = "", district = ""; |
| @@ -62,7 +66,7 @@ public class AppContext extends GlobalApplication { | @@ -62,7 +66,7 @@ public class AppContext extends GlobalApplication { | ||
| 62 | public void onCreate() { | 66 | public void onCreate() { |
| 63 | appContext = this; | 67 | appContext = this; |
| 64 | super.onCreate(); | 68 | super.onCreate(); |
| 65 | - | 69 | + sysInitSharedPreferences = getSharedPreferences(AppConfig.SYSTEM_INIT_FILE_NAME, MODE_PRIVATE); |
| 66 | NIMClient.init(this, loginInfo(), options()); | 70 | NIMClient.init(this, loginInfo(), options()); |
| 67 | if (null==AppConfig.getAppConfig(getContext()).get(AppConfig.DISTRICT)) | 71 | if (null==AppConfig.getAppConfig(getContext()).get(AppConfig.DISTRICT)) |
| 68 | AppConfig.getAppConfig(getContext()).set(AppConfig.DISTRICT,"越城区"); | 72 | AppConfig.getAppConfig(getContext()).set(AppConfig.DISTRICT,"越城区"); |
| @@ -246,4 +250,24 @@ public class AppContext extends GlobalApplication { | @@ -246,4 +250,24 @@ public class AppContext extends GlobalApplication { | ||
| 246 | 250 | ||
| 247 | } | 251 | } |
| 248 | 252 | ||
| 253 | + public String getHistroyUser() { | ||
| 254 | + return sysInitSharedPreferences.getString("histroyUser", "[]"); | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + public void setHistroyUser(String histroyUser) { | ||
| 258 | + String histroy = getHistroyUser(); | ||
| 259 | + if (histroy.contains(histroyUser)) return; | ||
| 260 | + JSONArray ja = null; | ||
| 261 | + try { | ||
| 262 | + ja = new JSONArray(histroy); | ||
| 263 | + ja.put(histroyUser); | ||
| 264 | + } catch (JSONException e) { | ||
| 265 | + e.printStackTrace(); | ||
| 266 | + } | ||
| 267 | + if (ja == null) ja = new JSONArray(); | ||
| 268 | + sysInitSharedPreferences.edit().putString("histroyUser", ja.toString()).apply(); | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + | ||
| 272 | + | ||
| 249 | } | 273 | } |
app/src/main/java/com/shunzhi/parent/adapter/MyArrayAdapter.java
0 → 100644
| @@ -0,0 +1,431 @@ | @@ -0,0 +1,431 @@ | ||
| 1 | +package com.shunzhi.parent.adapter; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.content.res.Resources; | ||
| 6 | +import android.support.annotation.IdRes; | ||
| 7 | +import android.support.annotation.LayoutRes; | ||
| 8 | +import android.support.annotation.NonNull; | ||
| 9 | +import android.view.LayoutInflater; | ||
| 10 | +import android.view.View; | ||
| 11 | +import android.view.ViewGroup; | ||
| 12 | +import android.widget.BaseAdapter; | ||
| 13 | +import android.widget.Filter; | ||
| 14 | +import android.widget.Filterable; | ||
| 15 | +import android.widget.TextView; | ||
| 16 | + | ||
| 17 | +import java.util.ArrayList; | ||
| 18 | +import java.util.Arrays; | ||
| 19 | +import java.util.Collection; | ||
| 20 | +import java.util.Collections; | ||
| 21 | +import java.util.Comparator; | ||
| 22 | +import java.util.List; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Created by Administrator on 2016/7/4. | ||
| 26 | + */ | ||
| 27 | +public class MyArrayAdapter<T> extends BaseAdapter implements Filterable, MyThemedSpinnerAdapter { | ||
| 28 | + private final Object mLock = new Object(); | ||
| 29 | + | ||
| 30 | + private final LayoutInflater mInflater; | ||
| 31 | + private List<T> mObjects; | ||
| 32 | + private int mResource; | ||
| 33 | + | ||
| 34 | + private int mDropDownResource; | ||
| 35 | + | ||
| 36 | + private int mFieldId = 0; | ||
| 37 | + | ||
| 38 | + private boolean mNotifyOnChange = true; | ||
| 39 | + | ||
| 40 | + private Context mContext; | ||
| 41 | + | ||
| 42 | + private ArrayList<T> mOriginalValues; | ||
| 43 | + private ArrayFilter mFilter; | ||
| 44 | + private LayoutInflater mDropDownInflater; | ||
| 45 | + | ||
| 46 | + public MyArrayAdapter(Context context, @LayoutRes int resource) { | ||
| 47 | + this(context, resource, 0, new ArrayList<T>()); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public MyArrayAdapter(Context context, @LayoutRes int resource, @IdRes int textViewResourceId) { | ||
| 51 | + this(context, resource, textViewResourceId, new ArrayList<T>()); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public MyArrayAdapter(Context context, @LayoutRes int resource, @NonNull List<T> objects) { | ||
| 55 | + this(context, resource, 0, objects); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * Constructor | ||
| 61 | + * | ||
| 62 | + * @param context The current context. | ||
| 63 | + * @param resource The resource ID for a layout file containing a TextView to use when | ||
| 64 | + * instantiating views. | ||
| 65 | + * @param objects The objects to represent in the ListView. | ||
| 66 | + */ | ||
| 67 | + public MyArrayAdapter(Context context, @LayoutRes int resource, @NonNull T[] objects) { | ||
| 68 | + this(context, resource, 0, Arrays.asList(objects)); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * Constructor | ||
| 73 | + * | ||
| 74 | + * @param context The current context. | ||
| 75 | + * @param resource The resource ID for a layout file containing a layout to use when | ||
| 76 | + * instantiating views. | ||
| 77 | + * @param textViewResourceId The id of the TextView within the layout resource to be populated | ||
| 78 | + * @param objects The objects to represent in the ListView. | ||
| 79 | + */ | ||
| 80 | + public MyArrayAdapter(Context context, @LayoutRes int resource, @IdRes int textViewResourceId, | ||
| 81 | + @NonNull T[] objects) { | ||
| 82 | + this(context, resource, textViewResourceId, Arrays.asList(objects)); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public MyArrayAdapter(Context context, @LayoutRes int resource, @IdRes int textViewResourceId, | ||
| 86 | + @NonNull List<T> objects) { | ||
| 87 | + mContext = context; | ||
| 88 | + mInflater = LayoutInflater.from(context); | ||
| 89 | + mResource = mDropDownResource = resource; | ||
| 90 | + mObjects = objects; | ||
| 91 | + mFieldId = textViewResourceId; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public void add(T object) { | ||
| 95 | + synchronized (mLock) { | ||
| 96 | + if (mOriginalValues != null) { | ||
| 97 | + mOriginalValues.add(object); | ||
| 98 | + } else { | ||
| 99 | + mObjects.add(object); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + if (mNotifyOnChange) notifyDataSetChanged(); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * Adds the specified Collection at the end of the array. | ||
| 107 | + * | ||
| 108 | + * @param collection The Collection to add at the end of the array. | ||
| 109 | + */ | ||
| 110 | + public void addAll(Collection<? extends T> collection) { | ||
| 111 | + synchronized (mLock) { | ||
| 112 | + if (mOriginalValues != null) { | ||
| 113 | + mOriginalValues.addAll(collection); | ||
| 114 | + } else { | ||
| 115 | + mObjects.addAll(collection); | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + if (mNotifyOnChange) notifyDataSetChanged(); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + /** | ||
| 122 | + * Adds the specified items at the end of the array. | ||
| 123 | + * | ||
| 124 | + * @param items The items to add at the end of the array. | ||
| 125 | + */ | ||
| 126 | + public void addAll(T... items) { | ||
| 127 | + synchronized (mLock) { | ||
| 128 | + if (mOriginalValues != null) { | ||
| 129 | + Collections.addAll(mOriginalValues, items); | ||
| 130 | + } else { | ||
| 131 | + Collections.addAll(mObjects, items); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + if (mNotifyOnChange) notifyDataSetChanged(); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * Inserts the specified object at the specified index in the array. | ||
| 139 | + * | ||
| 140 | + * @param object The object to insert into the array. | ||
| 141 | + * @param index The index at which the object must be inserted. | ||
| 142 | + */ | ||
| 143 | + public void insert(T object, int index) { | ||
| 144 | + synchronized (mLock) { | ||
| 145 | + if (mOriginalValues != null) { | ||
| 146 | + mOriginalValues.add(index, object); | ||
| 147 | + } else { | ||
| 148 | + mObjects.add(index, object); | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + if (mNotifyOnChange) notifyDataSetChanged(); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * Removes the specified object from the array. | ||
| 156 | + * | ||
| 157 | + * @param object The object to remove. | ||
| 158 | + */ | ||
| 159 | + public void remove(T object) { | ||
| 160 | + synchronized (mLock) { | ||
| 161 | + if (mOriginalValues != null) { | ||
| 162 | + mOriginalValues.remove(object); | ||
| 163 | + } else { | ||
| 164 | + mObjects.remove(object); | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + if (mNotifyOnChange) notifyDataSetChanged(); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + /** | ||
| 171 | + * Remove all elements from the list. | ||
| 172 | + */ | ||
| 173 | + public void clear() { | ||
| 174 | + synchronized (mLock) { | ||
| 175 | + if (mOriginalValues != null) { | ||
| 176 | + mOriginalValues.clear(); | ||
| 177 | + } else { | ||
| 178 | + mObjects.clear(); | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + if (mNotifyOnChange) notifyDataSetChanged(); | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + /** | ||
| 185 | + * Sorts the content of this adapter using the specified comparator. | ||
| 186 | + * | ||
| 187 | + * @param comparator The comparator used to sort the objects contained | ||
| 188 | + * in this adapter. | ||
| 189 | + */ | ||
| 190 | + public void sort(Comparator<? super T> comparator) { | ||
| 191 | + synchronized (mLock) { | ||
| 192 | + if (mOriginalValues != null) { | ||
| 193 | + Collections.sort(mOriginalValues, comparator); | ||
| 194 | + } else { | ||
| 195 | + Collections.sort(mObjects, comparator); | ||
| 196 | + } | ||
| 197 | + } | ||
| 198 | + if (mNotifyOnChange) notifyDataSetChanged(); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + /** | ||
| 202 | + * {@inheritDoc} | ||
| 203 | + */ | ||
| 204 | + @Override | ||
| 205 | + public void notifyDataSetChanged() { | ||
| 206 | + super.notifyDataSetChanged(); | ||
| 207 | + mNotifyOnChange = true; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + /** | ||
| 211 | + * Control whether methods that change the list ({@link #add}, | ||
| 212 | + * {@link #insert}, {@link #remove}, {@link #clear}) automatically call | ||
| 213 | + * {@link #notifyDataSetChanged}. If set to false, caller must | ||
| 214 | + * manually call notifyDataSetChanged() to have the changes | ||
| 215 | + * reflected in the attached view. | ||
| 216 | + * <p> | ||
| 217 | + * The default is true, and calling notifyDataSetChanged() | ||
| 218 | + * resets the flag to true. | ||
| 219 | + * | ||
| 220 | + * @param notifyOnChange if true, modifications to the list will | ||
| 221 | + * automatically call {@link | ||
| 222 | + * #notifyDataSetChanged} | ||
| 223 | + */ | ||
| 224 | + public void setNotifyOnChange(boolean notifyOnChange) { | ||
| 225 | + mNotifyOnChange = notifyOnChange; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + /** | ||
| 229 | + * Returns the context associated with this array adapter. The context is used | ||
| 230 | + * to create views from the resource passed to the constructor. | ||
| 231 | + * | ||
| 232 | + * @return The Context associated with this adapter. | ||
| 233 | + */ | ||
| 234 | + public Context getContext() { | ||
| 235 | + return mContext; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + /** | ||
| 239 | + * {@inheritDoc} | ||
| 240 | + */ | ||
| 241 | + public int getCount() { | ||
| 242 | + return mObjects.size(); | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + /** | ||
| 246 | + * {@inheritDoc} | ||
| 247 | + */ | ||
| 248 | + public T getItem(int position) { | ||
| 249 | + return mObjects.get(position); | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + /** | ||
| 253 | + * Returns the position of the specified item in the array. | ||
| 254 | + * | ||
| 255 | + * @param item The item to retrieve the position of. | ||
| 256 | + * @return The position of the specified item. | ||
| 257 | + */ | ||
| 258 | + public int getPosition(T item) { | ||
| 259 | + return mObjects.indexOf(item); | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + /** | ||
| 263 | + * {@inheritDoc} | ||
| 264 | + */ | ||
| 265 | + public long getItemId(int position) { | ||
| 266 | + return position; | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + /** | ||
| 270 | + * {@inheritDoc} | ||
| 271 | + */ | ||
| 272 | + public View getView(int position, View convertView, ViewGroup parent) { | ||
| 273 | + return createViewFromResource(mInflater, position, convertView, parent, mResource); | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + private View createViewFromResource(LayoutInflater inflater, int position, View convertView, | ||
| 277 | + ViewGroup parent, int resource) { | ||
| 278 | + View view; | ||
| 279 | + TextView text; | ||
| 280 | + | ||
| 281 | + if (convertView == null) { | ||
| 282 | + view = inflater.inflate(resource, parent, false); | ||
| 283 | + } else { | ||
| 284 | + view = convertView; | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + try { | ||
| 288 | + if (mFieldId == 0) { | ||
| 289 | + // If no custom field is assigned, assume the whole resource is a TextView | ||
| 290 | + text = (TextView) view; | ||
| 291 | + } else { | ||
| 292 | + // Otherwise, find the TextView field within the layout | ||
| 293 | + text = (TextView) view.findViewById(mFieldId); | ||
| 294 | + } | ||
| 295 | + } catch (ClassCastException e) { | ||
| 296 | + throw new IllegalStateException( | ||
| 297 | + "ArrayAdapter requires the resource ID to be a TextView", e); | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + T item = getItem(position); | ||
| 301 | + if (item instanceof CharSequence) { | ||
| 302 | + text.setText((CharSequence) item); | ||
| 303 | + } else { | ||
| 304 | + text.setText(item.toString()); | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + return view; | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + /** | ||
| 311 | + * <p>Sets the layout resource to create the drop down views.</p> | ||
| 312 | + * | ||
| 313 | + * @param resource the layout resource defining the drop down views | ||
| 314 | + * @see #getDropDownView(int, View, ViewGroup) | ||
| 315 | + */ | ||
| 316 | + public void setDropDownViewResource(@LayoutRes int resource) { | ||
| 317 | + this.mDropDownResource = resource; | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + /** | ||
| 321 | + * Sets the {@link Resources.Theme} against which drop-down views are | ||
| 322 | + * inflated. | ||
| 323 | + * <p> | ||
| 324 | + * By default, drop-down views are inflated against the theme of the | ||
| 325 | + * {@link Context} passed to the adapter's constructor. | ||
| 326 | + * | ||
| 327 | + * @param theme the theme against which to inflate drop-down views or | ||
| 328 | + * {@code null} to use the theme from the adapter's context | ||
| 329 | + * @see #getDropDownView(int, View, ViewGroup) | ||
| 330 | + */ | ||
| 331 | + @Override | ||
| 332 | + public void setDropDownViewTheme(Resources.Theme theme) { | ||
| 333 | + if (theme == null) { | ||
| 334 | + mDropDownInflater = null; | ||
| 335 | + } else if (theme == mInflater.getContext().getTheme()) { | ||
| 336 | + mDropDownInflater = mInflater; | ||
| 337 | + } | ||
| 338 | +// else { | ||
| 339 | +// final Context context = new ContextThemeWrapper(mContext, theme); | ||
| 340 | +// mDropDownInflater = LayoutInflater.from(context); | ||
| 341 | +// } | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + @Override | ||
| 345 | + public Resources.Theme getDropDownViewTheme() { | ||
| 346 | + return mDropDownInflater == null ? null : mDropDownInflater.getContext().getTheme(); | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + @Override | ||
| 350 | + public View getDropDownView(int position, View convertView, ViewGroup parent) { | ||
| 351 | + final LayoutInflater inflater = mDropDownInflater == null ? mInflater : mDropDownInflater; | ||
| 352 | + return createViewFromResource(inflater, position, convertView, parent, mDropDownResource); | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + | ||
| 356 | + public Filter getFilter() { | ||
| 357 | + if (mFilter == null) { | ||
| 358 | + mFilter = new ArrayFilter(); | ||
| 359 | + } | ||
| 360 | + return mFilter; | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | + private class ArrayFilter extends Filter { | ||
| 364 | + @Override | ||
| 365 | + protected FilterResults performFiltering(CharSequence prefix) { | ||
| 366 | + FilterResults results = new FilterResults(); | ||
| 367 | + | ||
| 368 | + if (mOriginalValues == null) { | ||
| 369 | + synchronized (mLock) { | ||
| 370 | + mOriginalValues = new ArrayList<T>(mObjects); | ||
| 371 | + } | ||
| 372 | + } | ||
| 373 | + | ||
| 374 | + if (prefix == null || prefix.length() == 0) { | ||
| 375 | + ArrayList<T> list; | ||
| 376 | + synchronized (mLock) { | ||
| 377 | + list = new ArrayList<T>(mOriginalValues); | ||
| 378 | + } | ||
| 379 | + results.values = list; | ||
| 380 | + results.count = list.size(); | ||
| 381 | + } else { | ||
| 382 | + String prefixString = prefix.toString().toLowerCase(); | ||
| 383 | + | ||
| 384 | + ArrayList<T> values; | ||
| 385 | + synchronized (mLock) { | ||
| 386 | + values = new ArrayList<T>(mOriginalValues); | ||
| 387 | + } | ||
| 388 | + | ||
| 389 | + final int count = values.size(); | ||
| 390 | + final ArrayList<T> newValues = new ArrayList<T>(); | ||
| 391 | + | ||
| 392 | + for (int i = 0; i < count; i++) { | ||
| 393 | + final T value = values.get(i); | ||
| 394 | + final String valueText = value.toString().toLowerCase(); | ||
| 395 | + | ||
| 396 | + // First match against the whole, non-splitted value | ||
| 397 | + if (valueText.startsWith(prefixString)) { | ||
| 398 | + newValues.add(value); | ||
| 399 | + } else { | ||
| 400 | + final String[] words = valueText.split(" "); | ||
| 401 | + final int wordCount = words.length; | ||
| 402 | + | ||
| 403 | + // Start at index 0, in case valueText starts with space(s) | ||
| 404 | + for (int k = 0; k < wordCount; k++) { | ||
| 405 | + if (words[k].contains(prefixString)) { | ||
| 406 | + newValues.add(value); | ||
| 407 | + break; | ||
| 408 | + } | ||
| 409 | + } | ||
| 410 | + } | ||
| 411 | + } | ||
| 412 | + | ||
| 413 | + results.values = newValues; | ||
| 414 | + results.count = newValues.size(); | ||
| 415 | + } | ||
| 416 | + | ||
| 417 | + return results; | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + @Override | ||
| 421 | + protected void publishResults(CharSequence constraint, FilterResults results) { | ||
| 422 | + //noinspection unchecked | ||
| 423 | + mObjects = (List<T>) results.values; | ||
| 424 | + if (results.count > 0) { | ||
| 425 | + notifyDataSetChanged(); | ||
| 426 | + } else { | ||
| 427 | + notifyDataSetInvalidated(); | ||
| 428 | + } | ||
| 429 | + } | ||
| 430 | + } | ||
| 431 | +} |
app/src/main/java/com/shunzhi/parent/adapter/MyThemedSpinnerAdapter.java
0 → 100644
| @@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
| 1 | +package com.shunzhi.parent.adapter; | ||
| 2 | + | ||
| 3 | +import android.content.res.Resources; | ||
| 4 | +import android.support.annotation.Nullable; | ||
| 5 | +import android.widget.SpinnerAdapter; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Created by Administrator on 2016/7/5. | ||
| 9 | + */ | ||
| 10 | +public interface MyThemedSpinnerAdapter extends SpinnerAdapter { | ||
| 11 | + @Nullable | ||
| 12 | + Resources.Theme getDropDownViewTheme(); | ||
| 13 | + void setDropDownViewTheme(@Nullable Resources.Theme theme); | ||
| 14 | +} | ||
| 15 | + |
app/src/main/java/com/shunzhi/parent/presenter/loginandregister/LoginAndRegisterPresenter.java
| @@ -60,6 +60,9 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre | @@ -60,6 +60,9 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre | ||
| 60 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_PWD, loginPwd); | 60 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_PWD, loginPwd); |
| 61 | RetrofitCreateHelper.getInstance().setAuthorization(jsonObject.get("access_token").getAsString()); | 61 | RetrofitCreateHelper.getInstance().setAuthorization(jsonObject.get("access_token").getAsString()); |
| 62 | getUserInfo(loginName, 0, ""); | 62 | getUserInfo(loginName, 0, ""); |
| 63 | + //fixme 新增历史登录账号 | ||
| 64 | + AppContext.getInstance().setHistroyUser(loginName); | ||
| 65 | + | ||
| 63 | } else { | 66 | } else { |
| 64 | ToastUtils.showToast(jsonObject.get("error").getAsString()); | 67 | ToastUtils.showToast(jsonObject.get("error").getAsString()); |
| 65 | } | 68 | } |
| @@ -173,7 +176,7 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre | @@ -173,7 +176,7 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre | ||
| 173 | 176 | ||
| 174 | if (currentBean.getStudentClass() != null && currentBean.getStudentClass().size() > 0) { | 177 | if (currentBean.getStudentClass() != null && currentBean.getStudentClass().size() > 0) { |
| 175 | AppConfig.getAppConfig(mIView.getBindActivity()).set(AppConfig.ISBINDING, "1"); | 178 | AppConfig.getAppConfig(mIView.getBindActivity()).set(AppConfig.ISBINDING, "1"); |
| 176 | - }else{ | 179 | + } else { |
| 177 | AppConfig.getAppConfig(mIView.getBindActivity()).set(AppConfig.ISBINDING, "0"); | 180 | AppConfig.getAppConfig(mIView.getBindActivity()).set(AppConfig.ISBINDING, "0"); |
| 178 | } | 181 | } |
| 179 | 182 |
app/src/main/java/com/shunzhi/parent/ui/activity/mywebview/WebViewActivity.java
| @@ -98,8 +98,12 @@ public class WebViewActivity extends BaseCompatActivity { | @@ -98,8 +98,12 @@ public class WebViewActivity extends BaseCompatActivity { | ||
| 98 | token = getIntent().getStringExtra("token"); | 98 | token = getIntent().getStringExtra("token"); |
| 99 | url = getIntent().getStringExtra("url"); | 99 | url = getIntent().getStringExtra("url"); |
| 100 | if (token != null && !"".equals(token) && !TextUtils.isEmpty(token)) { | 100 | if (token != null && !"".equals(token) && !TextUtils.isEmpty(token)) { |
| 101 | + if (token.length() < 21) | ||
| 102 | + token = ""; | ||
| 101 | url = url + "&Token=" + token; | 103 | url = url + "&Token=" + token; |
| 104 | + | ||
| 102 | } | 105 | } |
| 106 | + Log.e("sss--==", url); | ||
| 103 | if (type == AppConfig.BINDING_SUCCESS_HEZUO) { | 107 | if (type == AppConfig.BINDING_SUCCESS_HEZUO) { |
| 104 | binding_success.setVisibility(View.VISIBLE); | 108 | binding_success.setVisibility(View.VISIBLE); |
| 105 | binding_success2.setVisibility(View.GONE); | 109 | binding_success2.setVisibility(View.GONE); |
| @@ -119,6 +123,9 @@ public class WebViewActivity extends BaseCompatActivity { | @@ -119,6 +123,9 @@ public class WebViewActivity extends BaseCompatActivity { | ||
| 119 | binding_success2.setVisibility(View.GONE); | 123 | binding_success2.setVisibility(View.GONE); |
| 120 | title_web.setVisibility(View.VISIBLE); | 124 | title_web.setVisibility(View.VISIBLE); |
| 121 | title_web.setText("订购中心"); | 125 | title_web.setText("订购中心"); |
| 126 | + LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) nesteScrollWebView.getLayoutParams(); | ||
| 127 | + lp.setMargins(0, 0, 0, 0); | ||
| 128 | + nesteScrollWebView.setLayoutParams(lp); | ||
| 122 | 129 | ||
| 123 | } else { | 130 | } else { |
| 124 | binding_success.setVisibility(View.GONE); | 131 | binding_success.setVisibility(View.GONE); |
| @@ -132,7 +139,6 @@ public class WebViewActivity extends BaseCompatActivity { | @@ -132,7 +139,6 @@ public class WebViewActivity extends BaseCompatActivity { | ||
| 132 | 139 | ||
| 133 | initWebView(); | 140 | initWebView(); |
| 134 | initWebSetting(nesteScrollWebView.getSettings()); | 141 | initWebSetting(nesteScrollWebView.getSettings()); |
| 135 | - Log.e("aaaa", url); | ||
| 136 | nesteScrollWebView.loadUrl(url); | 142 | nesteScrollWebView.loadUrl(url); |
| 137 | } | 143 | } |
| 138 | 144 |
app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
| @@ -12,6 +12,7 @@ import android.view.LayoutInflater; | @@ -12,6 +12,7 @@ import android.view.LayoutInflater; | ||
| 12 | import android.view.View; | 12 | import android.view.View; |
| 13 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
| 14 | import android.view.WindowManager; | 14 | import android.view.WindowManager; |
| 15 | +import android.widget.AutoCompleteTextView; | ||
| 15 | import android.widget.EditText; | 16 | import android.widget.EditText; |
| 16 | import android.widget.ImageView; | 17 | import android.widget.ImageView; |
| 17 | import android.widget.LinearLayout; | 18 | import android.widget.LinearLayout; |
| @@ -25,19 +26,27 @@ import com.share.mvpsdk.utils.ToastUtils; | @@ -25,19 +26,27 @@ import com.share.mvpsdk.utils.ToastUtils; | ||
| 25 | import com.shunzhi.parent.AppConfig; | 26 | import com.shunzhi.parent.AppConfig; |
| 26 | import com.shunzhi.parent.AppContext; | 27 | import com.shunzhi.parent.AppContext; |
| 27 | import com.shunzhi.parent.R; | 28 | import com.shunzhi.parent.R; |
| 29 | +import com.shunzhi.parent.adapter.MyArrayAdapter; | ||
| 28 | import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract; | 30 | import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract; |
| 29 | import com.shunzhi.parent.presenter.loginandregister.LoginAndRegisterPresenter; | 31 | import com.shunzhi.parent.presenter.loginandregister.LoginAndRegisterPresenter; |
| 30 | import com.shunzhi.parent.ui.MainActivity; | 32 | import com.shunzhi.parent.ui.MainActivity; |
| 31 | import com.shunzhi.parent.ui.activity.LoginAndRegistActivity; | 33 | import com.shunzhi.parent.ui.activity.LoginAndRegistActivity; |
| 32 | import com.shunzhi.parent.views.MyProcessDialog; | 34 | import com.shunzhi.parent.views.MyProcessDialog; |
| 33 | 35 | ||
| 36 | +import org.json.JSONArray; | ||
| 37 | +import org.json.JSONException; | ||
| 38 | + | ||
| 39 | +import java.util.ArrayList; | ||
| 40 | +import java.util.List; | ||
| 41 | + | ||
| 34 | 42 | ||
| 35 | public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegisterContract.LoginPresenter, LoginAndRegisterContract.ILoginModel> | 43 | public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegisterContract.LoginPresenter, LoginAndRegisterContract.ILoginModel> |
| 36 | implements LoginAndRegisterContract.ILoginView, View.OnClickListener { | 44 | implements LoginAndRegisterContract.ILoginView, View.OnClickListener { |
| 37 | 45 | ||
| 38 | public RoundedImageView roundedImageView; | 46 | public RoundedImageView roundedImageView; |
| 39 | - public EditText phoneNumber, idCode, password, et_password_new; | ||
| 40 | - public TextView get_idCode, loginAndRegister, tv_info, tv_goto, tv_goto_zhuce, tv_goto_mima,center_title; | 47 | + public EditText idCode, password, et_password_new; |
| 48 | + AutoCompleteTextView phoneNumber; | ||
| 49 | + public TextView get_idCode, loginAndRegister, tv_info, tv_goto, tv_goto_zhuce, tv_goto_mima, center_title; | ||
| 41 | public LinearLayout phoneLayout, idCodeLayout, passwordLayout, main_login, passwordLayout_new; | 50 | public LinearLayout phoneLayout, idCodeLayout, passwordLayout, main_login, passwordLayout_new; |
| 42 | public ImageView img_eye, img_eye_new, back_top; | 51 | public ImageView img_eye, img_eye_new, back_top; |
| 43 | public static String typepage; | 52 | public static String typepage; |
| @@ -100,7 +109,6 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | @@ -100,7 +109,6 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | ||
| 100 | idCode.addTextChangedListener(textWatcher); | 109 | idCode.addTextChangedListener(textWatcher); |
| 101 | password.addTextChangedListener(textWatcher); | 110 | password.addTextChangedListener(textWatcher); |
| 102 | // mPresenter.loginResult("18358585335", "575335"); | 111 | // mPresenter.loginResult("18358585335", "575335"); |
| 103 | - | ||
| 104 | passwordLayout_new = view.findViewById(R.id.passwordLayout_new); | 112 | passwordLayout_new = view.findViewById(R.id.passwordLayout_new); |
| 105 | et_password_new = view.findViewById(R.id.et_password_new); | 113 | et_password_new = view.findViewById(R.id.et_password_new); |
| 106 | et_password_new.addTextChangedListener(textWatcher); | 114 | et_password_new.addTextChangedListener(textWatcher); |
| @@ -112,6 +120,7 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | @@ -112,6 +120,7 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | ||
| 112 | password.setHint("请输入密码:6~16个字符"); | 120 | password.setHint("请输入密码:6~16个字符"); |
| 113 | denglu.setVisibility(View.VISIBLE); | 121 | denglu.setVisibility(View.VISIBLE); |
| 114 | zhuce.setVisibility(View.GONE); | 122 | zhuce.setVisibility(View.GONE); |
| 123 | + initHistoryUser(); | ||
| 115 | } else if ("注册".equals(typepage)) { | 124 | } else if ("注册".equals(typepage)) { |
| 116 | idCodeLayout.setVisibility(View.VISIBLE); | 125 | idCodeLayout.setVisibility(View.VISIBLE); |
| 117 | passwordLayout_new.setVisibility(View.GONE); | 126 | passwordLayout_new.setVisibility(View.GONE); |
| @@ -138,8 +147,31 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | @@ -138,8 +147,31 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | ||
| 138 | } | 147 | } |
| 139 | 148 | ||
| 140 | 149 | ||
| 150 | + void initHistoryUser() { | ||
| 151 | + //autotv_login_name.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT); | ||
| 152 | + try { | ||
| 153 | + JSONArray ja = new JSONArray(AppContext.getInstance().getHistroyUser()); | ||
| 154 | + List<String> list = new ArrayList<>(); | ||
| 155 | + for (int i = 0; i < ja.length(); i++) { | ||
| 156 | + list.add(ja.optString(i)); | ||
| 157 | + } | ||
| 158 | + MyArrayAdapter adapter = new MyArrayAdapter(getActivity(), R.layout.simple_dropdown_item_1line, list); | ||
| 159 | + phoneNumber.setAdapter(adapter); | ||
| 160 | + phoneNumber.setThreshold(1); | ||
| 161 | + phoneNumber.setOnClickListener(new View.OnClickListener() { | ||
| 162 | + @Override | ||
| 163 | + public void onClick(View v) { | ||
| 164 | + phoneNumber.showDropDown(); | ||
| 165 | + } | ||
| 166 | + }); | ||
| 167 | + } catch (JSONException e) { | ||
| 168 | + e.printStackTrace(); | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + | ||
| 141 | @Override | 173 | @Override |
| 142 | - public void getUserInfo(int type,String message) { | 174 | + public void getUserInfo(int type, String message) { |
| 143 | progressDialog.dismiss(); | 175 | progressDialog.dismiss(); |
| 144 | if (type == 0) { | 176 | if (type == 0) { |
| 145 | startActivity(new Intent().setClass(getActivity(), MainActivity.class)); | 177 | startActivity(new Intent().setClass(getActivity(), MainActivity.class)); |
| @@ -173,11 +205,11 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | @@ -173,11 +205,11 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | ||
| 173 | 205 | ||
| 174 | popupWindow.setContentView(view); | 206 | popupWindow.setContentView(view); |
| 175 | popupWindow.showAtLocation(main_login, Gravity.CENTER, 0, 0); | 207 | popupWindow.showAtLocation(main_login, Gravity.CENTER, 0, 0); |
| 176 | - }else if(type==3){ | 208 | + } else if (type == 3) { |
| 177 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); | 209 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); |
| 178 | phoneNumber.setText(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.LOGIN_NAME)); | 210 | phoneNumber.setText(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.LOGIN_NAME)); |
| 179 | password.setFocusable(true); | 211 | password.setFocusable(true); |
| 180 | - }else ToastUtils.showToast(message); | 212 | + } else ToastUtils.showToast(message); |
| 181 | 213 | ||
| 182 | 214 | ||
| 183 | } | 215 | } |
| @@ -201,10 +233,10 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | @@ -201,10 +233,10 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | ||
| 201 | mPresenter.registerResult(phoneNumber.getText().toString(), idCode.getText().toString(), password.getText().toString()); | 233 | mPresenter.registerResult(phoneNumber.getText().toString(), idCode.getText().toString(), password.getText().toString()); |
| 202 | } else if (loginAndRegister.getText().toString().trim().equals("确定")) { | 234 | } else if (loginAndRegister.getText().toString().trim().equals("确定")) { |
| 203 | //修改密码 | 235 | //修改密码 |
| 204 | - if(TextUtils.isEmpty(password.getText().toString())&&TextUtils.isEmpty(et_password_new.getText().toString())) { | ||
| 205 | - if(password.getText().toString().equals(et_password_new.getText().toString())) { | 236 | + if (TextUtils.isEmpty(password.getText().toString()) && TextUtils.isEmpty(et_password_new.getText().toString())) { |
| 237 | + if (password.getText().toString().equals(et_password_new.getText().toString())) { | ||
| 206 | mPresenter.reSetpassResult(phoneNumber.getText().toString(), idCode.getText().toString(), password.getText().toString()); | 238 | mPresenter.reSetpassResult(phoneNumber.getText().toString(), idCode.getText().toString(), password.getText().toString()); |
| 207 | - }else{ | 239 | + } else { |
| 208 | ToastUtils.showToast("两次输入的密码不一致"); | 240 | ToastUtils.showToast("两次输入的密码不一致"); |
| 209 | } | 241 | } |
| 210 | } | 242 | } |
| @@ -243,11 +275,11 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | @@ -243,11 +275,11 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist | ||
| 243 | opennew = true; | 275 | opennew = true; |
| 244 | } | 276 | } |
| 245 | } else if (v == back_top) { | 277 | } else if (v == back_top) { |
| 246 | - if("找回密码".equals(typepage)) { | 278 | + if ("找回密码".equals(typepage)) { |
| 247 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); | 279 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); |
| 248 | - }else if("登录".equals(typepage)){ | 280 | + } else if ("登录".equals(typepage)) { |
| 249 | 281 | ||
| 250 | - }else if("注册".equals(typepage)){ | 282 | + } else if ("注册".equals(typepage)) { |
| 251 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); | 283 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); |
| 252 | } | 284 | } |
| 253 | getActivity().finish(); | 285 | getActivity().finish(); |
app/src/main/res/layout/fragment_login_and_regist.xml
| @@ -12,7 +12,8 @@ | @@ -12,7 +12,8 @@ | ||
| 12 | android:layout_width="match_parent" | 12 | android:layout_width="match_parent" |
| 13 | android:layout_height="match_parent" | 13 | android:layout_height="match_parent" |
| 14 | android:orientation="vertical"> | 14 | android:orientation="vertical"> |
| 15 | - <include layout="@layout/top"/> | 15 | + |
| 16 | + <include layout="@layout/top" /> | ||
| 16 | 17 | ||
| 17 | <com.makeramen.roundedimageview.RoundedImageView | 18 | <com.makeramen.roundedimageview.RoundedImageView |
| 18 | android:id="@+id/photoImage" | 19 | android:id="@+id/photoImage" |
| @@ -39,16 +40,35 @@ | @@ -39,16 +40,35 @@ | ||
| 39 | android:layout_height="wrap_content" | 40 | android:layout_height="wrap_content" |
| 40 | android:orientation="vertical"> | 41 | android:orientation="vertical"> |
| 41 | 42 | ||
| 42 | - <EditText | 43 | + <!--<EditText--> |
| 44 | + <!--android:id="@+id/et_phoneNumber"--> | ||
| 45 | + <!--android:layout_width="match_parent"--> | ||
| 46 | + <!--android:layout_height="50dp"--> | ||
| 47 | + <!--android:background="@null"--> | ||
| 48 | + <!--android:hint="请输入手机号码"--> | ||
| 49 | + <!--android:text=""--> | ||
| 50 | + <!--android:maxLength="11"--> | ||
| 51 | + <!--android:textColorHint="@color/hintTextColor"--> | ||
| 52 | + <!--android:textColor="@color/textColor"--> | ||
| 53 | + <!--android:textSize="@dimen/sp_16" />--> | ||
| 54 | + <AutoCompleteTextView | ||
| 43 | android:id="@+id/et_phoneNumber" | 55 | android:id="@+id/et_phoneNumber" |
| 44 | - android:layout_width="match_parent" | ||
| 45 | - android:layout_height="50dp" | 56 | + android:layout_width="fill_parent" |
| 57 | + android:layout_height="45dp" | ||
| 58 | + android:layout_alignParentTop="false" | ||
| 59 | + android:layout_centerInParent="true" | ||
| 60 | + android:layout_gravity="center_vertical" | ||
| 61 | + android:layout_marginRight="50dp" | ||
| 62 | + android:layout_toRightOf="@+id/iv_default" | ||
| 46 | android:background="@null" | 63 | android:background="@null" |
| 64 | + android:cursorVisible="true" | ||
| 65 | + android:gravity="center_vertical" | ||
| 47 | android:hint="请输入手机号码" | 66 | android:hint="请输入手机号码" |
| 48 | - android:text="" | ||
| 49 | - android:maxLength="11" | ||
| 50 | - android:textColorHint="@color/hintTextColor" | 67 | + android:inputType="textWebEmailAddress" |
| 68 | + android:singleLine="true" | ||
| 51 | android:textColor="@color/textColor" | 69 | android:textColor="@color/textColor" |
| 70 | + android:textColorHint="@color/hintTextColor" | ||
| 71 | + android:textCursorDrawable="@null" | ||
| 52 | android:textSize="@dimen/sp_16" /> | 72 | android:textSize="@dimen/sp_16" /> |
| 53 | 73 | ||
| 54 | <TextView | 74 | <TextView |
| @@ -75,8 +95,8 @@ | @@ -75,8 +95,8 @@ | ||
| 75 | android:layout_weight="1" | 95 | android:layout_weight="1" |
| 76 | android:background="@null" | 96 | android:background="@null" |
| 77 | android:hint="请输入验证码" | 97 | android:hint="请输入验证码" |
| 78 | - android:textColorHint="@color/hintTextColor" | ||
| 79 | android:textColor="@color/textColor" | 98 | android:textColor="@color/textColor" |
| 99 | + android:textColorHint="@color/hintTextColor" | ||
| 80 | android:textSize="@dimen/sp_16" /> | 100 | android:textSize="@dimen/sp_16" /> |
| 81 | 101 | ||
| 82 | <TextView | 102 | <TextView |
| @@ -120,9 +140,9 @@ | @@ -120,9 +140,9 @@ | ||
| 120 | android:layout_weight="1" | 140 | android:layout_weight="1" |
| 121 | android:background="@null" | 141 | android:background="@null" |
| 122 | android:hint="请设置密码:6~16个字符" | 142 | android:hint="请设置密码:6~16个字符" |
| 123 | - android:text="" | ||
| 124 | - android:maxLength="16" | ||
| 125 | android:inputType="textPassword" | 143 | android:inputType="textPassword" |
| 144 | + android:maxLength="16" | ||
| 145 | + android:text="" | ||
| 126 | android:textColorHint="@color/hintTextColor" | 146 | android:textColorHint="@color/hintTextColor" |
| 127 | android:textSize="@dimen/sp_16" /> | 147 | android:textSize="@dimen/sp_16" /> |
| 128 | 148 | ||
| @@ -142,12 +162,13 @@ | @@ -142,12 +162,13 @@ | ||
| 142 | android:background="@color/bottomline" /> | 162 | android:background="@color/bottomline" /> |
| 143 | 163 | ||
| 144 | </LinearLayout> | 164 | </LinearLayout> |
| 165 | + | ||
| 145 | <LinearLayout | 166 | <LinearLayout |
| 146 | android:id="@+id/passwordLayout_new" | 167 | android:id="@+id/passwordLayout_new" |
| 147 | android:layout_width="match_parent" | 168 | android:layout_width="match_parent" |
| 148 | android:layout_height="wrap_content" | 169 | android:layout_height="wrap_content" |
| 149 | - android:visibility="gone" | ||
| 150 | - android:orientation="vertical"> | 170 | + android:orientation="vertical" |
| 171 | + android:visibility="gone"> | ||
| 151 | 172 | ||
| 152 | <LinearLayout | 173 | <LinearLayout |
| 153 | android:layout_width="match_parent" | 174 | android:layout_width="match_parent" |
| @@ -160,8 +181,8 @@ | @@ -160,8 +181,8 @@ | ||
| 160 | android:layout_weight="1" | 181 | android:layout_weight="1" |
| 161 | android:background="@null" | 182 | android:background="@null" |
| 162 | android:hint="请设置密码:6~16个字符" | 183 | android:hint="请设置密码:6~16个字符" |
| 163 | - android:maxLength="16" | ||
| 164 | android:inputType="textPassword" | 184 | android:inputType="textPassword" |
| 185 | + android:maxLength="16" | ||
| 165 | android:textColorHint="@color/hintTextColor" | 186 | android:textColorHint="@color/hintTextColor" |
| 166 | android:textSize="@dimen/sp_16" /> | 187 | android:textSize="@dimen/sp_16" /> |
| 167 | 188 | ||
| @@ -222,13 +243,14 @@ | @@ -222,13 +243,14 @@ | ||
| 222 | android:textSize="@dimen/sp_16" /> | 243 | android:textSize="@dimen/sp_16" /> |
| 223 | 244 | ||
| 224 | </LinearLayout> | 245 | </LinearLayout> |
| 246 | + | ||
| 225 | <LinearLayout | 247 | <LinearLayout |
| 226 | android:id="@+id/denglu" | 248 | android:id="@+id/denglu" |
| 227 | android:layout_width="match_parent" | 249 | android:layout_width="match_parent" |
| 228 | android:layout_height="wrap_content" | 250 | android:layout_height="wrap_content" |
| 229 | - android:visibility="gone" | ||
| 230 | android:layout_marginTop="30dp" | 251 | android:layout_marginTop="30dp" |
| 231 | - android:orientation="horizontal"> | 252 | + android:orientation="horizontal" |
| 253 | + android:visibility="gone"> | ||
| 232 | 254 | ||
| 233 | <TextView | 255 | <TextView |
| 234 | android:id="@+id/tv_info_login" | 256 | android:id="@+id/tv_info_login" |
| @@ -245,11 +267,12 @@ | @@ -245,11 +267,12 @@ | ||
| 245 | android:text="注册" | 267 | android:text="注册" |
| 246 | android:textColor="#acc9fc" | 268 | android:textColor="#acc9fc" |
| 247 | android:textSize="@dimen/sp_16" /> | 269 | android:textSize="@dimen/sp_16" /> |
| 270 | + | ||
| 248 | <TextView | 271 | <TextView |
| 249 | android:layout_width="0dp" | 272 | android:layout_width="0dp" |
| 250 | android:layout_height="wrap_content" | 273 | android:layout_height="wrap_content" |
| 251 | - android:layout_weight="1" | ||
| 252 | - /> | 274 | + android:layout_weight="1" /> |
| 275 | + | ||
| 253 | <TextView | 276 | <TextView |
| 254 | android:id="@+id/tv_goto_mima" | 277 | android:id="@+id/tv_goto_mima" |
| 255 | android:layout_width="wrap_content" | 278 | android:layout_width="wrap_content" |
| @@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<!-- | ||
| 3 | +/* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml | ||
| 4 | +** | ||
| 5 | +** Copyright 2008, The Android Open Source Project | ||
| 6 | +** | ||
| 7 | +** Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 8 | +** you may not use this file except in compliance with the License. | ||
| 9 | +** You may obtain a copy of the License at | ||
| 10 | +** | ||
| 11 | +** http://www.apache.org/licenses/LICENSE-2.0 | ||
| 12 | +** | ||
| 13 | +** Unless required by applicable law or agreed to in writing, software | ||
| 14 | +** distributed under the License is distributed on an "AS IS" BASIS, | ||
| 15 | +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 16 | +** See the License for the specific language governing permissions and | ||
| 17 | +** limitations under the License. | ||
| 18 | +*/ | ||
| 19 | +--> | ||
| 20 | +<TextView xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 21 | + android:id="@android:id/text1" | ||
| 22 | + style="?android:attr/dropDownItemStyle" | ||
| 23 | + android:textAppearance="?android:attr/textAppearanceLargePopupMenu" | ||
| 24 | + android:singleLine="true" | ||
| 25 | + android:layout_width="match_parent" | ||
| 26 | + android:layout_height="?android:attr/listPreferredItemHeight" | ||
| 27 | + android:ellipsize="marquee" /> |