Commit 666971bfcc3eb5c10f399b0dbc18ec44a804ab4c
1 parent
ddfe0ee9
Exists in
yxb_dev
and in
1 other branch
no message
Showing
13 changed files
with
594 additions
and
44 deletions
Show diff stats
.idea/inspectionProfiles/profiles_settings.xml
.idea/misc.xml
... | ... | @@ -5,11 +5,12 @@ |
5 | 5 | <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> |
6 | 6 | <option name="myNullables"> |
7 | 7 | <value> |
8 | - <list size="4"> | |
8 | + <list size="5"> | |
9 | 9 | <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> |
10 | 10 | <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> |
11 | - <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> | |
12 | - <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> | |
11 | + <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" /> | |
12 | + <item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> | |
13 | + <item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> | |
13 | 14 | </list> |
14 | 15 | </value> |
15 | 16 | </option> |
... | ... | @@ -24,7 +25,7 @@ |
24 | 25 | </value> |
25 | 26 | </option> |
26 | 27 | </component> |
27 | - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |
28 | + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |
28 | 29 | <output url="file://$PROJECT_DIR$/build/classes" /> |
29 | 30 | </component> |
30 | 31 | <component name="ProjectType"> | ... | ... |
.idea/modules.xml
... | ... | @@ -4,9 +4,7 @@ |
4 | 4 | <modules> |
5 | 5 | <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> |
6 | 6 | <module fileurl="file://$PROJECT_DIR$/mvpsdk/mvpsdk.iml" filepath="$PROJECT_DIR$/mvpsdk/mvpsdk.iml" /> |
7 | - <module fileurl="file://$PROJECT_DIR$/parentWorkHolper.iml" filepath="$PROJECT_DIR$/parentWorkHolper.iml" /> | |
8 | 7 | <module fileurl="file://$PROJECT_DIR$/parentwork.iml" filepath="$PROJECT_DIR$/parentwork.iml" /> |
9 | - <module fileurl="file://F:/parentWorkHolper/parentwork.iml" filepath="F:/parentWorkHolper/parentwork.iml" /> | |
10 | 8 | <module fileurl="file://$PROJECT_DIR$/processor/processor.iml" filepath="$PROJECT_DIR$/processor/processor.iml" /> |
11 | 9 | <module fileurl="file://$PROJECT_DIR$/roundedimageview-2.2.1/roundedimageview-2.2.1.iml" filepath="$PROJECT_DIR$/roundedimageview-2.2.1/roundedimageview-2.2.1.iml" /> |
12 | 10 | </modules> | ... | ... |
.idea/vcs.xml
app/libs/processor.jar
No preview for this file type
app/src/main/java/com/shunzhi/parent/AppConfig.java
... | ... | @@ -13,6 +13,7 @@ import java.io.File; |
13 | 13 | */ |
14 | 14 | |
15 | 15 | public class AppConfig { |
16 | + public static final String SYSTEM_INIT_FILE_NAME = "shunzhi_sysini"; | |
16 | 17 | //保存键值对 |
17 | 18 | public static String SCHOOL_ID = "school_id"; |
18 | 19 | public static String LOGIN_NAME = "login_name"; |
... | ... | @@ -27,6 +28,7 @@ public class AppConfig { |
27 | 28 | public static String ISBINDING = "isbinding"; |
28 | 29 | public static String CURRCHILDJSONSTR = ""; |
29 | 30 | public static String DISTRICT="district"; |
31 | + public static String LOGINHISTORY = "login_history"; | |
30 | 32 | |
31 | 33 | |
32 | 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 | 26 | |
27 | 27 | import org.greenrobot.greendao.database.Database; |
28 | 28 | import org.greenrobot.greendao.database.DatabaseOpenHelper; |
29 | +import org.json.JSONArray; | |
30 | +import org.json.JSONException; | |
29 | 31 | |
30 | 32 | import timber.log.Timber; |
31 | 33 | |
... | ... | @@ -36,6 +38,8 @@ import timber.log.Timber; |
36 | 38 | public class AppContext extends GlobalApplication { |
37 | 39 | private static AppContext appContext; |
38 | 40 | |
41 | + private SharedPreferences sysInitSharedPreferences; | |
42 | + | |
39 | 43 | public final static int LOCATION_CITYNAME = 0x00; |
40 | 44 | |
41 | 45 | public String cityName = "", district = ""; |
... | ... | @@ -62,7 +66,7 @@ public class AppContext extends GlobalApplication { |
62 | 66 | public void onCreate() { |
63 | 67 | appContext = this; |
64 | 68 | super.onCreate(); |
65 | - | |
69 | + sysInitSharedPreferences = getSharedPreferences(AppConfig.SYSTEM_INIT_FILE_NAME, MODE_PRIVATE); | |
66 | 70 | NIMClient.init(this, loginInfo(), options()); |
67 | 71 | if (null==AppConfig.getAppConfig(getContext()).get(AppConfig.DISTRICT)) |
68 | 72 | AppConfig.getAppConfig(getContext()).set(AppConfig.DISTRICT,"越城区"); |
... | ... | @@ -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 @@ |
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 @@ |
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 | 60 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_PWD, loginPwd); |
61 | 61 | RetrofitCreateHelper.getInstance().setAuthorization(jsonObject.get("access_token").getAsString()); |
62 | 62 | getUserInfo(loginName, 0, ""); |
63 | + //fixme 新增历史登录账号 | |
64 | + AppContext.getInstance().setHistroyUser(loginName); | |
65 | + | |
63 | 66 | } else { |
64 | 67 | ToastUtils.showToast(jsonObject.get("error").getAsString()); |
65 | 68 | } |
... | ... | @@ -173,7 +176,7 @@ public class LoginAndRegisterPresenter extends LoginAndRegisterContract.LoginPre |
173 | 176 | |
174 | 177 | if (currentBean.getStudentClass() != null && currentBean.getStudentClass().size() > 0) { |
175 | 178 | AppConfig.getAppConfig(mIView.getBindActivity()).set(AppConfig.ISBINDING, "1"); |
176 | - }else{ | |
179 | + } else { | |
177 | 180 | AppConfig.getAppConfig(mIView.getBindActivity()).set(AppConfig.ISBINDING, "0"); |
178 | 181 | } |
179 | 182 | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/loginandregistfragment/LoginAndRegistFragment.java
... | ... | @@ -12,6 +12,7 @@ import android.view.LayoutInflater; |
12 | 12 | import android.view.View; |
13 | 13 | import android.view.ViewGroup; |
14 | 14 | import android.view.WindowManager; |
15 | +import android.widget.AutoCompleteTextView; | |
15 | 16 | import android.widget.EditText; |
16 | 17 | import android.widget.ImageView; |
17 | 18 | import android.widget.LinearLayout; |
... | ... | @@ -25,19 +26,27 @@ import com.share.mvpsdk.utils.ToastUtils; |
25 | 26 | import com.shunzhi.parent.AppConfig; |
26 | 27 | import com.shunzhi.parent.AppContext; |
27 | 28 | import com.shunzhi.parent.R; |
29 | +import com.shunzhi.parent.adapter.MyArrayAdapter; | |
28 | 30 | import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract; |
29 | 31 | import com.shunzhi.parent.presenter.loginandregister.LoginAndRegisterPresenter; |
30 | 32 | import com.shunzhi.parent.ui.MainActivity; |
31 | 33 | import com.shunzhi.parent.ui.activity.LoginAndRegistActivity; |
32 | 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 | 43 | public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegisterContract.LoginPresenter, LoginAndRegisterContract.ILoginModel> |
36 | 44 | implements LoginAndRegisterContract.ILoginView, View.OnClickListener { |
37 | 45 | |
38 | 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 | 50 | public LinearLayout phoneLayout, idCodeLayout, passwordLayout, main_login, passwordLayout_new; |
42 | 51 | public ImageView img_eye, img_eye_new, back_top; |
43 | 52 | public static String typepage; |
... | ... | @@ -100,7 +109,6 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist |
100 | 109 | idCode.addTextChangedListener(textWatcher); |
101 | 110 | password.addTextChangedListener(textWatcher); |
102 | 111 | // mPresenter.loginResult("18358585335", "575335"); |
103 | - | |
104 | 112 | passwordLayout_new = view.findViewById(R.id.passwordLayout_new); |
105 | 113 | et_password_new = view.findViewById(R.id.et_password_new); |
106 | 114 | et_password_new.addTextChangedListener(textWatcher); |
... | ... | @@ -112,6 +120,7 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist |
112 | 120 | password.setHint("请输入密码:6~16个字符"); |
113 | 121 | denglu.setVisibility(View.VISIBLE); |
114 | 122 | zhuce.setVisibility(View.GONE); |
123 | + initHistoryUser(); | |
115 | 124 | } else if ("注册".equals(typepage)) { |
116 | 125 | idCodeLayout.setVisibility(View.VISIBLE); |
117 | 126 | passwordLayout_new.setVisibility(View.GONE); |
... | ... | @@ -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 | 173 | @Override |
142 | - public void getUserInfo(int type,String message) { | |
174 | + public void getUserInfo(int type, String message) { | |
143 | 175 | progressDialog.dismiss(); |
144 | 176 | if (type == 0) { |
145 | 177 | startActivity(new Intent().setClass(getActivity(), MainActivity.class)); |
... | ... | @@ -173,11 +205,11 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist |
173 | 205 | |
174 | 206 | popupWindow.setContentView(view); |
175 | 207 | popupWindow.showAtLocation(main_login, Gravity.CENTER, 0, 0); |
176 | - }else if(type==3){ | |
208 | + } else if (type == 3) { | |
177 | 209 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); |
178 | 210 | phoneNumber.setText(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.LOGIN_NAME)); |
179 | 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 | 233 | mPresenter.registerResult(phoneNumber.getText().toString(), idCode.getText().toString(), password.getText().toString()); |
202 | 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 | 238 | mPresenter.reSetpassResult(phoneNumber.getText().toString(), idCode.getText().toString(), password.getText().toString()); |
207 | - }else{ | |
239 | + } else { | |
208 | 240 | ToastUtils.showToast("两次输入的密码不一致"); |
209 | 241 | } |
210 | 242 | } |
... | ... | @@ -243,11 +275,11 @@ public class LoginAndRegistFragment extends BaseMVPCompatFragment<LoginAndRegist |
243 | 275 | opennew = true; |
244 | 276 | } |
245 | 277 | } else if (v == back_top) { |
246 | - if("找回密码".equals(typepage)) { | |
278 | + if ("找回密码".equals(typepage)) { | |
247 | 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 | 283 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); |
252 | 284 | } |
253 | 285 | getActivity().finish(); | ... | ... |
app/src/main/res/layout/fragment_login_and_regist.xml
... | ... | @@ -12,7 +12,8 @@ |
12 | 12 | android:layout_width="match_parent" |
13 | 13 | android:layout_height="match_parent" |
14 | 14 | android:orientation="vertical"> |
15 | - <include layout="@layout/top"/> | |
15 | + | |
16 | + <include layout="@layout/top" /> | |
16 | 17 | |
17 | 18 | <com.makeramen.roundedimageview.RoundedImageView |
18 | 19 | android:id="@+id/photoImage" |
... | ... | @@ -39,16 +40,35 @@ |
39 | 40 | android:layout_height="wrap_content" |
40 | 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 | 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 | 63 | android:background="@null" |
64 | + android:cursorVisible="true" | |
65 | + android:gravity="center_vertical" | |
47 | 66 | android:hint="请输入手机号码" |
48 | - android:text="" | |
49 | - android:maxLength="11" | |
50 | - android:textColorHint="@color/hintTextColor" | |
67 | + android:inputType="textWebEmailAddress" | |
68 | + android:singleLine="true" | |
51 | 69 | android:textColor="@color/textColor" |
70 | + android:textColorHint="@color/hintTextColor" | |
71 | + android:textCursorDrawable="@null" | |
52 | 72 | android:textSize="@dimen/sp_16" /> |
53 | 73 | |
54 | 74 | <TextView |
... | ... | @@ -75,8 +95,8 @@ |
75 | 95 | android:layout_weight="1" |
76 | 96 | android:background="@null" |
77 | 97 | android:hint="请输入验证码" |
78 | - android:textColorHint="@color/hintTextColor" | |
79 | 98 | android:textColor="@color/textColor" |
99 | + android:textColorHint="@color/hintTextColor" | |
80 | 100 | android:textSize="@dimen/sp_16" /> |
81 | 101 | |
82 | 102 | <TextView |
... | ... | @@ -120,9 +140,9 @@ |
120 | 140 | android:layout_weight="1" |
121 | 141 | android:background="@null" |
122 | 142 | android:hint="请设置密码:6~16个字符" |
123 | - android:text="" | |
124 | - android:maxLength="16" | |
125 | 143 | android:inputType="textPassword" |
144 | + android:maxLength="16" | |
145 | + android:text="" | |
126 | 146 | android:textColorHint="@color/hintTextColor" |
127 | 147 | android:textSize="@dimen/sp_16" /> |
128 | 148 | |
... | ... | @@ -142,12 +162,13 @@ |
142 | 162 | android:background="@color/bottomline" /> |
143 | 163 | |
144 | 164 | </LinearLayout> |
165 | + | |
145 | 166 | <LinearLayout |
146 | 167 | android:id="@+id/passwordLayout_new" |
147 | 168 | android:layout_width="match_parent" |
148 | 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 | 173 | <LinearLayout |
153 | 174 | android:layout_width="match_parent" |
... | ... | @@ -160,8 +181,8 @@ |
160 | 181 | android:layout_weight="1" |
161 | 182 | android:background="@null" |
162 | 183 | android:hint="请设置密码:6~16个字符" |
163 | - android:maxLength="16" | |
164 | 184 | android:inputType="textPassword" |
185 | + android:maxLength="16" | |
165 | 186 | android:textColorHint="@color/hintTextColor" |
166 | 187 | android:textSize="@dimen/sp_16" /> |
167 | 188 | |
... | ... | @@ -222,13 +243,14 @@ |
222 | 243 | android:textSize="@dimen/sp_16" /> |
223 | 244 | |
224 | 245 | </LinearLayout> |
246 | + | |
225 | 247 | <LinearLayout |
226 | 248 | android:id="@+id/denglu" |
227 | 249 | android:layout_width="match_parent" |
228 | 250 | android:layout_height="wrap_content" |
229 | - android:visibility="gone" | |
230 | 251 | android:layout_marginTop="30dp" |
231 | - android:orientation="horizontal"> | |
252 | + android:orientation="horizontal" | |
253 | + android:visibility="gone"> | |
232 | 254 | |
233 | 255 | <TextView |
234 | 256 | android:id="@+id/tv_info_login" |
... | ... | @@ -245,11 +267,12 @@ |
245 | 267 | android:text="注册" |
246 | 268 | android:textColor="#acc9fc" |
247 | 269 | android:textSize="@dimen/sp_16" /> |
270 | + | |
248 | 271 | <TextView |
249 | 272 | android:layout_width="0dp" |
250 | 273 | android:layout_height="wrap_content" |
251 | - android:layout_weight="1" | |
252 | - /> | |
274 | + android:layout_weight="1" /> | |
275 | + | |
253 | 276 | <TextView |
254 | 277 | android:id="@+id/tv_goto_mima" |
255 | 278 | android:layout_width="wrap_content" | ... | ... |
... | ... | @@ -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" /> | ... | ... |