Skip to content

Commit

Permalink
sort contact list by Topic.touched, code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Feb 5, 2019
1 parent 4da93d3 commit 2dd230e
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 180 deletions.
14 changes: 7 additions & 7 deletions app/src/main/java/co/tinode/tindroid/ChatListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public class ChatListAdapter extends BaseAdapter {
private SparseBooleanArray mSelectedItems;


public ChatListAdapter(AppCompatActivity context) {
ChatListAdapter(AppCompatActivity context) {
super();
mContext = context;
mSelectedItems = new SparseBooleanArray();
resetContent();
}

public void resetContent() {
void resetContent() {
mTopics = Cache.getTinode().getFilteredTopics(ComTopic.TopicType.USER, null);
}

Expand Down Expand Up @@ -119,16 +119,16 @@ private void bindView(int position, ViewHolder holder) {
// Log.d(TAG, "User " + topic.getName() + " is " + (topic.getOnline() ? "online" : "offline"));
}

public void toggleSelected(int position) {
void toggleSelected(int position) {
selectView(position, !mSelectedItems.get(position));
}

public void removeSelection() {
void removeSelection() {
mSelectedItems = new SparseBooleanArray();
notifyDataSetChanged();
}

public String getTopicNameFromView(View view) {
String getTopicNameFromView(View view) {
final ViewHolder holder = (ViewHolder) view.getTag();
return holder != null ? holder.topic : null;
}
Expand All @@ -142,11 +142,11 @@ private void selectView(int position, boolean value) {
}


public int getSelectedCount() {
int getSelectedCount() {
return mSelectedItems.size();
}

public SparseBooleanArray getSelectedIds() {
SparseBooleanArray getSelectedIds() {
return mSelectedItems;
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/co/tinode/tindroid/db/SubscriberDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ public static long insert(SQLiteDatabase db, long topicId, int status, Subscript
db.setTransactionSuccessful();
sub.setLocal(ss);

} catch (SQLException ignored) {
Log.e(TAG, "Exception while inserting", ignored);
} catch (SQLException ex) {
Log.e(TAG, "Exception while inserting", ex);
}

db.endTransaction();
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/co/tinode/tindroid/db/TopicDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static long insert(SQLiteDatabase db, Topic topic) {
int status = topic.isNew() ? BaseDb.STATUS_QUEUED : BaseDb.STATUS_SYNCED;

// Convert topic description to a map of values
Date lastUsed = new Date();
Date lastUsed = topic.getTouched() != null ? topic.getTouched() : new Date();
ContentValues values = new ContentValues();
values.put(COLUMN_NAME_ACCOUNT_ID, BaseDb.getInstance().getAccountId());
values.put(COLUMN_NAME_STATUS, status);
Expand Down Expand Up @@ -276,7 +276,7 @@ public static boolean update(SQLiteDatabase db, Topic topic) {
values.put(COLUMN_NAME_PUBLIC, BaseDb.serialize(topic.getPub()));
values.put(COLUMN_NAME_PRIVATE, BaseDb.serialize(topic.getPriv()));

Date lastUsed = new Date();
Date lastUsed = topic.getTouched() != null ? topic.getTouched() : new Date();
values.put(COLUMN_NAME_LASTUSED, lastUsed.getTime());

int updated = db.update(TABLE_NAME, values, _ID + "=" + st.id, null);
Expand Down
Loading

0 comments on commit 2dd230e

Please sign in to comment.