removed unused code
fallback to basic image viewer when gif library failed to load improved keyboard shortcut in accounts dashboard
This commit is contained in:
parent
5d7765b6d3
commit
68ba8d458c
|
@ -29,6 +29,8 @@ import android.net.NetworkInfo;
|
|||
|
||||
public class NetworkStateUtil {
|
||||
|
||||
public static final int TYPE_NO_NETWORK = -1;
|
||||
|
||||
private static int getConnectedTypeValue(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
|
@ -41,33 +43,22 @@ public class NetworkStateUtil {
|
|||
return -1;
|
||||
}
|
||||
|
||||
public static String getConnectedType (Context context) {
|
||||
int type = -1;
|
||||
type = getConnectedTypeValue(context);
|
||||
String network = "unknown";
|
||||
switch (type) {
|
||||
case 0:
|
||||
network = "cellular";
|
||||
break;
|
||||
case 1:
|
||||
network = "wifi";
|
||||
break;
|
||||
case 2:
|
||||
network = "wimax";
|
||||
break;
|
||||
case 3:
|
||||
network = "ethernet";
|
||||
break;
|
||||
case 4:
|
||||
network = "bluetooth";
|
||||
break;
|
||||
case -1:
|
||||
network = "ERROR";
|
||||
break;
|
||||
public static String getConnectedType(Context context) {
|
||||
switch (getConnectedTypeValue(context)) {
|
||||
case ConnectivityManager.TYPE_MOBILE:
|
||||
return "cellular";
|
||||
case ConnectivityManager.TYPE_WIFI:
|
||||
return "wifi";
|
||||
case ConnectivityManager.TYPE_WIMAX:
|
||||
return "wimax";
|
||||
case ConnectivityManager.TYPE_ETHERNET:
|
||||
return "ethernet";
|
||||
case ConnectivityManager.TYPE_BLUETOOTH:
|
||||
return "bluetooth";
|
||||
case TYPE_NO_NETWORK:
|
||||
return "ERROR";
|
||||
default:
|
||||
network = "unknown";
|
||||
break;
|
||||
return "unknown";
|
||||
}
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ import android.support.v4.app.NotificationCompat;
|
|||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
|
@ -74,7 +73,6 @@ import org.mariotaku.twidere.activity.UsageStatisticsActivity;
|
|||
import org.mariotaku.twidere.adapter.support.SupportTabsAdapter;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.CustomTabsFragment;
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment;
|
||||
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
|
||||
import org.mariotaku.twidere.fragment.support.AccountsDashboardFragment;
|
||||
|
@ -138,7 +136,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
|
||||
private final ContentObserver mAccountChangeObserver = new AccountChangeObserver(this, mHandler);
|
||||
|
||||
private final SparseArray<Fragment> mAttachedFragments = new SparseArray<>();
|
||||
private ParcelableAccount mSelectedAccountToSearch;
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
|
@ -164,7 +161,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
private RightDrawerFrameLayout mRightDrawerContainer;
|
||||
private TintedStatusFrameLayout mColorStatusFrameLayout;
|
||||
|
||||
private Fragment mCurrentVisibleFragment;
|
||||
private UpdateUnreadCountTask mUpdateUnreadCountTask;
|
||||
|
||||
private int mTabDisplayOption;
|
||||
|
@ -184,35 +180,31 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
mSlidingMenu.showContent();
|
||||
}
|
||||
|
||||
public long[] getActivatedAccountIds() {
|
||||
final Fragment fragment = getLeftDrawerFragment();
|
||||
if (fragment instanceof AccountsDashboardFragment) {
|
||||
return ((AccountsDashboardFragment) fragment).getActivatedAccountIds();
|
||||
}
|
||||
return Utils.getActivatedAccountIds(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getCurrentVisibleFragment() {
|
||||
return mCurrentVisibleFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachFragment(final Fragment fragment) {
|
||||
if (fragment instanceof IBaseFragment && ((IBaseFragment) fragment).getTabPosition() != -1) {
|
||||
mAttachedFragments.remove(((IBaseFragment) fragment).getTabPosition());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetUserVisibleHint(final Fragment fragment, final boolean isVisibleToUser) {
|
||||
if (isVisibleToUser) {
|
||||
mCurrentVisibleFragment = fragment;
|
||||
}
|
||||
final int currentItem = mViewPager.getCurrentItem();
|
||||
if (currentItem < 0 || currentItem >= mPagerAdapter.getCount()) return null;
|
||||
return (Fragment) mPagerAdapter.instantiateItem(mViewPager, currentItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh(final int position) {
|
||||
final Fragment f = mAttachedFragments.get(position);
|
||||
return f instanceof RefreshScrollTopInterface && !f.isDetached()
|
||||
&& ((RefreshScrollTopInterface) f).triggerRefresh();
|
||||
final Fragment f = (Fragment) mPagerAdapter.instantiateItem(mViewPager, position);
|
||||
if (!(f instanceof RefreshScrollTopInterface)) return false;
|
||||
if (f.getActivity() == null || f.isDetached()) return false;
|
||||
return ((RefreshScrollTopInterface) f).triggerRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlBarVisibleAnimate(boolean visible) {
|
||||
mControlBarShowHideHelper.setControlBarVisibleAnimate(visible);
|
||||
public Fragment getLeftDrawerFragment() {
|
||||
return getSupportFragmentManager().findFragmentById(R.id.left_drawer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -223,15 +215,8 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setControlBarOffset(float offset) {
|
||||
mTabsContainer.setTranslationY(mTabColumns > 1 ? 0 : getControlBarHeight() * (offset - 1));
|
||||
final ViewGroup.LayoutParams lp = mActionsButton.getLayoutParams();
|
||||
if (lp instanceof MarginLayoutParams) {
|
||||
mActionsButton.setTranslationY((((MarginLayoutParams) lp).bottomMargin + mActionsButton.getHeight()) * (1 - offset));
|
||||
} else {
|
||||
mActionsButton.setTranslationY(mActionsButton.getHeight() * (1 - offset));
|
||||
}
|
||||
notifyControlBarOffsetChanged();
|
||||
public void setControlBarVisibleAnimate(boolean visible) {
|
||||
mControlBarShowHideHelper.setControlBarVisibleAnimate(visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -298,15 +283,29 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
switch (action) {
|
||||
case "navigation.previous_tab": {
|
||||
final int previous = mViewPager.getCurrentItem() - 1;
|
||||
if (previous >= 0 && previous < mPagerAdapter.getCount()) {
|
||||
mViewPager.setCurrentItem(previous, true);
|
||||
if (previous < 0) {
|
||||
mSlidingMenu.showMenu(true);
|
||||
setControlBarVisibleAnimate(true);
|
||||
} else if (previous < mPagerAdapter.getCount()) {
|
||||
if (mSlidingMenu.isSecondaryMenuShowing()) {
|
||||
mSlidingMenu.showContent(true);
|
||||
} else {
|
||||
mViewPager.setCurrentItem(previous, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "navigation.next_tab": {
|
||||
final int next = mViewPager.getCurrentItem() + 1;
|
||||
if (next >= 0 && next < mPagerAdapter.getCount()) {
|
||||
mViewPager.setCurrentItem(next, true);
|
||||
if (next >= mPagerAdapter.getCount()) {
|
||||
mSlidingMenu.showSecondaryMenu(true);
|
||||
setControlBarVisibleAnimate(true);
|
||||
} else if (next >= 0) {
|
||||
if (mSlidingMenu.isMenuShowing()) {
|
||||
mSlidingMenu.showContent(true);
|
||||
} else {
|
||||
mViewPager.setCurrentItem(next, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -315,6 +314,18 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
return mKeyboardShortcutsHandler.handleKey(this, null, keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlBarOffset(float offset) {
|
||||
mTabsContainer.setTranslationY(mTabColumns > 1 ? 0 : getControlBarHeight() * (offset - 1));
|
||||
final ViewGroup.LayoutParams lp = mActionsButton.getLayoutParams();
|
||||
if (lp instanceof MarginLayoutParams) {
|
||||
mActionsButton.setTranslationY((((MarginLayoutParams) lp).bottomMargin + mActionsButton.getHeight()) * (1 - offset));
|
||||
} else {
|
||||
mActionsButton.setTranslationY(mActionsButton.getHeight() * (1 - offset));
|
||||
}
|
||||
notifyControlBarOffsetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutRepeat(int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||
if (handleFragmentKeyboardShortcutRepeat(keyCode, repeatCount, event)) return true;
|
||||
|
@ -569,29 +580,13 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
}
|
||||
|
||||
public void setSystemWindowInsets(Rect insets) {
|
||||
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.left_drawer);
|
||||
final Fragment fragment = getLeftDrawerFragment();
|
||||
if (fragment instanceof AccountsDashboardFragment) {
|
||||
((AccountsDashboardFragment) fragment).setStatusBarHeight(insets.top);
|
||||
}
|
||||
mColorStatusFrameLayout.setStatusBarHeight(insets.top);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getControlBarOffset() {
|
||||
if (mTabColumns > 1) {
|
||||
final ViewGroup.LayoutParams lp = mActionsButton.getLayoutParams();
|
||||
float total;
|
||||
if (lp instanceof MarginLayoutParams) {
|
||||
total = ((MarginLayoutParams) lp).bottomMargin + mActionsButton.getHeight();
|
||||
} else {
|
||||
total = mActionsButton.getHeight();
|
||||
}
|
||||
return 1 - mActionsButton.getTranslationY() / total;
|
||||
}
|
||||
final float totalHeight = getControlBarHeight();
|
||||
return 1 + mTabsContainer.getTranslationY() / totalHeight;
|
||||
}
|
||||
|
||||
public void updateUnreadCount() {
|
||||
if (mTabIndicator == null || mUpdateUnreadCountTask != null
|
||||
&& mUpdateUnreadCountTask.getStatus() == AsyncTask.Status.RUNNING) return;
|
||||
|
@ -612,11 +607,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlBarHeight() {
|
||||
return mTabIndicator.getHeight() - mTabIndicator.getStripHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(final Intent intent) {
|
||||
final int tabPosition = handleIntent(intent, false);
|
||||
|
@ -625,13 +615,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachFragment(final Fragment fragment) {
|
||||
if (fragment instanceof IBaseFragment && ((IBaseFragment) fragment).getTabPosition() != -1) {
|
||||
mAttachedFragments.put(((IBaseFragment) fragment).getTabPosition(), fragment);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// Delete unused items in databases.
|
||||
|
@ -649,6 +632,22 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getControlBarOffset() {
|
||||
if (mTabColumns > 1) {
|
||||
final ViewGroup.LayoutParams lp = mActionsButton.getLayoutParams();
|
||||
float total;
|
||||
if (lp instanceof MarginLayoutParams) {
|
||||
total = ((MarginLayoutParams) lp).bottomMargin + mActionsButton.getHeight();
|
||||
} else {
|
||||
total = mActionsButton.getHeight();
|
||||
}
|
||||
return 1 - mActionsButton.getTranslationY() / total;
|
||||
}
|
||||
final float totalHeight = getControlBarHeight();
|
||||
return 1 + mTabsContainer.getTranslationY() / totalHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_MENU && event.getAction() == KeyEvent.ACTION_UP) {
|
||||
|
@ -675,26 +674,33 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
mColorStatusFrameLayout = (TintedStatusFrameLayout) findViewById(R.id.home_content);
|
||||
}
|
||||
|
||||
public long[] getActivatedAccountIds() {
|
||||
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.left_drawer);
|
||||
if (fragment instanceof AccountsDashboardFragment) {
|
||||
return ((AccountsDashboardFragment) fragment).getActivatedAccountIds();
|
||||
private Fragment getKeyboardShortcutRecipient() {
|
||||
if (mSlidingMenu.isMenuShowing()) {
|
||||
return getLeftDrawerFragment();
|
||||
} else if (mSlidingMenu.isSecondaryMenuShowing()) {
|
||||
return null;
|
||||
} else {
|
||||
return getCurrentVisibleFragment();
|
||||
}
|
||||
return Utils.getActivatedAccountIds(this);
|
||||
}
|
||||
|
||||
private boolean handleFragmentKeyboardShortcutSingle(int keyCode, @NonNull KeyEvent event) {
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
@Override
|
||||
public int getControlBarHeight() {
|
||||
return mTabIndicator.getHeight() - mTabIndicator.getStripHeight();
|
||||
}
|
||||
|
||||
private boolean handleFragmentKeyboardShortcutRepeat(int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||
final Fragment fragment = getKeyboardShortcutRecipient();
|
||||
if (fragment instanceof KeyboardShortcutCallback) {
|
||||
return ((KeyboardShortcutCallback) fragment).handleKeyboardShortcutSingle(keyCode, event);
|
||||
return ((KeyboardShortcutCallback) fragment).handleKeyboardShortcutRepeat(keyCode, repeatCount, event);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean handleFragmentKeyboardShortcutRepeat(int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
private boolean handleFragmentKeyboardShortcutSingle(int keyCode, @NonNull KeyEvent event) {
|
||||
final Fragment fragment = getKeyboardShortcutRecipient();
|
||||
if (fragment instanceof KeyboardShortcutCallback) {
|
||||
return ((KeyboardShortcutCallback) fragment).handleKeyboardShortcutRepeat(keyCode, repeatCount, event);
|
||||
return ((KeyboardShortcutCallback) fragment).handleKeyboardShortcutSingle(keyCode, event);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -957,7 +963,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
|||
mSlidingMenu.setTouchModeAbove(mode);
|
||||
}
|
||||
|
||||
|
||||
private static final class AccountChangeObserver extends ContentObserver {
|
||||
private final HomeActivity mActivity;
|
||||
|
||||
|
|
|
@ -80,16 +80,6 @@ public class LinkHandlerActivity extends BaseActionBarActivity implements System
|
|||
return getSupportFragmentManager().findFragmentById(R.id.main_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachFragment(Fragment fragment) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetUserVisibleHint(Fragment fragment, boolean isVisibleToUser) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh(int position) {
|
||||
return false;
|
||||
|
|
|
@ -81,6 +81,7 @@ import org.mariotaku.twidere.view.LinePageIndicator;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import pl.droidsonroids.gif.GifSupportChecker;
|
||||
import pl.droidsonroids.gif.GifTextureView;
|
||||
import pl.droidsonroids.gif.InputSource.FileSource;
|
||||
|
||||
|
@ -96,6 +97,8 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
private LinePageIndicator mIndicator;
|
||||
|
||||
|
||||
private static boolean ANIMATED_GIF_SUPPORTED = GifSupportChecker.isSupported();
|
||||
|
||||
@Override
|
||||
public int getThemeColor() {
|
||||
return ThemeUtils.getUserAccentColor(this);
|
||||
|
@ -211,11 +214,10 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
setBarVisibility(!isBarShowing());
|
||||
}
|
||||
|
||||
public static final class ImagePageFragment extends BaseSupportFragment
|
||||
public static class BaseImagePageFragment extends BaseSupportFragment
|
||||
implements DownloadListener, LoaderCallbacks<Result>, OnClickListener {
|
||||
|
||||
private SubsamplingScaleImageView mImageView;
|
||||
private GifTextureView mGifImageView;
|
||||
private ProgressWheel mProgressBar;
|
||||
private boolean mLoaderInitialized;
|
||||
private float mContentLength;
|
||||
|
@ -227,7 +229,6 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
public void onBaseViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onBaseViewCreated(view, savedInstanceState);
|
||||
mImageView = (SubsamplingScaleImageView) view.findViewById(R.id.image_view);
|
||||
mGifImageView = (GifTextureView) view.findViewById(R.id.gif_image_view);
|
||||
mProgressBar = (ProgressWheel) view.findViewById(R.id.load_progress);
|
||||
}
|
||||
|
||||
|
@ -240,7 +241,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
|
||||
@Override
|
||||
public Loader<Result> onCreateLoader(final int id, final Bundle args) {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
setLoadProgressVisibility(View.VISIBLE);
|
||||
mProgressBar.spin();
|
||||
invalidateOptionsMenu();
|
||||
final ParcelableMedia media = getMedia();
|
||||
|
@ -253,43 +254,43 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
if (data.hasData()) {
|
||||
mImageFile = data.file;
|
||||
if (data.useDecoder) {
|
||||
mGifImageView.setVisibility(View.GONE);
|
||||
mImageView.setVisibility(View.VISIBLE);
|
||||
setImageViewVisibility(View.VISIBLE);
|
||||
mImageView.setImage(ImageSource.uri(Uri.fromFile(data.file)));
|
||||
} else if ("image/gif".equals(data.options.outMimeType)) {
|
||||
mGifImageView.setVisibility(View.VISIBLE);
|
||||
mImageView.setVisibility(View.GONE);
|
||||
mGifImageView.setInputSource(new FileSource(data.file));
|
||||
updateScaleLimit();
|
||||
} else {
|
||||
mGifImageView.setVisibility(View.GONE);
|
||||
mImageView.setVisibility(View.VISIBLE);
|
||||
setImageViewVisibility(View.VISIBLE);
|
||||
mImageView.setImage(ImageSource.bitmap(data.bitmap));
|
||||
updateScaleLimit();
|
||||
}
|
||||
} else {
|
||||
mImageView.recycle();
|
||||
mImageFile = null;
|
||||
mImageView.setVisibility(View.GONE);
|
||||
mGifImageView.setVisibility(View.GONE);
|
||||
setImageViewVisibility(View.GONE);
|
||||
Utils.showErrorMessage(getActivity(), null, data.exception, true);
|
||||
}
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
mProgressBar.setProgress(0);
|
||||
setLoadProgressVisibility(View.GONE);
|
||||
setLoadProgress(0);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
protected void setImageViewVisibility(int visible) {
|
||||
mImageView.setVisibility(visible);
|
||||
|
||||
}
|
||||
|
||||
protected void setLoadProgress(float progress) {
|
||||
mProgressBar.setProgress(progress);
|
||||
}
|
||||
|
||||
protected void setLoadProgressVisibility(int visibility) {
|
||||
mProgressBar.setVisibility(visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<TileImageLoader.Result> loader) {
|
||||
// final Drawable drawable = mImageView.getDrawable();
|
||||
// if (drawable instanceof GifDrawable) {
|
||||
// ((GifDrawable) drawable).recycle();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_media_page_image, container, false);
|
||||
return inflater.inflate(R.layout.fragment_media_page_image_compat, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -316,17 +317,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
}
|
||||
return;
|
||||
}
|
||||
mProgressBar.setProgress(downloaded / mContentLength);
|
||||
}
|
||||
|
||||
public void onZoomIn() {
|
||||
final MediaViewerActivity activity = (MediaViewerActivity) getActivity();
|
||||
activity.setBarVisibility(false);
|
||||
}
|
||||
|
||||
public void onZoomOut() {
|
||||
final MediaViewerActivity activity = (MediaViewerActivity) getActivity();
|
||||
activity.setBarVisibility(true);
|
||||
setLoadProgress(downloaded / mContentLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -395,19 +386,6 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
mSaveFileTask.execute();
|
||||
}
|
||||
|
||||
private void updateScaleLimit() {
|
||||
// final int viewWidth = mImageView.getWidth(), viewHeight = mImageView.getHeight();
|
||||
// final Drawable drawable = mImageView.getDrawable();
|
||||
// if (drawable == null || viewWidth <= 0 || viewHeight <= 0) return;
|
||||
// final int drawableWidth = drawable.getIntrinsicWidth();
|
||||
// final int drawableHeight = drawable.getIntrinsicHeight();
|
||||
// if (drawableWidth <= 0 || drawableHeight <= 0) return;
|
||||
// final float widthRatio = viewWidth / (float) drawableWidth;
|
||||
// final float heightRatio = viewHeight / (float) drawableHeight;
|
||||
// mImageView.setMaxScale(Math.max(1, Math.max(heightRatio, widthRatio)));
|
||||
// mImageView.resetScale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
@ -444,15 +422,42 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static final class ImagePageFragment extends BaseImagePageFragment
|
||||
implements DownloadListener, LoaderCallbacks<Result>, OnClickListener {
|
||||
|
||||
private GifTextureView mGifImageView;
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
public void onBaseViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onBaseViewCreated(view, savedInstanceState);
|
||||
mGifImageView = (GifTextureView) view.findViewById(R.id.gif_image_view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
public void onLoadFinished(final Loader<TileImageLoader.Result> loader, final TileImageLoader.Result data) {
|
||||
if (data.hasData() && "image/gif".equals(data.options.outMimeType)) {
|
||||
mGifImageView.setVisibility(View.VISIBLE);
|
||||
setImageViewVisibility(View.GONE);
|
||||
mGifImageView.setInputSource(new FileSource(data.file));
|
||||
setLoadProgressVisibility(View.GONE);
|
||||
setLoadProgress(0);
|
||||
invalidateOptionsMenu();
|
||||
return;
|
||||
}
|
||||
super.onLoadFinished(loader, data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<TileImageLoader.Result> loader) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_media_page_image, container, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -491,7 +496,10 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
|||
return Fragment.instantiate(mActivity, VideoPageFragment.class.getName(), args);
|
||||
}
|
||||
default: {
|
||||
return Fragment.instantiate(mActivity, ImagePageFragment.class.getName(), args);
|
||||
if (ANIMATED_GIF_SUPPORTED) {
|
||||
return Fragment.instantiate(mActivity, ImagePageFragment.class.getName(), args);
|
||||
}
|
||||
return Fragment.instantiate(mActivity, BaseImagePageFragment.class.getName(), args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,10 +25,6 @@ public interface SupportFragmentCallback {
|
|||
|
||||
public Fragment getCurrentVisibleFragment();
|
||||
|
||||
public void onDetachFragment(Fragment fragment);
|
||||
|
||||
public void onSetUserVisibleHint(Fragment fragment, boolean isVisibleToUser);
|
||||
|
||||
public boolean triggerRefresh(int position);
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,10 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListFragment<A
|
|||
private PopupMenu mPopupMenu;
|
||||
private ReadStateManager mReadStateManager;
|
||||
private KeyboardShortcutsHandler mKeyboardShortcutsHandler;
|
||||
private RecyclerViewNavigationHelper mRecyclerViewNavigationHelper;
|
||||
|
||||
private ParcelableStatus mSelectedStatus;
|
||||
|
||||
private OnMenuItemClickListener mOnStatusMenuItemClickListener = new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
@ -72,7 +75,6 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListFragment<A
|
|||
getFragmentManager(), getTwitterWrapper(), status, item);
|
||||
}
|
||||
};
|
||||
private RecyclerViewNavigationHelper mRecyclerViewNavigationHelper;
|
||||
|
||||
protected AbsStatusesFragment() {
|
||||
mStatusesBusCallback = createMessageBusCallback();
|
||||
|
|
|
@ -40,6 +40,7 @@ import android.graphics.Rect;
|
|||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
|
@ -58,6 +59,7 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.support.v7.widget.RecyclerView.Adapter;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -93,6 +95,8 @@ import org.mariotaku.twidere.menu.SupportAccountActionProvider;
|
|||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Accounts;
|
||||
import org.mariotaku.twidere.util.CompareUtils;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.TransitionUtils;
|
||||
|
@ -112,9 +116,9 @@ import static org.mariotaku.twidere.util.Utils.openUserLists;
|
|||
import static org.mariotaku.twidere.util.Utils.openUserProfile;
|
||||
|
||||
public class AccountsDashboardFragment extends BaseSupportListFragment implements LoaderCallbacks<Cursor>,
|
||||
OnSharedPreferenceChangeListener, OnCheckedChangeListener, ImageLoadingListener, OnClickListener {
|
||||
OnSharedPreferenceChangeListener, OnCheckedChangeListener, ImageLoadingListener, OnClickListener,
|
||||
KeyboardShortcutCallback {
|
||||
|
||||
private static final int MENU_GROUP_ACCOUNT_TOGGLE = 101;
|
||||
private final SupportFragmentReloadCursorObserver mReloadContentObserver = new SupportFragmentReloadCursorObserver(
|
||||
this, 0, this);
|
||||
|
||||
|
@ -139,7 +143,63 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
private Context mThemedContext;
|
||||
private MediaLoaderWrapper mImageLoader;
|
||||
private SupportAccountActionProvider mAccountActionProvider;
|
||||
private KeyboardShortcutsHandler mKeyboardShortcutsHandler;
|
||||
|
||||
private boolean mSwitchAccountAnimationPlaying;
|
||||
|
||||
public long[] getActivatedAccountIds() {
|
||||
if (mAccountActionProvider == null) {
|
||||
return Utils.getActivatedAccountIds(getActivity());
|
||||
}
|
||||
return mAccountActionProvider.getActivatedAccountIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutSingle(int keyCode, @NonNull KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutRepeat(int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||
final String action = mKeyboardShortcutsHandler.getKeyAction("navigation", keyCode, event);
|
||||
if (action == null) return false;
|
||||
final int offset;
|
||||
switch (action) {
|
||||
case "navigation.previous": {
|
||||
offset = -1;
|
||||
break;
|
||||
}
|
||||
case "navigation.next": {
|
||||
offset = 1;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final ListView listView = getListView();
|
||||
int firstVisiblePosition = listView.getFirstVisiblePosition();
|
||||
final int selectedItem = listView.getSelectedItemPosition();
|
||||
final int count = listView.getCount();
|
||||
int resultPosition;
|
||||
if (!listView.isFocused() || selectedItem == ListView.INVALID_POSITION) {
|
||||
resultPosition = firstVisiblePosition;
|
||||
} else {
|
||||
resultPosition = selectedItem + offset;
|
||||
while (resultPosition >= 0 && resultPosition < count && !mAdapter.isEnabled(resultPosition)) {
|
||||
resultPosition += offset;
|
||||
}
|
||||
}
|
||||
final View focusedChild = listView.getFocusedChild();
|
||||
if (focusedChild == null) {
|
||||
listView.requestChildFocus(listView.getChildAt(0), null);
|
||||
}
|
||||
if (resultPosition >= 0 && resultPosition < count) {
|
||||
listView.setSelection(resultPosition);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
||||
switch (requestCode) {
|
||||
|
@ -340,9 +400,12 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
final View view = getView();
|
||||
if (view == null) throw new AssertionError();
|
||||
final Context context = view.getContext();
|
||||
mImageLoader = TwidereApplication.getInstance(context).getMediaLoaderWrapper();
|
||||
final TwidereApplication application = TwidereApplication.getInstance(context);
|
||||
mImageLoader = application.getMediaLoaderWrapper();
|
||||
mKeyboardShortcutsHandler = application.getKeyboardShortcutsHandler();
|
||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||
final ListView listView = getListView();
|
||||
listView.setItemsCanFocus(true);
|
||||
mAdapter = new MergeAdapter();
|
||||
mAccountsAdapter = new AccountSelectorAdapter(context, this);
|
||||
mAccountOptionsAdapter = new AccountOptionsAdapter(context);
|
||||
|
@ -381,7 +444,7 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
|
||||
mAccountProfileContainer.setOnClickListener(this);
|
||||
|
||||
mAdapter.addView(mAccountSelectorView, false);
|
||||
mAdapter.addView(mAccountSelectorView, true);
|
||||
mAdapter.addAdapter(mAccountOptionsAdapter);
|
||||
mAdapter.addView(mAppMenuSectionView, false);
|
||||
mAdapter.addAdapter(mAppMenuAdapter);
|
||||
|
@ -410,13 +473,6 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
super.onStop();
|
||||
}
|
||||
|
||||
public long[] getActivatedAccountIds() {
|
||||
if (mAccountActionProvider == null) {
|
||||
return Utils.getActivatedAccountIds(getActivity());
|
||||
}
|
||||
return mAccountActionProvider.getActivatedAccountIds();
|
||||
}
|
||||
|
||||
void initAccountActionsAdapter(ParcelableAccount[] accounts) {
|
||||
mAccountOptionsAdapter.clear();
|
||||
mAccountOptionsAdapter.add(new OptionItem(android.R.string.search_go, R.drawable.ic_action_search, MENU_SEARCH));
|
||||
|
@ -560,6 +616,8 @@ public class AccountsDashboardFragment extends BaseSupportListFragment implement
|
|||
final ImageView bannerView = mAccountProfileBannerView;
|
||||
if (bannerView.getDrawable() == null || !CompareUtils.objectEquals(bannerUrl, bannerView.getTag())) {
|
||||
mImageLoader.displayProfileBanner(mAccountProfileBannerView, bannerUrl, this);
|
||||
} else {
|
||||
mImageLoader.cancelDisplayTask(mAccountProfileBannerView);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.mariotaku.twidere.Constants;
|
|||
import org.mariotaku.twidere.activity.support.BaseActionBarActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment;
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
|
@ -148,32 +147,6 @@ public class BaseSupportFragment extends Fragment implements IBaseFragment, Cons
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
final Fragment fragment = getParentFragment();
|
||||
if (fragment instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) fragment).onDetachFragment(this);
|
||||
}
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) activity).onDetachFragment(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(final boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
final Activity activity = getActivity();
|
||||
final Fragment fragment = getParentFragment();
|
||||
if (fragment instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) fragment).onSetUserVisibleHint(this, isVisibleToUser);
|
||||
}
|
||||
if (activity instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) activity).onSetUserVisibleHint(this, isVisibleToUser);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fitSystemWindows(Rect insets) {
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.mariotaku.twidere.activity.iface.IControlBarActivity;
|
|||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment;
|
||||
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.ListScrollDistanceCalculator;
|
||||
import org.mariotaku.twidere.util.ListScrollDistanceCalculator.ScrollDistanceListener;
|
||||
|
@ -288,19 +287,6 @@ public class BaseSupportListFragment extends ListFragment implements IBaseFragme
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
final Fragment fragment = getParentFragment();
|
||||
if (fragment instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) fragment).onDetachFragment(this);
|
||||
}
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) activity).onDetachFragment(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPostStart() {
|
||||
}
|
||||
|
||||
|
@ -391,19 +377,6 @@ public class BaseSupportListFragment extends ListFragment implements IBaseFragme
|
|||
Utils.scrollListToPosition(getListView(), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(final boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
final Fragment fragment = getParentFragment();
|
||||
if (fragment instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) fragment).onSetUserVisibleHint(this, isVisibleToUser);
|
||||
}
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof SupportFragmentCallback) {
|
||||
((SupportFragmentCallback) activity).onSetUserVisibleHint(this, isVisibleToUser);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
return false;
|
||||
|
|
|
@ -62,10 +62,9 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
|
|||
private ViewPager mViewPager;
|
||||
private View mPagerWindowOverlay;
|
||||
|
||||
private SupportTabsAdapter mAdapter;
|
||||
private SupportTabsAdapter mPagerAdapter;
|
||||
private TabPagerIndicator mPagerIndicator;
|
||||
|
||||
private Fragment mCurrentVisibleFragment;
|
||||
private int mControlBarOffsetPixels;
|
||||
private int mControlBarHeight;
|
||||
|
||||
|
@ -153,7 +152,9 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
|
|||
|
||||
@Override
|
||||
public Fragment getCurrentVisibleFragment() {
|
||||
return mCurrentVisibleFragment;
|
||||
final int currentItem = mViewPager.getCurrentItem();
|
||||
if (currentItem < 0 || currentItem >= mPagerAdapter.getCount()) return null;
|
||||
return (Fragment) mPagerAdapter.instantiateItem(mViewPager, currentItem);
|
||||
}
|
||||
|
||||
public void hideIndicator() {
|
||||
|
@ -165,10 +166,10 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
|
|||
setHasOptionsMenu(true);
|
||||
final Bundle args = getArguments();
|
||||
final FragmentActivity activity = getActivity();
|
||||
mAdapter = new SupportTabsAdapter(activity, getChildFragmentManager(), null, 1);
|
||||
mAdapter.addTab(StatusesSearchFragment.class, args, getString(R.string.statuses), R.drawable.ic_action_twitter, 0, null);
|
||||
mAdapter.addTab(SearchUsersFragment.class, args, getString(R.string.users), R.drawable.ic_action_user, 1, null);
|
||||
mViewPager.setAdapter(mAdapter);
|
||||
mPagerAdapter = new SupportTabsAdapter(activity, getChildFragmentManager(), null, 1);
|
||||
mPagerAdapter.addTab(StatusesSearchFragment.class, args, getString(R.string.statuses), R.drawable.ic_action_twitter, 0, null);
|
||||
mPagerAdapter.addTab(SearchUsersFragment.class, args, getString(R.string.users), R.drawable.ic_action_user, 1, null);
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
mViewPager.setOffscreenPageLimit(2);
|
||||
mPagerIndicator.setViewPager(mViewPager);
|
||||
mPagerIndicator.setTabDisplayOption(TabPagerIndicator.LABEL);
|
||||
|
@ -212,11 +213,6 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
|
|||
return inflater.inflate(R.layout.fragment_content_pages, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachFragment(final Fragment fragment) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
@ -246,13 +242,6 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
|
|||
item.setTitle(getString(R.string.tweet_hashtag, getQuery()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetUserVisibleHint(final Fragment fragment, final boolean isVisibleToUser) {
|
||||
if (isVisibleToUser) {
|
||||
mCurrentVisibleFragment = fragment;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBaseViewCreated(final View view, final Bundle savedInstanceState) {
|
||||
super.onBaseViewCreated(view, savedInstanceState);
|
||||
|
@ -263,15 +252,17 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
|
|||
|
||||
@Override
|
||||
public boolean scrollToStart() {
|
||||
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) mCurrentVisibleFragment).scrollToStart();
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (!(fragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) fragment).scrollToStart();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) mCurrentVisibleFragment).triggerRefresh();
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (!(fragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) fragment).triggerRefresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
|
||||
private ActionBarDrawable mActionBarBackground;
|
||||
private Drawable mActionBarHomeAsUpIndicator;
|
||||
private Fragment mCurrentVisibleFragment;
|
||||
|
||||
|
||||
private final LoaderCallbacks<SingleResponse<Relationship>> mFriendshipLoaderCallbacks = new LoaderCallbacks<SingleResponse<Relationship>>() {
|
||||
|
@ -370,13 +369,13 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
|
||||
@Override
|
||||
public boolean canScroll(float dy) {
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
return fragment instanceof DrawerCallback && ((DrawerCallback) fragment).canScroll(dy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTouch() {
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (fragment instanceof DrawerCallback) {
|
||||
((DrawerCallback) fragment).cancelTouch();
|
||||
}
|
||||
|
@ -384,7 +383,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
|
||||
@Override
|
||||
public void fling(float velocity) {
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (fragment instanceof DrawerCallback) {
|
||||
((DrawerCallback) fragment).fling(velocity);
|
||||
}
|
||||
|
@ -448,7 +447,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
|
||||
@Override
|
||||
public void scrollBy(float dy) {
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (fragment instanceof DrawerCallback) {
|
||||
((DrawerCallback) fragment).scrollBy(dy);
|
||||
}
|
||||
|
@ -469,7 +468,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
final int offset = drawer.getPaddingTop() - top;
|
||||
updateScrollOffset(offset);
|
||||
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (fragment instanceof DrawerCallback) {
|
||||
((DrawerCallback) fragment).topChanged(top);
|
||||
}
|
||||
|
@ -546,17 +545,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
|
||||
@Override
|
||||
public Fragment getCurrentVisibleFragment() {
|
||||
return mCurrentVisibleFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachFragment(Fragment fragment) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetUserVisibleHint(Fragment fragment, boolean isVisibleToUser) {
|
||||
mCurrentVisibleFragment = isVisibleToUser ? fragment : null;
|
||||
final int currentItem = mViewPager.getCurrentItem();
|
||||
if (currentItem < 0 || currentItem >= mPagerAdapter.getCount()) return null;
|
||||
return (Fragment) mPagerAdapter.instantiateItem(mViewPager, currentItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1214,15 +1205,17 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
|||
|
||||
@Override
|
||||
public boolean scrollToStart() {
|
||||
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) mCurrentVisibleFragment).scrollToStart();
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (!(fragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) fragment).scrollToStart();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) mCurrentVisibleFragment).triggerRefresh();
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (!(fragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) fragment).triggerRefresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,17 +136,16 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList
|
|||
}
|
||||
};
|
||||
private boolean mUserListLoaderInitialized;
|
||||
private Fragment mCurrentVisibleFragment;
|
||||
|
||||
@Override
|
||||
public boolean canScroll(float dy) {
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
return fragment instanceof DrawerCallback && ((DrawerCallback) fragment).canScroll(dy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTouch() {
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (fragment instanceof DrawerCallback) {
|
||||
((DrawerCallback) fragment).cancelTouch();
|
||||
}
|
||||
|
@ -154,7 +153,7 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList
|
|||
|
||||
@Override
|
||||
public void fling(float velocity) {
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (fragment instanceof DrawerCallback) {
|
||||
((DrawerCallback) fragment).fling(velocity);
|
||||
}
|
||||
|
@ -171,7 +170,7 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList
|
|||
|
||||
@Override
|
||||
public void scrollBy(float dy) {
|
||||
final Fragment fragment = mCurrentVisibleFragment;
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (fragment instanceof DrawerCallback) {
|
||||
((DrawerCallback) fragment).scrollBy(dy);
|
||||
}
|
||||
|
@ -214,17 +213,9 @@ public class UserListFragment extends BaseSupportFragment implements OnClickList
|
|||
|
||||
@Override
|
||||
public Fragment getCurrentVisibleFragment() {
|
||||
return mCurrentVisibleFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachFragment(Fragment fragment) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetUserVisibleHint(Fragment fragment, boolean isVisibleToUser) {
|
||||
mCurrentVisibleFragment = isVisibleToUser ? fragment : null;
|
||||
final int currentItem = mViewPager.getCurrentItem();
|
||||
if (currentItem < 0 || currentItem >= mPagerAdapter.getCount()) return null;
|
||||
return (Fragment) mPagerAdapter.instantiateItem(mViewPager, currentItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,14 +42,14 @@ public class UserListsFragment extends BaseSupportFragment implements RefreshScr
|
|||
|
||||
private ViewPager mViewPager;
|
||||
|
||||
private SupportTabsAdapter mAdapter;
|
||||
private SupportTabsAdapter mPagerAdapter;
|
||||
private TabPagerIndicator mPagerIndicator;
|
||||
|
||||
private Fragment mCurrentVisibleFragment;
|
||||
|
||||
@Override
|
||||
public Fragment getCurrentVisibleFragment() {
|
||||
return mCurrentVisibleFragment;
|
||||
final int currentItem = mViewPager.getCurrentItem();
|
||||
if (currentItem < 0 || currentItem >= mPagerAdapter.getCount()) return null;
|
||||
return (Fragment) mPagerAdapter.instantiateItem(mViewPager, currentItem);
|
||||
}
|
||||
|
||||
public void hideIndicator() {
|
||||
|
@ -60,10 +60,10 @@ public class UserListsFragment extends BaseSupportFragment implements RefreshScr
|
|||
super.onActivityCreated(savedInstanceState);
|
||||
final Bundle args = getArguments();
|
||||
final FragmentActivity activity = getActivity();
|
||||
mAdapter = new SupportTabsAdapter(activity, getChildFragmentManager(), null, 1);
|
||||
mAdapter.addTab(UserListsListFragment.class, args, getString(R.string.follows), null, 0, null);
|
||||
mAdapter.addTab(UserListMembershipsListFragment.class, args, getString(R.string.belongs_to), 0, 1, null);
|
||||
mViewPager.setAdapter(mAdapter);
|
||||
mPagerAdapter = new SupportTabsAdapter(activity, getChildFragmentManager(), null, 1);
|
||||
mPagerAdapter.addTab(UserListsListFragment.class, args, getString(R.string.follows), null, 0, null);
|
||||
mPagerAdapter.addTab(UserListMembershipsListFragment.class, args, getString(R.string.belongs_to), 0, 1, null);
|
||||
mViewPager.setAdapter(mPagerAdapter);
|
||||
mViewPager.setOffscreenPageLimit(2);
|
||||
mPagerIndicator.setViewPager(mViewPager);
|
||||
mPagerIndicator.setTabDisplayOption(TabPagerIndicator.LABEL);
|
||||
|
@ -77,18 +77,6 @@ public class UserListsFragment extends BaseSupportFragment implements RefreshScr
|
|||
return inflater.inflate(R.layout.fragment_content_pages, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachFragment(final Fragment fragment) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetUserVisibleHint(final Fragment fragment, final boolean isVisibleToUser) {
|
||||
if (isVisibleToUser) {
|
||||
mCurrentVisibleFragment = fragment;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBaseViewCreated(final View view, final Bundle savedInstanceState) {
|
||||
super.onBaseViewCreated(view, savedInstanceState);
|
||||
|
@ -98,8 +86,9 @@ public class UserListsFragment extends BaseSupportFragment implements RefreshScr
|
|||
|
||||
@Override
|
||||
public boolean scrollToStart() {
|
||||
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) mCurrentVisibleFragment).scrollToStart();
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (!(fragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) fragment).scrollToStart();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -108,8 +97,9 @@ public class UserListsFragment extends BaseSupportFragment implements RefreshScr
|
|||
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) mCurrentVisibleFragment).triggerRefresh();
|
||||
final Fragment fragment = getCurrentVisibleFragment();
|
||||
if (!(fragment instanceof RefreshScrollTopInterface)) return false;
|
||||
((RefreshScrollTopInterface) fragment).triggerRefresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ import android.view.KeyEvent;
|
|||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/21.
|
||||
*/
|
||||
* Created by mariotaku on 15/4/21.
|
||||
*/
|
||||
public class RecyclerViewNavigationHelper {
|
||||
|
||||
private int positionBackup;
|
||||
|
@ -49,32 +49,41 @@ public class RecyclerViewNavigationHelper {
|
|||
public boolean handleKeyboardShortcutRepeat(int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||
final String action = handler.getKeyAction("navigation", keyCode, event);
|
||||
if (action == null) return false;
|
||||
final int direction;
|
||||
switch (action) {
|
||||
case "navigation.previous": {
|
||||
direction = -1;
|
||||
break;
|
||||
}
|
||||
case "navigation.next": {
|
||||
direction = 1;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final LinearLayoutManager layoutManager = this.manager;
|
||||
final View focusedChild = RecyclerViewUtils.findRecyclerViewChild(view, layoutManager.getFocusedChild());
|
||||
final int position;
|
||||
final int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
|
||||
final int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
|
||||
final int itemCount = adapter.getItemCount();
|
||||
if (focusedChild != null) {
|
||||
position = view.getChildLayoutPosition(focusedChild);
|
||||
} else if (layoutManager.findFirstVisibleItemPosition() == 0) {
|
||||
} else if (firstVisibleItemPosition == 0) {
|
||||
position = -1;
|
||||
} else if (lastVisibleItemPosition == itemCount - 1) {
|
||||
position = itemCount;
|
||||
} else if (direction > 0 && positionBackup < firstVisibleItemPosition) {
|
||||
position = firstVisibleItemPosition;
|
||||
} else if (direction < 0 && positionBackup > lastVisibleItemPosition) {
|
||||
position = lastVisibleItemPosition;
|
||||
} else {
|
||||
final int itemCount = adapter.getItemCount();
|
||||
if (layoutManager.findLastVisibleItemPosition() == itemCount - 1) {
|
||||
position = itemCount;
|
||||
} else {
|
||||
position = positionBackup;
|
||||
}
|
||||
position = positionBackup;
|
||||
}
|
||||
positionBackup = position;
|
||||
switch (action) {
|
||||
case "navigation.previous": {
|
||||
RecyclerViewUtils.focusNavigate(view, layoutManager, position, -1);
|
||||
return true;
|
||||
}
|
||||
case "navigation.next": {
|
||||
RecyclerViewUtils.focusNavigate(view, layoutManager, position, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
RecyclerViewUtils.focusNavigate(view, layoutManager, position, direction);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import android.view.ViewParent;
|
|||
* Created by mariotaku on 15/4/13.
|
||||
*/
|
||||
public class RecyclerViewUtils {
|
||||
|
||||
public static View findRecyclerViewChild(RecyclerView recyclerView, View view) {
|
||||
if (view == null) return null;
|
||||
final ViewParent parent = view.getParent();
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Twidere - Twitter client for Android
|
||||
*
|
||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package pl.droidsonroids.gif;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/21.
|
||||
*/
|
||||
public class GifSupportChecker {
|
||||
|
||||
public static boolean isSupported() {
|
||||
try {
|
||||
// Just make it trying to load native library
|
||||
System.identityHashCode(GifInfoHandle.NULL_INFO);
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,5 +25,4 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="false"
|
||||
tools:context=".fragment.support.AccountsDashboardFragment"/>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
|
@ -17,7 +18,24 @@
|
|||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<resources>
|
||||
<dimen name="drawer_offset_home">128dp</dimen>
|
||||
</resources>
|
||||
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
android:id="@+id/image_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<com.pnikosis.materialishprogress.ProgressWheel
|
||||
android:id="@+id/load_progress"
|
||||
android:layout_width="@dimen/element_size_normal"
|
||||
android:layout_height="@dimen/element_size_normal"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"
|
||||
app:matProg_barColor="@color/branding_color"/>
|
||||
|
||||
</FrameLayout>
|
|
@ -24,6 +24,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
tools:layout_height="160dp"
|
||||
tools:layout_width="280dp">
|
||||
|
||||
|
@ -35,6 +36,7 @@
|
|||
android:layout_alignTop="@id/profile_container"
|
||||
android:alpha="0.5"
|
||||
android:contentDescription="@string/profile_banner"
|
||||
android:focusable="false"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/nyan_stars_background"/>
|
||||
|
||||
|
@ -42,11 +44,13 @@
|
|||
android:id="@+id/profile_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:foreground="?android:selectableItemBackground">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:paddingBottom="@dimen/element_spacing_normal"
|
||||
android:paddingLeft="@dimen/element_spacing_large"
|
||||
android:paddingRight="@dimen/element_spacing_large"
|
||||
|
@ -59,6 +63,7 @@
|
|||
android:layout_height="@dimen/icon_size_profile_image_dashboard_current"
|
||||
android:layout_marginBottom="@dimen/element_spacing_mlarge"
|
||||
android:layout_marginTop="@dimen/element_spacing_mlarge"
|
||||
android:focusable="false"
|
||||
app:sivBorder="true"
|
||||
app:sivBorderWidth="2dp"
|
||||
tools:src="@mipmap/ic_launcher"/>
|
||||
|
@ -71,27 +76,31 @@
|
|||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@id/profile_image"
|
||||
android:layout_marginBottom="@dimen/element_spacing_large"
|
||||
android:layout_toRightOf="@id/profile_image"/>
|
||||
android:layout_toRightOf="@id/profile_image"
|
||||
android:focusable="false"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_below="@id/profile_image"
|
||||
android:baselineAligned="false"
|
||||
android:focusable="false"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:focusable="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.mariotaku.twidere.view.themed.ThemedTextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
|
@ -102,20 +111,25 @@
|
|||
android:id="@+id/screen_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:text="\@username"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/element_size_normal">
|
||||
android:layout_height="@dimen/element_size_normal"
|
||||
android:focusable="false">
|
||||
|
||||
<org.mariotaku.twidere.view.TwidereActionMenuView
|
||||
android:id="@+id/toggle_menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="false"/>
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
|
@ -126,6 +140,7 @@
|
|||
android:id="@+id/floating_profile_image_snapshot"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="invisible"
|
||||
tools:ignore="ContentDescription"/>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<dimen name="pane_spacing_right">150dp</dimen>
|
||||
<dimen name="icon_size_wizard_large">480dp</dimen>
|
||||
<dimen name="icon_size_user_profile">108dp</dimen>
|
||||
<dimen name="drawer_width_home">320dp</dimen>
|
||||
<dimen name="drawer_width_home">280dp</dimen>
|
||||
<dimen name="accounts_drawer_name_size">18sp</dimen>
|
||||
<dimen name="accounts_drawer_screen_name_size">16sp</dimen>
|
||||
<dimen name="accounts_drawer_default_indicator_size">14sp</dimen>
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
<bool name="default_shadow_slidable">true</bool>
|
||||
<bool name="shadow_slidable">true</bool>
|
||||
<bool name="has_font_family">false</bool>
|
||||
<bool name="relative_behind_width">true</bool>
|
||||
<bool name="relative_behind_width">false</bool>
|
||||
|
||||
</resources>
|
|
@ -31,7 +31,7 @@
|
|||
<dimen name="default_sliding_menu_margin_threshold">16dp</dimen>
|
||||
<dimen name="button_bar_height">52dp</dimen>
|
||||
<dimen name="minimum_element_size">48dp</dimen>
|
||||
<dimen name="drawer_width_home">280dp</dimen>
|
||||
<dimen name="drawer_width_home">288dp</dimen>
|
||||
<dimen name="drawer_offset_home">72dp</dimen>
|
||||
<dimen name="accounts_drawer_name_size">16sp</dimen>
|
||||
<dimen name="accounts_drawer_screen_name_size">14sp</dimen>
|
||||
|
|
Loading…
Reference in New Issue