reversed quick return when 'read from bottom' is on

This commit is contained in:
Mariotaku Lee 2016-04-02 18:35:50 +08:00
parent a8e5e62b99
commit afc8f0ac04
7 changed files with 37 additions and 5 deletions

View File

@ -145,8 +145,8 @@ dependencies {
compile 'com.lnikkila:extendedtouchview:0.1.0'
compile 'com.google.dagger:dagger:2.1'
compile 'org.attoparser:attoparser:1.4.0.RELEASE'
compile 'com.github.mariotaku.MediaViewerLibrary:base:0.9.15-SNAPSHOT'
compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.15-SNAPSHOT'
compile 'com.github.mariotaku.MediaViewerLibrary:base:0.9.15'
compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.15'
compile 'com.github.mariotaku.SQLiteQB:library:0.9.6'
compile 'com.github.mariotaku.ObjectCursor:core:0.9.7'
compile 'com.github.mariotaku:MultiValueSwitch:0.9.4'

View File

@ -504,6 +504,7 @@ public abstract class AbsActivitiesFragment extends AbsContentListRecyclerViewFr
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mScrollListener.setReversed(mPreferences.getBoolean(KEY_READ_FROM_BOTTOM));
final ParcelableActivitiesAdapter adapter = getAdapter();
final RecyclerView recyclerView = getRecyclerView();
final LinearLayoutManager layoutManager = getLayoutManager();

View File

@ -71,7 +71,7 @@ public abstract class AbsContentRecyclerViewFragment<A extends LoadMoreSupportAd
// Callbacks and listeners
private SimpleDrawerCallback mDrawerCallback;
private RecyclerViewScrollHandler mScrollListener;
protected RecyclerViewScrollHandler mScrollListener;
// Data fields
private Rect mSystemWindowsInsets = new Rect();
@ -251,8 +251,8 @@ public abstract class AbsContentRecyclerViewFragment<A extends LoadMoreSupportAd
mRecyclerView.setAdapter(mAdapter);
mScrollListener = new RecyclerViewScrollHandler(this, new RecyclerViewScrollHandler.RecyclerViewCallback(mRecyclerView));
mRecyclerView.setOnTouchListener(mScrollListener.getOnTouchListener());
mScrollListener.setTouchSlop(ViewConfiguration.get(context).getScaledTouchSlop());
mRecyclerView.setOnTouchListener(mScrollListener.getOnTouchListener());
}
protected abstract void setupRecyclerView(Context context, boolean compact);

View File

@ -506,6 +506,7 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mScrollListener.setReversed(mPreferences.getBoolean(KEY_READ_FROM_BOTTOM));
final ParcelableStatusesAdapter adapter = getAdapter();
final RecyclerView recyclerView = getRecyclerView();
final LinearLayoutManager layoutManager = getLayoutManager();

View File

@ -1,6 +1,10 @@
package org.mariotaku.twidere.fragment;
import android.content.Context;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.nfc.NfcEvent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager;
@ -18,6 +22,7 @@ import org.mariotaku.twidere.model.SingleResponse;
import org.mariotaku.twidere.model.UserKey;
import org.mariotaku.twidere.model.util.ParcelableGroupUtils;
import org.mariotaku.twidere.util.TwitterAPIFactory;
import org.mariotaku.twidere.util.Utils;
/**
* Created by mariotaku on 16/3/23.
@ -37,6 +42,18 @@ public class GroupFragment extends AbsToolbarTabPagesFragment implements
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Utils.setNdefPushMessageCallback(getActivity(), new NfcAdapter.CreateNdefMessageCallback() {
@Override
public NdefMessage createNdefMessage(NfcEvent event) {
final ParcelableGroup group = getGroup();
if (group == null || group.url == null) return null;
return new NdefMessage(new NdefRecord[]{
NdefRecord.createUri(group.url),
});
}
});
getGroupInfo(false);
}
@ -90,6 +107,10 @@ public class GroupFragment extends AbsToolbarTabPagesFragment implements
}
}
public ParcelableGroup getGroup() {
return mGroup;
}
static class ParcelableGroupLoader extends AsyncTaskLoader<SingleResponse<ParcelableGroup>> {
private final boolean mOmitIntentExtra;

View File

@ -40,6 +40,7 @@ public class ContentScrollHandler {
private int mScrollState;
private int mScrollSum;
private int mTouchSlop;
private boolean mReversed;
private int mScrollDirection;
@ -53,6 +54,10 @@ public class ContentScrollHandler {
mTouchSlop = touchSlop;
}
public void setReversed(boolean inversed) {
mReversed = inversed;
}
public View.OnTouchListener getOnTouchListener() {
return mTouchListener;
}
@ -122,7 +127,7 @@ public class ContentScrollHandler {
}
mScrollSum += dy;
if (Math.abs(mScrollSum) > mTouchSlop) {
mContentListSupport.setControlVisible(dy < 0);
mContentListSupport.setControlVisible(mReversed ^ dy < 0);
mScrollSum = 0;
}
if (scrollState == idleState) {

View File

@ -19,6 +19,10 @@ public class RecyclerViewScrollHandler extends RecyclerView.OnScrollListener {
mScrollHandler = new ContentScrollHandler(contentListSupport, viewCallback);
}
public void setReversed(boolean inversed) {
mScrollHandler.setReversed(inversed);
}
public void setTouchSlop(int touchSlop) {
mScrollHandler.setTouchSlop(touchSlop);
}