mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-09 10:33:41 +02:00
Added operation state
This commit is contained in:
@@ -26,6 +26,7 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -53,6 +54,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||
private View view;
|
||||
private ImageView ivState;
|
||||
private TextView tvFolder;
|
||||
private TextView tvOperation;
|
||||
private TextView tvTime;
|
||||
@@ -62,6 +64,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
|
||||
super(itemView);
|
||||
|
||||
view = itemView.findViewById(R.id.clItem);
|
||||
ivState = itemView.findViewById(R.id.ivState);
|
||||
tvFolder = itemView.findViewById(R.id.tvFolder);
|
||||
tvOperation = itemView.findViewById(R.id.tvOperation);
|
||||
tvTime = itemView.findViewById(R.id.tvTime);
|
||||
@@ -96,6 +99,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
|
||||
String folderName =
|
||||
(operation.accountName == null ? "" : operation.accountName + "/") + operation.folderName;
|
||||
|
||||
ivState.setVisibility(operation.state == null ? View.INVISIBLE : View.VISIBLE);
|
||||
tvFolder.setText(folderName);
|
||||
tvOperation.setText(sb.toString());
|
||||
tvTime.setText(Helper.getRelativeTimeSpanString(context, operation.created));
|
||||
|
||||
@@ -180,6 +180,8 @@ class Core {
|
||||
|
||||
// Operations should use database transaction when needed
|
||||
|
||||
db.operation().setOperationState(op.id, "executing");
|
||||
|
||||
switch (op.name) {
|
||||
case EntityOperation.SEEN:
|
||||
onSeen(context, jargs, folder, message, (IMAPFolder) ifolder);
|
||||
@@ -307,6 +309,8 @@ class Core {
|
||||
}
|
||||
|
||||
throw ex;
|
||||
} finally {
|
||||
db.operation().setOperationState(op.id, null);
|
||||
}
|
||||
} finally {
|
||||
Log.i(folder.name + " end op=" + op.id + "/" + op.name);
|
||||
|
||||
@@ -51,7 +51,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
|
||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 80,
|
||||
version = 81,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
@@ -809,6 +809,13 @@ public abstract class DB extends RoomDatabase {
|
||||
db.execSQL("CREATE INDEX `index_attachment_message_cid` ON `attachment` (`message`, `cid`)");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(80, 81) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `operation` ADD COLUMN `state` TEXT");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,9 @@ public interface DaoOperation {
|
||||
" AND message = :message")
|
||||
int getOperationCount(long folder, long message);
|
||||
|
||||
@Query("UPDATE operation SET state = :state WHERE id = :id")
|
||||
int setOperationState(long id, String state);
|
||||
|
||||
@Query("UPDATE operation SET error = :error WHERE id = :id")
|
||||
int setOperationError(long id, String error);
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class EntityOperation {
|
||||
public String args;
|
||||
@NonNull
|
||||
public Long created;
|
||||
public String state;
|
||||
public String error;
|
||||
|
||||
static final String ADD = "add";
|
||||
@@ -285,6 +286,7 @@ public class EntityOperation {
|
||||
this.name.equals(other.name) &&
|
||||
this.args.equals(other.args) &&
|
||||
this.created.equals(other.created) &&
|
||||
Objects.equals(this.state, other.state) &&
|
||||
Objects.equals(this.error, other.error));
|
||||
} else
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user