mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-07 23:47:30 +00:00
Merge branch 'master' into feature/scroll-stories-with-feed
This commit is contained in:
commit
88ed4257c0
@ -264,7 +264,8 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private RecyclerLazyLoader feedLazyLoader, discoverLazyLoader;
|
||||
private DiscoverAdapter discoverAdapter;
|
||||
public SimpleExoPlayer currentFeedPlayer; // hack for remix drawer layout
|
||||
public final boolean isLoggedIn = !Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE));
|
||||
private String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
|
||||
public boolean isLoggedIn = !Utils.isEmpty(cookie);
|
||||
|
||||
public MainHelper(@NonNull final Main main) {
|
||||
stopCurrentExecutor();
|
||||
@ -282,6 +283,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
final ImageView iconDiscover = (ImageView) iconSlider.getChildAt(2);
|
||||
|
||||
final boolean isBottomToolbar = Utils.settingsHelper.getBoolean(BOTTOM_TOOLBAR);
|
||||
isLoggedIn = !Utils.isEmpty(cookie);
|
||||
if (!isLoggedIn) {
|
||||
main.mainBinding.drawerLayout.removeView(main.mainBinding.feedView.feedLayout);
|
||||
main.mainBinding.drawerLayout.removeView(main.mainBinding.discoverSwipeRefreshLayout);
|
||||
@ -724,9 +726,6 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
return;
|
||||
}
|
||||
|
||||
final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
|
||||
final boolean isLoggedIn = !Utils.isEmpty(cookie);
|
||||
|
||||
currentlyExecuting = new PostsFetcher(main.userQuery, postsFetchListener)
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
@ -793,25 +792,25 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
main.mainBinding.profileView.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
|
||||
final String profileId = profileModel.getId();
|
||||
|
||||
final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
|
||||
final boolean isLoggedIn = !Utils.isEmpty(cookie);
|
||||
new iStoryStatusFetcher(profileId, profileModel.getUsername(), false, false,
|
||||
(!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), false,
|
||||
result -> {
|
||||
main.storyModels = result;
|
||||
if (result != null && result.length > 0) main.mainBinding.profileView.mainProfileImage.setStoriesBorder();
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (isLoggedIn || Utils.settingsHelper.getBoolean(Constants.STORIESIG)) {
|
||||
new iStoryStatusFetcher(profileId, profileModel.getUsername(), false, false,
|
||||
(!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), false,
|
||||
result -> {
|
||||
main.storyModels = result;
|
||||
if (result != null && result.length > 0) main.mainBinding.profileView.mainProfileImage.setStoriesBorder();
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
new HighlightsFetcher(profileId, (!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), result -> {
|
||||
if (result != null && result.length > 0) {
|
||||
main.mainBinding.profileView.highlightsList.setVisibility(View.VISIBLE);
|
||||
main.highlightsAdapter.setData(result);
|
||||
}
|
||||
else main.mainBinding.profileView.highlightsList.setVisibility(View.GONE);
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new HighlightsFetcher(profileId, (!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), result -> {
|
||||
if (result != null && result.length > 0) {
|
||||
main.mainBinding.profileView.highlightsList.setVisibility(View.VISIBLE);
|
||||
main.highlightsAdapter.setData(result);
|
||||
}
|
||||
else main.mainBinding.profileView.highlightsList.setVisibility(View.GONE);
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
if (isLoggedIn) {
|
||||
final String myId = Utils.getUserIdFromCookie(Utils.settingsHelper.getString(Constants.COOKIE));
|
||||
final String myId = Utils.getUserIdFromCookie(cookie);
|
||||
if (!profileId.equals(myId)) {
|
||||
main.mainBinding.profileView.btnTagged.setVisibility(View.GONE);
|
||||
main.mainBinding.profileView.btnSaved.setVisibility(View.GONE);
|
||||
@ -1009,8 +1008,6 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
final String profileId = locationModel.getId();
|
||||
|
||||
final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
|
||||
final boolean isLoggedIn = !Utils.isEmpty(cookie);
|
||||
if (isLoggedIn) {
|
||||
new iStoryStatusFetcher(profileId.split("/")[0], null, true, false, false, false, result -> {
|
||||
main.storyModels = result;
|
||||
@ -1224,7 +1221,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
final boolean iamme = (isLoggedIn && main.profileModel != null)
|
||||
? Utils.getUserIdFromCookie(Utils.settingsHelper.getString(Constants.COOKIE)).equals(main.profileModel.getId())
|
||||
? Utils.getUserIdFromCookie(cookie).equals(main.profileModel.getId())
|
||||
: false;
|
||||
if (!isLoggedIn && Utils.dataBox.getFavorite(main.userQuery) != null && v == main.mainBinding.profileView.btnFollow) {
|
||||
Utils.dataBox.delFavorite(new DataBox.FavoriteModel(main.userQuery,
|
||||
@ -1284,8 +1281,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
urlConnection.setRequestMethod("POST");
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT);
|
||||
urlConnection.setRequestProperty("x-csrftoken",
|
||||
Utils.settingsHelper.getString(Constants.COOKIE).split("csrftoken=")[1].split(";")[0]);
|
||||
urlConnection.setRequestProperty("x-csrftoken", cookie.split("csrftoken=")[1].split(";")[0]);
|
||||
if (action == "restrict") {
|
||||
final String urlParameters = "target_user_id="+main.profileModel.getId();
|
||||
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
@ -164,7 +164,7 @@ public final class DirectMessagesUserInbox extends AppCompatActivity {
|
||||
.putExtra(Constants.EXTRAS_STORIES, sms)
|
||||
);
|
||||
}
|
||||
else if (directItemModel.getText() != null) {
|
||||
else if (directItemModel.getText() != null && directItemModel.getText().toString().contains("@")) {
|
||||
searchUsername(directItemModel.getText().toString().split("@")[1].split(" ")[0]);
|
||||
}
|
||||
break;
|
||||
|
@ -135,6 +135,7 @@ public final class Main extends BaseLanguageActivity {
|
||||
setStack(bundle);
|
||||
userQuery = bundle.getString("query");
|
||||
}
|
||||
mainHelper.isLoggedIn = !Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE));
|
||||
|
||||
itemGetter = itemGetType -> {
|
||||
if (itemGetType == ItemGetType.MAIN_ITEMS) return allItems;
|
||||
|
@ -60,11 +60,11 @@ public final class DirectMessagesAdapter extends RecyclerView.Adapter<DirectMess
|
||||
for (int i = 0; i < Math.min(3, users.length); ++i)
|
||||
glideRequestManager.load(users[i].getSdProfilePic()).into(holder.multipleProfilePics[i]);
|
||||
|
||||
} else if (users.length == 1) {
|
||||
} else {
|
||||
holder.ivProfilePic.setVisibility(View.VISIBLE);
|
||||
holder.multipleProfilePicsContainer.setVisibility(View.GONE);
|
||||
|
||||
glideRequestManager.load(users[0].getSdProfilePic()).into(holder.ivProfilePic);
|
||||
glideRequestManager.load(users.length == 1 ? users[0].getSdProfilePic() : null).into(holder.ivProfilePic);
|
||||
}
|
||||
|
||||
holder.tvUsername.setText(threadModel.getThreadTitle());
|
||||
@ -79,6 +79,7 @@ public final class DirectMessagesAdapter extends RecyclerView.Adapter<DirectMess
|
||||
final CharSequence messageText;
|
||||
switch (itemType) {
|
||||
case TEXT:
|
||||
case LIKE:
|
||||
messageText = lastItemModel.getText();
|
||||
break;
|
||||
case LINK:
|
||||
|
@ -167,6 +167,7 @@ public final class MessageItemsAdapter extends RecyclerView.Adapter<TextMessageV
|
||||
holder.tvMessage.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case TEXT:
|
||||
case LIKE:
|
||||
text = directItemModel.getText();
|
||||
text = Utils.getSpannableUrl(text.toString()); // for urls
|
||||
if (Utils.hasMentions(text)) text = Utils.getMentionText(text); // for mentions
|
||||
@ -217,13 +218,11 @@ public final class MessageItemsAdapter extends RecyclerView.Adapter<TextMessageV
|
||||
|
||||
case RAVEN_MEDIA: {
|
||||
final DirectItemRavenMediaModel ravenMediaModel = directItemModel.getRavenMediaModel();
|
||||
final RavenExpiringMediaActionSummaryModel mediaActionSummary = ravenMediaModel.getExpiringMediaActionSummary();
|
||||
|
||||
mediaModel = ravenMediaModel.getMedia();
|
||||
|
||||
final boolean isExpired = mediaModel == null ||
|
||||
final boolean isExpired = ravenMediaModel == null || (mediaModel = ravenMediaModel.getMedia()) == null ||
|
||||
Utils.isEmpty(mediaModel.getThumbUrl()) && mediaModel.getPk() < 1;
|
||||
|
||||
final RavenExpiringMediaActionSummaryModel mediaActionSummary = ravenMediaModel.getExpiringMediaActionSummary();
|
||||
holder.mediaExpiredIcon.setVisibility(isExpired ? View.VISIBLE : View.GONE);
|
||||
|
||||
int textRes = R.string.dms_inbox_raven_media_unknown;
|
||||
|
@ -702,8 +702,7 @@ public final class Utils {
|
||||
break;
|
||||
|
||||
case LIKE:
|
||||
text = new SpannableString(itemObject.getString("like"));
|
||||
((SpannableString) text).setSpan(new RelativeSizeSpan(15f), 0, text.length(), 0);
|
||||
text = itemObject.getString("like");
|
||||
break;
|
||||
|
||||
case STORY_SHARE:
|
||||
|
Loading…
Reference in New Issue
Block a user