Search in sources :

Example 1 with BaseActivity

use of com.keylesspalace.tusky.BaseActivity in project Tusky by Vavassor.

the class SFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    BaseActivity activity = (BaseActivity) getActivity();
    mastodonAPI = activity.mastodonAPI;
    userRemovedListener = (OnUserRemovedListener) activity;
}
Also used : BaseActivity(com.keylesspalace.tusky.BaseActivity)

Example 2 with BaseActivity

use of com.keylesspalace.tusky.BaseActivity in project Tusky by Vavassor.

the class AccountListFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    BaseActivity activity = (BaseActivity) getActivity();
    if (jumpToTopAllowed()) {
        TabLayout layout = (TabLayout) activity.findViewById(R.id.tab_layout);
        onTabSelectedListener = new TabLayout.OnTabSelectedListener() {

            @Override
            public void onTabSelected(TabLayout.Tab tab) {
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
                jumpToTop();
            }
        };
        layout.addOnTabSelectedListener(onTabSelectedListener);
    }
    /* MastodonAPI on the base activity is only guaranteed to be initialised after the parent
         * activity is created, so everything needing to access the api object has to be delayed
         * until here. */
    api = activity.mastodonAPI;
    scrollListener = new EndlessOnScrollListener(layoutManager) {

        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            AccountAdapter adapter = (AccountAdapter) view.getAdapter();
            Account account = adapter.getItem(adapter.getItemCount() - 2);
            if (account != null) {
                fetchAccounts(account.id, null);
            } else {
                fetchAccounts();
            }
        }
    };
    recyclerView.addOnScrollListener(scrollListener);
}
Also used : Account(com.keylesspalace.tusky.entity.Account) EndlessOnScrollListener(com.keylesspalace.tusky.view.EndlessOnScrollListener) TabLayout(android.support.design.widget.TabLayout) BaseActivity(com.keylesspalace.tusky.BaseActivity) RecyclerView(android.support.v7.widget.RecyclerView) AccountAdapter(com.keylesspalace.tusky.adapter.AccountAdapter)

Example 3 with BaseActivity

use of com.keylesspalace.tusky.BaseActivity in project Tusky by Vavassor.

the class ViewThreadFragment method onShowFavs.

@Override
public void onShowFavs(int position) {
    String statusId = statuses.get(position).getId();
    Intent intent = AccountListActivity.newIntent(getContext(), AccountListActivity.Type.FAVOURITED, statusId);
    ((BaseActivity) getActivity()).startActivityWithSlideInAnimation(intent);
}
Also used : BaseActivity(com.keylesspalace.tusky.BaseActivity) Intent(android.content.Intent)

Example 4 with BaseActivity

use of com.keylesspalace.tusky.BaseActivity in project Tusky by Vavassor.

the class SFragment method showOpenAsDialog.

private void showOpenAsDialog(String statusUrl, CharSequence dialogTitle) {
    BaseActivity activity = (BaseActivity) getActivity();
    activity.showAccountChooserDialog(dialogTitle, false, account -> openAsAccount(statusUrl, account));
}
Also used : BaseActivity(com.keylesspalace.tusky.BaseActivity)

Example 5 with BaseActivity

use of com.keylesspalace.tusky.BaseActivity in project Tusky by Vavassor.

the class SFragment method openAsAccount.

private void openAsAccount(String statusUrl, AccountEntity account) {
    accountManager.setActiveAccount(account);
    Intent intent = new Intent(getContext(), MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.putExtra(MainActivity.STATUS_URL, statusUrl);
    startActivity(intent);
    ((BaseActivity) getActivity()).finishWithoutSlideOutAnimation();
}
Also used : BaseActivity(com.keylesspalace.tusky.BaseActivity) Intent(android.content.Intent)

Aggregations

BaseActivity (com.keylesspalace.tusky.BaseActivity)6 Intent (android.content.Intent)3 TabLayout (android.support.design.widget.TabLayout)1 RecyclerView (android.support.v7.widget.RecyclerView)1 AccountAdapter (com.keylesspalace.tusky.adapter.AccountAdapter)1 Account (com.keylesspalace.tusky.entity.Account)1 EndlessOnScrollListener (com.keylesspalace.tusky.view.EndlessOnScrollListener)1