Navigate to single system folder

This commit is contained in:
M66B
2022-03-13 16:00:04 +01:00
parent cb168a6133
commit 69d6d99196
3 changed files with 43 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -148,10 +149,43 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
if (EntityFolder.OUTBOX.equals(folder.type))
lbm.sendBroadcast(new Intent(ActivityView.ACTION_VIEW_OUTBOX));
else
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("type", folder.type));
else {
Bundle args = new Bundle();
args.putString("type", folder.type);
new SimpleTask<EntityFolder>() {
@Override
protected EntityFolder onExecute(Context context, Bundle args) throws Throwable {
String type = args.getString("type");
DB db = DB.getInstance(context);
List<EntityFolder> folders = db.folder().getFoldersByType(type);
return (folders != null && folders.size() == 1 ? folders.get(0) : null);
}
@Override
protected void onExecuted(Bundle args, EntityFolder one) {
if (one == null)
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("type", folder.type));
else
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("account", one.account)
.putExtra("folder", one.id)
.putExtra("type", one.type));
}
@Override
protected void onException(Bundle args, Throwable ex) {
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("type", folder.type));
}
}.execute(context, owner, args, "nav:folder");
}
}
}