Search in sources :

Example 66 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Signal-Android by WhisperSystems.

the class ConversationListFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    constraintLayout = view.findViewById(R.id.constraint_layout);
    list = view.findViewById(R.id.list);
    fab = view.findViewById(R.id.fab);
    cameraFab = view.findViewById(R.id.camera_fab);
    searchEmptyState = view.findViewById(R.id.search_no_results);
    searchAction = view.findViewById(R.id.search_action);
    toolbarShadow = view.findViewById(R.id.conversation_list_toolbar_shadow);
    notificationProfileStatus = view.findViewById(R.id.conversation_list_notification_profile_status);
    proxyStatus = view.findViewById(R.id.conversation_list_proxy_status);
    unreadPaymentsDot = view.findViewById(R.id.unread_payments_indicator);
    bottomActionBar = view.findViewById(R.id.conversation_list_bottom_action_bar);
    reminderView = new Stub<>(view.findViewById(R.id.reminder));
    emptyState = new Stub<>(view.findViewById(R.id.empty_state));
    searchToolbar = new Stub<>(view.findViewById(R.id.search_toolbar));
    megaphoneContainer = new Stub<>(view.findViewById(R.id.megaphone_container));
    paymentNotificationView = new Stub<>(view.findViewById(R.id.payments_notification));
    voiceNotePlayerViewStub = new Stub<>(view.findViewById(R.id.voice_note_player));
    Toolbar toolbar = getToolbar(view);
    toolbar.setVisibility(View.VISIBLE);
    ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
    notificationProfileStatus.setOnClickListener(v -> handleNotificationProfile());
    proxyStatus.setOnClickListener(v -> onProxyStatusClicked());
    fab.show();
    cameraFab.show();
    archiveDecoration = new ConversationListArchiveItemDecoration(new ColorDrawable(getResources().getColor(R.color.conversation_list_archive_background_end)));
    itemAnimator = new ConversationListItemAnimator();
    list.setLayoutManager(new LinearLayoutManager(requireActivity()));
    list.setItemAnimator(itemAnimator);
    list.addOnScrollListener(new ScrollListener());
    list.addItemDecoration(archiveDecoration);
    snapToTopDataObserver = new SnapToTopDataObserver(list);
    new ItemTouchHelper(new ArchiveListenerCallback(getResources().getColor(R.color.conversation_list_archive_background_start), getResources().getColor(R.color.conversation_list_archive_background_end))).attachToRecyclerView(list);
    fab.setOnClickListener(v -> startActivity(new Intent(getActivity(), NewConversationActivity.class)));
    cameraFab.setOnClickListener(v -> {
        Permissions.with(this).request(Manifest.permission.CAMERA).ifNecessary().withRationaleDialog(getString(R.string.ConversationActivity_to_capture_photos_and_video_allow_signal_access_to_the_camera), R.drawable.ic_camera_24).withPermanentDenialDialog(getString(R.string.ConversationActivity_signal_needs_the_camera_permission_to_take_photos_or_video)).onAllGranted(() -> startActivity(MediaSelectionActivity.camera(requireContext()))).onAnyDenied(() -> Toast.makeText(requireContext(), R.string.ConversationActivity_signal_needs_camera_permissions_to_take_photos_or_video, Toast.LENGTH_LONG).show()).execute();
    });
    initializeViewModel();
    initializeListAdapters();
    initializeTypingObserver();
    initializeSearchListener();
    initializeVoiceNotePlayer();
    RatingManager.showRatingDialogIfNecessary(requireContext());
    TooltipCompat.setTooltipText(searchAction, getText(R.string.SearchToolbar_search_for_conversations_contacts_and_messages));
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) ColorDrawable(android.graphics.drawable.ColorDrawable) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) SnapToTopDataObserver(org.thoughtcrime.securesms.util.SnapToTopDataObserver) Intent(android.content.Intent) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) SearchToolbar(org.thoughtcrime.securesms.components.SearchToolbar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 67 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Signal-Android by WhisperSystems.

the class MentionsPickerFragment method initializeList.

private void initializeList() {
    adapter = new MentionsPickerAdapter(this::handleMentionClicked, () -> updateBottomSheetBehavior(adapter.getItemCount()));
    list.setLayoutManager(new LinearLayoutManager(requireContext()));
    list.setAdapter(adapter);
    list.setItemAnimator(null);
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 68 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project xabber-android by redsolution.

the class AccountListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account_list);
    toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NavUtils.navigateUpFromSameTask(AccountListActivity.this);
        }
    });
    toolbar.setTitle(R.string.title_reordering_account);
    toolbar.inflateMenu(R.menu.toolbar_account_list);
    toolbar.setOnMenuItemClickListener(this);
    barPainter = new BarPainter(this, toolbar);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.account_list_recycler_view);
    tvSummary = (TextView) findViewById(R.id.tvSummary);
    accountListAdapter = new AccountListReorderAdapter(this, this);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(accountListAdapter);
    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(accountListAdapter);
    touchHelper = new ItemTouchHelper(callback);
    touchHelper.attachToRecyclerView(recyclerView);
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) SimpleItemTouchHelperCallback(com.xabber.android.ui.widget.SimpleItemTouchHelperCallback) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AccountListReorderAdapter(com.xabber.android.ui.adapter.AccountListReorderAdapter) BarPainter(com.xabber.android.ui.color.BarPainter)

Example 69 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project xabber-android by redsolution.

the class AccountActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    account = getAccount(intent);
    if (account == null) {
        LogManager.i(LOG_TAG, "Account is null, finishing!");
        finish();
        return;
    }
    accountItem = AccountManager.getInstance().getAccount(account);
    if (accountItem == null) {
        Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
        finish();
        return;
    }
    if (ACTION_CONNECTION_SETTINGS.equals(intent.getAction())) {
        isConnectionSettingsAction = true;
        startAccountSettingsActivity();
        setIntent(null);
    }
    setContentView(R.layout.activity_account);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NavUtils.navigateUpFromSameTask(AccountActivity.this);
        }
    });
    toolbar.setTitle(R.string.contact_account);
    toolbar.inflateMenu(R.menu.toolbar_account);
    MenuItem item = toolbar.getMenu().findItem(R.id.action_account_switch);
    switchCompat = (SwitchCompat) item.getActionView().findViewById(R.id.account_switch_view);
    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            AccountManager.getInstance().setEnabled(accountItem.getAccount(), isChecked);
        }
    });
    barPainter = new BarPainter(this, toolbar);
    UserJid fakeAccountUser;
    try {
        fakeAccountUser = UserJid.from(account.getFullJid().asBareJid());
    } catch (UserJid.UserJidCreateException e) {
        throw new IllegalStateException();
    }
    bestContact = RosterManager.getInstance().getBestContact(account, fakeAccountUser);
    contactTitleView = findViewById(R.id.contact_title_expanded);
    statusIcon = findViewById(R.id.ivStatus);
    statusText = (TextView) findViewById(R.id.status_text);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.account_options_recycler_view);
    accountOptionsAdapter = new AccountOptionsAdapter(AccountOption.getValues(), this, accountItem);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(accountOptionsAdapter);
    recyclerView.setNestedScrollingEnabled(false);
    Fragment fragmentById = getFragmentManager().findFragmentById(R.id.account_fragment_container);
    if (fragmentById == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.account_fragment_container, ContactVcardViewerFragment.newInstance(account)).commit();
    }
}
Also used : UserJid(com.xabber.android.data.entity.UserJid) Intent(android.content.Intent) MenuItem(android.view.MenuItem) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ContactVcardViewerFragment(com.xabber.android.ui.fragment.ContactVcardViewerFragment) Fragment(android.app.Fragment) BarPainter(com.xabber.android.ui.color.BarPainter) AccountOptionsAdapter(com.xabber.android.ui.adapter.accountoptions.AccountOptionsAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) CompoundButton(android.widget.CompoundButton) Toolbar(androidx.appcompat.widget.Toolbar)

Example 70 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project xabber-android by redsolution.

the class ActiveSessionsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_active_sessions);
    final Intent intent = getIntent();
    AccountJid account = getAccount(intent);
    if (account == null) {
        finish();
        return;
    }
    accountItem = AccountManager.getInstance().getAccount(account);
    if (accountItem == null) {
        Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
        finish();
        return;
    }
    toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    toolbar.setTitle(R.string.account_active_sessions);
    barPainter = new BarPainter(this, toolbar);
    barPainter.updateWithAccountName(account);
    progressBar = findViewById(R.id.progressBar);
    contentView = findViewById(R.id.contentView);
    tvActiveSessions = findViewById(R.id.tvActiveSessions);
    terminateAll = findViewById(R.id.llTerminateAll);
    terminateAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showTerminateAllSessionsDialog();
        }
    });
    // other sessions
    RecyclerView recyclerView = findViewById(R.id.rvSessions);
    adapter = new SessionAdapter(this);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);
    recyclerView.setNestedScrollingEnabled(false);
    // current session
    tvCurrentClient = findViewById(R.id.tvClient);
    tvCurrentDevice = findViewById(R.id.tvDevice);
    tvCurrentIPAddress = findViewById(R.id.tvIPAddress);
    tvCurrentDate = findViewById(R.id.tvDate);
    updateData();
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) Intent(android.content.Intent) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) BarPainter(com.xabber.android.ui.color.BarPainter)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)502 RecyclerView (androidx.recyclerview.widget.RecyclerView)301 View (android.view.View)197 TextView (android.widget.TextView)75 ArrayList (java.util.ArrayList)44 Bundle (android.os.Bundle)43 Nullable (androidx.annotation.Nullable)41 Intent (android.content.Intent)36 ImageView (android.widget.ImageView)34 Toolbar (androidx.appcompat.widget.Toolbar)34 List (java.util.List)33 NonNull (androidx.annotation.NonNull)31 Context (android.content.Context)28 ViewGroup (android.view.ViewGroup)27 AlertDialog (androidx.appcompat.app.AlertDialog)24 Test (org.junit.Test)24 LayoutInflater (android.view.LayoutInflater)23 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)20 MenuItem (android.view.MenuItem)18 DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)17