Added seek bar

pull/147/head
M66B 7 years ago
parent ac02d5989e
commit e7ec4db73f

@ -51,6 +51,7 @@ import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.TextView;
import com.google.android.material.bottomnavigation.BottomNavigationView;
@ -100,6 +101,7 @@ public class FragmentMessages extends FragmentBase {
private ImageButton ibHintSelect;
private TextView tvNoEmail;
private FixedRecyclerView rvMessage;
private SeekBar seekBar;
private BottomNavigationView bottom_navigation;
private ContentLoadingProgressBar pbWait;
private Group grpSupport;
@ -218,6 +220,7 @@ public class FragmentMessages extends FragmentBase {
ibHintSelect = view.findViewById(R.id.ibHintSelect);
tvNoEmail = view.findViewById(R.id.tvNoEmail);
rvMessage = view.findViewById(R.id.rvMessage);
seekBar = view.findViewById(R.id.seekBar);
bottom_navigation = view.findViewById(R.id.bottom_navigation);
pbWait = view.findViewById(R.id.pbWait);
grpSupport = view.findViewById(R.id.grpSupport);
@ -291,6 +294,84 @@ public class FragmentMessages extends FragmentBase {
rvMessage.setAdapter(adapter);
new ItemTouchHelper(touchHelper).attachToRecyclerView(rvMessage);
bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.action_delete:
onActionMove(EntityFolder.TRASH);
return true;
case R.id.action_archive:
onActionMove(EntityFolder.ARCHIVE);
return true;
case R.id.action_prev:
navigate(previous, true);
return true;
case R.id.action_next:
navigate(next, false);
return true;
default:
return false;
}
}
});
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EntityFolder drafts = (EntityFolder) fab.getTag();
startActivity(new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "new")
.putExtra("account", drafts.account)
);
}
});
fab.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
EntityFolder drafts = (EntityFolder) fab.getTag();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("account", drafts.account)
.putExtra("folder", drafts.id));
return true;
}
});
fabMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onMore();
}
});
((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener);
// Initialize
swipeRefresh.setEnabled(pull);
tvNoEmail.setVisibility(View.GONE);
seekBar.setEnabled(false);
seekBar.setVisibility(View.GONE);
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(false);
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(false);
bottom_navigation.setVisibility(View.GONE);
grpReady.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
fab.hide();
fabMore.hide();
if (viewType == AdapterMessage.ViewType.THREAD) {
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
model.observePrevNext(getViewLifecycleOwner(), id, new ViewModelMessages.IPrevNext() {
@ -305,6 +386,13 @@ public class FragmentMessages extends FragmentBase {
next = id;
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(id != null);
}
@Override
public void onFound(int position, int size) {
seekBar.setProgress(position);
seekBar.setMax(size - 1);
seekBar.setVisibility(View.VISIBLE);
}
});
ActivityBase activity = (ActivityBase) getActivity();
@ -371,82 +459,6 @@ public class FragmentMessages extends FragmentBase {
});
}
new ItemTouchHelper(touchHelper).attachToRecyclerView(rvMessage);
bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.action_delete:
onActionMove(EntityFolder.TRASH);
return true;
case R.id.action_archive:
onActionMove(EntityFolder.ARCHIVE);
return true;
case R.id.action_prev:
navigate(previous, true);
return true;
case R.id.action_next:
navigate(next, false);
return true;
default:
return false;
}
}
});
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EntityFolder drafts = (EntityFolder) fab.getTag();
startActivity(new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "new")
.putExtra("account", drafts.account)
);
}
});
fab.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
EntityFolder drafts = (EntityFolder) fab.getTag();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("account", drafts.account)
.putExtra("folder", drafts.id));
return true;
}
});
fabMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onMore();
}
});
((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener);
// Initialize
swipeRefresh.setEnabled(pull);
tvNoEmail.setVisibility(View.GONE);
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(false);
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(false);
bottom_navigation.setVisibility(View.GONE);
grpReady.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
fab.hide();
fabMore.hide();
return view;
}
@ -1799,6 +1811,11 @@ public class FragmentMessages extends FragmentBase {
}
}
}
@Override
public void onFound(int position, int size) {
// Do nothing
}
});
} else
loadMessagesNext();

@ -99,17 +99,19 @@ public class ViewModelMessages extends ViewModel {
TupleMessageEx next = messages.get(pos - 1);
if (next == null)
load = true;
reportNext(intf, true, next == null ? null : next.id);
intf.onNext(true, next == null ? null : next.id);
} else
reportNext(intf, false, null);
intf.onNext(false, null);
if (pos + 1 < messages.size()) {
TupleMessageEx prev = messages.get(pos + 1);
if (prev == null)
load = true;
reportPrevious(intf, true, prev == null ? null : prev.id);
intf.onPrevious(true, prev == null ? null : prev.id);
} else
reportPrevious(intf, false, null);
intf.onPrevious(false, null);
intf.onFound(pos, messages.size());
if (load)
messages.loadAround(pos);
@ -123,19 +125,11 @@ public class ViewModelMessages extends ViewModel {
});
}
private void reportPrevious(IPrevNext intf, boolean exists, Long id) {
Log.i("Previous exists=" + exists + " id=" + id);
intf.onPrevious(exists, id);
}
private void reportNext(IPrevNext intf, boolean exists, Long id) {
Log.i("Next exists=" + exists + " id=" + id);
intf.onNext(exists, id);
}
interface IPrevNext {
void onPrevious(boolean exists, Long id);
void onNext(boolean exists, Long id);
void onFound(int position, int size);
}
}

@ -135,7 +135,7 @@
android:layout_height="wrap_content"
android:text="@string/title_no_messages"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorHintSelect" />
@ -146,7 +146,7 @@
android:layout_height="0dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorHintSelect" />
@ -157,11 +157,19 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintBottom_toTopOf="@+id/seekBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorHintSelect" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"

Loading…
Cancel
Save