Small improvements

This commit is contained in:
M66B 2019-01-17 12:14:16 +00:00
parent 6157eece5e
commit 3113d71ced
4 changed files with 13 additions and 8 deletions

View File

@ -52,8 +52,8 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
private EntityAccount primary = null;
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
View itemView;
TextView tvName;
private View itemView;
private TextView tvName;
ViewHolder(View itemView) {
super(itemView);

View File

@ -73,7 +73,7 @@ public class FragmentAnswer extends FragmentBase {
public boolean onNavigationItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.action_delete:
onActionTrash();
onActionDelete();
return true;
case R.id.action_save:
onActionSave();
@ -108,7 +108,7 @@ public class FragmentAnswer extends FragmentBase {
new SimpleTask<EntityAnswer>() {
@Override
protected EntityAnswer onExecute(Context context, Bundle args) throws Throwable {
protected EntityAnswer onExecute(Context context, Bundle args) {
long id = args.getLong("id");
return DB.getInstance(context).answer().getAnswer(id);
}
@ -130,7 +130,7 @@ public class FragmentAnswer extends FragmentBase {
}.execute(this, args, "answer:get");
}
private void onActionTrash() {
private void onActionDelete() {
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(R.string.title_ask_delete_answer)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

View File

@ -26,6 +26,7 @@ import android.view.ViewGroup;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
@ -90,7 +91,11 @@ public class FragmentAnswers extends FragmentBase {
db.answer().liveAnswers().observe(getViewLifecycleOwner(), new Observer<List<EntityAnswer>>() {
@Override
public void onChanged(List<EntityAnswer> answers) {
if (answers == null)
answers = new ArrayList<>();
adapter.set(answers);
pbWait.setVisibility(View.GONE);
grpReady.setVisibility(View.VISIBLE);
}

View File

@ -8,14 +8,14 @@
android:id="@+id/tvName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Name"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@+id/tvSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -23,8 +23,8 @@
android:id="@+id/vSeparator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="6dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvName" />