click account to open profile

This commit is contained in:
Mariotaku Lee 2015-08-08 21:15:36 +08:00
parent d272a2785f
commit 78cc736b23
2 changed files with 21 additions and 15 deletions

View File

@ -107,10 +107,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static org.mariotaku.twidere.util.Utils.openUserFavorites;
import static org.mariotaku.twidere.util.Utils.openUserLists;
import static org.mariotaku.twidere.util.Utils.openUserProfile;
public class AccountsDashboardFragment extends BaseSupportFragment implements LoaderCallbacks<Cursor>, public class AccountsDashboardFragment extends BaseSupportFragment implements LoaderCallbacks<Cursor>,
OnSharedPreferenceChangeListener, ImageLoadingListener, OnClickListener, KeyboardShortcutCallback, AdapterView.OnItemClickListener { OnSharedPreferenceChangeListener, ImageLoadingListener, OnClickListener, KeyboardShortcutCallback, AdapterView.OnItemClickListener {
@ -228,7 +224,7 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
final FragmentActivity activity = getActivity(); final FragmentActivity activity = getActivity();
final Bundle activityOption = Utils.makeSceneTransitionOption(activity, final Bundle activityOption = Utils.makeSceneTransitionOption(activity,
new Pair<View, String>(mAccountProfileImageView, UserFragment.TRANSITION_NAME_PROFILE_IMAGE)); new Pair<View, String>(mAccountProfileImageView, UserFragment.TRANSITION_NAME_PROFILE_IMAGE));
openUserProfile(activity, account.account_id, account.account_id, Utils.openUserProfile(activity, account.account_id, account.account_id,
account.screen_name, activityOption); account.screen_name, activityOption);
break; break;
} }
@ -301,11 +297,11 @@ public class AccountsDashboardFragment extends BaseSupportFragment implements Lo
break; break;
} }
case R.id.favorites: { case R.id.favorites: {
openUserFavorites(getActivity(), account.account_id, account.account_id, account.screen_name); Utils.openUserFavorites(getActivity(), account.account_id, account.account_id, account.screen_name);
break; break;
} }
case R.id.lists: { case R.id.lists: {
openUserLists(getActivity(), account.account_id, account.account_id, account.screen_name); Utils.openUserLists(getActivity(), account.account_id, account.account_id, account.screen_name);
break; break;
} }
case R.id.edit: { case R.id.edit: {

View File

@ -28,6 +28,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -55,7 +56,8 @@ import java.util.ArrayList;
/** /**
* Created by mariotaku on 14/10/26. * Created by mariotaku on 14/10/26.
*/ */
public class AccountsManagerFragment extends BaseSupportFragment implements LoaderCallbacks<Cursor>, DropListener, OnSharedPreferenceChangeListener { public class AccountsManagerFragment extends BaseSupportFragment implements LoaderCallbacks<Cursor>,
DropListener, OnSharedPreferenceChangeListener, AdapterView.OnItemClickListener {
private static final String FRAGMENT_TAG_ACCOUNT_DELETION = "account_deletion"; private static final String FRAGMENT_TAG_ACCOUNT_DELETION = "account_deletion";
@ -137,6 +139,13 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
return false; return false;
} }
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final ParcelableAccount account = mAdapter.getAccount(position);
Utils.openUserProfile(getActivity(), account.account_id, account.account_id, account.screen_name,
null);
}
public static final class AccountDeletionDialogFragment extends BaseSupportDialogFragment implements public static final class AccountDeletionDialogFragment extends BaseSupportDialogFragment implements
DialogInterface.OnClickListener { DialogInterface.OnClickListener {
@ -144,18 +153,18 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
@Override @Override
public void onClick(final DialogInterface dialog, final int which) { public void onClick(final DialogInterface dialog, final int which) {
final Bundle args = getArguments(); final Bundle args = getArguments();
final long account_id = args != null ? args.getLong(EXTRA_ACCOUNT_ID, -1) : -1; final long accountId = args != null ? args.getLong(EXTRA_ACCOUNT_ID, -1) : -1;
if (account_id < 0) return; if (accountId < 0) return;
final ContentResolver resolver = getContentResolver(); final ContentResolver resolver = getContentResolver();
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: { case DialogInterface.BUTTON_POSITIVE: {
resolver.delete(Accounts.CONTENT_URI, Accounts.ACCOUNT_ID + " = " + account_id, null); resolver.delete(Accounts.CONTENT_URI, Expression.equals(Accounts.ACCOUNT_ID, accountId).getSQL(), null);
// Also delete tweets related to the account we previously // Also delete tweets related to the account we previously
// deleted. // deleted.
resolver.delete(Statuses.CONTENT_URI, Statuses.ACCOUNT_ID + " = " + account_id, null); resolver.delete(Statuses.CONTENT_URI, Expression.equals(Statuses.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Mentions.CONTENT_URI, Mentions.ACCOUNT_ID + " = " + account_id, null); resolver.delete(Mentions.CONTENT_URI, Expression.equals(Mentions.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Inbox.CONTENT_URI, DirectMessages.ACCOUNT_ID + " = " + account_id, null); resolver.delete(Inbox.CONTENT_URI, Expression.equals(DirectMessages.ACCOUNT_ID, accountId).getSQL(), null);
resolver.delete(Outbox.CONTENT_URI, DirectMessages.ACCOUNT_ID + " = " + account_id, null); resolver.delete(Outbox.CONTENT_URI, Expression.equals(DirectMessages.ACCOUNT_ID, accountId).getSQL(), null);
break; break;
} }
} }
@ -216,6 +225,7 @@ public class AccountsManagerFragment extends BaseSupportFragment implements Load
mListView.setAdapter(mAdapter); mListView.setAdapter(mAdapter);
mListView.setDragEnabled(true); mListView.setDragEnabled(true);
mListView.setDropListener(this); mListView.setDropListener(this);
mListView.setOnItemClickListener(this);
mListView.setOnCreateContextMenuListener(this); mListView.setOnCreateContextMenuListener(this);
mListView.setEmptyView(mEmptyView); mListView.setEmptyView(mEmptyView);
mEmptyText.setText(R.string.no_account); mEmptyText.setText(R.string.no_account);