Login#10
Conversation
| values.put(FIELD_NAME, team.getDisplayName()); | ||
| list.add(values); | ||
| } | ||
| ContentValues[] contentValues = new ContentValues[teams.size()]; |
There was a problem hiding this comment.
Здесь в принципе можно не создавать новый массив, а прямо в вызове метода прописать list.toArray()
|
|
||
| @Override | ||
| public boolean onOptionsItemSelected(MenuItem item) { | ||
| finish(); |
There was a problem hiding this comment.
Сделай проверку на то, что мы нажимаем именно home button.
| } | ||
| db.setTransactionSuccessful(); | ||
| db.endTransaction(); | ||
| getContext().getContentResolver().notifyChange(uri, null); |
| .getApplicationContext() | ||
| .getContentResolver() | ||
| .bulkInsert(MattermostContentProvider.CONTENT_URI_TEAMS, contentValues); | ||
| } |
There was a problem hiding this comment.
MattermostApp.getSingleton().getApplicationContext()
Может сократить длину? каждому репозиторию добавить метод по умолчанию, который будет возвращать нужный контекст?
| holder.bindTo(mCursor); | ||
| holder.itemView.setOnClickListener(view ->{ | ||
| if(mCursor.moveToPosition(position)){ | ||
| onItemClickListener.onItemClick(mCursor.getString(mCursor.getColumnIndex(DBHelper.FIELD_COMMON_ID))); |
There was a problem hiding this comment.
Да, я понял, о чем ты говорил. Чтобы получить одно поле, надо дофига чего написать. Действительно тогда будет лучше это завернуть в статические методы соответствующих классов
There was a problem hiding this comment.
Это пока не точно, так как пока не известна точная модель данных.
| null, | ||
| null, | ||
| null, | ||
| FIELD_NAME); |
There was a problem hiding this comment.
Почему sortOrder передаем только название поле? Вроде нужно указывать по возрастанию или убыванию.
| values.put(FIELD_LAST_PICTURE_UPDATE, user.getLastPictureUpdate()); | ||
| values.put(FIELD_STATUS, user.getStatus()); | ||
| /* values.put(FIELD_IN_TEAM, user.getInTeam()); | ||
| values.put(FIELD_IS_SHOW, user.get());*/ |
There was a problem hiding this comment.
Почему поля в комментарии?
|
|
||
| @Override | ||
| public Loader onCreateLoader(int id, Bundle args) { | ||
| return new TeamsCursorLoader(getApplicationContext()); |
There was a problem hiding this comment.
тут малость не правильно, т.к id не обрабатывается.
There was a problem hiding this comment.
Я думаю мы пока решили вопрос с @kraftuK
|
|
||
| @Override | ||
| public void onLoadFinished(Loader<Cursor> loader, Cursor data) { | ||
| teamListAdapter.swapCursor(data); |
There was a problem hiding this comment.
проверку нужно сделать teamListAdapter может быть null
|
|
||
| RealmResults<Team> teams = TeamRepository.query(); | ||
| TeamListAdapter teamListAdapter = new TeamListAdapter(this, teams, this::setTeam); | ||
| teamListAdapter = new TeamListCursorAdapter(this, null,this::setTeam); |
There was a problem hiding this comment.
Я думаю нужно добавить конструктор, который который null скроет.
There was a problem hiding this comment.
@kraftuK ну вот зато без такого конструктора я точно вижу, что в начале мы туда передаем курсор, но "пустой". На мой взгляд читаемость лучше.
| holder.bindTo(mCursor); | ||
| holder.itemView.setOnClickListener(view ->{ | ||
| if(mCursor.moveToPosition(position)){ | ||
| onItemClickListener.onItemClick(mCursor.getString(mCursor.getColumnIndex(DBHelper.FIELD_COMMON_ID))); |
There was a problem hiding this comment.
- нужно проверить листенера, мб null будет
- нужно эту логику перенести внутрь холдера
| } else { | ||
| return 0; | ||
| } | ||
| } |
There was a problem hiding this comment.
Нужно заменить на, будет красивее ()?():() =)
| } | ||
| this.mCursor = newCursor; | ||
| notifyDataSetChanged(); | ||
| } |
| public void bindTo(Cursor mCursor) { | ||
| if (mCursor.moveToPosition(getAdapterPosition())) { | ||
| String displayName = mCursor.getString(mCursor.getColumnIndex(TeamsRepository.FIELD_NAME)); | ||
| if (displayName.length() != 0) { |
There was a problem hiding this comment.
Используй TextUntils.isEmpty
| } | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Логику связки view и данные перенес бы viewholder
| private static final int CODE_TEAMS_WITH_ID = 6; | ||
| private static final int CODE_USERS = 7; | ||
| private static final int CODE_USERS_WITH_ID = 8; | ||
| private static final int CODE_PREFERENCES = 9; |
There was a problem hiding this comment.
А варианта с указанием Id не будет или впадлу писать?)
| values.put(FIELD_VALUE, preferences.getValue()); | ||
| list.add(values); | ||
| } | ||
| ContentValues[] contentValues = new ContentValues[preferencesList.size()]; |
There was a problem hiding this comment.
Здесь также можно обойтись без создания массива
There was a problem hiding this comment.
согласен, поправим
create sqlite logic for login and choose team activity