mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-08 07:57:28 +00:00
Add Location fragment
This commit is contained in:
parent
5c273d18a4
commit
649115a665
@ -307,7 +307,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
};
|
||||
private final MentionClickListener mentionClickListener = new MentionClickListener() {
|
||||
@Override
|
||||
public void onClick(final RamboTextView view, final String text, final boolean isHashtag) {
|
||||
public void onClick(final RamboTextView view, final String text, final boolean isHashtag, final boolean isLocation) {
|
||||
new AlertDialog.Builder(mainActivity).setMessage(isHashtag ? R.string.comment_view_mention_hash_search : R.string.comment_view_mention_user_search)
|
||||
.setTitle(text).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||
if (MainActivityBackup.scanHack != null) MainActivityBackup.scanHack.onResult(text);
|
||||
@ -640,7 +640,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
case R.id.ivProfilePic:
|
||||
profileModel = feedModel.getProfileModel();
|
||||
if (profileModel != null)
|
||||
mentionClickListener.onClick(null, profileModel.getUsername(), false);
|
||||
mentionClickListener.onClick(null, profileModel.getUsername(), false, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -655,7 +655,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
final LinearLayoutManager layoutManager = new LinearLayoutManager(mainActivity);
|
||||
mainActivity.mainBinding.feedView.feedPosts.setHasFixedSize(true);
|
||||
mainActivity.mainBinding.feedView.feedPosts.setLayoutManager(layoutManager);
|
||||
mainActivity.mainBinding.feedView.feedPosts.setAdapter(feedAdapter = new FeedAdapter(clickListener, (view, text, isHashtag) ->
|
||||
mainActivity.mainBinding.feedView.feedPosts.setAdapter(feedAdapter = new FeedAdapter(clickListener, (view, text, isHashtag, isLocation) ->
|
||||
new AlertDialog.Builder(mainActivity).setMessage(isHashtag ? R.string.comment_view_mention_hash_search : R.string.comment_view_mention_user_search)
|
||||
.setTitle(text).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||
if (MainActivityBackup.scanHack != null) {
|
||||
|
@ -187,7 +187,7 @@ public final class CommentsViewer extends BaseLanguageActivity implements SwipeR
|
||||
}
|
||||
};
|
||||
|
||||
private final MentionClickListener mentionClickListener = (view, text, isHashtag) ->
|
||||
private final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) ->
|
||||
new AlertDialog.Builder(this).setTitle(text)
|
||||
.setMessage(isHashtag ? R.string.comment_view_mention_hash_search : R.string.comment_view_mention_user_search)
|
||||
.setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok,
|
||||
|
@ -44,7 +44,8 @@ public class MainActivity extends BaseLanguageActivity {
|
||||
R.id.discoverFragment,
|
||||
R.id.morePreferencesFragment,
|
||||
R.id.settingsPreferencesFragment,
|
||||
R.id.hashTagFragment);
|
||||
R.id.hashTagFragment,
|
||||
R.id.locationFragment);
|
||||
private ActivityMainBinding binding;
|
||||
private LiveData<NavController> currentNavControllerLiveData;
|
||||
|
||||
|
@ -114,7 +114,7 @@ public final class NotificationsViewer extends BaseLanguageActivity implements S
|
||||
}
|
||||
};
|
||||
|
||||
private final MentionClickListener mentionClickListener = (view, text, isHashtag) ->
|
||||
private final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) ->
|
||||
new AlertDialog.Builder(this).setTitle(text)
|
||||
.setMessage(isHashtag ? R.string.comment_view_mention_hash_search : R.string.comment_view_mention_user_search)
|
||||
.setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok,
|
||||
|
@ -276,7 +276,7 @@ public final class PostViewer extends BaseLanguageActivity {
|
||||
resources = getResources();
|
||||
|
||||
viewerBinding.topPanel.title.setMovementMethod(new LinkMovementMethod());
|
||||
viewerBinding.topPanel.title.setMentionClickListener((view, text, isHashtag) -> searchUsername(text));
|
||||
viewerBinding.topPanel.title.setMentionClickListener((view, text, isHashtag, isLocation) -> searchUsername(text));
|
||||
viewerBinding.topPanel.ivProfilePic.setOnClickListener(onClickListener);
|
||||
|
||||
viewerBinding.ivToggleFullScreen.setOnClickListener(onClickListener);
|
||||
@ -578,7 +578,7 @@ public final class PostViewer extends BaseLanguageActivity {
|
||||
|
||||
if (Utils.hasMentions(postCaption)) {
|
||||
viewerBinding.bottomPanel.viewerCaption.setText(Utils.getMentionText(postCaption), TextView.BufferType.SPANNABLE);
|
||||
viewerBinding.bottomPanel.viewerCaption.setMentionClickListener((view, text, isHashtag) -> searchUsername(text));
|
||||
viewerBinding.bottomPanel.viewerCaption.setMentionClickListener((view, text, isHashtag, isLocation) -> searchUsername(text));
|
||||
} else {
|
||||
viewerBinding.bottomPanel.viewerCaption.setMentionClickListener(null);
|
||||
viewerBinding.bottomPanel.viewerCaption.setText(postCaption);
|
||||
|
@ -127,7 +127,7 @@ public final class ProfileViewer extends BaseLanguageActivity implements SwipeRe
|
||||
};
|
||||
private final MentionClickListener mentionClickListener = new MentionClickListener() {
|
||||
@Override
|
||||
public void onClick(final RamboTextView view, final String text, final boolean isHashtag) {
|
||||
public void onClick(final RamboTextView view, final String text, final boolean isHashtag, final boolean isLocation) {
|
||||
startActivity(new Intent(getApplicationContext(), ProfileViewer.class).putExtra(Constants.EXTRAS_USERNAME, text));
|
||||
}
|
||||
};
|
||||
|
@ -8,12 +8,10 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.customviews.CommentMentionClickSpan;
|
||||
import awais.instagrabber.customviews.RamboTextView;
|
||||
import awais.instagrabber.databinding.ItemFeedBottomBinding;
|
||||
@ -65,7 +63,7 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
|
||||
final SpannableString spannableString = new SpannableString("@" + profileModel.getUsername());
|
||||
spannableString.setSpan(new CommentMentionClickSpan(), 0, titleLen, 0);
|
||||
topBinding.title.setText(spannableString);
|
||||
topBinding.title.setMentionClickListener((view, text, isHashtag) -> mentionClickListener.onClick(null, profileModel.getUsername(), false));
|
||||
topBinding.title.setMentionClickListener((view, text, isHashtag, isLocation) -> mentionClickListener.onClick(null, profileModel.getUsername(), false, false));
|
||||
}
|
||||
bottomBinding.tvPostDate.setText(feedModel.getPostDate());
|
||||
final long commentsCount = feedModel.getCommentsCount();
|
||||
@ -101,12 +99,10 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
|
||||
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
topBinding.location.setOnClickListener(v -> {
|
||||
new AlertDialog.Builder(v.getContext()).setTitle(location.optString("name"))
|
||||
.setMessage(R.string.comment_view_mention_location_search)
|
||||
.setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.ok,
|
||||
(dialog, which) -> mentionClickListener.onClick(null, location.optString("id") + "/" + location.optString("slug"), false)).show();
|
||||
});
|
||||
topBinding.location.setOnClickListener(v -> mentionClickListener.onClick(topBinding.location,
|
||||
location.optString("id") + "/" + location.optString("slug"),
|
||||
false,
|
||||
true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public final class RamboTextView extends AppCompatTextView {
|
||||
if (indexOfEllipsize != -1)
|
||||
subSequence = subSequence.subSequence(0, indexOfEllipsize - 1);
|
||||
|
||||
mentionClickListener.onClick(this, subSequence.toString(), ishHashtag);
|
||||
mentionClickListener.onClick(this, subSequence.toString(), ishHashtag, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,341 @@
|
||||
package awais.instagrabber.fragments;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.view.ActionMode;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.activity.OnBackPressedDispatcher;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.MainActivity;
|
||||
import awais.instagrabber.activities.PostViewer;
|
||||
import awais.instagrabber.adapters.PostsAdapter;
|
||||
import awais.instagrabber.asyncs.LocationFetcher;
|
||||
import awais.instagrabber.asyncs.PostsFetcher;
|
||||
import awais.instagrabber.asyncs.i.iStoryStatusFetcher;
|
||||
import awais.instagrabber.customviews.PrimaryActionModeCallback;
|
||||
import awais.instagrabber.customviews.helpers.GridAutofitLayoutManager;
|
||||
import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration;
|
||||
import awais.instagrabber.customviews.helpers.NestedCoordinatorLayout;
|
||||
import awais.instagrabber.customviews.helpers.RecyclerLazyLoader;
|
||||
import awais.instagrabber.databinding.FragmentLocationBinding;
|
||||
import awais.instagrabber.fragments.main.viewmodels.PostsViewModel;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.LocationModel;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
import awais.instagrabber.models.StoryModel;
|
||||
import awais.instagrabber.models.enums.DownloadMethod;
|
||||
import awais.instagrabber.models.enums.ItemGetType;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awaisomereport.LogCollector;
|
||||
|
||||
import static awais.instagrabber.utils.Utils.logCollector;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public class LocationFragment extends Fragment {
|
||||
private static final String TAG = "LocationFragment";
|
||||
|
||||
private MainActivity fragmentActivity;
|
||||
private FragmentLocationBinding binding;
|
||||
private NestedCoordinatorLayout root;
|
||||
private boolean shouldRefresh = true;
|
||||
private String location;
|
||||
private LocationModel locationModel;
|
||||
private PostsViewModel postsViewModel;
|
||||
private PostsAdapter postsAdapter;
|
||||
private ActionMode actionMode;
|
||||
private boolean hasNextPage;
|
||||
private String endCursor;
|
||||
private AsyncTask<?, ?, ?> currentlyExecuting;
|
||||
private boolean isLoggedIn;
|
||||
private StoryModel[] storyModels;
|
||||
|
||||
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (postsAdapter == null) {
|
||||
setEnabled(false);
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
postsAdapter.clearSelection();
|
||||
setEnabled(false);
|
||||
remove();
|
||||
}
|
||||
};
|
||||
private final PrimaryActionModeCallback multiSelectAction = new PrimaryActionModeCallback(
|
||||
R.menu.multi_select_download_menu,
|
||||
new PrimaryActionModeCallback.CallbacksHelper() {
|
||||
@Override
|
||||
public void onDestroy(final ActionMode mode) {
|
||||
onBackPressedCallback.handleOnBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_download) {
|
||||
if (postsAdapter == null || location == null) {
|
||||
return false;
|
||||
}
|
||||
Utils.batchDownload(requireContext(),
|
||||
location,
|
||||
DownloadMethod.DOWNLOAD_MAIN,
|
||||
postsAdapter.getSelectedModels());
|
||||
checkAndResetAction();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
private final FetchListener<PostModel[]> postsFetchListener = new FetchListener<PostModel[]>() {
|
||||
@Override
|
||||
public void onResult(final PostModel[] result) {
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
if (result == null) return;
|
||||
binding.mainPosts.post(() -> binding.mainPosts.setVisibility(View.VISIBLE));
|
||||
final List<PostModel> postModels = postsViewModel.getList().getValue();
|
||||
final List<PostModel> finalList = postModels == null || postModels.isEmpty() ? new ArrayList<>() : new ArrayList<>(postModels);
|
||||
finalList.addAll(Arrays.asList(result));
|
||||
postsViewModel.getList().postValue(finalList);
|
||||
PostModel model = null;
|
||||
if (result.length != 0) {
|
||||
model = result[result.length - 1];
|
||||
}
|
||||
if (model == null) return;
|
||||
endCursor = model.getEndCursor();
|
||||
hasNextPage = model.hasNextPage();
|
||||
model.setPageCursor(false, null);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fragmentActivity = (MainActivity) requireActivity();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
|
||||
if (root != null) {
|
||||
shouldRefresh = false;
|
||||
return root;
|
||||
}
|
||||
binding = FragmentLocationBinding.inflate(inflater, container, false);
|
||||
root = binding.getRoot();
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||
if (!shouldRefresh) return;
|
||||
init();
|
||||
shouldRefresh = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (postsViewModel != null) {
|
||||
postsViewModel.getList().postValue(Collections.emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (getArguments() == null) return;
|
||||
final String cookie = settingsHelper.getString(Constants.COOKIE);
|
||||
isLoggedIn = !Utils.isEmpty(cookie) && Utils.getUserIdFromCookie(cookie) != null;
|
||||
final LocationFragmentArgs fragmentArgs = LocationFragmentArgs.fromBundle(getArguments());
|
||||
location = fragmentArgs.getLocation();
|
||||
setTitle();
|
||||
setupPosts();
|
||||
fetchLocationModel();
|
||||
}
|
||||
|
||||
private void setupPosts() {
|
||||
postsViewModel = new ViewModelProvider(this).get(PostsViewModel.class);
|
||||
final GridAutofitLayoutManager layoutManager = new GridAutofitLayoutManager(requireContext(), Utils.convertDpToPx(110));
|
||||
binding.mainPosts.setLayoutManager(layoutManager);
|
||||
binding.mainPosts.addItemDecoration(new GridSpacingItemDecoration(Utils.convertDpToPx(4)));
|
||||
postsAdapter = new PostsAdapter((postModel, position) -> {
|
||||
if (postsAdapter.isSelecting()) {
|
||||
if (actionMode == null) return;
|
||||
final String title = getString(R.string.number_selected, postsAdapter.getSelectedModels().size());
|
||||
actionMode.setTitle(title);
|
||||
return;
|
||||
}
|
||||
if (checkAndResetAction()) return;
|
||||
startActivity(new Intent(requireContext(), PostViewer.class)
|
||||
.putExtra(Constants.EXTRAS_INDEX, position)
|
||||
.putExtra(Constants.EXTRAS_POST, postModel)
|
||||
.putExtra(Constants.EXTRAS_USER, location)
|
||||
.putExtra(Constants.EXTRAS_TYPE, ItemGetType.MAIN_ITEMS));
|
||||
|
||||
}, (model, position) -> {
|
||||
if (!postsAdapter.isSelecting()) {
|
||||
checkAndResetAction();
|
||||
return true;
|
||||
}
|
||||
if (onBackPressedCallback.isEnabled()) {
|
||||
return true;
|
||||
}
|
||||
final OnBackPressedDispatcher onBackPressedDispatcher = fragmentActivity.getOnBackPressedDispatcher();
|
||||
onBackPressedCallback.setEnabled(true);
|
||||
actionMode = fragmentActivity.startActionMode(multiSelectAction);
|
||||
final String title = getString(R.string.number_selected, 1);
|
||||
actionMode.setTitle(title);
|
||||
onBackPressedDispatcher.addCallback(getViewLifecycleOwner(), onBackPressedCallback);
|
||||
return true;
|
||||
});
|
||||
postsViewModel.getList().observe(fragmentActivity, postsAdapter::submitList);
|
||||
binding.mainPosts.setAdapter(postsAdapter);
|
||||
final RecyclerLazyLoader lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
|
||||
if (!hasNextPage) return;
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
fetchPosts();
|
||||
endCursor = null;
|
||||
});
|
||||
binding.mainPosts.addOnScrollListener(lazyLoader);
|
||||
}
|
||||
|
||||
private void fetchLocationModel() {
|
||||
stopCurrentExecutor();
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
currentlyExecuting = new LocationFetcher(location.split("/")[0], result -> {
|
||||
locationModel = result;
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
if (locationModel == null) {
|
||||
Toast.makeText(requireContext(), R.string.error_loading_profile, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
setTitle();
|
||||
setupLocationDetails();
|
||||
fetchPosts();
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private void setupLocationDetails() {
|
||||
final String locationId = locationModel.getId();
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
if (isLoggedIn) {
|
||||
new iStoryStatusFetcher(locationId.split("/")[0], null, true, false, false, false, stories -> {
|
||||
storyModels = stories;
|
||||
if (stories != null && stories.length > 0) {
|
||||
binding.mainLocationImage.setStoriesBorder();
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
binding.mainLocationImage.setImageURI(locationModel.getSdProfilePic());
|
||||
final String postCount = String.valueOf(locationModel.getPostCount());
|
||||
final SpannableStringBuilder span = new SpannableStringBuilder(getString(R.string.main_posts_count, postCount));
|
||||
span.setSpan(new RelativeSizeSpan(1.2f), 0, postCount.length(), 0);
|
||||
span.setSpan(new StyleSpan(Typeface.BOLD), 0, postCount.length(), 0);
|
||||
binding.mainLocPostCount.setText(span);
|
||||
binding.mainLocPostCount.setVisibility(View.VISIBLE);
|
||||
binding.locationFullName.setText(locationModel.getName());
|
||||
CharSequence biography = locationModel.getBio();
|
||||
binding.locationBiography.setCaptionIsExpandable(true);
|
||||
binding.locationBiography.setCaptionIsExpanded(true);
|
||||
|
||||
if (Utils.isEmpty(biography)) {
|
||||
binding.locationBiography.setVisibility(View.GONE);
|
||||
} else if (Utils.hasMentions(biography)) {
|
||||
binding.locationBiography.setVisibility(View.VISIBLE);
|
||||
biography = Utils.getMentionText(biography);
|
||||
binding.locationBiography.setText(biography, TextView.BufferType.SPANNABLE);
|
||||
// binding.locationBiography.setMentionClickListener(mentionClickListener);
|
||||
} else {
|
||||
binding.locationBiography.setVisibility(View.VISIBLE);
|
||||
binding.locationBiography.setText(biography);
|
||||
binding.locationBiography.setMentionClickListener(null);
|
||||
}
|
||||
|
||||
if (!locationModel.getGeo().startsWith("geo:0.0,0.0?z=17")) {
|
||||
binding.btnMap.setVisibility(View.VISIBLE);
|
||||
binding.btnMap.setOnClickListener(v -> {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(locationModel.getGeo()));
|
||||
startActivity(intent);
|
||||
});
|
||||
} else {
|
||||
binding.btnMap.setVisibility(View.GONE);
|
||||
binding.btnMap.setOnClickListener(null);
|
||||
}
|
||||
|
||||
final String url = locationModel.getUrl();
|
||||
if (Utils.isEmpty(url)) {
|
||||
binding.locationUrl.setVisibility(View.GONE);
|
||||
} else if (!url.startsWith("http")) {
|
||||
binding.locationUrl.setVisibility(View.VISIBLE);
|
||||
binding.locationUrl.setText(Utils.getSpannableUrl("http://" + url));
|
||||
} else {
|
||||
binding.locationUrl.setVisibility(View.VISIBLE);
|
||||
binding.locationUrl.setText(Utils.getSpannableUrl(url));
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchPosts() {
|
||||
stopCurrentExecutor();
|
||||
currentlyExecuting = new PostsFetcher(locationModel.getId(), endCursor, postsFetchListener)
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
public void stopCurrentExecutor() {
|
||||
if (currentlyExecuting != null) {
|
||||
try {
|
||||
currentlyExecuting.cancel(true);
|
||||
} catch (final Exception e) {
|
||||
if (logCollector != null)
|
||||
logCollector.appendException(e, LogCollector.LogFile.MAIN_HELPER, "stopCurrentExecutor");
|
||||
Log.e(TAG, "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setTitle() {
|
||||
final ActionBar actionBar = fragmentActivity.getSupportActionBar();
|
||||
if (actionBar != null && locationModel != null) {
|
||||
actionBar.setTitle(locationModel.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkAndResetAction() {
|
||||
if (!onBackPressedCallback.isEnabled() && actionMode == null) {
|
||||
return false;
|
||||
}
|
||||
if (onBackPressedCallback.isEnabled()) {
|
||||
onBackPressedCallback.setEnabled(false);
|
||||
onBackPressedCallback.remove();
|
||||
}
|
||||
if (actionMode != null) {
|
||||
actionMode.finish();
|
||||
actionMode = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -314,7 +314,7 @@ public class DirectMessageThreadFragment extends Fragment {
|
||||
.show();
|
||||
}
|
||||
};
|
||||
final MentionClickListener mentionClickListener = (view, text, isHashtag) -> searchUsername(text);
|
||||
final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) -> searchUsername(text);
|
||||
final DirectMessageItemsAdapter adapter = new DirectMessageItemsAdapter(users, leftUsers, onClickListener, mentionClickListener);
|
||||
messageList.setAdapter(adapter);
|
||||
listViewModel.getList().observe(fragmentActivity, adapter::submitList);
|
||||
|
@ -198,23 +198,17 @@ public class FeedFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
final MentionClickListener mentionClickListener = (view, text, isHashtag) -> {
|
||||
// final AlertDialog.Builder builder = new AlertDialog.Builder(requireContext())
|
||||
// .setMessage(isHashtag ? R.string.comment_view_mention_hash_search : R.string.comment_view_mention_user_search)
|
||||
// .setTitle(text)
|
||||
// .setNegativeButton(R.string.cancel, null)
|
||||
// .setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||
// // if (MainActivityBackup.scanHack != null) {
|
||||
// // mainActivity.mainBinding.drawerLayout.closeDrawers();
|
||||
// // MainActivityBackup.scanHack.onResult(text);
|
||||
// // }
|
||||
// });
|
||||
// builder.show();
|
||||
final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) -> {
|
||||
if (isHashtag) {
|
||||
final NavDirections action = FeedFragmentDirections.actionFeedFragmentToHashTagFragment(text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
return;
|
||||
}
|
||||
if (isLocation) {
|
||||
final NavDirections action = FeedFragmentDirections.actionFeedFragmentToLocationFragment(text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
return;
|
||||
}
|
||||
final NavDirections action = FeedFragmentDirections.actionFeedFragmentToProfileFragment("@" + text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
};
|
||||
@ -294,7 +288,7 @@ public class FeedFragment extends Fragment {
|
||||
case R.id.ivProfilePic:
|
||||
profileModel = feedModel.getProfileModel();
|
||||
if (profileModel != null)
|
||||
mentionClickListener.onClick(null, profileModel.getUsername(), false);
|
||||
mentionClickListener.onClick(null, profileModel.getUsername(), false, false);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
@ -3,5 +3,8 @@ package awais.instagrabber.interfaces;
|
||||
import awais.instagrabber.customviews.RamboTextView;
|
||||
|
||||
public interface MentionClickListener {
|
||||
void onClick(final RamboTextView view, final String text, final boolean isHashtag);
|
||||
void onClick(final RamboTextView view,
|
||||
final String text,
|
||||
final boolean isHashtag,
|
||||
final boolean isLocation);
|
||||
}
|
131
app/src/main/res/layout/fragment_location.xml
Normal file
131
app/src/main/res/layout/fragment_location.xml
Normal file
@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<awais.instagrabber.customviews.helpers.NestedCoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorOnPrimarySurface">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorOnPrimarySurface">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/locInfoContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="@null"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/locInfo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/profile_info_container_bottom_space">
|
||||
|
||||
<awais.instagrabber.customviews.CircularImageView
|
||||
android:id="@+id/mainLocationImage"
|
||||
android:layout_width="@dimen/profile_picture_size"
|
||||
android:layout_height="@dimen/profile_picture_size"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
app:actualImageScaleType="fitCenter" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/mainLocPostCount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||
android:textSize="15sp"
|
||||
tools:text="35\nPosts" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/btnMap"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="2"
|
||||
android:text="@string/map"
|
||||
android:textColor="@color/btn_green_text_color"
|
||||
android:textSize="20sp"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="@color/btn_green_background" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/locationFullName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/locInfo"
|
||||
android:ellipsize="marquee"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
android:textSize="16sp"
|
||||
tools:text="OUR HOUSE" />
|
||||
|
||||
<awais.instagrabber.customviews.RamboTextView
|
||||
android:id="@+id/locationBiography"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/locationFullName"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone"
|
||||
tools:text="IN THE MIDDLE OF OUR STREET" />
|
||||
|
||||
<awais.instagrabber.customviews.RamboTextView
|
||||
android:id="@+id/locationUrl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/locationBiography"
|
||||
android:ellipsize="marquee"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone"
|
||||
tools:text="https://austinhuang.me/" />
|
||||
</RelativeLayout>
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipeRefreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/mainPosts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
tools:listitem="@layout/item_post" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</awais.instagrabber.customviews.helpers.NestedCoordinatorLayout>
|
@ -19,6 +19,9 @@
|
||||
<action
|
||||
android:id="@+id/action_feedFragment_to_hashTagFragment"
|
||||
app:destination="@id/hashTagFragment" />
|
||||
<action
|
||||
android:id="@+id/action_feedFragment_to_locationFragment"
|
||||
app:destination="@id/locationFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/storyViewerFragment"
|
||||
@ -57,4 +60,14 @@
|
||||
app:argType="string"
|
||||
app:nullable="false" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/locationFragment"
|
||||
android:name="awais.instagrabber.fragments.LocationFragment"
|
||||
android:label=""
|
||||
tools:layout="@layout/fragment_location" >
|
||||
<argument
|
||||
android:name="location"
|
||||
app:argType="string"
|
||||
app:nullable="false" />
|
||||
</fragment>
|
||||
</navigation>
|
Loading…
Reference in New Issue
Block a user