Small behavior improvement

pull/159/head
M66B 6 years ago
parent 17aa81ccaf
commit 86c0638fa0

@ -24,6 +24,7 @@ import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -43,6 +44,7 @@ public class FragmentDialogFolder extends DialogFragmentEx {
String title = getArguments().getString("title"); String title = getArguments().getString("title");
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_folder_select, null); final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_folder_select, null);
final TextView tvNoFolder = dview.findViewById(R.id.tvNoFolder);
final RecyclerView rvFolder = dview.findViewById(R.id.rvFolder); final RecyclerView rvFolder = dview.findViewById(R.id.rvFolder);
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait); final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
@ -50,15 +52,24 @@ public class FragmentDialogFolder extends DialogFragmentEx {
LinearLayoutManager llm = new LinearLayoutManager(getContext()); LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvFolder.setLayoutManager(llm); rvFolder.setLayoutManager(llm);
rvFolder.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("account", getArguments().getLong("account")); args.putLong("account", getArguments().getLong("account"));
new SimpleTask<List<TupleFolderEx>>() { new SimpleTask<List<TupleFolderEx>>() {
@Override @Override
protected List<TupleFolderEx> onExecute(Context context, Bundle args) { protected void onPreExecute(Bundle args) {
tvNoFolder.setVisibility(View.GONE);
rvFolder.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
}
@Override
protected void onPostExecute(Bundle args) {
pbWait.setVisibility(View.GONE);
}
@Override
protected List<TupleFolderEx> onExecute(Context context, Bundle args) throws Throwable {
long account = args.getLong("account"); long account = args.getLong("account");
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
@ -70,26 +81,29 @@ public class FragmentDialogFolder extends DialogFragmentEx {
if (folders == null) if (folders == null)
folders = new ArrayList<>(); folders = new ArrayList<>();
long account = args.getLong("account"); if (folders.size() == 0)
AdapterFolder adapter = new AdapterFolder(getContext(), getActivity(), tvNoFolder.setVisibility(View.VISIBLE);
account, false, new AdapterFolder.IFolderSelectedListener() { else {
@Override long account = args.getLong("account");
public void onFolderSelected(TupleFolderEx folder) { AdapterFolder adapter = new AdapterFolder(getContext(), getActivity(),
Bundle args = getArguments(); account, false, new AdapterFolder.IFolderSelectedListener() {
args.putLong("folder", folder.id); @Override
public void onFolderSelected(TupleFolderEx folder) {
sendResult(RESULT_OK); Bundle args = getArguments();
dismiss(); args.putLong("folder", folder.id);
}
}); sendResult(RESULT_OK);
dismiss();
rvFolder.setAdapter(adapter); }
});
adapter.setDisabled(Helper.fromLongArray(getArguments().getLongArray("disabled")));
adapter.set(folders); rvFolder.setAdapter(adapter);
pbWait.setVisibility(View.GONE); adapter.setDisabled(Helper.fromLongArray(getArguments().getLongArray("disabled")));
rvFolder.setVisibility(View.VISIBLE); adapter.set(folders);
rvFolder.setVisibility(View.VISIBLE);
}
} }
@Override @Override

@ -4,6 +4,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<TextView
android:id="@+id/tvNoFolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="24dp"
android:text="@string/title_no_folders"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvFolder" android:id="@+id/rvFolder"
android:layout_width="match_parent" android:layout_width="match_parent"

@ -424,6 +424,7 @@
<string name="title_folder_thread">Conversation %1$s</string> <string name="title_folder_thread">Conversation %1$s</string>
<string name="title_folders_unified">Unified inbox folders</string> <string name="title_folders_unified">Unified inbox folders</string>
<string name="title_no_messages">No messages</string> <string name="title_no_messages">No messages</string>
<string name="title_no_folders">No folders</string>
<string name="title_subject_reply">Re: %1$s</string> <string name="title_subject_reply">Re: %1$s</string>
<string name="title_subject_forward">Fwd: %1$s</string> <string name="title_subject_forward">Fwd: %1$s</string>

Loading…
Cancel
Save