Browse Source

Code cleanup and Downloads hotfix.

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
6763b4d081
  1. 1
      app/src/main/AndroidManifest.xml
  2. 36
      app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
  3. 18
      app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java
  4. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java
  5. 33
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  6. 11
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  7. 5
      app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java
  8. 5
      app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java
  9. 22
      app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java
  10. 15
      app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java
  11. 1
      app/src/main/res/layout/dialog_topic_info.xml
  12. 1
      app/src/main/res/layout/fragment_unread_mark_read_row.xml

1
app/src/main/AndroidManifest.xml

@ -90,7 +90,6 @@
</activity> </activity>
<activity <activity
android:name=".activities.downloads.DownloadsActivity" android:name=".activities.downloads.DownloadsActivity"
android:launchMode="singleInstance"
android:parentActivityName=".activities.main.MainActivity" android:parentActivityName=".activities.main.MainActivity"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<meta-data <meta-data

36
app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java

@ -26,6 +26,7 @@ import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.model.Board; import gr.thmmy.mthmmy.model.Board;
import gr.thmmy.mthmmy.model.ThmmyPage; import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.model.TopicSummary; import gr.thmmy.mthmmy.model.TopicSummary;
import timber.log.Timber;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL;
@ -39,7 +40,7 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL;
public class MainActivity extends BaseActivity implements RecentFragment.RecentFragmentInteractionListener, ForumFragment.ForumFragmentInteractionListener, UnreadFragment.UnreadFragmentInteractionListener { public class MainActivity extends BaseActivity implements RecentFragment.RecentFragmentInteractionListener, ForumFragment.ForumFragmentInteractionListener, UnreadFragment.UnreadFragmentInteractionListener {
//-----------------------------------------CLASS VARIABLES------------------------------------------ //-----------------------------------------CLASS VARIABLES------------------------------------------
private static final int TIME_INTERVAL = 2000; private static final int TIME_INTERVAL = 2000;
private long mBackPressed; private long mBackPressed;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
@ -52,8 +53,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
redirectToActivityFromIntent(intentFilter); redirectToActivityFromIntent(intentFilter);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
if (sessionManager.isLoginScreenDefault()) if (sessionManager.isLoginScreenDefault()) {
{
//Go to login //Go to login
Intent intent = new Intent(MainActivity.this, LoginActivity.class); Intent intent = new Intent(MainActivity.this, LoginActivity.class);
startActivity(intent); startActivity(intent);
@ -68,7 +68,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
sectionsPagerAdapter.addFragment(RecentFragment.newInstance(1), "RECENT"); sectionsPagerAdapter.addFragment(RecentFragment.newInstance(1), "RECENT");
sectionsPagerAdapter.addFragment(ForumFragment.newInstance(2), "FORUM"); sectionsPagerAdapter.addFragment(ForumFragment.newInstance(2), "FORUM");
if(sessionManager.isLoggedIn()) if (sessionManager.isLoggedIn())
sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD"); sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD");
@ -129,13 +129,13 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
@Override @Override
public void onUnreadFragmentInteraction(TopicSummary topicSummary) { public void onUnreadFragmentInteraction(TopicSummary topicSummary) {
if (topicSummary.getLastUser() == null && topicSummary.getDateTimeModified() == null) { if (topicSummary.getTopicUrl() != null) {
return; //TODO! Intent i = new Intent(MainActivity.this, TopicActivity.class);
} i.putExtra(BUNDLE_TOPIC_URL, topicSummary.getTopicUrl());
Intent i = new Intent(MainActivity.this, TopicActivity.class); i.putExtra(BUNDLE_TOPIC_TITLE, topicSummary.getSubject());
i.putExtra(BUNDLE_TOPIC_URL, topicSummary.getTopicUrl()); startActivity(i);
i.putExtra(BUNDLE_TOPIC_TITLE, topicSummary.getSubject()); } else
startActivity(i); Timber.e("onUnreadFragmentInteraction TopicSummary came without a link");
} }
//---------------------------------FragmentPagerAdapter--------------------------------------------- //---------------------------------FragmentPagerAdapter---------------------------------------------
@ -164,8 +164,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
fragmentList.remove(position); fragmentList.remove(position);
fragmentTitleList.remove(position); fragmentTitleList.remove(position);
notifyDataSetChanged(); notifyDataSetChanged();
if(viewPager.getCurrentItem()==position) if (viewPager.getCurrentItem() == position)
viewPager.setCurrentItem(position-1); viewPager.setCurrentItem(position - 1);
} }
@Override @Override
@ -185,16 +185,16 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
@Override @Override
public int getItemPosition(Object object) { public int getItemPosition(Object object) {
int position = fragmentList.indexOf(object); @SuppressWarnings("RedundantCast")
int position = fragmentList.indexOf((Fragment) object);
return position == -1 ? POSITION_NONE : position; return position == -1 ? POSITION_NONE : position;
} }
} }
public void updateTabs() public void updateTabs() {
{ if (!sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 3)
if(!sessionManager.isLoggedIn()&&sectionsPagerAdapter.getCount()==3)
sectionsPagerAdapter.removeFragment(2); sectionsPagerAdapter.removeFragment(2);
else if(sessionManager.isLoggedIn()&&sectionsPagerAdapter.getCount()==2) else if (sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 2)
sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD"); sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD");
} }
//-------------------------------FragmentPagerAdapter END------------------------------------------- //-------------------------------FragmentPagerAdapter END-------------------------------------------

18
app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java

@ -58,18 +58,18 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
} }
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
if (holder instanceof UnreadAdapter.EmptyViewHolder) { if (holder instanceof UnreadAdapter.EmptyViewHolder) {
final UnreadAdapter.EmptyViewHolder emptyViewHolder = (UnreadAdapter.EmptyViewHolder) holder; final UnreadAdapter.EmptyViewHolder emptyViewHolder = (UnreadAdapter.EmptyViewHolder) holder;
emptyViewHolder.text.setText(unreadList.get(position).getDateTimeModified()); emptyViewHolder.text.setText(unreadList.get(holder.getAdapterPosition()).getDateTimeModified());
} else if (holder instanceof UnreadAdapter.ViewHolder) { } else if (holder instanceof UnreadAdapter.ViewHolder) {
final UnreadAdapter.ViewHolder viewHolder = (UnreadAdapter.ViewHolder) holder; final UnreadAdapter.ViewHolder viewHolder = (UnreadAdapter.ViewHolder) holder;
viewHolder.mTitleView.setText(unreadList.get(position).getSubject()); viewHolder.mTitleView.setText(unreadList.get(holder.getAdapterPosition()).getSubject());
viewHolder.mDateTimeView.setText(unreadList.get(position).getDateTimeModified()); viewHolder.mDateTimeView.setText(unreadList.get(holder.getAdapterPosition()).getDateTimeModified());
viewHolder.mUserView.setText(context.getString(R.string.byUser, unreadList.get(position).getLastUser())); viewHolder.mUserView.setText(context.getString(R.string.byUser, unreadList.get(position).getLastUser()));
viewHolder.topic = unreadList.get(position); viewHolder.topic = unreadList.get(holder.getAdapterPosition());
viewHolder.mView.setOnClickListener(new View.OnClickListener() { viewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -83,8 +83,8 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
}); });
} else if (holder instanceof UnreadAdapter.MarkReadViewHolder) { } else if (holder instanceof UnreadAdapter.MarkReadViewHolder) {
final UnreadAdapter.MarkReadViewHolder markReadViewHolder = (UnreadAdapter.MarkReadViewHolder) holder; final UnreadAdapter.MarkReadViewHolder markReadViewHolder = (UnreadAdapter.MarkReadViewHolder) holder;
markReadViewHolder.text.setText(unreadList.get(position).getSubject()); markReadViewHolder.text.setText(unreadList.get(holder.getAdapterPosition()).getSubject());
markReadViewHolder.topic = unreadList.get(position); markReadViewHolder.topic = unreadList.get(holder.getAdapterPosition());
markReadViewHolder.mView.setOnClickListener(new View.OnClickListener() { markReadViewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -92,7 +92,7 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (null != mListener) { if (null != mListener) {
// Notify the active callbacks interface (the activity, if the // Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected. // fragment is attached to one) that an item has been selected.
markReadListener.onMarkReadInteraction(unreadList.get(position).getTopicUrl()); markReadListener.onMarkReadInteraction(unreadList.get(holder.getAdapterPosition()).getTopicUrl());
} }
} }
}); });
@ -141,7 +141,7 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
} }
} }
public interface MarkReadInteractionListener { interface MarkReadInteractionListener {
void onMarkReadInteraction(String markReadLinkUrl); void onMarkReadInteraction(String markReadLinkUrl);
} }
} }

2
app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java

@ -33,7 +33,7 @@ import timber.log.Timber;
/** /**
* Use the {@link LatestPostsFragment#newInstance} factory method to create an instance of this fragment. * Use the {@link LatestPostsFragment#newInstance} factory method to create an instance of this fragment.
*/ */
public class LatestPostsFragment extends BaseFragment implements LatestPostsAdapter.OnLoadMoreListener{ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdapter.OnLoadMoreListener {
/** /**
* The key to use when putting profile's url String to {@link LatestPostsFragment}'s Bundle. * The key to use when putting profile's url String to {@link LatestPostsFragment}'s Bundle.
*/ */

33
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -241,7 +241,6 @@ public class TopicActivity extends BaseActivity {
LayoutInflater inflater = this.getLayoutInflater(); LayoutInflater inflater = this.getLayoutInflater();
LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info
, null); , null);
((TextView) infoDialog.findViewById(R.id.dialog_title)).setText("Info");
TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods); TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods);
treeAndMods.setText(topicTreeAndMods); treeAndMods.setText(topicTreeAndMods);
treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); treeAndMods.setMovementMethod(LinkMovementMethod.getInstance());
@ -317,25 +316,25 @@ public class TopicActivity extends BaseActivity {
lastPage.setEnabled(enabled); lastPage.setEnabled(enabled);
} }
private void paginationEnabledExcept(boolean enabled, View exception) { private void paginationDisable(View exception) {
if (exception == firstPage) { if (exception == firstPage) {
previousPage.setEnabled(enabled); previousPage.setEnabled(false);
nextPage.setEnabled(enabled); nextPage.setEnabled(false);
lastPage.setEnabled(enabled); lastPage.setEnabled(false);
} else if (exception == previousPage) { } else if (exception == previousPage) {
firstPage.setEnabled(enabled); firstPage.setEnabled(false);
nextPage.setEnabled(enabled); nextPage.setEnabled(false);
lastPage.setEnabled(enabled); lastPage.setEnabled(false);
} else if (exception == nextPage) { } else if (exception == nextPage) {
firstPage.setEnabled(enabled); firstPage.setEnabled(false);
previousPage.setEnabled(enabled); previousPage.setEnabled(false);
lastPage.setEnabled(enabled); lastPage.setEnabled(false);
} else if (exception == lastPage) { } else if (exception == lastPage) {
firstPage.setEnabled(enabled); firstPage.setEnabled(false);
previousPage.setEnabled(enabled); previousPage.setEnabled(false);
nextPage.setEnabled(enabled); nextPage.setEnabled(false);
} else { } else {
paginationEnabled(enabled); paginationEnabled(false);
} }
} }
@ -356,7 +355,7 @@ public class TopicActivity extends BaseActivity {
increment.setOnLongClickListener( increment.setOnLongClickListener(
new View.OnLongClickListener() { new View.OnLongClickListener() {
public boolean onLongClick(View arg0) { public boolean onLongClick(View arg0) {
paginationEnabledExcept(false, arg0); paginationDisable(arg0);
autoIncrement = true; autoIncrement = true;
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY);
return false; return false;
@ -404,7 +403,7 @@ public class TopicActivity extends BaseActivity {
decrement.setOnLongClickListener( decrement.setOnLongClickListener(
new View.OnLongClickListener() { new View.OnLongClickListener() {
public boolean onLongClick(View arg0) { public boolean onLongClick(View arg0) {
paginationEnabledExcept(false, arg0); paginationDisable(arg0);
autoDecrement = true; autoDecrement = true;
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY);
return false; return false;

11
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -138,10 +138,8 @@ public abstract class BaseActivity extends AppCompatActivity {
private AccountHeader accountHeader; private AccountHeader accountHeader;
private ProfileDrawerItem profileDrawerItem; private ProfileDrawerItem profileDrawerItem;
private PrimaryDrawerItem homeItem, downloadsItem, bookmarksItem, loginLogoutItem, aboutItem; private PrimaryDrawerItem downloadsItem, loginLogoutItem;
private IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected, private IconicsDrawable loginIcon, logoutIcon;
bookmarksIcon, bookmarksIconSelected, loginIcon, logoutIcon, aboutIcon,
aboutIconSelected;
/** /**
* Call only after initializing Toolbar * Call only after initializing Toolbar
@ -151,6 +149,11 @@ public abstract class BaseActivity extends AppCompatActivity {
final int selectedPrimaryColor = ContextCompat.getColor(this, R.color.primary_dark); final int selectedPrimaryColor = ContextCompat.getColor(this, R.color.primary_dark);
final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.accent); final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.accent);
PrimaryDrawerItem homeItem, bookmarksItem, aboutItem;
IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected,
bookmarksIcon, bookmarksIconSelected, aboutIcon,
aboutIconSelected;
//Drawer Icons //Drawer Icons
homeIcon = new IconicsDrawable(this) homeIcon = new IconicsDrawable(this)
.icon(FontAwesome.Icon.faw_home) .icon(FontAwesome.Icon.faw_home)

5
app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java

@ -13,15 +13,12 @@ public abstract class BaseFragment extends Fragment {
protected FragmentInteractionListener fragmentInteractionListener; protected FragmentInteractionListener fragmentInteractionListener;
private String TAG;
private int sectionNumber;
protected static OkHttpClient client; protected static OkHttpClient client;
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
TAG = getArguments().getString(ARG_TAG); //int sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER);
sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER);
if (client == null) if (client == null)
client = BaseApplication.getInstance().getClient(); //must check every time - e.g. client = BaseApplication.getInstance().getClient(); //must check every time - e.g.
// becomes null when app restarts after crash // becomes null when app restarts after crash

5
app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java

@ -3,12 +3,11 @@ package gr.thmmy.mthmmy.utils;
import android.content.Context; import android.content.Context;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import timber.log.Timber; import timber.log.Timber;
public class CustomLinearLayoutManager extends LinearLayoutManager { public class CustomLinearLayoutManager extends LinearLayoutManager {
private String pageUrl; private final String pageUrl;
public CustomLinearLayoutManager(Context context, String pageUrl) { public CustomLinearLayoutManager(Context context, String pageUrl) {
super(context); super(context);
@ -21,8 +20,6 @@ public class CustomLinearLayoutManager extends LinearLayoutManager {
super.onLayoutChildren(recycler, state); super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
Timber.wtf(e, "Inconsistency detected: topic_requested = \"" + pageUrl + "\""); Timber.wtf(e, "Inconsistency detected: topic_requested = \"" + pageUrl + "\"");
Log.d("CustomLinearLayoutMan", "Inconsistency detected: topic_requested = \""
+ pageUrl + "\"", e);
} }
} }

22
app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java

@ -1,6 +1,7 @@
package gr.thmmy.mthmmy.utils; package gr.thmmy.mthmmy.utils;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
@ -11,27 +12,28 @@ import android.view.View;
* Extends FloatingActionButton's behavior so the button will hide when scrolling down and show * Extends FloatingActionButton's behavior so the button will hide when scrolling down and show
* otherwise. * otherwise.
*/ */
@SuppressWarnings("WeakerAccess") @SuppressWarnings("unused")
public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> { public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> {
String TAG = "ScrollAwareFABBehavior";
@SuppressWarnings("UnusedParameters")
public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { public ScrollAwareFABBehavior(Context context, AttributeSet attrs) {
super(); super();
} }
@Override @Override
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, public boolean onStartNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout,
final View directTargetChild, final View target, final int nestedScrollAxes) { @NonNull final FloatingActionButton child,
@NonNull final View directTargetChild, @NonNull final View target,
final int nestedScrollAxes, int type) {
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL; return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL;
} }
@Override @Override
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, public void onNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout,
final FloatingActionButton child, @NonNull final FloatingActionButton child,
final View target, final int dxConsumed, final int dyConsumed, @NonNull final View target, final int dxConsumed, final int dyConsumed,
final int dxUnconsumed, final int dyUnconsumed) { final int dxUnconsumed, final int dyUnconsumed, int type) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
dyUnconsumed, type);
if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0 if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0
&& dyUnconsumed < 40)) && child.getVisibility() == View.VISIBLE) { && dyUnconsumed < 40)) && child.getVisibility() == View.VISIBLE) {
child.hide(new FloatingActionButton.OnVisibilityChangedListener() { child.hide(new FloatingActionButton.OnVisibilityChangedListener() {

15
app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java

@ -2,6 +2,7 @@ package gr.thmmy.mthmmy.utils;
import android.animation.Animator; import android.animation.Animator;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.CoordinatorLayout;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.support.v4.view.animation.FastOutSlowInInterpolator;
@ -14,7 +15,7 @@ import android.view.ViewPropertyAnimator;
* <p>When a nested ScrollView is scrolled down, the view will disappear. * <p>When a nested ScrollView is scrolled down, the view will disappear.
* When the ScrollView is scrolled back up, the view will reappear.</p> * When the ScrollView is scrolled back up, the view will reappear.</p>
*/ */
@SuppressWarnings("WeakerAccess") @SuppressWarnings("unused")
public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior<View> { public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior<View> {
private static final int ANIMATION_DURATION = 100; private static final int ANIMATION_DURATION = 100;
@ -23,15 +24,19 @@ public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior<View>
} }
@Override @Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) { public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
@NonNull View child, @NonNull View directTargetChild,
@NonNull View target, int nestedScrollAxes, int type) {
return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0; return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
} }
@Override @Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, View bottomNavBar, View target, public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
@NonNull View bottomNavBar, @NonNull View target,
int dxConsumed, int dyConsumed, int dxConsumed, int dyConsumed,
int dxUnconsumed, int dyUnconsumed) { int dxUnconsumed, int dyUnconsumed, int type) {
super.onNestedScroll(coordinatorLayout, bottomNavBar, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); super.onNestedScroll(coordinatorLayout, bottomNavBar, target, dxConsumed, dyConsumed,
dxUnconsumed, dyUnconsumed, type);
if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0 if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0
&& dyUnconsumed < 40)) && bottomNavBar.getVisibility() == View.VISIBLE) { && dyUnconsumed < 40)) && bottomNavBar.getVisibility() == View.VISIBLE) {
hide(bottomNavBar); hide(bottomNavBar);

1
app/src/main/res/layout/dialog_topic_info.xml

@ -8,6 +8,7 @@
<TextView <TextView
android:id="@+id/dialog_title" android:id="@+id/dialog_title"
android:text="@string/info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="20dp" android:layout_marginBottom="20dp"

1
app/src/main/res/layout/fragment_unread_mark_read_row.xml

@ -4,6 +4,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:paddingStart="10dp"
android:paddingTop="7dp"> android:paddingTop="7dp">
<TextView <TextView

Loading…
Cancel
Save