fixed switch width

This commit is contained in:
Mariotaku Lee 2016-06-21 21:49:02 +08:00
parent b21f179bb4
commit 432aa8dd23
2 changed files with 33 additions and 3 deletions

View File

@ -165,7 +165,7 @@ dependencies {
compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.17' compile 'com.github.mariotaku.MediaViewerLibrary:subsample-image-view:0.9.17'
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.9' compile 'com.github.mariotaku.ObjectCursor:core:0.9.9'
compile 'com.github.mariotaku:MultiValueSwitch:0.9.4' compile 'com.github.mariotaku:MultiValueSwitch:0.9.6'
compile 'com.github.mariotaku:AbstractTask:0.9.2' compile 'com.github.mariotaku:AbstractTask:0.9.2'
compile 'com.github.mariotaku.CommonsLibrary:parcel:0.9.8' compile 'com.github.mariotaku.CommonsLibrary:parcel:0.9.8'
compile 'com.github.mariotaku.CommonsLibrary:io:0.9.8' compile 'com.github.mariotaku.CommonsLibrary:io:0.9.8'

View File

@ -20,6 +20,8 @@
package org.mariotaku.twidere.fragment; package org.mariotaku.twidere.fragment;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -34,7 +36,9 @@ import android.view.KeyEvent;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.mariotaku.commons.parcel.ParcelUtils; import org.mariotaku.commons.parcel.ParcelUtils;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.ParcelableUsersAdapter; import org.mariotaku.twidere.adapter.ParcelableUsersAdapter;
import org.mariotaku.twidere.adapter.decorator.DividerItemDecoration;
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition; import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter.IndicatorPosition;
import org.mariotaku.twidere.adapter.iface.IUsersAdapter; import org.mariotaku.twidere.adapter.iface.IUsersAdapter;
import org.mariotaku.twidere.adapter.iface.IUsersAdapter.UserClickListener; import org.mariotaku.twidere.adapter.iface.IUsersAdapter.UserClickListener;
@ -194,9 +198,35 @@ public abstract class ParcelableUsersFragment extends AbsContentListRecyclerView
@NonNull final Bundle args, @NonNull final Bundle args,
final boolean fromUser); final boolean fromUser);
@Nullable
@Override @Override
protected void setupRecyclerView(Context context, RecyclerView recyclerView) { protected RecyclerView.ItemDecoration createItemDecoration(Context context, RecyclerView recyclerView, LinearLayoutManager layoutManager) {
super.setupRecyclerView(context, recyclerView); final ParcelableUsersAdapter adapter = getAdapter();
final DividerItemDecoration itemDecoration = new DividerItemDecoration(context,
((LinearLayoutManager) recyclerView.getLayoutManager()).getOrientation());
final Resources res = context.getResources();
if (adapter.isProfileImageEnabled()) {
final int decorPaddingLeft = res.getDimensionPixelSize(R.dimen.element_spacing_normal) * 2
+ res.getDimensionPixelSize(R.dimen.icon_size_status_profile_image);
itemDecoration.setPadding(new DividerItemDecoration.Padding() {
@Override
public boolean get(int position, Rect rect) {
final int itemViewType = adapter.getItemViewType(position);
boolean nextItemIsUser = false;
if (position < adapter.getItemCount() - 1) {
nextItemIsUser = adapter.getItemViewType(position + 1) == ParcelableUsersAdapter.ITEM_VIEW_TYPE_USER;
}
if (nextItemIsUser && itemViewType == ParcelableUsersAdapter.ITEM_VIEW_TYPE_USER) {
rect.left = decorPaddingLeft;
} else {
rect.left = 0;
}
return true;
}
});
}
itemDecoration.setDecorationEndOffset(1);
return itemDecoration;
} }
private int findPosition(ParcelableUsersAdapter adapter, UserKey accountKey, UserKey userKey) { private int findPosition(ParcelableUsersAdapter adapter, UserKey accountKey, UserKey userKey) {