This commit is contained in:
Mariotaku Lee 2016-04-27 20:03:30 +08:00
parent bc6ee1bbf4
commit d13458d684
6 changed files with 23 additions and 10 deletions

View File

@ -157,6 +157,7 @@ public final class DummyItemAdapter implements IStatusesAdapter<Object>,
return textSize;
}
@Override
@Nullable
public UserClickListener getUserClickListener() {
return userClickListener;

View File

@ -102,7 +102,10 @@ public abstract class ParcelableStatusesAdapter extends LoadMoreSupportAdapter<R
mShowCardActions = !mPreferences.getBoolean(KEY_HIDE_CARD_ACTIONS, false);
mUseStarsForLikes = mPreferences.getBoolean(KEY_I_WANT_MY_STARS_BACK);
mShowAbsoluteTime = mPreferences.getBoolean(KEY_SHOW_ABSOLUTE_TIME, false);
mLinkify = new TwidereLinkify(new StatusAdapterLinkClickHandler<>(this, mPreferences));
final StatusAdapterLinkClickHandler<List<ParcelableStatus>> handler = new StatusAdapterLinkClickHandler<>(context,
mPreferences);
mLinkify = new TwidereLinkify(handler);
handler.setAdapter(this);
setShowInReplyTo(true);
setHasStableIds(true);
}

View File

@ -8,6 +8,7 @@ import android.view.ViewGroup;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.model.ParcelableUserList;
import org.mariotaku.twidere.util.StatusAdapterLinkClickHandler;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.TwidereLinkify;
import org.mariotaku.twidere.view.holder.StatusViewHolder;
@ -39,7 +40,10 @@ public class VariousItemsAdapter extends LoadMoreSupportAdapter<RecyclerView.Vie
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(context,
ThemeUtils.getThemeBackgroundOption(context),
ThemeUtils.getUserThemeBackgroundAlpha(context));
mDummyAdapter = new DummyItemAdapter(context, new TwidereLinkify(null), this);
final StatusAdapterLinkClickHandler<Object> handler = new StatusAdapterLinkClickHandler<>(context,
mPreferences);
mDummyAdapter = new DummyItemAdapter(context, new TwidereLinkify(handler), this);
handler.setAdapter(mDummyAdapter);
mDummyAdapter.updateOptions();
setLoadMoreIndicatorPosition(IndicatorPosition.NONE);
}

View File

@ -1745,8 +1745,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
} else {
mCardLayoutResource = R.layout.card_item_status;
}
mTwidereLinkify = new TwidereLinkify(new StatusAdapterLinkClickHandler<>(this,
mPreferences));
final StatusAdapterLinkClickHandler<List<ParcelableStatus>> listener = new StatusAdapterLinkClickHandler<>(context,
mPreferences);
listener.setAdapter(this);
mTwidereLinkify = new TwidereLinkify(listener);
}
public int findPositionById(long itemId) {

View File

@ -19,6 +19,7 @@
package org.mariotaku.twidere.util;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
@ -32,12 +33,10 @@ import org.mariotaku.twidere.model.util.ParcelableMediaUtils;
*/
public class StatusAdapterLinkClickHandler<D> extends OnLinkClickHandler {
private final IStatusesAdapter<D> adapter;
private IStatusesAdapter<D> adapter;
public StatusAdapterLinkClickHandler(IStatusesAdapter<D> adapter,
SharedPreferencesWrapper preferences) {
super(adapter.getContext(), null, preferences);
this.adapter = adapter;
public StatusAdapterLinkClickHandler(Context context, SharedPreferencesWrapper preferences) {
super(context, null, preferences);
}
@Override
@ -65,4 +64,8 @@ public class StatusAdapterLinkClickHandler<D> extends OnLinkClickHandler {
}
return super.isMedia(link, extraId);
}
public void setAdapter(IStatusesAdapter<D> adapter) {
this.adapter = adapter;
}
}

View File

@ -290,7 +290,7 @@ public class ThemeUtils implements Constants {
public static int getActionBarAlpha(final int alpha) {
final int normalizedAlpha = TwidereMathUtils.clamp(alpha, 0, 0xFF);
final int delta = (ThemeBackgroundPreference.MAX_ALPHA - normalizedAlpha);
final int delta = ThemeBackgroundPreference.MAX_ALPHA - normalizedAlpha;
return TwidereMathUtils.clamp(ThemeBackgroundPreference.MAX_ALPHA - delta / 2,
ThemeBackgroundPreference.MIN_ALPHA, ThemeBackgroundPreference.MAX_ALPHA);
}