Skip to content
Permalink
Browse files

code clean up and NPE fix

  • Loading branch information...
iNPUTmice committed Aug 25, 2019
1 parent 0f84ef7 commit dc360ac5bb8f5ad80417079316428bf1bb26a858
@@ -18,41 +18,24 @@
import android.app.Application;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.paging.LivePagedListBuilder;
import androidx.paging.PagedList;

import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.paging.LivePagedListBuilder;
import androidx.paging.PagedList;
import androidx.work.Constraints;
import androidx.work.Data;
import androidx.work.ExistingWorkPolicy;
import androidx.work.NetworkType;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import rs.ltt.android.Credentials;
import rs.ltt.android.cache.DatabaseCache;
import rs.ltt.android.database.LttrsDatabase;
import rs.ltt.android.entity.KeywordOverwriteEntity;
import rs.ltt.android.entity.MailboxOverviewItem;
import rs.ltt.android.entity.MailboxWithRoleAndName;
import rs.ltt.android.entity.ThreadOverviewItem;
import rs.ltt.android.worker.ModifyKeywordWorker;
import rs.ltt.jmap.client.session.SessionFileCache;
import rs.ltt.jmap.common.entity.IdentifiableMailboxWithRole;
import rs.ltt.jmap.common.entity.Keyword;
import rs.ltt.jmap.common.entity.Role;
import rs.ltt.jmap.common.entity.query.EmailQuery;
import rs.ltt.jmap.mua.Mua;

public class QueryRepository extends LttrsRepository {

@@ -120,22 +120,24 @@ public static void setFrom(final ImageView imageView, final Map.Entry<String, St

@BindingAdapter("from")
public static void setFrom(final TextView textView, final ThreadOverviewItem.From[] from) {
final boolean shorten = from.length > 1;
final SpannableStringBuilder builder = new SpannableStringBuilder();
for (int i = 0; i < from.length; ++i) {
ThreadOverviewItem.From individual = from[i];
if (builder.length() != 0) {
builder.append(", ");
}
int start = builder.length();
builder.append(shorten ? EmailAddressUtil.shorten(individual.name) : individual.name);
if (!individual.seen) {
builder.setSpan(new StyleSpan(Typeface.BOLD), start, builder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (from.length > 3) {
if (i < from.length - 3) {
builder.append(""); //TODO small?
i = from.length - 3;
if (from != null) {
final boolean shorten = from.length > 1;
for (int i = 0; i < from.length; ++i) {
ThreadOverviewItem.From individual = from[i];
if (builder.length() != 0) {
builder.append(", ");
}
int start = builder.length();
builder.append(shorten ? EmailAddressUtil.shorten(individual.name) : individual.name);
if (!individual.seen) {
builder.setSpan(new StyleSpan(Typeface.BOLD), start, builder.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (from.length > 3) {
if (i < from.length - 3) {
builder.append(""); //TODO small?
i = from.length - 3;
}
}
}
}
@@ -16,24 +16,15 @@
package rs.ltt.android.ui.model;

import android.app.Application;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Transformations;
import androidx.paging.PagedList;
import androidx.work.Constraints;
import androidx.work.Data;
import androidx.work.ExistingWorkPolicy;
import androidx.work.NetworkType;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
import rs.ltt.android.entity.KeywordOverwriteEntity;

import rs.ltt.android.entity.ThreadOverviewItem;
import rs.ltt.android.repository.QueryRepository;
import rs.ltt.android.worker.ModifyKeywordWorker;
import rs.ltt.jmap.common.entity.Keyword;
import rs.ltt.jmap.common.entity.query.EmailQuery;

public abstract class AbstractQueryViewModel extends AndroidViewModel {

0 comments on commit dc360ac

Please sign in to comment.
You can’t perform that action at this time.