added account toggle

This commit is contained in:
Mariotaku Lee 2015-09-02 15:03:17 +08:00
parent 5452a03338
commit 170184144b
22 changed files with 236 additions and 155 deletions

View File

@ -14,7 +14,7 @@ android {
applicationId "org.mariotaku.twidere"
minSdkVersion 14
targetSdkVersion 23
versionCode 121
versionCode 122
versionName "0.3.0"
multiDexEnabled true
}
@ -91,6 +91,7 @@ dependencies {
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.1'
compile 'com.github.mariotaku:PickNCrop:44b09cbc69'
compile 'com.diogobernardino:williamchart:2.0.1'
compile 'com.lnikkila:extendedtouchview:0.1.0'
googleCompile 'com.google.android.gms:play-services-maps:7.8.0'
googleCompile 'com.google.maps.android:android-maps-utils:0.4'
fdroidCompile 'org.osmdroid:osmdroid-android:4.3'

View File

@ -133,7 +133,7 @@ public class AccountSelectorActivity extends BaseSupportDialogActivity implement
mAdapter = new AccountsAdapter(this);
final boolean isSingleSelection = isSingleSelection();
mListView.setChoiceMode(isSingleSelection ? ListView.CHOICE_MODE_NONE : ListView.CHOICE_MODE_MULTIPLE);
mAdapter.setChoiceMode(mListView.getChoiceMode());
mAdapter.setSwitchEnabled(!isSingleSelection);
mAdapter.setSortEnabled(false);
if (isSingleSelection) {
mListView.setOnItemClickListener(this);

View File

@ -24,7 +24,7 @@ import android.content.SharedPreferences;
import android.database.Cursor;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.CompoundButton;
import com.mobeta.android.dslv.SimpleDragSortCursorAdapter;
@ -44,9 +44,20 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
private final SharedPreferences mPreferences;
private boolean mDisplayProfileImage;
private int mChoiceMode;
private boolean mSortEnabled;
private Indices mIndices;
private boolean mSwitchEnabled;
private OnAccountToggleListener mOnAccountToggleListener;
private CompoundButton.OnCheckedChangeListener mCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
final Object tag = buttonView.getTag();
if (!(tag instanceof Long) || mOnAccountToggleListener == null) return;
final long accountId = (Long) tag;
mOnAccountToggleListener.onAccountToggle(accountId, isChecked);
}
};
public AccountsAdapter(final Context context) {
super(context, R.layout.list_item_account, null, new String[]{Accounts.NAME},
@ -66,17 +77,17 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
public void bindView(final View view, final Context context, final Cursor cursor) {
final int color = cursor.getInt(mIndices.color);
final AccountViewHolder holder = (AccountViewHolder) view.getTag();
holder.screen_name.setText("@" + cursor.getString(mIndices.screen_name));
holder.screenName.setText("@" + cursor.getString(mIndices.screen_name));
holder.setAccountColor(color);
if (mDisplayProfileImage) {
mImageLoader.displayProfileImage(holder.profile_image, cursor.getString(mIndices.profile_image_url));
mImageLoader.displayProfileImage(holder.profileImage, cursor.getString(mIndices.profile_image_url));
} else {
mImageLoader.cancelDisplayTask(holder.profile_image);
// holder.profile_image.setImageResource(R.drawable.ic_profile_image_default);
mImageLoader.cancelDisplayTask(holder.profileImage);
}
final boolean isMultipleChoice = mChoiceMode == ListView.CHOICE_MODE_MULTIPLE
|| mChoiceMode == ListView.CHOICE_MODE_MULTIPLE_MODAL;
holder.checkbox.setVisibility(isMultipleChoice ? View.VISIBLE : View.GONE);
holder.toggle.setChecked(cursor.getShort(mIndices.is_activated) == 1);
holder.toggle.setOnCheckedChangeListener(mCheckedChangeListener);
holder.toggle.setVisibility(mSwitchEnabled ? View.VISIBLE : View.GONE);
holder.toggle.setTag(cursor.getLong(mIndices.account_id));
holder.setSortEnabled(mSortEnabled);
super.bindView(view, context, cursor);
}
@ -99,35 +110,49 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
return 0;
}
@Override
public void setLinkHighlightOption(String option) {
}
@Override
public float getTextSize() {
return 0;
}
@Override
public void setTextSize(float textSize) {
}
@Override
public boolean isDisplayNameFirst() {
return false;
}
@Override
public void setDisplayNameFirst(boolean nameFirst) {
}
@Override
public boolean isProfileImageDisplayed() {
return mDisplayProfileImage;
}
@Override
public boolean isShowAccountColor() {
return false;
}
@Override
public void setDisplayNameFirst(boolean nameFirst) {
public void setShowAccountColor(boolean show) {
}
public void setChoiceMode(final int mode) {
if (mChoiceMode == mode) return;
mChoiceMode = mode;
public void setSwitchEnabled(final boolean enabled) {
if (mSwitchEnabled == enabled) return;
mSwitchEnabled = enabled;
notifyDataSetChanged();
}
@ -137,19 +162,8 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
notifyDataSetChanged();
}
@Override
public void setLinkHighlightOption(String option) {
}
@Override
public void setShowAccountColor(boolean show) {
}
@Override
public void setTextSize(float textSize) {
public void setOnAccountToggleListener(OnAccountToggleListener listener) {
mOnAccountToggleListener = listener;
}
@Override
@ -165,4 +179,8 @@ public class AccountsAdapter extends SimpleDragSortCursorAdapter implements Cons
mSortEnabled = sortEnabled;
notifyDataSetChanged();
}
public interface OnAccountToggleListener {
void onAccountToggle(long accountId, boolean state);
}
}

View File

@ -64,38 +64,6 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentRecyclerViewFr
implements LoaderCallbacks<Data>, StatusAdapterListener, KeyboardShortcutCallback {
private final Object mStatusesBusCallback;
private SharedPreferences mPreferences;
private PopupMenu mPopupMenu;
private ReadStateManager mReadStateManager;
private RecyclerViewNavigationHelper mNavigationHelper;
private ParcelableStatus mSelectedStatus;
private OnMenuItemClickListener mOnStatusMenuItemClickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
final ParcelableStatus status = mSelectedStatus;
if (status == null) return false;
if (item.getItemId() == R.id.share) {
final Intent shareIntent = Utils.createStatusShareIntent(getActivity(), status);
startActivity(Intent.createChooser(shareIntent, getString(R.string.share_status)));
return true;
}
return Utils.handleMenuItemClick(getActivity(), AbsStatusesFragment.this,
getFragmentManager(), getTwitterWrapper(), status, item);
}
};
private final OnScrollListener mOnScrollListener = new OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
final LinearLayoutManager layoutManager = getLayoutManager();
saveReadPosition(layoutManager.findFirstVisibleItemPosition());
}
}
};
private OnScrollListener mPauseOnScrollListener;
private final OnScrollListener mHotMobiScrollTracker = new OnScrollListener() {
public List<ScrollRecord> mRecords;
@ -107,7 +75,7 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentRecyclerViewFr
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
final LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
final int firstVisiblePosition = layoutManager.findFirstVisibleItemPosition();
if (firstVisiblePosition != mFirstVisiblePosition) {
if (firstVisiblePosition != mFirstVisiblePosition && firstVisiblePosition >= 0) {
//noinspection unchecked
final AbsStatusesAdapter<Data> adapter = (AbsStatusesAdapter<Data>) recyclerView.getAdapter();
final ParcelableStatus status = adapter.getStatus(firstVisiblePosition);
@ -137,7 +105,35 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentRecyclerViewFr
}
}
};
private SharedPreferences mPreferences;
private PopupMenu mPopupMenu;
private ReadStateManager mReadStateManager;
private final OnScrollListener mOnScrollListener = new OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
final LinearLayoutManager layoutManager = getLayoutManager();
saveReadPosition(layoutManager.findFirstVisibleItemPosition());
}
}
};
private RecyclerViewNavigationHelper mNavigationHelper;
private ParcelableStatus mSelectedStatus;
private OnMenuItemClickListener mOnStatusMenuItemClickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
final ParcelableStatus status = mSelectedStatus;
if (status == null) return false;
if (item.getItemId() == R.id.share) {
final Intent shareIntent = Utils.createStatusShareIntent(getActivity(), status);
startActivity(Intent.createChooser(shareIntent, getString(R.string.share_status)));
return true;
}
return Utils.handleMenuItemClick(getActivity(), AbsStatusesFragment.this,
getFragmentManager(), getTwitterWrapper(), status, item);
}
};
private OnScrollListener mPauseOnScrollListener;
private OnScrollListener mActiveHotMobiScrollTracker;
protected AbsStatusesFragment() {
@ -261,7 +257,7 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentRecyclerViewFr
} else {
lastVisiblePos = layoutManager.findFirstVisibleItemPosition();
}
if (lastVisiblePos != RecyclerView.NO_POSITION) {
if (lastVisiblePos != RecyclerView.NO_POSITION && lastVisiblePos < adapter.getItemCount()) {
lastReadId = adapter.getStatusId(lastVisiblePos);
final View positionView = layoutManager.findViewByPosition(lastVisiblePos);
lastVisibleTop = positionView != null ? positionView.getTop() : 0;

View File

@ -39,6 +39,7 @@ import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -110,9 +111,7 @@ import java.util.List;
public class AccountsDashboardFragment extends BaseSupportFragment implements LoaderCallbacks<Cursor>,
OnSharedPreferenceChangeListener, ImageLoadingListener, OnClickListener, KeyboardShortcutCallback, AdapterView.OnItemClickListener {
private final SupportFragmentReloadCursorObserver mReloadContentObserver = new SupportFragmentReloadCursorObserver(
this, 0, this);
private final Rect mSystemWindowsInsets = new Rect();
private ContentResolver mResolver;
private SharedPreferences mPreferences;
private MergeAdapter mAdapter;
@ -135,9 +134,18 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
private Context mThemedContext;
private MediaLoaderWrapper mImageLoader;
private AccountToggleProvider mAccountActionProvider;
private final SupportFragmentReloadCursorObserver mReloadContentObserver = new SupportFragmentReloadCursorObserver(
this, 0, this) {
@Override
public void onChange(boolean selfChange, @Nullable Uri uri) {
final ContentResolver cr = getContentResolver();
final Cursor c = cr.query(Accounts.CONTENT_URI, Accounts.COLUMNS, null, null, Accounts.SORT_POSITION);
updateAccountProviderData(c);
c.close();
super.onChange(selfChange, uri);
}
};
private boolean mSwitchAccountAnimationPlaying;
private final Rect mSystemWindowsInsets = new Rect();
public long[] getActivatedAccountIds() {
if (mAccountActionProvider != null) {
@ -244,9 +252,13 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
@Override
public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) {
updateAccountProviderData(data);
}
private void updateAccountProviderData(final Cursor cursor) {
final Menu menu = mAccountsToggleMenu.getMenu();
mAccountActionProvider = (AccountToggleProvider) MenuItemCompat.getActionProvider(menu.findItem(R.id.select_account));
final ParcelableAccount[] accounts = ParcelableAccount.getAccounts(data);
final ParcelableAccount[] accounts = ParcelableAccount.getAccounts(cursor);
if (accounts.length > 0) {
mNoAccountContainer.setVisibility(View.GONE);
mAccountProfileContainer.setVisibility(View.VISIBLE);
@ -719,6 +731,13 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
setHasStableIds(true);
}
private static int indexOfAccount(List<ParcelableAccount> accounts, long accountId) {
for (int i = 0, j = accounts.size(); i < j; i++) {
if (accounts.get(i).account_id == accountId) return i;
}
return -1;
}
public ParcelableAccount getAdapterAccount(int adapterPosition) {
if (mInternalAccounts == null || mInternalAccounts.length < 1) {
return null;
@ -800,13 +819,6 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
mFragment.onAccountSelected(holder, getAdapterAccount(holder.getAdapterPosition()));
}
private static int indexOfAccount(List<ParcelableAccount> accounts, long accountId) {
for (int i = 0, j = accounts.size(); i < j; i++) {
if (accounts.get(i).account_id == accountId) return i;
}
return -1;
}
private void swap(long fromId, long toId) {
int fromIdx = -1, toIdx = -1;
for (int i = 0, j = mInternalAccounts.length; i < j; i++) {
@ -856,8 +868,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
final OptionItem other = (OptionItem) obj;
if (icon != other.icon) return false;
if (id != other.id) return false;
if (name != other.name) return false;
return true;
return name == other.name;
}
@Override

View File

@ -19,6 +19,7 @@ import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.util.LongSparseArray;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
@ -36,7 +37,9 @@ import android.widget.TextView;
import com.mobeta.android.dslv.DragSortListView;
import com.mobeta.android.dslv.DragSortListView.DropListener;
import org.mariotaku.sqliteqb.library.Columns;
import org.mariotaku.sqliteqb.library.Expression;
import org.mariotaku.sqliteqb.library.RawItemArray;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity;
import org.mariotaku.twidere.activity.support.SignInActivity;
@ -50,20 +53,23 @@ import org.mariotaku.twidere.provider.TwidereDataStore.Mentions;
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.collection.CompactHashSet;
import java.util.ArrayList;
import java.util.Set;
/**
* Created by mariotaku on 14/10/26.
*/
public class AccountsManagerFragment extends BaseSupportFragment implements LoaderCallbacks<Cursor>,
DropListener, OnSharedPreferenceChangeListener, AdapterView.OnItemClickListener {
DropListener, OnSharedPreferenceChangeListener, AdapterView.OnItemClickListener, AccountsAdapter.OnAccountToggleListener {
private static final String FRAGMENT_TAG_ACCOUNT_DELETION = "account_deletion";
private AccountsAdapter mAdapter;
private SharedPreferences mPreferences;
private ParcelableAccount mSelectedAccount;
private LongSparseArray<Boolean> mActivatedState = new LongSparseArray<>();
private DragSortListView mListView;
private View mEmptyView;
@ -146,42 +152,34 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
null);
}
@Override
public void onStop() {
super.onStop();
saveActivatedState();
}
public static final class AccountDeletionDialogFragment extends BaseSupportDialogFragment implements
DialogInterface.OnClickListener {
@Override
public void onClick(final DialogInterface dialog, final int which) {
final Bundle args = getArguments();
final long accountId = args != null ? args.getLong(EXTRA_ACCOUNT_ID, -1) : -1;
if (accountId < 0) return;
final ContentResolver resolver = getContentResolver();
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
resolver.delete(Accounts.CONTENT_URI, Expression.equals(Accounts.ACCOUNT_ID, accountId).getSQL(), null);
// Also delete tweets related to the account we previously
// deleted.
resolver.delete(Statuses.CONTENT_URI, Expression.equals(Statuses.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Mentions.CONTENT_URI, Expression.equals(Mentions.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Inbox.CONTENT_URI, Expression.equals(DirectMessages.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Outbox.CONTENT_URI, Expression.equals(DirectMessages.ACCOUNT_ID, accountId).getSQL(), null);
break;
}
private void saveActivatedState() {
final Set<Long> trueIds = new CompactHashSet<>(), falseIds = new CompactHashSet<>();
for (int i = 0, j = mActivatedState.size(); i < j; i++) {
if (mActivatedState.valueAt(i)) {
trueIds.add(mActivatedState.keyAt(i));
} else {
falseIds.add(mActivatedState.keyAt(i));
}
}
final ContentResolver cr = getContentResolver();
final ContentValues values = new ContentValues();
values.put(Accounts.IS_ACTIVATED, true);
Expression where = Expression.in(new Columns.Column(Accounts.ACCOUNT_ID), new RawItemArray(trueIds.toArray()));
cr.update(Accounts.CONTENT_URI, values, where.getSQL(), null);
values.put(Accounts.IS_ACTIVATED, false);
where = Expression.in(new Columns.Column(Accounts.ACCOUNT_ID), new RawItemArray(falseIds.toArray()));
cr.update(Accounts.CONTENT_URI, values, where.getSQL(), null);
}
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
builder.setNegativeButton(android.R.string.cancel, null);
builder.setPositiveButton(android.R.string.ok, this);
builder.setTitle(R.string.account_delete_confirm_title);
builder.setMessage(R.string.account_delete_confirm_message);
return builder.create();
}
@Override
public void onAccountToggle(long accountId, boolean state) {
mActivatedState.append(accountId, state);
}
@Override
@ -195,7 +193,6 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
mProgressContainer = view.findViewById(R.id.progress_container);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
if (!(menuInfo instanceof AdapterContextMenuInfo)) return;
@ -222,6 +219,8 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
mAdapter = new AccountsAdapter(activity);
Utils.configBaseAdapter(activity, mAdapter);
mAdapter.setSortEnabled(true);
mAdapter.setSwitchEnabled(true);
mAdapter.setOnAccountToggleListener(this);
mListView.setAdapter(mAdapter);
mListView.setDragEnabled(true);
mListView.setDropListener(this);
@ -265,7 +264,6 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
saveAccountPositions();
}
private void saveAccountPositions() {
final ContentResolver cr = getContentResolver();
final ArrayList<Integer> positions = mAdapter.getCursorPositions();
@ -293,4 +291,41 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
private void updateDefaultAccount() {
mAdapter.notifyDataSetChanged();
}
public static final class AccountDeletionDialogFragment extends BaseSupportDialogFragment implements
DialogInterface.OnClickListener {
@Override
public void onClick(final DialogInterface dialog, final int which) {
final Bundle args = getArguments();
final long accountId = args != null ? args.getLong(EXTRA_ACCOUNT_ID, -1) : -1;
if (accountId < 0) return;
final ContentResolver resolver = getContentResolver();
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
resolver.delete(Accounts.CONTENT_URI, Expression.equals(Accounts.ACCOUNT_ID, accountId).getSQL(), null);
// Also delete tweets related to the account we previously
// deleted.
resolver.delete(Statuses.CONTENT_URI, Expression.equals(Statuses.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Mentions.CONTENT_URI, Expression.equals(Mentions.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Inbox.CONTENT_URI, Expression.equals(DirectMessages.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Outbox.CONTENT_URI, Expression.equals(DirectMessages.ACCOUNT_ID, accountId).getSQL(), null);
break;
}
}
}
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
builder.setNegativeButton(android.R.string.cancel, null);
builder.setPositiveButton(android.R.string.ok, this);
builder.setTitle(R.string.account_delete_confirm_title);
builder.setMessage(R.string.account_delete_confirm_message);
return builder.create();
}
}
}

View File

@ -24,39 +24,40 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import org.mariotaku.twidere.TwidereConstants;
public final class SupportFragmentReloadCursorObserver extends ContentObserver implements TwidereConstants {
public class SupportFragmentReloadCursorObserver extends ContentObserver implements TwidereConstants {
private final Fragment mFragment;
private final int mLoaderId;
private final LoaderCallbacks<Cursor> mCallback;
private final Fragment mFragment;
private final int mLoaderId;
private final LoaderCallbacks<Cursor> mCallback;
public SupportFragmentReloadCursorObserver(final Fragment fragment, final int loaderId,
final LoaderCallbacks<Cursor> callback) {
super(createHandler());
mFragment = fragment;
mLoaderId = loaderId;
mCallback = callback;
}
public SupportFragmentReloadCursorObserver(final Fragment fragment, final int loaderId,
final LoaderCallbacks<Cursor> callback) {
super(createHandler());
mFragment = fragment;
mLoaderId = loaderId;
mCallback = callback;
}
@Override
public void onChange(final boolean selfChange) {
onChange(selfChange, null);
}
private static Handler createHandler() {
if (Thread.currentThread().getId() != 1) return new Handler(Looper.getMainLooper());
return new Handler();
}
@Override
public void onChange(final boolean selfChange, final Uri uri) {
if (mFragment == null || mFragment.getActivity() == null || mFragment.isDetached()) return;
// Handle change.
mFragment.getLoaderManager().restartLoader(mLoaderId, null, mCallback);
}
@Override
public final void onChange(final boolean selfChange) {
onChange(selfChange, null);
}
private static Handler createHandler() {
if (Thread.currentThread().getId() != 1) return new Handler(Looper.getMainLooper());
return new Handler();
}
@Override
public void onChange(final boolean selfChange, @Nullable final Uri uri) {
if (mFragment == null || mFragment.getActivity() == null || mFragment.isDetached()) return;
// Handle change.
mFragment.getLoaderManager().restartLoader(mLoaderId, null, mCallback);
}
}

View File

@ -20,7 +20,7 @@
package org.mariotaku.twidere.view.holder;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;
@ -29,19 +29,19 @@ import org.mariotaku.twidere.view.ColorLabelRelativeLayout;
public class AccountViewHolder {
public final ImageView profile_image;
public final TextView name, screen_name;
public final CheckBox checkbox;
public final ImageView profileImage;
public final TextView name, screenName;
public final CompoundButton toggle;
private final ColorLabelRelativeLayout content;
private final View drag_handle;
private final View dragHandle;
public AccountViewHolder(final View view) {
content = (ColorLabelRelativeLayout) view;
name = (TextView) view.findViewById(android.R.id.text1);
screen_name = (TextView) view.findViewById(android.R.id.text2);
profile_image = (ImageView) view.findViewById(android.R.id.icon);
checkbox = (CheckBox) view.findViewById(android.R.id.checkbox);
drag_handle = view.findViewById(R.id.drag_handle);
screenName = (TextView) view.findViewById(android.R.id.text2);
profileImage = (ImageView) view.findViewById(android.R.id.icon);
toggle = (CompoundButton) view.findViewById(android.R.id.toggle);
dragHandle = view.findViewById(R.id.drag_handle);
}
public void setAccountColor(final int color) {
@ -49,6 +49,6 @@ public class AccountViewHolder {
}
public void setSortEnabled(boolean enabled) {
drag_handle.setVisibility(enabled ? View.VISIBLE : View.GONE);
dragHandle.setVisibility(enabled ? View.VISIBLE : View.GONE);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 558 B

View File

@ -52,9 +52,9 @@
android:layout_alignWithParentIfMissing="true"
android:layout_centerVertical="true"
android:layout_toEndOf="@android:id/icon"
android:layout_toLeftOf="@android:id/checkbox"
android:layout_toLeftOf="@+id/toggle_container"
android:layout_toRightOf="@android:id/icon"
android:layout_toStartOf="@android:id/checkbox"
android:layout_toStartOf="@+id/toggle_container"
android:orientation="vertical"
android:padding="@dimen/element_spacing_normal">
@ -75,14 +75,21 @@
android:textColor="?android:textColorSecondary" />
</LinearLayout>
<org.mariotaku.twidere.view.ActivatedCheckBox
android:id="@android:id/checkbox"
<com.lnikkila.extendedtouchview.ExtendedTouchView
android:id="@+id/toggle_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:clickable="false"
android:focusable="false" />
app:touchHeight="48dp"
app:touchWidth="48dp">
<android.support.v7.widget.SwitchCompat
android:id="@android:id/toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</com.lnikkila.extendedtouchview.ExtendedTouchView>
</org.mariotaku.twidere.view.ColorLabelRelativeLayout>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<!-- Generator: Sketch 3.3.3 (12081) - http://www.bohemiancoding.com/sketch -->
<title>Artboard</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="Artboard" sketch:type="MSArtboardGroup" fill="#FFFFFF">
<path d="M19.5,18 L18.71,18 L18.43,17.73 C19.41,16.59 20,15.11 20,13.5 C20,9.91 17.09,7 13.5,7 C9.91,7 7,9.91 7,13.5 C7,17.09 9.91,20 13.5,20 C15.11,20 16.59,19.41 17.73,18.43 L18,18.71 L18,19.5 L23,24.49 L24.49,23 L19.5,18 L19.5,18 Z M13.5,18 C11.01,18 9,15.99 9,13.5 C9,11.01 11.01,9 13.5,9 C15.99,9 18,11.01 18,13.5 C18,15.99 15.99,18 13.5,18 L13.5,18 Z" id="Shape" sketch:type="MSShapeGroup"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB