Skip to content

Login#10

Open
evgenysuetin wants to merge 4 commits into
login_and_left_menufrom
login
Open

Login#10
evgenysuetin wants to merge 4 commits into
login_and_left_menufrom
login

Conversation

@evgenysuetin

Copy link
Copy Markdown
Contributor

create sqlite logic for login and choose team activity

values.put(FIELD_NAME, team.getDisplayName());
list.add(values);
}
ContentValues[] contentValues = new ContentValues[teams.size()];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь в принципе можно не создавать новый массив, а прямо в вызове метода прописать list.toArray()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@evgenysuetin evgenysuetin Feb 10, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+


@Override
public boolean onOptionsItemSelected(MenuItem item) {
finish();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделай проверку на то, что мы нажимаем именно home button.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+

}
db.setTransactionSuccessful();
db.endTransaction();
getContext().getContentResolver().notifyChange(uri, null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему не count?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+

.getApplicationContext()
.getContentResolver()
.bulkInsert(MattermostContentProvider.CONTENT_URI_TEAMS, contentValues);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MattermostApp.getSingleton().getApplicationContext()
Может сократить длину? каждому репозиторию добавить метод по умолчанию, который будет возвращать нужный контекст?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-

holder.bindTo(mCursor);
holder.itemView.setOnClickListener(view ->{
if(mCursor.moveToPosition(position)){
onItemClickListener.onItemClick(mCursor.getString(mCursor.getColumnIndex(DBHelper.FIELD_COMMON_ID)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, я понял, о чем ты говорил. Чтобы получить одно поле, надо дофига чего написать. Действительно тогда будет лучше это завернуть в статические методы соответствующих классов

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это пока не точно, так как пока не известна точная модель данных.

@kraftuK kraftuK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как то так

null,
null,
null,
FIELD_NAME);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему sortOrder передаем только название поле? Вроде нужно указывать по возрастанию или убыванию.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+

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());*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему поля в комментарии?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+


@Override
public Loader onCreateLoader(int id, Bundle args) {
return new TeamsCursorLoader(getApplicationContext());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут малость не правильно, т.к id не обрабатывается.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я думаю мы пока решили вопрос с @kraftuK


@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
teamListAdapter.swapCursor(data);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверку нужно сделать teamListAdapter может быть null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+


RealmResults<Team> teams = TeamRepository.query();
TeamListAdapter teamListAdapter = new TeamListAdapter(this, teams, this::setTeam);
teamListAdapter = new TeamListCursorAdapter(this, null,this::setTeam);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я думаю нужно добавить конструктор, который который null скроет.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kraftuK ну вот зато без такого конструктора я точно вижу, что в начале мы туда передаем курсор, но "пустой". На мой взгляд читаемость лучше.

holder.bindTo(mCursor);
holder.itemView.setOnClickListener(view ->{
if(mCursor.moveToPosition(position)){
onItemClickListener.onItemClick(mCursor.getString(mCursor.getColumnIndex(DBHelper.FIELD_COMMON_ID)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. нужно проверить листенера, мб null будет
  2. нужно эту логику перенести внутрь холдера

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+-

} else {
return 0;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно заменить на, будет красивее ()?():() =)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+

}
this.mCursor = newCursor;
notifyDataSetChanged();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут не нужны this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+

public void bindTo(Cursor mCursor) {
if (mCursor.moveToPosition(getAdapterPosition())) {
String displayName = mCursor.getString(mCursor.getColumnIndex(TeamsRepository.FIELD_NAME));
if (displayName.length() != 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Используй TextUntils.isEmpty

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+

}
}

}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Логику связки view и данные перенес бы viewholder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+-

@evgenysuetin

Copy link
Copy Markdown
Contributor Author

@kraftuK @Keparlg смотрите последие изменения

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А варианта с указанием Id не будет или впадлу писать?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не будет

values.put(FIELD_VALUE, preferences.getValue());
list.add(values);
}
ContentValues[] contentValues = new ContentValues[preferencesList.size()];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь также можно обойтись без создания массива

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

согласен, поправим

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants