diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/TopicActivity.java index f377f485..bd3bec83 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/TopicActivity.java @@ -60,9 +60,10 @@ public class TopicActivity extends BaseActivity { private LinearLayout postsLinearLayout; private static final int NO_POST_FOCUS = -1; private int postFocus = NO_POST_FOCUS; + //Quote //TODO - /* --Posts end-- */ + /* --Topic's pages-- */ private int thisPage = 1; private String base_url = ""; @@ -77,11 +78,14 @@ public class TopicActivity extends BaseActivity { private static final int SMALL_STEP = 1; private static final int LARGE_STEP = 10; private Integer pageValue; - /* --Topic's pages end-- */ + private ImageButton firstPage; + private ImageButton previousPage; + private ImageButton nextPage; + private ImageButton lastPage; + /* --Thumbnail-- */ private static final int THUMBNAIL_SIZE = 80; private ImageLoader imageLoader = ImageController.getInstance().getImageLoader(); - /* --Thumbnail end-- */ //Other variables private ProgressBar progressBar; @@ -113,17 +117,20 @@ public class TopicActivity extends BaseActivity { if(!Objects.equals(topicTitle, "")) actionbar.setTitle(topicTitle); - - ImageButton firstPage = (ImageButton) findViewById(R.id.page_first_button); - ImageButton previousPage = (ImageButton) findViewById(R.id.page_previous_button); + firstPage = (ImageButton) findViewById(R.id.page_first_button); + previousPage = (ImageButton) findViewById(R.id.page_previous_button); pageIndicator = (TextView) findViewById(R.id.page_indicator); - ImageButton nextPage = (ImageButton) findViewById(R.id.page_next_button); - ImageButton lastPage = (ImageButton) findViewById(R.id.page_last_button); + nextPage = (ImageButton) findViewById(R.id.page_next_button); + lastPage = (ImageButton) findViewById(R.id.page_last_button); initDecrementButton(firstPage, LARGE_STEP); initDecrementButton(previousPage, SMALL_STEP); initIncrementButton(nextPage, SMALL_STEP); initIncrementButton(lastPage, LARGE_STEP); + firstPage.setEnabled(false); + previousPage.setEnabled(false); + nextPage.setEnabled(false); + lastPage.setEnabled(false); new TopicTask().execute(extras.getString("TOPIC_URL")); //Attempt data parsing } @@ -501,6 +508,12 @@ public class TopicActivity extends BaseActivity { } } + //Now that parsing is complete and we have the url for every page enable page nav buttons + firstPage.setEnabled(true); + previousPage.setEnabled(true); + nextPage.setEnabled(true); + lastPage.setEnabled(true); + //Initialize an inflater LayoutInflater inflater = (LayoutInflater) getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); @@ -662,7 +675,7 @@ public class TopicActivity extends BaseActivity { private float downCoordinateY; private final float SCROLL_THRESHOLD = 7; - Runnable WebViewLongClick = new Runnable() { + final Runnable WebViewLongClick = new Runnable() { public void run() { wasLongClick = true; //TODO diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java new file mode 100644 index 00000000..fe760787 --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java @@ -0,0 +1,32 @@ +package gr.thmmy.mthmmy.utils; + +import android.content.Context; +import android.support.design.widget.CoordinatorLayout; +import android.support.design.widget.FloatingActionButton; +import android.util.AttributeSet; +import android.view.View; + +public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior { + public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { + super(); + } + + @Override + public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, + final View directTargetChild, final View target, final int nestedScrollAxes) { + return true; + } + + @Override + public void onNestedScroll(final CoordinatorLayout coordinatorLayout, + final FloatingActionButton child, + final View target, final int dxConsumed, final int dyConsumed, + final int dxUnconsumed, final int dyUnconsumed) { + super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed,dxUnconsumed, dyUnconsumed); + if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { + child.hide(); + } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { + child.show(); + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index 93d28888..1a83cc4d 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -1,17 +1,20 @@ - + @@ -27,77 +30,75 @@ - + app:elevation="8dp"> - + android:layout_weight="0.8" + android:background="@color/primary" + android:contentDescription="@string/text_first" + app:srcCompat="@drawable/page_first"/> - - - + - + - + - + - - - + + - +