1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-01-31 17:04:59 +01:00

improved hide/show card actions

This commit is contained in:
Mariotaku Lee 2016-05-18 08:50:52 +08:00
parent 8d61df7bf6
commit bcaa7affd1
5 changed files with 24 additions and 8 deletions

View File

@ -97,4 +97,11 @@ public abstract class BaseRecyclerViewAdapter<VH extends RecyclerView.ViewHolder
public final BidiFormatter getBidiFormatter() {
return mBidiFormatter;
}
public int findPositionByItemId(long itemId) {
for (int i = 0, j = getItemCount(); i < j; i++) {
if (getItemId(i) == itemId) return i;
}
return RecyclerView.NO_POSITION;
}
}

View File

@ -81,7 +81,7 @@ public abstract class ParcelableStatusesAdapter extends LoadMoreSupportAdapter<R
private boolean mShowInReplyTo;
private boolean mShowAccountsColor;
private List<ParcelableStatus> mData;
private int mShowingActionCardPosition = RecyclerView.NO_POSITION;
private long mShowingActionCardId = RecyclerView.NO_ID;
private boolean mLastItemFiltered;
public ParcelableStatusesAdapter(Context context, boolean compact) {
@ -302,15 +302,19 @@ public abstract class ParcelableStatusesAdapter extends LoadMoreSupportAdapter<R
@Override
public boolean isCardActionsShown(int position) {
if (position == RecyclerView.NO_POSITION) return mShowCardActions;
return mShowCardActions || mShowingActionCardPosition == position;
return mShowCardActions || mShowingActionCardId == getItemId(position);
}
@Override
public void showCardActions(int position) {
if (mShowingActionCardPosition != RecyclerView.NO_POSITION) {
notifyItemChanged(mShowingActionCardPosition);
if (mShowingActionCardId != RecyclerView.NO_ID) {
final int pos = findPositionByItemId(mShowingActionCardId);
if (pos != RecyclerView.NO_POSITION) {
notifyItemChanged(pos);
}
}
mShowingActionCardPosition = position;
mShowingActionCardId = getItemId(position);
if (position != RecyclerView.NO_POSITION) {
notifyItemChanged(position);
}

View File

@ -82,7 +82,6 @@ import android.widget.TextView;
import com.afollestad.appthemeengine.ATEActivity;
import com.afollestad.appthemeengine.Config;
import com.afollestad.appthemeengine.util.ATEUtil;
import com.squareup.otto.Subscribe;
import org.apache.commons.lang3.ObjectUtils;
@ -1482,7 +1481,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final BaseActivity activity = (BaseActivity) getActivity();
if (Config.coloredActionBar(activity, activity.getATEKey())) {
mPrimaryColor = color;
mPrimaryColorDark = ATEUtil.darkenColor(color);
mPrimaryColorDark = ThemeUtils.computeDarkColor(color);
} else {
mPrimaryColor = Config.primaryColor(activity, activity.getATEKey());
mPrimaryColorDark = Color.BLACK;
@ -1574,7 +1573,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final int statusBarColor = (int) sArgbEvaluator.evaluate(factor, 0xA0000000,
ATEUtil.darkenColor(mPrimaryColorDark));
ThemeUtils.computeDarkColor(mPrimaryColorDark));
final Window window = activity.getWindow();
mTintedStatusFrameLayout.setStatusBarColor(statusBarColor);
ThemeUtils.setLightStatusBar(window, ThemeUtils.isLightColor(statusBarColor));

View File

@ -216,6 +216,7 @@ public class IntentUtils implements Constants {
final ComponentName componentName = intent.resolveActivity(context.getPackageManager());
if (componentName == null || componentName.getClassName() == null) return null;
if (TextUtils.equals("android", componentName.getPackageName())) return null;
return componentName.getPackageName();
}

View File

@ -52,6 +52,7 @@ import android.view.WindowManager;
import android.widget.FrameLayout;
import com.afollestad.appthemeengine.Config;
import com.afollestad.appthemeengine.util.ATEUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.mariotaku.twidere.Constants;
@ -626,4 +627,8 @@ public class ThemeUtils implements Constants {
return getOptimalAccentColor(themeColor, getContrastColor(themeColor, Color.BLACK,
Color.WHITE));
}
public static int computeDarkColor(int color) {
return ATEUtil.darkenColor(color);
}
}