This commit is contained in:
Mariotaku Lee 2015-03-31 19:05:19 +08:00
parent 18aa437d7b
commit d198e7dec5
2 changed files with 15 additions and 13 deletions

View File

@ -82,7 +82,7 @@ import static org.mariotaku.twidere.util.CustomTabUtils.isTabTypeValid;
import static org.mariotaku.twidere.util.Utils.getAccountIds; import static org.mariotaku.twidere.util.Utils.getAccountIds;
public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<Cursor>, public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<Cursor>,
MultiChoiceModeListener, DropListener, OnItemClickListener { MultiChoiceModeListener, OnItemClickListener {
private ContentResolver mResolver; private ContentResolver mResolver;
@ -94,14 +94,6 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
private TextView mEmptyText; private TextView mEmptyText;
private ImageView mEmptyIcon; private ImageView mEmptyIcon;
@Override
public void drop(final int from, final int to) {
mAdapter.drop(from, to);
if (mListView.getChoiceMode() != AbsListView.CHOICE_MODE_NONE) {
mListView.moveCheckState(from, to);
}
saveTabPositions();
}
@Override @Override
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
@ -127,10 +119,19 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
mAdapter = new CustomTabsAdapter(context); mAdapter = new CustomTabsAdapter(context);
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
mListView.setMultiChoiceModeListener(this); mListView.setMultiChoiceModeListener(this);
mListView.setDropListener(this);
mListView.setOnItemClickListener(this); mListView.setOnItemClickListener(this);
mListView.setAdapter(mAdapter); mListView.setAdapter(mAdapter);
mListView.setEmptyView(mEmptyView); mListView.setEmptyView(mEmptyView);
mListView.setDropListener(new DropListener() {
@Override
public void drop(final int from, final int to) {
mAdapter.drop(from, to);
if (mListView.getChoiceMode() != AbsListView.CHOICE_MODE_NONE) {
mListView.moveCheckState(from, to);
}
saveTabPositions();
}
});
mEmptyText.setText(R.string.no_tab); mEmptyText.setText(R.string.no_tab);
mEmptyIcon.setImageResource(R.drawable.ic_info_tab); mEmptyIcon.setImageResource(R.drawable.ic_info_tab);
getLoaderManager().initLoader(0, null, this); getLoaderManager().initLoader(0, null, this);
@ -316,7 +317,7 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
final long id = c.getLong(idIdx); final long id = c.getLong(idIdx);
final ContentValues values = new ContentValues(); final ContentValues values = new ContentValues();
values.put(Tabs.POSITION, i); values.put(Tabs.POSITION, i);
final String where = Tabs._ID + " = " + id; final String where = Expression.equals(Tabs._ID, id).getSQL();
mResolver.update(Tabs.CONTENT_URI, values, where, null); mResolver.update(Tabs.CONTENT_URI, values, where, null);
} }
} }

View File

@ -56,6 +56,7 @@ import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.app.SharedElementCallback; import android.support.v4.app.SharedElementCallback;
import android.support.v4.content.AsyncTaskLoader; import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader; import android.support.v4.content.Loader;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
@ -376,7 +377,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
drawableRes = R.drawable.ic_follow_none; drawableRes = R.drawable.ic_follow_none;
} }
} }
final Drawable icon = getResources().getDrawable(drawableRes); final Drawable icon = ResourcesCompat.getDrawable(getResources(), drawableRes, null);
final int iconSize = Math.round(mFollowButton.getTextSize() * 1.4f); final int iconSize = Math.round(mFollowButton.getTextSize() * 1.4f);
icon.setBounds(0, 0, iconSize, iconSize); icon.setBounds(0, 0, iconSize, iconSize);
icon.setColorFilter(mFollowButton.getCurrentTextColor(), Mode.SRC_ATOP); icon.setColorFilter(mFollowButton.getCurrentTextColor(), Mode.SRC_ATOP);
@ -1241,7 +1242,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final ActionBar actionBar = linkHandler.getSupportActionBar(); final ActionBar actionBar = linkHandler.getSupportActionBar();
if (actionBar == null) return; if (actionBar == null) return;
final int themeResId = linkHandler.getCurrentThemeResourceId(); final int themeResId = linkHandler.getCurrentThemeResourceId();
final Drawable shadow = activity.getResources().getDrawable(R.drawable.shadow_user_banner_action_bar); final Drawable shadow = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.shadow_user_banner_action_bar, null);
final Drawable background = ThemeUtils.getActionBarBackground(activity, themeResId); final Drawable background = ThemeUtils.getActionBarBackground(activity, themeResId);
mActionBarBackground = new ActionBarDrawable(getResources(), shadow, background, ThemeUtils.isDarkTheme(themeResId)); mActionBarBackground = new ActionBarDrawable(getResources(), shadow, background, ThemeUtils.isDarkTheme(themeResId));
mActionBarBackground.setAlpha(linkHandler.getCurrentThemeBackgroundAlpha()); mActionBarBackground.setAlpha(linkHandler.getCurrentThemeBackgroundAlpha());