|
@ -103,11 +103,6 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
* long click is held in either first or last buttons |
|
|
* long click is held in either first or last buttons |
|
|
*/ |
|
|
*/ |
|
|
private static final int LARGE_STEP = 10; |
|
|
private static final int LARGE_STEP = 10; |
|
|
/** |
|
|
|
|
|
* Holds the value (index) of the page to be requested when a user interaction with bottom |
|
|
|
|
|
* navigation bar occurs |
|
|
|
|
|
*/ |
|
|
|
|
|
private Integer pageRequestValue; |
|
|
|
|
|
|
|
|
|
|
|
//Bottom navigation bar graphics related
|
|
|
//Bottom navigation bar graphics related
|
|
|
private LinearLayout bottomNavBar; |
|
|
private LinearLayout bottomNavBar; |
|
@ -206,6 +201,11 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
|
|
|
|
|
|
paginationEnabled(false); |
|
|
paginationEnabled(false); |
|
|
|
|
|
|
|
|
|
|
|
viewModel.getPageIndicatorIndex().observe(this, pageIndicatorIndex -> { |
|
|
|
|
|
if (pageIndicatorIndex == null) return; |
|
|
|
|
|
pageIndicator.setText(String.valueOf(pageIndicatorIndex) + "/" + |
|
|
|
|
|
String.valueOf(viewModel.getPageCount())); |
|
|
|
|
|
}); |
|
|
viewModel.getTopicTaskResult().observe(this, topicTaskResult -> { |
|
|
viewModel.getTopicTaskResult().observe(this, topicTaskResult -> { |
|
|
if (topicTaskResult == null) { |
|
|
if (topicTaskResult == null) { |
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
|
progressBar.setVisibility(ProgressBar.VISIBLE); |
|
@ -222,9 +222,6 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
postsList.addAll(topicTaskResult.getNewPostsList()); |
|
|
postsList.addAll(topicTaskResult.getNewPostsList()); |
|
|
topicAdapter.notifyDataSetChanged(); |
|
|
topicAdapter.notifyDataSetChanged(); |
|
|
|
|
|
|
|
|
pageIndicator.setText(String.valueOf(topicTaskResult.getCurrentPageIndex()) + "/" + |
|
|
|
|
|
String.valueOf(topicTaskResult.getPageCount())); |
|
|
|
|
|
pageRequestValue = topicTaskResult.getCurrentPageIndex(); |
|
|
|
|
|
paginationEnabled(true); |
|
|
paginationEnabled(true); |
|
|
|
|
|
|
|
|
if (topicTaskResult.getCurrentPageIndex() == topicTaskResult.getPageCount()) { |
|
|
if (topicTaskResult.getCurrentPageIndex() == topicTaskResult.getPageCount()) { |
|
@ -400,10 +397,10 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
public void run() { |
|
|
public void run() { |
|
|
long REPEAT_DELAY = 250; |
|
|
long REPEAT_DELAY = 250; |
|
|
if (autoIncrement) { |
|
|
if (autoIncrement) { |
|
|
incrementPageRequestValue(step); |
|
|
viewModel.incrementPageRequestValue(step); |
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), REPEAT_DELAY); |
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), REPEAT_DELAY); |
|
|
} else if (autoDecrement) { |
|
|
} else if (autoDecrement) { |
|
|
decrementPageRequestValue(step); |
|
|
viewModel.decrementPageRequestValue(step); |
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), REPEAT_DELAY); |
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), REPEAT_DELAY); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -443,11 +440,11 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
// Increment once for a click
|
|
|
// Increment once for a click
|
|
|
increment.setOnClickListener(v -> { |
|
|
increment.setOnClickListener(v -> { |
|
|
if (!autoIncrement && step == LARGE_STEP) { |
|
|
if (!autoIncrement && step == LARGE_STEP) { |
|
|
incrementPageRequestValue(viewModel.getPageCount()); |
|
|
viewModel.incrementPageRequestValue(viewModel.getPageCount()); |
|
|
viewModel.changePage(viewModel.getPageCount() - 1); |
|
|
viewModel.changePage(viewModel.getPageCount() - 1); |
|
|
} else if (!autoIncrement) { |
|
|
} else if (!autoIncrement) { |
|
|
incrementPageRequestValue(step); |
|
|
viewModel.incrementPageRequestValue(step); |
|
|
viewModel.changePage(pageRequestValue - 1); |
|
|
viewModel.changePage(viewModel.getPageIndicatorIndex().getValue() - 1); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -471,11 +468,12 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
} else if (rect != null && event.getAction() == MotionEvent.ACTION_UP && autoIncrement) { |
|
|
} else if (rect != null && event.getAction() == MotionEvent.ACTION_UP && autoIncrement) { |
|
|
autoIncrement = false; |
|
|
autoIncrement = false; |
|
|
paginationEnabled(true); |
|
|
paginationEnabled(true); |
|
|
viewModel.changePage(pageRequestValue - 1); |
|
|
viewModel.changePage(viewModel.getPageIndicatorIndex().getValue() - 1); |
|
|
} else if (rect != null && event.getAction() == MotionEvent.ACTION_MOVE) { |
|
|
} else if (rect != null && event.getAction() == MotionEvent.ACTION_MOVE) { |
|
|
if (!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { |
|
|
if (!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { |
|
|
autoIncrement = false; |
|
|
autoIncrement = false; |
|
|
decrementPageRequestValue(pageRequestValue - viewModel.getCurrentPageIndex()); |
|
|
viewModel.decrementPageRequestValue(viewModel.getPageIndicatorIndex().getValue() |
|
|
|
|
|
- viewModel.getCurrentPageIndex()); |
|
|
paginationEnabled(true); |
|
|
paginationEnabled(true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -489,11 +487,11 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
// Decrement once for a click
|
|
|
// Decrement once for a click
|
|
|
decrement.setOnClickListener(v -> { |
|
|
decrement.setOnClickListener(v -> { |
|
|
if (!autoDecrement && step == LARGE_STEP) { |
|
|
if (!autoDecrement && step == LARGE_STEP) { |
|
|
decrementPageRequestValue(viewModel.getPageCount()); |
|
|
viewModel.decrementPageRequestValue(viewModel.getPageCount()); |
|
|
viewModel.changePage(0); |
|
|
viewModel.changePage(0); |
|
|
} else if (!autoDecrement) { |
|
|
} else if (!autoDecrement) { |
|
|
decrementPageRequestValue(step); |
|
|
viewModel.decrementPageRequestValue(step); |
|
|
viewModel.changePage(pageRequestValue - 1); |
|
|
viewModel.changePage(viewModel.getPageIndicatorIndex().getValue() - 1); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -517,12 +515,13 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
} else if (event.getAction() == MotionEvent.ACTION_UP && autoDecrement) { |
|
|
} else if (event.getAction() == MotionEvent.ACTION_UP && autoDecrement) { |
|
|
autoDecrement = false; |
|
|
autoDecrement = false; |
|
|
paginationEnabled(true); |
|
|
paginationEnabled(true); |
|
|
viewModel.changePage(pageRequestValue - 1); |
|
|
viewModel.changePage(viewModel.getPageIndicatorIndex().getValue() - 1); |
|
|
} else if (event.getAction() == MotionEvent.ACTION_MOVE) { |
|
|
} else if (event.getAction() == MotionEvent.ACTION_MOVE) { |
|
|
if (rect != null && |
|
|
if (rect != null && |
|
|
!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { |
|
|
!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { |
|
|
autoIncrement = false; |
|
|
autoIncrement = false; |
|
|
incrementPageRequestValue(viewModel.getCurrentPageIndex() - pageRequestValue); |
|
|
viewModel.incrementPageRequestValue(viewModel.getCurrentPageIndex() |
|
|
|
|
|
- viewModel.getPageIndicatorIndex().getValue()); |
|
|
paginationEnabled(true); |
|
|
paginationEnabled(true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -531,22 +530,6 @@ public class TopicActivity extends BaseActivity implements TopicTask.TopicTaskOb |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void incrementPageRequestValue(int step) { |
|
|
|
|
|
if (pageRequestValue < viewModel.getPageCount() - step) { |
|
|
|
|
|
pageRequestValue = pageRequestValue + step; |
|
|
|
|
|
} else |
|
|
|
|
|
pageRequestValue = viewModel.getPageCount(); |
|
|
|
|
|
pageIndicator.setText(pageRequestValue + "/" + String.valueOf(viewModel.getPageCount())); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void decrementPageRequestValue(int step) { |
|
|
|
|
|
if (pageRequestValue > step) |
|
|
|
|
|
pageRequestValue = pageRequestValue - step; |
|
|
|
|
|
else |
|
|
|
|
|
pageRequestValue = 1; |
|
|
|
|
|
pageIndicator.setText(pageRequestValue + "/" + String.valueOf(viewModel.getPageCount())); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------BOTTOM NAV BAR METHODS END------------------------------------
|
|
|
//------------------------------------BOTTOM NAV BAR METHODS END------------------------------------
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|