Search in sources :

Example 1 with ScrollState

use of de.pixart.messenger.ui.util.ScrollState in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method onSaveInstanceState.

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (conversation != null) {
        outState.putString(STATE_CONVERSATION_UUID, conversation.getUuid());
        final Uri uri = pendingTakePhotoUri.peek();
        if (uri != null) {
            outState.putString(STATE_PHOTO_URI, uri.toString());
        }
        final ScrollState scrollState = getScrollPosition();
        if (scrollState != null) {
            outState.putParcelable(STATE_SCROLL_POSITION, scrollState);
        }
    }
}
Also used : ScrollState(de.pixart.messenger.ui.util.ScrollState) Uri(android.net.Uri)

Example 2 with ScrollState

use of de.pixart.messenger.ui.util.ScrollState in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method onBackendConnected.

@Override
public void onBackendConnected() {
    Log.d(Config.LOGTAG, "ConversationFragment.onBackendConnected()");
    String uuid = pendingConversationsUuid.pop();
    if (uuid != null) {
        Conversation conversation = activity.xmppConnectionService.findConversationByUuid(uuid);
        if (conversation == null) {
            Log.d(Config.LOGTAG, "unable to restore activity");
            clearPending();
            return;
        }
        reInit(conversation);
        ScrollState scrollState = pendingScrollState.pop();
        if (scrollState != null) {
            setScrollPosition(scrollState);
        }
    }
    ActivityResult activityResult = postponedActivityResult.pop();
    if (activityResult != null) {
        handleActivityResult(activityResult);
    }
    clearPending();
}
Also used : ScrollState(de.pixart.messenger.ui.util.ScrollState) Conversation(de.pixart.messenger.entities.Conversation) ActivityResult(de.pixart.messenger.ui.util.ActivityResult)

Example 3 with ScrollState

use of de.pixart.messenger.ui.util.ScrollState in project Pix-Art-Messenger by kriztan.

the class ConversationsOverviewFragment method onSaveInstanceState.

@Override
public void onSaveInstanceState(Bundle bundle) {
    super.onSaveInstanceState(bundle);
    ScrollState scrollState = getScrollState();
    if (scrollState != null) {
        bundle.putParcelable(STATE_SCROLL_POSITION, scrollState);
    }
}
Also used : ScrollState(de.pixart.messenger.ui.util.ScrollState)

Example 4 with ScrollState

use of de.pixart.messenger.ui.util.ScrollState in project Pix-Art-Messenger by kriztan.

the class ConversationsOverviewFragment method refresh.

@Override
void refresh() {
    if (this.binding == null || this.activity == null) {
        Log.d(Config.LOGTAG, "ConversationsOverviewFragment.refresh() skipped updated because view binding or activity was null");
        return;
    }
    this.activity.xmppConnectionService.populateWithOrderedConversations(this.conversations);
    this.conversationsAdapter.notifyDataSetChanged();
    ScrollState scrollState = pendingScrollState.pop();
    if (scrollState != null) {
        setScrollPosition(scrollState);
    }
}
Also used : ScrollState(de.pixart.messenger.ui.util.ScrollState)

Example 5 with ScrollState

use of de.pixart.messenger.ui.util.ScrollState in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method getScrollPosition.

private ScrollState getScrollPosition() {
    final ListView listView = this.binding.messagesView;
    if (listView.getCount() == 0 || listView.getLastVisiblePosition() == listView.getCount() - 1) {
        return null;
    } else {
        final int pos = listView.getFirstVisiblePosition();
        final View view = listView.getChildAt(0);
        if (view == null) {
            return null;
        } else {
            return new ScrollState(pos, view.getTop());
        }
    }
}
Also used : ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) ScrollState(de.pixart.messenger.ui.util.ScrollState) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) SuppressLint(android.annotation.SuppressLint)

Aggregations

ScrollState (de.pixart.messenger.ui.util.ScrollState)6 View (android.view.View)2 SuppressLint (android.annotation.SuppressLint)1 Uri (android.net.Uri)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 Conversation (de.pixart.messenger.entities.Conversation)1 ActivityResult (de.pixart.messenger.ui.util.ActivityResult)1