reversed quick return when 'read from bottom' is on
This commit is contained in:
parent
a8e5e62b99
commit
afc8f0ac04
|
@ -145,8 +145,8 @@ dependencies {
|
||||||
compile 'com.lnikkila:extendedtouchview:0.1.0'
|
compile 'com.lnikkila:extendedtouchview:0.1.0'
|
||||||
compile 'com.google.dagger:dagger:2.1'
|
compile 'com.google.dagger:dagger:2.1'
|
||||||
compile 'org.attoparser:attoparser:1.4.0.RELEASE'
|
compile 'org.attoparser:attoparser:1.4.0.RELEASE'
|
||||||
compile 'com.github.mariotaku.MediaViewerLibrary:base:0.9.15-SNAPSHOT'
|
compile 'com.github.mariotaku.MediaViewerLibrary:base:0.9.15'
|
||||||
compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.15-SNAPSHOT'
|
compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.15'
|
||||||
compile 'com.github.mariotaku.SQLiteQB:library:0.9.6'
|
compile 'com.github.mariotaku.SQLiteQB:library:0.9.6'
|
||||||
compile 'com.github.mariotaku.ObjectCursor:core:0.9.7'
|
compile 'com.github.mariotaku.ObjectCursor:core:0.9.7'
|
||||||
compile 'com.github.mariotaku:MultiValueSwitch:0.9.4'
|
compile 'com.github.mariotaku:MultiValueSwitch:0.9.4'
|
||||||
|
|
|
@ -504,6 +504,7 @@ public abstract class AbsActivitiesFragment extends AbsContentListRecyclerViewFr
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
mScrollListener.setReversed(mPreferences.getBoolean(KEY_READ_FROM_BOTTOM));
|
||||||
final ParcelableActivitiesAdapter adapter = getAdapter();
|
final ParcelableActivitiesAdapter adapter = getAdapter();
|
||||||
final RecyclerView recyclerView = getRecyclerView();
|
final RecyclerView recyclerView = getRecyclerView();
|
||||||
final LinearLayoutManager layoutManager = getLayoutManager();
|
final LinearLayoutManager layoutManager = getLayoutManager();
|
||||||
|
|
|
@ -71,7 +71,7 @@ public abstract class AbsContentRecyclerViewFragment<A extends LoadMoreSupportAd
|
||||||
|
|
||||||
// Callbacks and listeners
|
// Callbacks and listeners
|
||||||
private SimpleDrawerCallback mDrawerCallback;
|
private SimpleDrawerCallback mDrawerCallback;
|
||||||
private RecyclerViewScrollHandler mScrollListener;
|
protected RecyclerViewScrollHandler mScrollListener;
|
||||||
|
|
||||||
// Data fields
|
// Data fields
|
||||||
private Rect mSystemWindowsInsets = new Rect();
|
private Rect mSystemWindowsInsets = new Rect();
|
||||||
|
@ -251,8 +251,8 @@ public abstract class AbsContentRecyclerViewFragment<A extends LoadMoreSupportAd
|
||||||
mRecyclerView.setAdapter(mAdapter);
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
mScrollListener = new RecyclerViewScrollHandler(this, new RecyclerViewScrollHandler.RecyclerViewCallback(mRecyclerView));
|
mScrollListener = new RecyclerViewScrollHandler(this, new RecyclerViewScrollHandler.RecyclerViewCallback(mRecyclerView));
|
||||||
mRecyclerView.setOnTouchListener(mScrollListener.getOnTouchListener());
|
|
||||||
mScrollListener.setTouchSlop(ViewConfiguration.get(context).getScaledTouchSlop());
|
mScrollListener.setTouchSlop(ViewConfiguration.get(context).getScaledTouchSlop());
|
||||||
|
mRecyclerView.setOnTouchListener(mScrollListener.getOnTouchListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void setupRecyclerView(Context context, boolean compact);
|
protected abstract void setupRecyclerView(Context context, boolean compact);
|
||||||
|
|
|
@ -506,6 +506,7 @@ public abstract class AbsStatusesFragment extends AbsContentListRecyclerViewFrag
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
mScrollListener.setReversed(mPreferences.getBoolean(KEY_READ_FROM_BOTTOM));
|
||||||
final ParcelableStatusesAdapter adapter = getAdapter();
|
final ParcelableStatusesAdapter adapter = getAdapter();
|
||||||
final RecyclerView recyclerView = getRecyclerView();
|
final RecyclerView recyclerView = getRecyclerView();
|
||||||
final LinearLayoutManager layoutManager = getLayoutManager();
|
final LinearLayoutManager layoutManager = getLayoutManager();
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package org.mariotaku.twidere.fragment;
|
package org.mariotaku.twidere.fragment;
|
||||||
|
|
||||||
import android.content.Context;
|
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.os.Bundle;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.LoaderManager;
|
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.UserKey;
|
||||||
import org.mariotaku.twidere.model.util.ParcelableGroupUtils;
|
import org.mariotaku.twidere.model.util.ParcelableGroupUtils;
|
||||||
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
import org.mariotaku.twidere.util.TwitterAPIFactory;
|
||||||
|
import org.mariotaku.twidere.util.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mariotaku on 16/3/23.
|
* Created by mariotaku on 16/3/23.
|
||||||
|
@ -37,6 +42,18 @@ public class GroupFragment extends AbsToolbarTabPagesFragment implements
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(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);
|
getGroupInfo(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +107,10 @@ public class GroupFragment extends AbsToolbarTabPagesFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ParcelableGroup getGroup() {
|
||||||
|
return mGroup;
|
||||||
|
}
|
||||||
|
|
||||||
static class ParcelableGroupLoader extends AsyncTaskLoader<SingleResponse<ParcelableGroup>> {
|
static class ParcelableGroupLoader extends AsyncTaskLoader<SingleResponse<ParcelableGroup>> {
|
||||||
|
|
||||||
private final boolean mOmitIntentExtra;
|
private final boolean mOmitIntentExtra;
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class ContentScrollHandler {
|
||||||
private int mScrollState;
|
private int mScrollState;
|
||||||
private int mScrollSum;
|
private int mScrollSum;
|
||||||
private int mTouchSlop;
|
private int mTouchSlop;
|
||||||
|
private boolean mReversed;
|
||||||
|
|
||||||
private int mScrollDirection;
|
private int mScrollDirection;
|
||||||
|
|
||||||
|
@ -53,6 +54,10 @@ public class ContentScrollHandler {
|
||||||
mTouchSlop = touchSlop;
|
mTouchSlop = touchSlop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setReversed(boolean inversed) {
|
||||||
|
mReversed = inversed;
|
||||||
|
}
|
||||||
|
|
||||||
public View.OnTouchListener getOnTouchListener() {
|
public View.OnTouchListener getOnTouchListener() {
|
||||||
return mTouchListener;
|
return mTouchListener;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +127,7 @@ public class ContentScrollHandler {
|
||||||
}
|
}
|
||||||
mScrollSum += dy;
|
mScrollSum += dy;
|
||||||
if (Math.abs(mScrollSum) > mTouchSlop) {
|
if (Math.abs(mScrollSum) > mTouchSlop) {
|
||||||
mContentListSupport.setControlVisible(dy < 0);
|
mContentListSupport.setControlVisible(mReversed ^ dy < 0);
|
||||||
mScrollSum = 0;
|
mScrollSum = 0;
|
||||||
}
|
}
|
||||||
if (scrollState == idleState) {
|
if (scrollState == idleState) {
|
||||||
|
|
|
@ -19,6 +19,10 @@ public class RecyclerViewScrollHandler extends RecyclerView.OnScrollListener {
|
||||||
mScrollHandler = new ContentScrollHandler(contentListSupport, viewCallback);
|
mScrollHandler = new ContentScrollHandler(contentListSupport, viewCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setReversed(boolean inversed) {
|
||||||
|
mScrollHandler.setReversed(inversed);
|
||||||
|
}
|
||||||
|
|
||||||
public void setTouchSlop(int touchSlop) {
|
public void setTouchSlop(int touchSlop) {
|
||||||
mScrollHandler.setTouchSlop(touchSlop);
|
mScrollHandler.setTouchSlop(touchSlop);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue