mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-05 22:24:45 +01:00
This commit is contained in:
parent
533b45c01a
commit
c1190c0d87
@ -24,8 +24,10 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import androidx.transition.AutoTransition;
|
import androidx.transition.AutoTransition;
|
||||||
import androidx.transition.TransitionManager;
|
import androidx.transition.TransitionManager;
|
||||||
|
|
||||||
|
import com.evernote.android.state.State;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.livefront.bridge.Bridge;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@ -61,7 +63,6 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
public static final String EXTRA_PRIVATE_MESSAGE_INDEX = "EPM";
|
public static final String EXTRA_PRIVATE_MESSAGE_INDEX = "EPM";
|
||||||
public static final String EXTRA_MESSAGE_POSITION = "EMP";
|
public static final String EXTRA_MESSAGE_POSITION = "EMP";
|
||||||
private static final String USER_AVATAR_STATE = "UAS";
|
private static final String USER_AVATAR_STATE = "UAS";
|
||||||
private static final String PRIVATE_MESSAGES_STATE = "PMS";
|
|
||||||
@BindView(R.id.coordinator_layout_view_private_messages_activity)
|
@BindView(R.id.coordinator_layout_view_private_messages_activity)
|
||||||
CoordinatorLayout mCoordinatorLayout;
|
CoordinatorLayout mCoordinatorLayout;
|
||||||
@BindView(R.id.appbar_layout_view_private_messages_activity)
|
@BindView(R.id.appbar_layout_view_private_messages_activity)
|
||||||
@ -98,7 +99,10 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
private LinearLayoutManagerBugFixed mLinearLayoutManager;
|
private LinearLayoutManagerBugFixed mLinearLayoutManager;
|
||||||
private PrivateMessagesDetailRecyclerViewAdapter mAdapter;
|
private PrivateMessagesDetailRecyclerViewAdapter mAdapter;
|
||||||
private Message privateMessage;
|
@State
|
||||||
|
Message privateMessage;
|
||||||
|
@State
|
||||||
|
Message replyTo;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String mUserAvatar;
|
private String mUserAvatar;
|
||||||
@ -118,6 +122,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
|
|
||||||
setContentView(R.layout.activity_view_private_messages);
|
setContentView(R.layout.activity_view_private_messages);
|
||||||
|
|
||||||
|
Bridge.restoreInstanceState(this, savedInstanceState);
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
@ -162,7 +168,6 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mUserAvatar = savedInstanceState.getString(USER_AVATAR_STATE);
|
mUserAvatar = savedInstanceState.getString(USER_AVATAR_STATE);
|
||||||
privateMessage = savedInstanceState.getParcelable(PRIVATE_MESSAGES_STATE);
|
|
||||||
if (privateMessage == null) {
|
if (privateMessage == null) {
|
||||||
EventBus.getDefault().post(new PassPrivateMessageIndexEvent(getIntent().getIntExtra(EXTRA_PRIVATE_MESSAGE_INDEX, -1)));
|
EventBus.getDefault().post(new PassPrivateMessageIndexEvent(getIntent().getIntExtra(EXTRA_PRIVATE_MESSAGE_INDEX, -1)));
|
||||||
} else {
|
} else {
|
||||||
@ -226,14 +231,10 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
if (!mEditText.getText().toString().equals("")) {
|
if (!mEditText.getText().toString().equals("")) {
|
||||||
//Send Message
|
//Send Message
|
||||||
if (privateMessage != null) {
|
if (privateMessage != null) {
|
||||||
Message replyTo;
|
|
||||||
ArrayList<Message> replies = privateMessage.getReplies();
|
ArrayList<Message> replies = privateMessage.getReplies();
|
||||||
if (replies != null && !replies.isEmpty()) {
|
if (replyTo == null) {
|
||||||
replyTo = replies.get(replies.size() - 1);
|
|
||||||
} else {
|
|
||||||
replyTo = privateMessage;
|
replyTo = privateMessage;
|
||||||
}
|
}
|
||||||
if (replyTo != null) {
|
|
||||||
isSendingMessage = true;
|
isSendingMessage = true;
|
||||||
mSendImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mSendImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
ReplyMessage.replyMessage(mEditText.getText().toString(), replyTo.getFullname(),
|
ReplyMessage.replyMessage(mEditText.getText().toString(), replyTo.getFullname(),
|
||||||
@ -284,10 +285,6 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
public void readFailed() {}
|
public void readFailed() {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
isSendingMessage = false;
|
|
||||||
Snackbar.make(mCoordinatorLayout, R.string.error_getting_message, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,13 +334,14 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putString(USER_AVATAR_STATE, mUserAvatar);
|
outState.putString(USER_AVATAR_STATE, mUserAvatar);
|
||||||
outState.putParcelable(PRIVATE_MESSAGES_STATE, privateMessage);
|
Bridge.saveInstanceState(this, outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
EventBus.getDefault().unregister(this);
|
EventBus.getDefault().unregister(this);
|
||||||
|
Bridge.clear(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -383,6 +381,20 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
public void onPassPrivateMessageEvent(PassPrivateMessageEvent passPrivateMessageEvent) {
|
public void onPassPrivateMessageEvent(PassPrivateMessageEvent passPrivateMessageEvent) {
|
||||||
privateMessage = passPrivateMessageEvent.message;
|
privateMessage = passPrivateMessageEvent.message;
|
||||||
if (privateMessage != null) {
|
if (privateMessage != null) {
|
||||||
|
if (privateMessage.getAuthor().equals(mAccountName)) {
|
||||||
|
for (int i = privateMessage.getReplies().size() - 1; i >= 0; i--) {
|
||||||
|
if (!privateMessage.getReplies().get(i).getAuthor().equals(mAccountName)) {
|
||||||
|
replyTo = privateMessage.getReplies().get(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (replyTo == null) {
|
||||||
|
replyTo = privateMessage;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
replyTo = privateMessage;
|
||||||
|
}
|
||||||
|
|
||||||
bindView();
|
bindView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1216,12 +1216,10 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
comments = mCommentsAdapter == null ? null : mCommentsAdapter.getVisibleComments();
|
comments = mCommentsAdapter == null ? null : mCommentsAdapter.getVisibleComments();
|
||||||
if (mCommentsRecyclerView != null) {
|
if (mCommentsRecyclerView != null) {
|
||||||
//scrollpositionn = mcommentsadapter.getPosition()
|
|
||||||
LinearLayoutManager myLayoutManager = (LinearLayoutManager) mCommentsRecyclerView.getLayoutManager();
|
LinearLayoutManager myLayoutManager = (LinearLayoutManager) mCommentsRecyclerView.getLayoutManager();
|
||||||
scrollPosition = myLayoutManager != null ? myLayoutManager.findFirstVisibleItemPosition() : 0;
|
scrollPosition = myLayoutManager != null ? myLayoutManager.findFirstVisibleItemPosition() : 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//scrollposition = mrecyclerviewadapter.getposition()
|
|
||||||
LinearLayoutManager myLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
LinearLayoutManager myLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
||||||
scrollPosition = myLayoutManager != null ? myLayoutManager.findFirstVisibleItemPosition() : 0;
|
scrollPosition = myLayoutManager != null ? myLayoutManager.findFirstVisibleItemPosition() : 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user