From 95b362970b113bfbd1f0043447e8e76c27fadf53 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Mon, 7 Sep 2020 21:21:36 +0900 Subject: [PATCH] Remove unused files --- .../java/awais/instagrabber/MainHelper.java | 1521 ----------------- .../activities/DirectMessagesActivity.java | 94 - .../activities/MainActivityBackup.java | 607 ------- .../instagrabber/activities/PostViewer.java | 786 --------- .../activities/ProfilePicViewer.java | 223 --- .../activities/ProfileViewer.java | 950 ---------- 6 files changed, 4181 deletions(-) delete mode 100755 app/src/main/java/awais/instagrabber/MainHelper.java delete mode 100644 app/src/main/java/awais/instagrabber/activities/DirectMessagesActivity.java delete mode 100644 app/src/main/java/awais/instagrabber/activities/MainActivityBackup.java delete mode 100755 app/src/main/java/awais/instagrabber/activities/PostViewer.java delete mode 100755 app/src/main/java/awais/instagrabber/activities/ProfilePicViewer.java delete mode 100755 app/src/main/java/awais/instagrabber/activities/ProfileViewer.java diff --git a/app/src/main/java/awais/instagrabber/MainHelper.java b/app/src/main/java/awais/instagrabber/MainHelper.java deleted file mode 100755 index 0de238be..00000000 --- a/app/src/main/java/awais/instagrabber/MainHelper.java +++ /dev/null @@ -1,1521 +0,0 @@ -// package awais.instagrabber; -// -// import android.content.Context; -// import android.content.DialogInterface; -// import android.content.Intent; -// import android.content.res.ColorStateList; -// import android.content.res.Resources; -// import android.graphics.Typeface; -// import android.net.Uri; -// import android.os.AsyncTask; -// import android.os.Bundle; -// import android.text.SpannableStringBuilder; -// import android.text.method.LinkMovementMethod; -// import android.text.style.RelativeSizeSpan; -// import android.text.style.StyleSpan; -// import android.util.Log; -// import android.util.TypedValue; -// import android.view.View; -// import android.view.ViewGroup; -// import android.widget.AdapterView; -// import android.widget.ArrayAdapter; -// import android.widget.ImageView; -// import android.widget.LinearLayout; -// import android.widget.TextView; -// import android.widget.Toast; -// -// import androidx.annotation.NonNull; -// import androidx.appcompat.app.AlertDialog; -// import androidx.core.content.ContextCompat; -// import androidx.core.view.GravityCompat; -// import androidx.core.widget.ImageViewCompat; -// import androidx.recyclerview.widget.LinearLayoutManager; -// import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -// -// import com.bumptech.glide.Glide; -// import com.bumptech.glide.RequestManager; -// import com.facebook.common.executors.UiThreadImmediateExecutorService; -// import com.facebook.datasource.BaseDataSubscriber; -// import com.facebook.datasource.DataSource; -// import com.facebook.drawee.backends.pipeline.Fresco; -// import com.facebook.imagepipeline.request.ImageRequest; -// -// import java.io.DataOutputStream; -// import java.net.HttpURLConnection; -// import java.net.URL; -// import java.util.ArrayList; -// import java.util.Arrays; -// import java.util.Collections; -// import java.util.HashMap; -// import java.util.Map; -// -// import awais.instagrabber.fragments.CommentsViewerFragment; -// import awais.instagrabber.activities.MainActivityBackup; -// import awais.instagrabber.activities.PostViewer; -// import awais.instagrabber.adapters.DiscoverAdapter; -// import awais.instagrabber.adapters.FeedAdapter; -// import awais.instagrabber.adapters.PostsAdapter; -// import awais.instagrabber.adapters.viewholder.feed.FeedItemViewHolder; -// import awais.instagrabber.asyncs.DiscoverFetcher; -// import awais.instagrabber.asyncs.FeedFetcher; -// import awais.instagrabber.asyncs.FeedStoriesFetcher; -// import awais.instagrabber.asyncs.HashtagFetcher; -// import awais.instagrabber.asyncs.HighlightsFetcher; -// import awais.instagrabber.asyncs.LocationFetcher; -// import awais.instagrabber.asyncs.PostsFetcher; -// import awais.instagrabber.asyncs.ProfileFetcher; -// import awais.instagrabber.asyncs.i.iStoryStatusFetcher; -// import awais.instagrabber.asyncs.i.iTopicFetcher; -// import awais.instagrabber.customviews.MouseDrawer; -// import awais.instagrabber.customviews.RamboTextView; -// import awais.instagrabber.customviews.helpers.GridAutofitLayoutManager; -// import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration; -// import awais.instagrabber.customviews.helpers.PauseGlideOnFlingScrollListener; -// import awais.instagrabber.customviews.helpers.RecyclerLazyLoader; -// import awais.instagrabber.customviews.helpers.VideoAwareRecyclerScroller; -// import awais.instagrabber.fragments.SavedViewerFragment; -// import awais.instagrabber.interfaces.FetchListener; -// import awais.instagrabber.interfaces.MentionClickListener; -// import awais.instagrabber.models.BasePostModel; -// import awais.instagrabber.models.DiscoverItemModel; -// import awais.instagrabber.models.DiscoverTopicModel; -// import awais.instagrabber.models.FeedModel; -// import awais.instagrabber.models.FeedStoryModel; -// import awais.instagrabber.models.IntentModel; -// import awais.instagrabber.models.PostModel; -// import awais.instagrabber.models.ProfileModel; -// import awais.instagrabber.models.ViewerPostModel; -// import awais.instagrabber.models.enums.DownloadMethod; -// import awais.instagrabber.models.enums.IntentModelType; -// import awais.instagrabber.models.enums.MediaItemType; -// import awais.instagrabber.models.enums.PostItemType; -// import awais.instagrabber.utils.Constants; -// import awais.instagrabber.utils.DataBox; -// import awais.instagrabber.utils.Utils; -// import awaisomereport.LogCollector; -// -// import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS; -// import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR; -// import static awais.instagrabber.utils.Utils.logCollector; -// import static awais.instagrabber.utils.Utils.settingsHelper; -// -// @Deprecated -// public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { -// private static final String TAG = "MainHelper"; -// private static final double MAX_VIDEO_HEIGHT = 0.9 * Utils.displayMetrics.heightPixels; -// private static final int RESIZED_VIDEO_HEIGHT = (int) (0.8 * Utils.displayMetrics.heightPixels); -// public static final boolean SHOULD_AUTO_PLAY = settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS); -// -// private static AsyncTask currentlyExecuting; -// private AsyncTask prevStoriesFetcher; -// private FeedStoryModel[] stories; -// private boolean hasNextPage = false; -// private boolean feedHasNextPage = false; -// private boolean discoverHasMore = false; -// private String endCursor = null; -// private String feedEndCursor = null; -// private String discoverEndMaxId = null; -// private String topic = null; -// private String rankToken = null; -// private String[] topicIds = null; -// -// private final boolean autoloadPosts; -// private final FetchListener postsFetchListener = new FetchListener() { -// @Override -// public void onResult(final PostModel[] result) { -// if (result != null) { -// final int oldSize = mainActivity.allItems.size(); -// mainActivity.allItems.addAll(Arrays.asList(result)); -// -// postsAdapter.notifyItemRangeInserted(oldSize, result.length); -// -// mainActivity.mainBinding.profileView.mainPosts.post(() -> { -// mainActivity.mainBinding.profileView.mainPosts.setNestedScrollingEnabled(true); -// mainActivity.mainBinding.profileView.mainPosts.setVisibility(View.VISIBLE); -// }); -// -// if (isHashtag) -// mainActivity.mainBinding.toolbar.toolbar.setTitle(mainActivity.userQuery); -// else if (isLocation) -// mainActivity.mainBinding.toolbar.toolbar.setTitle(mainActivity.locationModel.getName()); -// else -// mainActivity.mainBinding.toolbar.toolbar.setTitle("@" + mainActivity.profileModel.getUsername()); -// -// final PostModel model = result[result.length - 1]; -// if (model != null) { -// endCursor = model.getEndCursor(); -// hasNextPage = model.hasNextPage(); -// if (autoloadPosts && hasNextPage) -// currentlyExecuting = new PostsFetcher( -// mainActivity.profileModel != null ? mainActivity.profileModel.getId() -// : (mainActivity.hashtagModel != null -// ? mainActivity.userQuery -// : mainActivity.locationModel.getId()), -// mainActivity.profileModel != null -// ? PostItemType.MAIN -// : (mainActivity.hashtagModel != null ? PostItemType.HASHTAG : PostItemType.LOCATION), -// endCursor, -// this) -// .setUsername((isLocation || isHashtag) ? null : mainActivity.profileModel.getUsername()) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// else { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// } -// model.setPageCursor(false, null); -// } -// } else { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// mainActivity.mainBinding.profileView.privatePage1.setImageResource(R.drawable.ic_cancel); -// mainActivity.mainBinding.profileView.privatePage2.setText(R.string.empty_acc); -// mainActivity.mainBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// } -// } -// }; -// private final FetchListener feedFetchListener = new FetchListener() { -// @Override -// public void doBefore() { -// mainActivity.mainBinding.feedView.feedSwipeRefreshLayout -// .post(() -> mainActivity.mainBinding.feedView.feedSwipeRefreshLayout.setRefreshing(true)); -// } -// -// @Override -// public void onResult(final FeedModel[] result) { -// if (result == null) { -// return; -// } -// final int oldSize = mainActivity.feedItems.size(); -// final HashMap thumbToFeedMap = new HashMap<>(); -// for (final FeedModel feedModel : result) { -// thumbToFeedMap.put(feedModel.getThumbnailUrl(), feedModel); -// } -// final BaseDataSubscriber subscriber = new BaseDataSubscriber() { -// int success = 0; -// int failed = 0; -// -// @Override -// protected void onNewResultImpl(@NonNull final DataSource dataSource) { -// // dataSource -// final Map extras = dataSource.getExtras(); -// if (extras == null) { -// return; -// } -// // Log.d(TAG, "extras: " + extras); -// final Uri thumbUri = (Uri) extras.get("uri_source"); -// if (thumbUri == null) { -// return; -// } -// final Integer encodedWidth = (Integer) extras.get("encoded_width"); -// final Integer encodedHeight = (Integer) extras.get("encoded_height"); -// if (encodedWidth == null || encodedHeight == null) { -// return; -// } -// final FeedModel feedModel = thumbToFeedMap.get(thumbUri.toString()); -// if (feedModel == null) { -// return; -// } -// int requiredWidth = Utils.displayMetrics.widthPixels; -// int resultingHeight = Utils.getResultingHeight(requiredWidth, encodedHeight, encodedWidth); -// if (feedModel.getItemType() == MediaItemType.MEDIA_TYPE_VIDEO && resultingHeight >= MAX_VIDEO_HEIGHT) { -// // If its a video and the height is too large, need to reduce the height, -// // so that entire video fits on screen -// resultingHeight = RESIZED_VIDEO_HEIGHT; -// requiredWidth = Utils.getResultingWidth(RESIZED_VIDEO_HEIGHT, resultingHeight, requiredWidth); -// } -// feedModel.setImageWidth(requiredWidth); -// feedModel.setImageHeight(resultingHeight); -// success++; -// updateAdapter(); -// } -// -// @Override -// protected void onFailureImpl(@NonNull final DataSource dataSource) { -// failed++; -// updateAdapter(); -// } -// -// public void updateAdapter() { -// if (failed + success != result.length) return; -// mainActivity.feedItems.addAll(Arrays.asList(result)); -// feedAdapter.submitList(mainActivity.feedItems); -// feedAdapter.notifyItemRangeInserted(oldSize, result.length); -// -// mainActivity.mainBinding.feedView.feedPosts -// .post(() -> mainActivity.mainBinding.feedView.feedPosts.setNestedScrollingEnabled(true)); -// -// final PostModel feedPostModel = result[result.length - 1]; -// if (feedPostModel != null) { -// feedEndCursor = feedPostModel.getEndCursor(); -// feedHasNextPage = feedPostModel.hasNextPage(); -// feedPostModel.setPageCursor(false, null); -// } -// mainActivity.mainBinding.feedView.feedSwipeRefreshLayout.setRefreshing(false); -// } -// }; -// for (final FeedModel feedModel : result) { -// final DataSource ds = Fresco.getImagePipeline().prefetchToBitmapCache(ImageRequest.fromUri(feedModel.getThumbnailUrl()), null); -// ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance()); -// } -// } -// }; -// private final FetchListener discoverFetchListener = new FetchListener() { -// @Override -// public void doBefore() { -// mainActivity.mainBinding.discoverSwipeRefreshLayout.setRefreshing(true); -// } -// -// @Override -// public void onResult(final DiscoverItemModel[] result) { -// if (result == null || result.length == 0) { -// Toast.makeText(mainActivity, R.string.discover_empty, Toast.LENGTH_SHORT).show(); -// } else { -// final int oldSize = mainActivity.discoverItems.size(); -// mainActivity.discoverItems.addAll(Arrays.asList(result)); -// discoverAdapter.notifyItemRangeInserted(oldSize, result.length); -// -// final DiscoverItemModel discoverItemModel = result[result.length - 1]; -// if (discoverItemModel != null) { -// discoverEndMaxId = discoverItemModel.getNextMaxId(); -// discoverHasMore = discoverItemModel.hasMore(); -// discoverItemModel.setMore(false, null); -// } -// } -// -// mainActivity.mainBinding.discoverSwipeRefreshLayout.setRefreshing(false); -// } -// }; -// private final FetchListener topicFetchListener = new FetchListener() { -// @Override -// public void doBefore() {} -// -// @Override -// public void onResult(final DiscoverTopicModel result) { -// if (result != null) { -// topicIds = result.getIds(); -// rankToken = result.getToken(); -// ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>( -// mainActivity, android.R.layout.simple_spinner_dropdown_item, result.getNames()); -// mainActivity.mainBinding.discoverType.setAdapter(spinnerArrayAdapter); -// } -// } -// }; -// private final FetchListener feedStoriesListener = new FetchListener() { -// @Override -// public void doBefore() { -// mainActivity.mainBinding.feedView.feedStories.setVisibility(View.GONE); -// } -// -// @Override -// public void onResult(final FeedStoryModel[] result) { -// // feedStoriesAdapter.setData(result); -// if (result != null && result.length > 0) { -// mainActivity.mainBinding.feedView.feedStories.setVisibility(View.VISIBLE); -// stories = result; -// } -// } -// }; -// private final MentionClickListener mentionClickListener = new MentionClickListener() { -// @Override -// 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); -// }).show(); -// } -// }; -// // private final FeedStoriesAdapter feedStoriesAdapter = new FeedStoriesAdapter(null, new View.OnClickListener() { -// // @Override -// // public void onClick(final View v) { -// // final Object tag = v.getTag(); -// // if (tag instanceof FeedStoryModel) { -// // final FeedStoryModel feedStoryModel = (FeedStoryModel) tag; -// // final int index = indexOfIntArray(stories, feedStoryModel); -// // new iStoryStatusFetcher(feedStoryModel.getStoryMediaId(), null, false, false, false, false, result -> { -// // if (result != null && result.length > 0) -// // mainActivity.startActivity(new Intent(mainActivity, StoryViewer.class) -// // .putExtra(Constants.EXTRAS_STORIES, result) -// // .putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername()) -// // .putExtra(Constants.FEED, stories) -// // .putExtra(Constants.FEED_ORDER, index) -// // ); -// // else -// // Toast.makeText(mainActivity, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); -// // }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// // } -// // } -// // }); -// private MainActivityBackup mainActivity; -// private Resources resources; -// private final View collapsingToolbar; -// private final RecyclerLazyLoader lazyLoader; -// private boolean isHashtag; -// private boolean isLocation; -// private PostsAdapter postsAdapter; -// private FeedAdapter feedAdapter; -// private RecyclerLazyLoader feedLazyLoader, discoverLazyLoader; -// private DiscoverAdapter discoverAdapter; -// private String cookie = settingsHelper.getString(Constants.COOKIE); -// private boolean isLoggedIn; -// private RequestManager glide; -// private VideoAwareRecyclerScroller videoAwareRecyclerScroller; -// -// public MainHelper(@NonNull final MainActivityBackup mainActivity) { -// stopCurrentExecutor(); -// -// this.mainActivity = mainActivity; -// this.resources = mainActivity.getResources(); -// this.autoloadPosts = settingsHelper.getBoolean(AUTOLOAD_POSTS); -// glide = Glide.with(mainActivity); -// -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setOnRefreshListener(this); -// mainActivity.mainBinding.profileView.mainUrl.setMovementMethod(new LinkMovementMethod()); -// -// final LinearLayout iconSlider = mainActivity.findViewById(R.id.iconSlider); -// final ImageView iconFeed = (ImageView) iconSlider.getChildAt(0); -// final ImageView iconProfile = (ImageView) iconSlider.getChildAt(1); -// final ImageView iconDiscover = (ImageView) iconSlider.getChildAt(2); -// -// final boolean isBottomToolbar = settingsHelper.getBoolean(BOTTOM_TOOLBAR); -// isLoggedIn = !Utils.isEmpty(cookie) && Utils.getUserIdFromCookie(cookie) != null; -// if (!isLoggedIn) { -// mainActivity.mainBinding.drawerLayout.removeView(mainActivity.mainBinding.feedView.feedLayout); -// mainActivity.mainBinding.drawerLayout.removeView(mainActivity.mainBinding.discoverLayout); -// iconFeed.setAlpha(0.4f); -// iconDiscover.setAlpha(0.4f); -// } else { -// iconFeed.setAlpha(1f); -// iconDiscover.setAlpha(1f); -// -// setupExplore(); -// -// setupFeed(); -// -// final TypedValue resolvedAttr = new TypedValue(); -// mainActivity.getTheme().resolveAttribute(android.R.attr.textColorPrimary, resolvedAttr, true); -// -// final int selectedItem = ContextCompat.getColor(mainActivity, resolvedAttr.resourceId != 0 ? resolvedAttr.resourceId : resolvedAttr.data); -// final ColorStateList colorStateList = ColorStateList.valueOf(selectedItem); -// -// mainActivity.mainBinding.toolbar.toolbar.measure(0, -1); -// final int toolbarMeasuredHeight = mainActivity.mainBinding.toolbar.toolbar.getMeasuredHeight(); -// -// final ViewGroup.LayoutParams layoutParams = mainActivity.mainBinding.toolbar.toolbar.getLayoutParams(); -// final MouseDrawer.DrawerListener simpleDrawerListener = new MouseDrawer.DrawerListener() { -// private final String titleDiscover = resources.getString(R.string.title_discover); -// -// @Override -// public void onDrawerSlide(final View drawerView, @MouseDrawer.EdgeGravity final int gravity, final float slideOffset) { -// final int currentIconAlpha = (int) Math.max(100, 255 - 255 * slideOffset); -// final int otherIconAlpha = (int) Math.max(100, 255 * slideOffset); -// -// ImageViewCompat.setImageTintList(iconProfile, colorStateList.withAlpha(currentIconAlpha)); -// -// final boolean drawerOpening = slideOffset > 0.0f; -// final int alpha; -// final ColorStateList imageTintList; -// -// if (gravity == GravityCompat.START) { -// // this helps hide the toolbar when opening feed -// -// final int roundedToolbarHeight; -// final float toolbarHeight; -// -// if (isBottomToolbar) { -// toolbarHeight = toolbarMeasuredHeight * slideOffset; -// roundedToolbarHeight = -Math.round(toolbarHeight); -// } else { -// toolbarHeight = -toolbarMeasuredHeight * slideOffset; -// roundedToolbarHeight = Math.round(toolbarHeight); -// } -// -// layoutParams.height = Math.max(0, Math.min(toolbarMeasuredHeight, toolbarMeasuredHeight + roundedToolbarHeight)); -// mainActivity.mainBinding.toolbar.toolbar.setLayoutParams(layoutParams); -// mainActivity.mainBinding.toolbar.toolbar.setTranslationY(toolbarHeight); -// -// imageTintList = ImageViewCompat.getImageTintList(iconDiscover); -// alpha = imageTintList != null ? (imageTintList.getDefaultColor() & 0xFF_000000) >> 24 : 0; -// -// if (drawerOpening && alpha > 100) -// ImageViewCompat.setImageTintList(iconDiscover, colorStateList.withAlpha(currentIconAlpha)); -// -// ImageViewCompat.setImageTintList(iconFeed, colorStateList.withAlpha(otherIconAlpha)); -// } else { -// // this changes toolbar title -// mainActivity.mainBinding.toolbar.toolbar.setTitle(slideOffset >= 0.466 ? titleDiscover : -// (mainActivity.userQuery == null -// ? resources.getString(R.string.app_name) -// : mainActivity.userQuery)); -// -// imageTintList = ImageViewCompat.getImageTintList(iconFeed); -// alpha = imageTintList != null ? (imageTintList.getDefaultColor() & 0xFF_000000) >> 24 : 0; -// -// if (drawerOpening && alpha > 100) -// ImageViewCompat.setImageTintList(iconFeed, colorStateList.withAlpha(currentIconAlpha)); -// -// ImageViewCompat.setImageTintList(iconDiscover, colorStateList.withAlpha(otherIconAlpha)); -// } -// } -// -// @Override -// public void onDrawerOpened(@NonNull final View drawerView, @MouseDrawer.EdgeGravity final int gravity) { -// if (gravity == GravityCompat.START || drawerView == mainActivity.mainBinding.feedView.feedLayout) { -// if (videoAwareRecyclerScroller != null) { -// if (SHOULD_AUTO_PLAY) { -// videoAwareRecyclerScroller.startPlaying(); -// } -// } -// } else { -// // clear selection -// isSelectionCleared(); -// } -// } -// -// @Override -// public void onDrawerClosed(@NonNull final View drawerView, @MouseDrawer.EdgeGravity final int gravity) { -// if (gravity == GravityCompat.START || drawerView == mainActivity.mainBinding.feedView.feedLayout) { -// if (videoAwareRecyclerScroller != null) { -// videoAwareRecyclerScroller.stopPlaying(); -// } -// } else { -// // clear selection -// isSelectionCleared(); -// } -// } -// }; -// -// ImageViewCompat.setImageTintList(iconFeed, colorStateList.withAlpha(100)); // to change colors when created -// ImageViewCompat.setImageTintList(iconProfile, colorStateList.withAlpha(255)); // to change colors when created -// ImageViewCompat.setImageTintList(iconDiscover, colorStateList.withAlpha(100)); // to change colors when created -// -// mainActivity.mainBinding.drawerLayout.addDrawerListener(simpleDrawerListener); -// } -// -// collapsingToolbar = mainActivity.mainBinding.profileView.appBarLayout.getChildAt(0); -// -// mainActivity.mainBinding.profileView.mainPosts.setNestedScrollingEnabled(false); -// mainActivity.mainBinding.profileView.highlightsList -// .setLayoutManager(new LinearLayoutManager(mainActivity, LinearLayoutManager.HORIZONTAL, false)); -// mainActivity.mainBinding.profileView.highlightsList.setAdapter(mainActivity.highlightsAdapter); -// -// // int color = -1; -// // final Drawable background = main.mainBinding.profileView.appBarLayout.getBackground(); -// // if (background instanceof MaterialShapeDrawable) { -// // final MaterialShapeDrawable drawable = (MaterialShapeDrawable) background; -// // final ColorStateList fillColor = drawable.getFillColor(); -// // if (fillColor != null) color = fillColor.getDefaultColor(); -// // } else { -// // final Bitmap bitmap = Bitmap.createBitmap(9, 9, Bitmap.Config.ARGB_8888); -// // final Canvas canvas = new Canvas(); -// // canvas.setBitmap(bitmap); -// // background.draw(canvas); -// // color = bitmap.getPixel(4, 4); -// // if (!bitmap.isRecycled()) bitmap.recycle(); -// // } -// // if (color == -1 || color == 0) color = resources.getBoolean(R.bool.isNight) ? 0xff212121 : 0xfff5f5f5; -// // main.mainBinding.profileView.profileInfo.setBackgroundColor(color); -// // if (!isBottomToolbar) main.mainBinding.toolbar.toolbar.setBackgroundColor(color); -// -// // main.mainBinding.profileView.appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { -// // private int height; -// // -// // @Override -// // public void onOffsetChanged(final AppBarLayout appBarLayout, final int verticalOffset) { -// // if (height == 0) { -// // height = main.mainBinding.profileView.profileInfo.getHeight(); -// // collapsingToolbar.setMinimumHeight(height); -// // } -// // main.mainBinding.profileView.profileInfo.setTranslationY(-Math.min(0, verticalOffset)); -// // } -// // }); -// -// mainActivity.setSupportActionBar(mainActivity.mainBinding.toolbar.toolbar); -// if (isBottomToolbar) { -// final LinearLayout linearLayout = (LinearLayout) mainActivity.mainBinding.toolbar.toolbar.getParent(); -// linearLayout.removeView(mainActivity.mainBinding.toolbar.toolbar); -// linearLayout.addView(mainActivity.mainBinding.toolbar.toolbar, linearLayout.getChildCount()); -// } -// -// // change the next number to adjust grid -// final GridAutofitLayoutManager layoutManager = new GridAutofitLayoutManager(mainActivity, Utils.convertDpToPx(110)); -// mainActivity.mainBinding.profileView.mainPosts.setLayoutManager(layoutManager); -// mainActivity.mainBinding.profileView.mainPosts.addItemDecoration(new GridSpacingItemDecoration(Utils.convertDpToPx(4))); -// // mainActivity.mainBinding.profileView.mainPosts.setAdapter(postsAdapter = new PostsAdapter(/*mainActivity.allItems,*/ v -> { -// // final Object tag = v.getTag(); -// // if (tag instanceof PostModel) { -// // final PostModel postModel = (PostModel) tag; -// // -// // if (postsAdapter.isSelecting) toggleSelection(postModel); -// // else mainActivity.startActivity(new Intent(mainActivity, PostViewer.class) -// // .putExtra(Constants.EXTRAS_INDEX, postModel.getPosition()) -// // .putExtra(Constants.EXTRAS_POST, postModel) -// // .putExtra(Constants.EXTRAS_USER, mainActivity.userQuery) -// // .putExtra(Constants.EXTRAS_TYPE, ItemGetType.MAIN_ITEMS)); -// // } -// // }, v -> { // long click listener -// // // final Object tag = v.getTag(); -// // // if (tag instanceof PostModel) { -// // // postsAdapter.isSelecting = true; -// // // toggleSelection((PostModel) tag); -// // // } -// // // return true; -// // return false; -// // })); -// -// this.lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> { -// if ((!autoloadPosts || isHashtag) && hasNextPage) { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(true); -// stopCurrentExecutor(); -// currentlyExecuting = new PostsFetcher(mainActivity.profileModel != null ? mainActivity.profileModel.getId() -// : (mainActivity.hashtagModel != null -// ? mainActivity.userQuery -// : mainActivity.locationModel.getId()), -// mainActivity.profileModel != null -// ? PostItemType.MAIN -// : (mainActivity.hashtagModel != null ? PostItemType.HASHTAG : PostItemType.LOCATION), -// endCursor, -// postsFetchListener) -// .setUsername((isHashtag || isLocation) ? null : mainActivity.profileModel.getUsername()) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// endCursor = null; -// } -// }); -// mainActivity.mainBinding.profileView.mainPosts.addOnScrollListener(lazyLoader); -// } -// -// private final View.OnClickListener clickListener = v -> { -// if (mainActivity == null) { -// return; -// } -// final Object tag = v.getTag(); -// final Context context = v.getContext(); -// -// if (tag instanceof FeedModel) { -// final FeedModel feedModel = (FeedModel) tag; -// -// if (v instanceof RamboTextView) { -// if (feedModel.isMentionClicked()) -// feedModel.toggleCaption(); -// feedModel.setMentionClicked(false); -// if (!FeedItemViewHolder.expandCollapseTextView((RamboTextView) v, feedModel.getPostCaption())) -// feedModel.toggleCaption(); -// -// } else { -// final int id = v.getId(); -// switch (id) { -// case R.id.btnComments: -// mainActivity.startActivityForResult(new Intent(mainActivity, CommentsViewerFragment.class) -// .putExtra(Constants.EXTRAS_SHORTCODE, feedModel.getShortCode()) -// .putExtra(Constants.EXTRAS_POST, feedModel.getPostId()) -// .putExtra(Constants.EXTRAS_USER, feedModel.getProfileModel().getId()), 6969); -// break; -// -// case R.id.viewStoryPost: -// mainActivity.startActivity(new Intent(mainActivity, PostViewer.class) -// .putExtra(Constants.EXTRAS_INDEX, feedModel.getPosition()) -// .putExtra(Constants.EXTRAS_POST, new PostModel(feedModel.getShortCode(), false)) -// .putExtra(Constants.EXTRAS_TYPE, PostItemType.FEED)); -// break; -// -// case R.id.btnDownload: -// ProfileModel profileModel = feedModel.getProfileModel(); -// final String username = profileModel != null ? profileModel.getUsername() : null; -// -// final ViewerPostModel[] sliderItems = feedModel.getSliderItems(); -// -// if (feedModel.getItemType() != MediaItemType.MEDIA_TYPE_SLIDER || sliderItems == null || sliderItems.length == 1) -// Utils.batchDownload(context, username, DownloadMethod.DOWNLOAD_FEED, Collections.singletonList(feedModel)); -// else { -// final ArrayList postModels = new ArrayList<>(); -// final DialogInterface.OnClickListener clickListener1 = (dialog, which) -> { -// postModels.clear(); -// -// final boolean breakWhenFoundSelected = which == DialogInterface.BUTTON_POSITIVE; -// -// for (final ViewerPostModel sliderItem : sliderItems) { -// if (sliderItem != null) { -// if (!breakWhenFoundSelected) -// postModels.add(sliderItem); -// else if (sliderItem.isSelected()) { -// postModels.add(sliderItem); -// break; -// } -// } -// } -// -// // shows 0 items on first item of viewpager cause onPageSelected hasn't been called yet -// if (breakWhenFoundSelected && postModels.size() == 0) -// postModels.add(sliderItems[0]); -// -// if (postModels.size() > 0) -// Utils.batchDownload(context, username, DownloadMethod.DOWNLOAD_FEED, postModels); -// }; -// -// new AlertDialog.Builder(context).setTitle(R.string.post_viewer_download_dialog_title) -// .setPositiveButton(R.string.post_viewer_download_current, clickListener1) -// .setNegativeButton(R.string.post_viewer_download_album, clickListener1).show(); -// } -// break; -// -// case R.id.ivProfilePic: -// profileModel = feedModel.getProfileModel(); -// if (profileModel != null) -// mentionClickListener.onClick(null, profileModel.getUsername(), false, false); -// break; -// } -// } -// } -// }; -// -// private void setupFeed() { -// mainActivity.mainBinding.feedView.feedStories.setLayoutManager(new LinearLayoutManager(mainActivity, LinearLayoutManager.HORIZONTAL, false)); -// // mainActivity.mainBinding.feedView.feedStories.setAdapter(feedStoriesAdapter); -// refreshFeedStories(); -// -// 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, 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) { -// mainActivity.mainBinding.drawerLayout.closeDrawers(); -// MainActivityBackup.scanHack.onResult(text); -// } -// }).show())); -// -// mainActivity.mainBinding.feedView.feedSwipeRefreshLayout.setOnRefreshListener(() -> { -// refreshFeedStories(); -// -// if (feedLazyLoader != null) feedLazyLoader.resetState(); -// mainActivity.feedItems.clear(); -// if (feedAdapter != null) feedAdapter.notifyDataSetChanged(); -// new FeedFetcher(feedFetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// }); -// -// mainActivity.mainBinding.feedView.feedPosts -// .addOnScrollListener(feedLazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> { -// if (feedHasNextPage) { -// mainActivity.mainBinding.feedView.feedSwipeRefreshLayout.setRefreshing(true); -// new FeedFetcher(feedEndCursor, feedFetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// feedEndCursor = null; -// } -// })); -// -// if (SHOULD_AUTO_PLAY) { -// videoAwareRecyclerScroller = new VideoAwareRecyclerScroller(); -// mainActivity.mainBinding.feedView.feedPosts.addOnScrollListener(videoAwareRecyclerScroller); -// } -// mainActivity.mainBinding.feedView.feedPosts.addOnScrollListener(new PauseGlideOnFlingScrollListener(glide)); -// -// new FeedFetcher(feedFetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// private void refreshFeedStories() { -// // todo setup feed stories -// if (prevStoriesFetcher != null) { -// try { -// prevStoriesFetcher.cancel(true); -// } catch (final Exception e) { -// // ignore -// } -// } -// prevStoriesFetcher = new FeedStoriesFetcher(feedStoriesListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// private void setupExplore() { -// final GridAutofitLayoutManager layoutManager = new GridAutofitLayoutManager(mainActivity, Utils.convertDpToPx(110)); -// mainActivity.mainBinding.discoverPosts.setLayoutManager(layoutManager); -// mainActivity.mainBinding.discoverPosts.addItemDecoration(new GridSpacingItemDecoration(Utils.convertDpToPx(4))); -// -// new iTopicFetcher(topicFetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// mainActivity.mainBinding.discoverType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { -// @Override -// public void onItemSelected(AdapterView parent, View view, int pos, long id) { -// if (topicIds != null) { -// topic = topicIds[pos]; -// mainActivity.mainBinding.discoverSwipeRefreshLayout.setRefreshing(true); -// if (discoverLazyLoader != null) discoverLazyLoader.resetState(); -// mainActivity.discoverItems.clear(); -// if (discoverAdapter != null) discoverAdapter.notifyDataSetChanged(); -// new DiscoverFetcher(topic, null, rankToken, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } -// -// @Override -// public void onNothingSelected(AdapterView parent) { -// } -// }); -// -// mainActivity.mainBinding.discoverSwipeRefreshLayout.setOnRefreshListener(() -> { -// if (discoverLazyLoader != null) discoverLazyLoader.resetState(); -// mainActivity.discoverItems.clear(); -// if (discoverAdapter != null) discoverAdapter.notifyDataSetChanged(); -// new DiscoverFetcher(topic, null, rankToken, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// }); -// -// // mainActivity.mainBinding.discoverPosts.setAdapter(discoverAdapter = new DiscoverAdapter(mainActivity.discoverItems, v -> { -// // final Object tag = v.getTag(); -// // if (tag instanceof DiscoverItemModel) { -// // final DiscoverItemModel itemModel = (DiscoverItemModel) tag; -// // -// // if (discoverAdapter.isSelecting) toggleDiscoverSelection(itemModel); -// // else mainActivity.startActivity(new Intent(mainActivity, PostViewer.class) -// // .putExtra(Constants.EXTRAS_INDEX, itemModel.getPosition()) -// // .putExtra(Constants.EXTRAS_TYPE, ItemGetType.DISCOVER_ITEMS) -// // .putExtra(Constants.EXTRAS_POST, new PostModel(itemModel.getShortCode(), false))); -// // } -// // }, v -> { -// // final Object tag = v.getTag(); -// // if (tag instanceof DiscoverItemModel) { -// // discoverAdapter.isSelecting = true; -// // toggleDiscoverSelection((DiscoverItemModel) tag); -// // } -// // return true; -// // })); -// -// mainActivity.mainBinding.discoverPosts -// .addOnScrollListener(discoverLazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> { -// if (discoverHasMore) { -// mainActivity.mainBinding.discoverSwipeRefreshLayout.setRefreshing(true); -// new DiscoverFetcher(topic, discoverEndMaxId, rankToken, discoverFetchListener, false) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// discoverEndMaxId = null; -// } -// })); -// } -// -// public void onIntent(final Intent intent) { -// if (intent != null) { -// final String action = intent.getAction(); -// if (!Utils.isEmpty(action) && !Intent.ACTION_MAIN.equals(action)) { -// intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); -// -// boolean error = true; -// -// String data = null; -// final Bundle extras = intent.getExtras(); -// if (extras != null) { -// final Object extraData = extras.get(Intent.EXTRA_TEXT); -// if (extraData != null) { -// error = false; -// data = extraData.toString(); -// } -// } -// -// if (error) { -// final Uri intentData = intent.getData(); -// if (intentData != null) data = intentData.toString(); -// } -// -// if (data != null && !Utils.isEmpty(data)) { -// if (data.indexOf('\n') > 0) data = data.substring(data.lastIndexOf('\n') + 1); -// -// final IntentModel model = Utils.parseUrl(data); -// if (model != null) { -// final String modelText = model.getText(); -// final IntentModelType modelType = model.getType(); -// -// if (modelType == IntentModelType.POST) { -// mainActivity.startActivityForResult(new Intent(mainActivity, PostViewer.class) -// .putExtra(Constants.EXTRAS_USER, mainActivity.userQuery) -// .putExtra(Constants.EXTRAS_POST, new PostModel(modelText, false)), 9629); -// } else { -// mainActivity.addToStack(); -// mainActivity.userQuery = modelType == IntentModelType.HASHTAG ? ('#' + modelText) : -// (modelType == IntentModelType.LOCATION ? modelText : ('@' + modelText)); -// onRefresh(); -// } -// } -// } -// } -// } -// } -// -// @Override -// public void onRefresh() { -// mainActivity.mainBinding.drawerLayout.closeDrawers(); -// if (lazyLoader != null) lazyLoader.resetState(); -// stopCurrentExecutor(); -// mainActivity.allItems.clear(); -// mainActivity.selectedItems.clear(); -// if (postsAdapter != null) { -// // postsAdapter.isSelecting = false; -// postsAdapter.notifyDataSetChanged(); -// } -// mainActivity.mainBinding.profileView.appBarLayout.setExpanded(true, true); -// mainActivity.mainBinding.profileView.privatePage.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.privatePage2.setTextSize(28); -// // mainActivity.mainBinding.profileView.mainProfileImage.setImageBitmap(null); -// // mainActivity.mainBinding.profileView.mainHashtagImage.setImageBitmap(null); -// // mainActivity.mainBinding.profileView.mainLocationImage.setImageBitmap(null); -// mainActivity.mainBinding.profileView.mainUrl.setText(null); -// mainActivity.mainBinding.profileView.locationUrl.setText(null); -// mainActivity.mainBinding.profileView.mainFullName.setText(null); -// mainActivity.mainBinding.profileView.locationFullName.setText(null); -// mainActivity.mainBinding.profileView.mainPostCount.setText(null); -// mainActivity.mainBinding.profileView.mainLocPostCount.setText(null); -// mainActivity.mainBinding.profileView.mainTagPostCount.setText(null); -// mainActivity.mainBinding.profileView.mainFollowers.setText(null); -// mainActivity.mainBinding.profileView.mainFollowing.setText(null); -// mainActivity.mainBinding.profileView.mainBiography.setText(null); -// mainActivity.mainBinding.profileView.locationBiography.setText(null); -// mainActivity.mainBinding.profileView.mainBiography.setEnabled(false); -// mainActivity.mainBinding.profileView.locationBiography.setEnabled(false); -// mainActivity.mainBinding.profileView.mainProfileImage.setEnabled(false); -// mainActivity.mainBinding.profileView.mainLocationImage.setEnabled(false); -// mainActivity.mainBinding.profileView.mainHashtagImage.setEnabled(false); -// mainActivity.mainBinding.profileView.mainBiography.setMentionClickListener(null); -// mainActivity.mainBinding.profileView.locationBiography.setMentionClickListener(null); -// mainActivity.mainBinding.profileView.mainUrl.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.locationUrl.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.isVerified.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnFollow.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnRestrict.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnBlock.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnSaved.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnLiked.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnTagged.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnMap.setVisibility(View.GONE); -// -// mainActivity.mainBinding.profileView.btnFollow.setOnClickListener(profileActionListener); -// mainActivity.mainBinding.profileView.btnRestrict.setOnClickListener(profileActionListener); -// mainActivity.mainBinding.profileView.btnBlock.setOnClickListener(profileActionListener); -// mainActivity.mainBinding.profileView.btnSaved.setOnClickListener(profileActionListener); -// mainActivity.mainBinding.profileView.btnLiked.setOnClickListener(profileActionListener); -// mainActivity.mainBinding.profileView.btnTagged.setOnClickListener(profileActionListener); -// mainActivity.mainBinding.profileView.btnFollowTag.setOnClickListener(profileActionListener); -// -// mainActivity.mainBinding.profileView.infoContainer.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.tagInfoContainer.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.locInfoContainer.setVisibility(View.GONE); -// -// mainActivity.mainBinding.profileView.mainPosts.setNestedScrollingEnabled(false); -// mainActivity.mainBinding.profileView.highlightsList.setVisibility(View.GONE); -// collapsingToolbar.setVisibility(View.GONE); -// mainActivity.highlightsAdapter.setData(null); -// -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(mainActivity.userQuery != null); -// if (mainActivity.userQuery == null) { -// mainActivity.mainBinding.toolbar.toolbar.setTitle(R.string.app_name); -// return; -// } -// -// isHashtag = mainActivity.userQuery.charAt(0) == '#'; -// final boolean isUser = mainActivity.userQuery.charAt(0) == '@'; -// isLocation = mainActivity.userQuery.contains("/"); -// collapsingToolbar.setVisibility(isUser ? View.VISIBLE : View.GONE); -// -// if (isHashtag) { -// mainActivity.profileModel = null; -// mainActivity.locationModel = null; -// mainActivity.mainBinding.toolbar.toolbar.setTitle(mainActivity.userQuery); -// mainActivity.mainBinding.profileView.tagInfoContainer.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnFollowTag.setVisibility(View.GONE); -// -// currentlyExecuting = new HashtagFetcher(mainActivity.userQuery.substring(1), hashtagModel -> { -// mainActivity.hashtagModel = hashtagModel; -// -// if (hashtagModel == null) { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// Toast.makeText(mainActivity, R.string.error_loading_profile, Toast.LENGTH_SHORT).show(); -// mainActivity.mainBinding.toolbar.toolbar.setTitle(R.string.app_name); -// return; -// } -// -// currentlyExecuting = new PostsFetcher(mainActivity.userQuery, PostItemType.HASHTAG, null, postsFetchListener) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// -// mainActivity.mainBinding.profileView.btnFollowTag.setVisibility(View.VISIBLE); -// -// if (isLoggedIn) { -// new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, false, false, result -> { -// mainActivity.storyModels = result; -// if (result != null && result.length > 0) -// mainActivity.mainBinding.profileView.mainHashtagImage.setStoriesBorder(); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// -// if (hashtagModel.getFollowing()) { -// mainActivity.mainBinding.profileView.btnFollowTag.setText(R.string.unfollow); -// mainActivity.mainBinding.profileView.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_purple_background))); -// } else { -// mainActivity.mainBinding.profileView.btnFollowTag.setText(R.string.follow); -// mainActivity.mainBinding.profileView.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_pink_background))); -// } -// } else { -// if (Utils.dataBox.getFavorite(mainActivity.userQuery) != null) { -// mainActivity.mainBinding.profileView.btnFollowTag.setText(R.string.unfavorite_short); -// mainActivity.mainBinding.profileView.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_purple_background))); -// } else { -// mainActivity.mainBinding.profileView.btnFollowTag.setText(R.string.favorite_short); -// mainActivity.mainBinding.profileView.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_pink_background))); -// } -// } -// -// mainActivity.mainBinding.profileView.mainHashtagImage.setEnabled(false); -// // new MyTask().execute(); -// mainActivity.mainBinding.profileView.mainHashtagImage.setImageURI(hashtagModel.getSdProfilePic()); -// mainActivity.mainBinding.profileView.mainHashtagImage.setEnabled(true); -// -// final String postCount = String.valueOf(hashtagModel.getPostCount()); -// -// SpannableStringBuilder span = new SpannableStringBuilder(resources.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); -// mainActivity.mainBinding.profileView.mainTagPostCount.setText(span); -// mainActivity.mainBinding.profileView.mainTagPostCount.setVisibility(View.VISIBLE); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } else if (isUser) { -// mainActivity.hashtagModel = null; -// mainActivity.locationModel = null; -// mainActivity.mainBinding.toolbar.toolbar.setTitle(mainActivity.userQuery); -// mainActivity.mainBinding.profileView.infoContainer.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnFollowTag.setVisibility(View.GONE); -// -// currentlyExecuting = new ProfileFetcher(mainActivity.userQuery.substring(1), profileModel -> { -// mainActivity.profileModel = profileModel; -// -// if (profileModel == null) { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// Toast.makeText(mainActivity, R.string.error_loading_profile, Toast.LENGTH_SHORT).show(); -// mainActivity.mainBinding.toolbar.toolbar.setTitle(R.string.app_name); -// return; -// } -// -// mainActivity.mainBinding.profileView.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE); -// final String profileId = profileModel.getId(); -// -// if (isLoggedIn || settingsHelper.getBoolean(Constants.STORIESIG)) { -// new iStoryStatusFetcher(profileId, profileModel.getUsername(), false, false, -// (!isLoggedIn && settingsHelper.getBoolean(Constants.STORIESIG)), false, -// result -> { -// mainActivity.storyModels = result; -// if (result != null && result.length > 0) -// mainActivity.mainBinding.profileView.mainProfileImage.setStoriesBorder(); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// -// new HighlightsFetcher(profileId, (!isLoggedIn && settingsHelper.getBoolean(Constants.STORIESIG)), result -> { -// if (result != null && result.length > 0) { -// mainActivity.mainBinding.profileView.highlightsList.setVisibility(View.VISIBLE); -// mainActivity.highlightsAdapter.setData(result); -// } else -// mainActivity.mainBinding.profileView.highlightsList.setVisibility(View.GONE); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// if (isLoggedIn) { -// final String myId = Utils.getUserIdFromCookie(cookie); -// if (!profileId.equals(myId)) { -// mainActivity.mainBinding.profileView.btnTagged.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnSaved.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnLiked.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnFollow.setVisibility(View.VISIBLE); -// if (profileModel.getFollowing() == true) { -// mainActivity.mainBinding.profileView.btnFollow.setText(R.string.unfollow); -// mainActivity.mainBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_purple_background))); -// } else if (profileModel.getRequested() == true) { -// mainActivity.mainBinding.profileView.btnFollow.setText(R.string.cancel); -// mainActivity.mainBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_purple_background))); -// } else { -// mainActivity.mainBinding.profileView.btnFollow.setText(R.string.follow); -// mainActivity.mainBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_pink_background))); -// } -// mainActivity.mainBinding.profileView.btnRestrict.setVisibility(View.VISIBLE); -// if (profileModel.getRestricted() == true) { -// mainActivity.mainBinding.profileView.btnRestrict.setText(R.string.unrestrict); -// mainActivity.mainBinding.profileView.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_green_background))); -// } else { -// mainActivity.mainBinding.profileView.btnRestrict.setText(R.string.restrict); -// mainActivity.mainBinding.profileView.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_orange_background))); -// } -// if (profileModel.isReallyPrivate()) { -// mainActivity.mainBinding.profileView.btnBlock.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnTagged.setVisibility(View.GONE); -// if (profileModel.getBlocked() == true) { -// mainActivity.mainBinding.profileView.btnBlock.setText(R.string.unblock); -// mainActivity.mainBinding.profileView.btnBlock.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_green_background))); -// } else { -// mainActivity.mainBinding.profileView.btnBlock.setText(R.string.block); -// mainActivity.mainBinding.profileView.btnBlock.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_red_background))); -// } -// } else { -// mainActivity.mainBinding.profileView.btnBlock.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnSaved.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnTagged.setVisibility(View.VISIBLE); -// if (profileModel.getBlocked() == true) { -// mainActivity.mainBinding.profileView.btnSaved.setText(R.string.unblock); -// mainActivity.mainBinding.profileView.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_green_background))); -// } else { -// mainActivity.mainBinding.profileView.btnSaved.setText(R.string.block); -// mainActivity.mainBinding.profileView.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_red_background))); -// } -// } -// } else { -// mainActivity.mainBinding.profileView.btnTagged.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnSaved.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnLiked.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnSaved.setText(R.string.saved); -// mainActivity.mainBinding.profileView.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_orange_background))); -// } -// } else { -// if (Utils.dataBox.getFavorite(mainActivity.userQuery) != null) { -// mainActivity.mainBinding.profileView.btnFollow.setText(R.string.unfavorite_short); -// mainActivity.mainBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_purple_background))); -// } else { -// mainActivity.mainBinding.profileView.btnFollow.setText(R.string.favorite_short); -// mainActivity.mainBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_pink_background))); -// } -// mainActivity.mainBinding.profileView.btnFollow.setVisibility(View.VISIBLE); -// if (!profileModel.isReallyPrivate()) { -// mainActivity.mainBinding.profileView.btnRestrict.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnRestrict.setText(R.string.tagged); -// mainActivity.mainBinding.profileView.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// mainActivity, R.color.btn_blue_background))); -// } -// } -// -// // mainActivity.mainBinding.profileView.mainProfileImage.setEnabled(false); -// // new MyTask().execute(); -// mainActivity.mainBinding.profileView.mainProfileImage.setImageURI(profileModel.getSdProfilePic()); -// // mainActivity.mainBinding.profileView.mainProfileImage.setEnabled(true); -// -// final long followersCount = profileModel.getFollowersCount(); -// final long followingCount = profileModel.getFollowingCount(); -// -// final String postCount = String.valueOf(profileModel.getPostCount()); -// -// SpannableStringBuilder span = new SpannableStringBuilder(resources.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); -// mainActivity.mainBinding.profileView.mainPostCount.setText(span); -// -// final String followersCountStr = String.valueOf(followersCount); -// final int followersCountStrLen = followersCountStr.length(); -// span = new SpannableStringBuilder(resources.getString(R.string.main_posts_followers, followersCountStr)); -// span.setSpan(new RelativeSizeSpan(1.2f), 0, followersCountStrLen, 0); -// span.setSpan(new StyleSpan(Typeface.BOLD), 0, followersCountStrLen, 0); -// mainActivity.mainBinding.profileView.mainFollowers.setText(span); -// -// final String followingCountStr = String.valueOf(followingCount); -// final int followingCountStrLen = followingCountStr.length(); -// span = new SpannableStringBuilder(resources.getString(R.string.main_posts_following, followingCountStr)); -// span.setSpan(new RelativeSizeSpan(1.2f), 0, followingCountStrLen, 0); -// span.setSpan(new StyleSpan(Typeface.BOLD), 0, followingCountStrLen, 0); -// mainActivity.mainBinding.profileView.mainFollowing.setText(span); -// -// mainActivity.mainBinding.profileView.mainFullName -// .setText(Utils.isEmpty(profileModel.getName()) ? profileModel.getUsername() : profileModel.getName()); -// -// CharSequence biography = profileModel.getBiography(); -// mainActivity.mainBinding.profileView.mainBiography.setCaptionIsExpandable(true); -// mainActivity.mainBinding.profileView.mainBiography.setCaptionIsExpanded(true); -// if (Utils.hasMentions(biography)) { -// biography = Utils.getMentionText(biography); -// mainActivity.mainBinding.profileView.mainBiography.setText(biography, TextView.BufferType.SPANNABLE); -// mainActivity.mainBinding.profileView.mainBiography.setMentionClickListener(mentionClickListener); -// } else { -// mainActivity.mainBinding.profileView.mainBiography.setText(biography); -// mainActivity.mainBinding.profileView.mainBiography.setMentionClickListener(null); -// } -// -// final String url = profileModel.getUrl(); -// if (Utils.isEmpty(url)) { -// mainActivity.mainBinding.profileView.mainUrl.setVisibility(View.GONE); -// } else { -// mainActivity.mainBinding.profileView.mainUrl.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.mainUrl.setText(Utils.getSpannableUrl(url)); -// } -// -// mainActivity.mainBinding.profileView.mainFullName.setSelected(true); -// mainActivity.mainBinding.profileView.mainBiography.setEnabled(true); -// -// if (!profileModel.isReallyPrivate()) { -// mainActivity.mainBinding.profileView.mainFollowing.setClickable(true); -// mainActivity.mainBinding.profileView.mainFollowers.setClickable(true); -// -// if (isLoggedIn) { -// // final View.OnClickListener followClickListener = v -> mainActivity.startActivity(new Intent(mainActivity, FollowViewerFragment.class) -// // .putExtra(Constants.EXTRAS_FOLLOWERS, -// // v == mainActivity.mainBinding.profileView.mainFollowers) -// // .putExtra(Constants.EXTRAS_NAME, -// // profileModel.getUsername()) -// // .putExtra(Constants.EXTRAS_ID, -// // profileId)); -// // -// // mainActivity.mainBinding.profileView.mainFollowers.setOnClickListener(followersCount > 0 ? followClickListener : null); -// // mainActivity.mainBinding.profileView.mainFollowing.setOnClickListener(followingCount > 0 ? followClickListener : null); -// } -// -// if (profileModel.getPostCount() == 0) { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// mainActivity.mainBinding.profileView.privatePage1.setImageResource(R.drawable.ic_cancel); -// mainActivity.mainBinding.profileView.privatePage2.setText(R.string.empty_acc); -// mainActivity.mainBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// } else { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(true); -// mainActivity.mainBinding.profileView.mainPosts.setVisibility(View.VISIBLE); -// currentlyExecuting = new PostsFetcher(profileId, PostItemType.MAIN, null, postsFetchListener) -// .setUsername(profileModel.getUsername()) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } else { -// mainActivity.mainBinding.profileView.mainFollowers.setClickable(false); -// mainActivity.mainBinding.profileView.mainFollowing.setClickable(false); -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// // error -// mainActivity.mainBinding.profileView.privatePage1.setImageResource(R.drawable.lock); -// mainActivity.mainBinding.profileView.privatePage2.setText(R.string.priv_acc); -// mainActivity.mainBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.mainPosts.setVisibility(View.GONE); -// } -// } -// ).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } else if (isLocation) { -// mainActivity.profileModel = null; -// mainActivity.hashtagModel = null; -// mainActivity.mainBinding.toolbar.toolbar.setTitle(mainActivity.userQuery); -// mainActivity.mainBinding.profileView.locInfoContainer.setVisibility(View.VISIBLE); -// -// currentlyExecuting = new LocationFetcher(mainActivity.userQuery.split("/")[0], locationModel -> { -// mainActivity.locationModel = locationModel; -// -// if (locationModel == null) { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// Toast.makeText(mainActivity, R.string.error_loading_profile, Toast.LENGTH_SHORT).show(); -// mainActivity.mainBinding.toolbar.toolbar.setTitle(R.string.app_name); -// return; -// } -// mainActivity.mainBinding.toolbar.toolbar.setTitle(locationModel.getName()); -// -// final String profileId = locationModel.getId(); -// -// if (isLoggedIn) { -// new iStoryStatusFetcher(profileId.split("/")[0], null, true, false, false, false, result -> { -// mainActivity.storyModels = result; -// if (result != null && result.length > 0) -// mainActivity.mainBinding.profileView.mainLocationImage.setStoriesBorder(); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// // mainActivity.mainBinding.profileView.mainLocationImage.setEnabled(false); -// // new MyTask().execute(); -// mainActivity.mainBinding.profileView.mainLocationImage.setImageURI(locationModel.getSdProfilePic()); -// // mainActivity.mainBinding.profileView.mainLocationImage.setEnabled(true); -// -// final String postCount = String.valueOf(locationModel.getPostCount()); -// -// SpannableStringBuilder span = new SpannableStringBuilder(resources.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); -// mainActivity.mainBinding.profileView.mainLocPostCount.setText(span); -// -// mainActivity.mainBinding.profileView.locationFullName.setText(locationModel.getName()); -// -// CharSequence biography = locationModel.getBio(); -// mainActivity.mainBinding.profileView.locationBiography.setCaptionIsExpandable(true); -// mainActivity.mainBinding.profileView.locationBiography.setCaptionIsExpanded(true); -// -// if (Utils.isEmpty(biography)) { -// mainActivity.mainBinding.profileView.locationBiography.setVisibility(View.GONE); -// } else if (Utils.hasMentions(biography)) { -// mainActivity.mainBinding.profileView.locationBiography.setVisibility(View.VISIBLE); -// biography = Utils.getMentionText(biography); -// mainActivity.mainBinding.profileView.locationBiography.setText(biography, TextView.BufferType.SPANNABLE); -// mainActivity.mainBinding.profileView.locationBiography.setMentionClickListener(mentionClickListener); -// } else { -// mainActivity.mainBinding.profileView.locationBiography.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.locationBiography.setText(biography); -// mainActivity.mainBinding.profileView.locationBiography.setMentionClickListener(null); -// } -// -// if (!locationModel.getGeo().startsWith("geo:0.0,0.0?z=17")) { -// mainActivity.mainBinding.profileView.btnMap.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.btnMap.setOnClickListener(v -> { -// final Intent intent = new Intent(Intent.ACTION_VIEW); -// intent.setData(Uri.parse(locationModel.getGeo())); -// mainActivity.startActivity(intent); -// }); -// } else { -// mainActivity.mainBinding.profileView.btnMap.setVisibility(View.GONE); -// mainActivity.mainBinding.profileView.btnMap.setOnClickListener(null); -// } -// -// final String url = locationModel.getUrl(); -// if (Utils.isEmpty(url)) { -// mainActivity.mainBinding.profileView.locationUrl.setVisibility(View.GONE); -// } else if (!url.startsWith("http")) { -// mainActivity.mainBinding.profileView.locationUrl.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.locationUrl.setText(Utils.getSpannableUrl("http://" + url)); -// } else { -// mainActivity.mainBinding.profileView.locationUrl.setVisibility(View.VISIBLE); -// mainActivity.mainBinding.profileView.locationUrl.setText(Utils.getSpannableUrl(url)); -// } -// -// mainActivity.mainBinding.profileView.locationFullName.setSelected(true); -// mainActivity.mainBinding.profileView.locationBiography.setEnabled(true); -// -// if (locationModel.getPostCount() == 0) { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// mainActivity.mainBinding.profileView.privatePage1.setImageResource(R.drawable.ic_cancel); -// mainActivity.mainBinding.profileView.privatePage2.setText(R.string.empty_acc); -// mainActivity.mainBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// } else { -// mainActivity.mainBinding.profileView.swipeRefreshLayout.setRefreshing(true); -// mainActivity.mainBinding.profileView.mainPosts.setVisibility(View.VISIBLE); -// currentlyExecuting = new PostsFetcher(profileId, PostItemType.LOCATION, null, postsFetchListener) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } -// ).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } -// -// public static void stopCurrentExecutor() { -// if (currentlyExecuting != null) { -// try { -// currentlyExecuting.cancel(true); -// } catch (final Exception e) { -// if (logCollector != null) -// logCollector.appendException(e, LogCollector.LogFile.MAIN_HELPER, "stopCurrentExecutor"); -// if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); -// } -// } -// } -// -// private void toggleSelection(final PostModel postModel) { -// if (postModel != null && postsAdapter != null && mainActivity.selectedItems.size() >= 100) { -// Toast.makeText(mainActivity, R.string.downloader_too_many, Toast.LENGTH_SHORT); -// } else if (postModel != null && postsAdapter != null) { -// if (postModel.isSelected()) mainActivity.selectedItems.remove(postModel); -// else if (mainActivity.selectedItems.size() >= 100) { -// Toast.makeText(mainActivity, R.string.downloader_too_many, Toast.LENGTH_SHORT); -// return; -// } else mainActivity.selectedItems.add(postModel); -// postModel.setSelected(!postModel.isSelected()); -// notifyAdapter(postModel); -// } -// } -// -// private void notifyAdapter(final PostModel postModel) { -// // if (mainActivity.selectedItems.size() < 1) postsAdapter.isSelecting = false; -// // if (postModel.getPosition() < 0) postsAdapter.notifyDataSetChanged(); -// // else postsAdapter.notifyItemChanged(postModel.getPosition(), postModel); -// // -// // if (mainActivity.downloadAction != null) -// // mainActivity.downloadAction.setVisible(postsAdapter.isSelecting); -// } -// -// private void toggleDiscoverSelection(final DiscoverItemModel itemModel) { -// if (itemModel != null && discoverAdapter != null) { -// if (itemModel.isSelected()) mainActivity.selectedDiscoverItems.remove(itemModel); -// else mainActivity.selectedDiscoverItems.add(itemModel); -// itemModel.setSelected(!itemModel.isSelected()); -// notifyDiscoverAdapter(itemModel); -// } -// } -// -// private void notifyDiscoverAdapter(final DiscoverItemModel itemModel) { -// // if (mainActivity.selectedDiscoverItems.size() < 1) discoverAdapter.isSelecting = false; -// // if (itemModel.getPosition() < 0) discoverAdapter.notifyDataSetChanged(); -// // else discoverAdapter.notifyItemChanged(itemModel.getPosition(), itemModel); -// // -// // if (mainActivity.downloadAction != null) -// // mainActivity.downloadAction.setVisible(discoverAdapter.isSelecting); -// } -// -// public boolean isSelectionCleared() { -// // if (postsAdapter != null && postsAdapter.isSelecting()) { -// // for (final PostModel postModel : mainActivity.selectedItems) -// // postModel.setSelected(false); -// // mainActivity.selectedItems.clear(); -// // // postsAdapter.isSelecting = false; -// // postsAdapter.notifyDataSetChanged(); -// // if (mainActivity.downloadAction != null) mainActivity.downloadAction.setVisible(false); -// // return false; -// // } else if (discoverAdapter != null && discoverAdapter.isSelecting) { -// // for (final DiscoverItemModel itemModel : mainActivity.selectedDiscoverItems) -// // itemModel.setSelected(false); -// // mainActivity.selectedDiscoverItems.clear(); -// // discoverAdapter.isSelecting = false; -// // discoverAdapter.notifyDataSetChanged(); -// // if (mainActivity.downloadAction != null) mainActivity.downloadAction.setVisible(false); -// // return false; -// // } -// // return true; -// return false; -// } -// -// public void deselectSelection(final BasePostModel postModel) { -// if (postModel instanceof PostModel) { -// mainActivity.selectedItems.remove(postModel); -// postModel.setSelected(false); -// if (postsAdapter != null) notifyAdapter((PostModel) postModel); -// } else if (postModel instanceof DiscoverItemModel) { -// mainActivity.selectedDiscoverItems.remove(postModel); -// postModel.setSelected(false); -// if (discoverAdapter != null) notifyDiscoverAdapter((DiscoverItemModel) postModel); -// } -// } -// -// public void onPause() { -// if (videoAwareRecyclerScroller != null) { -// videoAwareRecyclerScroller.stopPlaying(); -// } -// } -// -// public void onResume() { -// if (videoAwareRecyclerScroller != null && SHOULD_AUTO_PLAY) { -// videoAwareRecyclerScroller.startPlaying(); -// } -// } -// -// public static int indexOfIntArray(Object[] array, Object key) { -// int returnvalue = -1; -// for (int i = 0; i < array.length; ++i) { -// if (key == array[i]) { -// returnvalue = i; -// break; -// } -// } -// return returnvalue; -// } -// -// private final View.OnClickListener profileActionListener = new View.OnClickListener() { -// @Override -// public void onClick(final View v) { -// final String userIdFromCookie = Utils.getUserIdFromCookie(MainHelper.this.cookie); -// final boolean isSelf = (isLoggedIn && mainActivity.profileModel != null) && userIdFromCookie != null && userIdFromCookie -// .equals(mainActivity.profileModel.getId()); -// if (!isLoggedIn -// && Utils.dataBox.getFavorite(mainActivity.userQuery) != null -// && v == mainActivity.mainBinding.profileView.btnFollow) { -// Utils.dataBox.delFavorite(new DataBox.FavoriteModel(mainActivity.userQuery, -// Long.parseLong(Utils.dataBox.getFavorite(mainActivity.userQuery).split("/")[1]), -// mainActivity.locationModel != null -// ? mainActivity.locationModel.getName() -// : mainActivity.userQuery.replaceAll("^@", ""))); -// onRefresh(); -// } else if (!isLoggedIn -// && (v == mainActivity.mainBinding.profileView.btnFollow || v == mainActivity.mainBinding.profileView.btnFollowTag)) { -// Utils.dataBox.addFavorite(new DataBox.FavoriteModel(mainActivity.userQuery, System.currentTimeMillis(), -// mainActivity.locationModel != null -// ? mainActivity.locationModel.getName() -// : mainActivity.userQuery.replaceAll("^@", ""))); -// onRefresh(); -// } else if (v == mainActivity.mainBinding.profileView.btnFollow) { -// if (mainActivity.profileModel.isPrivate() && mainActivity.profileModel.getFollowing()) { -// new AlertDialog.Builder(mainActivity) -// .setTitle(R.string.priv_acc) -// .setMessage(R.string.priv_acc_confirm) -// .setNegativeButton(R.string.no, null) -// .setPositiveButton(R.string.yes, (dialog, which) -> new ProfileAction().execute("follow")) -// .show(); -// } else new ProfileAction().execute("follow"); -// } else if (v == mainActivity.mainBinding.profileView.btnRestrict && isLoggedIn) { -// new ProfileAction().execute("restrict"); -// } else if (v == mainActivity.mainBinding.profileView.btnSaved && !isSelf) { -// new ProfileAction().execute("block"); -// } else if (v == mainActivity.mainBinding.profileView.btnFollowTag) { -// new ProfileAction().execute("followtag"); -// } else if (v == mainActivity.mainBinding.profileView.btnTagged || v == mainActivity.mainBinding.profileView.btnRestrict) { -// mainActivity.startActivity(new Intent(mainActivity, SavedViewerFragment.class) -// .putExtra(Constants.EXTRAS_INDEX, "%" + mainActivity.profileModel.getId()) -// .putExtra(Constants.EXTRAS_USER, "@" + mainActivity.profileModel.getUsername()) -// ); -// } else if (v == mainActivity.mainBinding.profileView.btnSaved) { -// mainActivity.startActivity(new Intent(mainActivity, SavedViewerFragment.class) -// .putExtra(Constants.EXTRAS_INDEX, "$" + mainActivity.profileModel.getId()) -// .putExtra(Constants.EXTRAS_USER, "@" + mainActivity.profileModel.getUsername()) -// ); -// } else if (v == mainActivity.mainBinding.profileView.btnLiked) { -// mainActivity.startActivity(new Intent(mainActivity, SavedViewerFragment.class) -// .putExtra(Constants.EXTRAS_INDEX, "^" + mainActivity.profileModel.getId()) -// .putExtra(Constants.EXTRAS_USER, "@" + mainActivity.profileModel.getUsername()) -// ); -// } -// } -// }; -// -// class ProfileAction extends AsyncTask { -// boolean ok = false; -// String action; -// -// protected Void doInBackground(String... rawAction) { -// action = rawAction[0]; -// final String url = "https://www.instagram.com/web/" + (action.equals("followtag") && mainActivity.hashtagModel != null -// ? "tags/" + (mainActivity.hashtagModel.getFollowing() -// ? "unfollow/" -// : "follow/") + mainActivity.hashtagModel.getName() + "/" -// : (action.equals("restrict") && mainActivity.profileModel != null -// ? "restrict_action" -// : "friendships/" + mainActivity.profileModel.getId()) + "/" + (action.equals( -// "follow") ? -// mainActivity.profileModel -// .getFollowing() || mainActivity.profileModel -// .getRequested() -// ? "unfollow/" -// : "follow/" : -// action.equals( -// "restrict") -// ? -// mainActivity.profileModel -// .getRestricted() -// ? "unrestrict/" -// : "restrict/" -// : -// mainActivity.profileModel -// .getBlocked() -// ? "unblock/" -// : "block/")); -// try { -// final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); -// urlConnection.setRequestMethod("POST"); -// urlConnection.setUseCaches(false); -// urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT); -// urlConnection.setRequestProperty("x-csrftoken", cookie.split("csrftoken=")[1].split(";")[0]); -// if (action == "restrict") { -// final String urlParameters = "target_user_id=" + mainActivity.profileModel.getId(); -// urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); -// urlConnection.setRequestProperty("Content-Length", "" + -// urlParameters.getBytes().length); -// urlConnection.setDoOutput(true); -// DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream()); -// wr.writeBytes(urlParameters); -// wr.flush(); -// wr.close(); -// } else urlConnection.connect(); -// if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { -// ok = true; -// } else -// Toast.makeText(mainActivity, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); -// urlConnection.disconnect(); -// } catch (Throwable ex) { -// Log.e("austin_debug", action + ": " + ex); -// } -// return null; -// } -// -// @Override -// protected void onPostExecute(Void result) { -// if (ok == true) { -// onRefresh(); -// } -// } -// } -// } diff --git a/app/src/main/java/awais/instagrabber/activities/DirectMessagesActivity.java b/app/src/main/java/awais/instagrabber/activities/DirectMessagesActivity.java deleted file mode 100644 index b2b9c9dc..00000000 --- a/app/src/main/java/awais/instagrabber/activities/DirectMessagesActivity.java +++ /dev/null @@ -1,94 +0,0 @@ -// package awais.instagrabber.activities; -// -// import android.os.Bundle; -// import android.view.View; -// import android.widget.TextView; -// -// import androidx.annotation.NonNull; -// import androidx.annotation.Nullable; -// import androidx.appcompat.widget.AppCompatImageView; -// import androidx.appcompat.widget.Toolbar; -// import androidx.coordinatorlayout.widget.CoordinatorLayout; -// import androidx.navigation.NavController; -// import androidx.navigation.NavDestination; -// import androidx.navigation.Navigation; -// import androidx.navigation.ui.AppBarConfiguration; -// import androidx.navigation.ui.NavigationUI; -// -// import awais.instagrabber.R; -// import awais.instagrabber.databinding.ActivityDirectMessagesBinding; -// import awais.instagrabber.fragments.directmessages.DirectMessageThreadFragmentArgs; -// import awais.instagrabber.utils.Constants; -// import static awais.instagrabber.utils.Utils.settingsHelper; -// -// @Deprecated -// public class DirectMessagesActivity extends BaseLanguageActivity implements NavController.OnDestinationChangedListener { -// -// private TextView toolbarTitle; -// private AppCompatImageView dmInfo, dmSeen; -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// final ActivityDirectMessagesBinding binding = ActivityDirectMessagesBinding.inflate(getLayoutInflater()); -// final CoordinatorLayout root = binding.getRoot(); -// setContentView(root); -// -// toolbarTitle = binding.toolbarTitle; -// -// final Toolbar toolbar = binding.toolbar; -// setSupportActionBar(toolbar); -// -// dmInfo = binding.dmInfo; -// dmSeen = binding.dmSeen; -// -// final NavController navController = Navigation.findNavController(this, R.id.direct_messages_nav_host_fragment); -// navController.addOnDestinationChangedListener(this); -// final AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build(); -// NavigationUI.setupWithNavController(toolbar, navController, appBarConfiguration); -// } -// -// @Override -// public void onDestinationChanged(@NonNull final NavController controller, -// @NonNull final NavDestination destination, -// @Nullable final Bundle arguments) { -// switch (destination.getId()) { -// case R.id.directMessagesInboxFragment: -// setToolbarTitle(R.string.action_dms); -// dmInfo.setVisibility(View.GONE); -// dmSeen.setVisibility(View.GONE); -// return; -// case R.id.directMessagesThreadFragment: -// if (arguments == null) { -// return; -// } -// final String title = DirectMessageThreadFragmentArgs.fromBundle(arguments).getTitle(); -// setToolbarTitle(title); -// dmInfo.setVisibility(View.VISIBLE); -// dmSeen.setVisibility(settingsHelper.getBoolean(Constants.DM_MARK_AS_SEEN) ? View.GONE : View.VISIBLE); -// return; -// case R.id.directMessagesSettingsFragment: -// if (arguments == null) { -// return; -// } -// setToolbarTitle(R.string.action_settings); -// dmInfo.setVisibility(View.GONE); -// dmSeen.setVisibility(View.GONE); -// return; -// } -// } -// -// private void setToolbarTitle(final String text) { -// if (toolbarTitle == null) { -// return; -// } -// toolbarTitle.setText(text); -// } -// -// private void setToolbarTitle(final int resourceId) { -// if (toolbarTitle == null) { -// return; -// } -// toolbarTitle.setText(resourceId); -// } -// } diff --git a/app/src/main/java/awais/instagrabber/activities/MainActivityBackup.java b/app/src/main/java/awais/instagrabber/activities/MainActivityBackup.java deleted file mode 100644 index 0a4cb8f6..00000000 --- a/app/src/main/java/awais/instagrabber/activities/MainActivityBackup.java +++ /dev/null @@ -1,607 +0,0 @@ -// package awais.instagrabber.activities; -// -// import android.app.Notification; -// import android.app.PendingIntent; -// import android.content.DialogInterface; -// import android.content.Intent; -// import android.content.pm.PackageManager; -// import android.content.res.Resources; -// import android.database.MatrixCursor; -// import android.os.AsyncTask; -// import android.os.Bundle; -// import android.os.Handler; -// import android.os.PersistableBundle; -// import android.provider.BaseColumns; -// import android.text.TextUtils; -// import android.view.Menu; -// import android.view.MenuItem; -// import android.view.View; -// import android.widget.ArrayAdapter; -// import android.widget.AutoCompleteTextView; -// import android.widget.Toast; -// -// import androidx.annotation.NonNull; -// import androidx.annotation.Nullable; -// import androidx.appcompat.app.AlertDialog; -// import androidx.appcompat.widget.SearchView; -// import androidx.core.app.NotificationCompat; -// import androidx.fragment.app.FragmentManager; -// import androidx.recyclerview.widget.GridLayoutManager; -// -// import java.util.ArrayList; -// import java.util.List; -// import java.util.Stack; -// -// import awais.instagrabber.MainHelper; -// import awais.instagrabber.R; -// import awais.instagrabber.adapters.HighlightsAdapter; -// import awais.instagrabber.adapters.SuggestionsAdapter; -// import awais.instagrabber.asyncs.GetActivityAsyncTask; -// import awais.instagrabber.asyncs.SuggestionsFetcher; -// import awais.instagrabber.asyncs.UsernameFetcher; -// import awais.instagrabber.asyncs.i.iStoryStatusFetcher; -// import awais.instagrabber.customviews.MouseDrawer; -// import awais.instagrabber.databinding.ActivityMainbackupBinding; -// import awais.instagrabber.dialogs.AboutDialog; -// import awais.instagrabber.dialogs.QuickAccessDialog; -// import awais.instagrabber.dialogs.SettingsDialog; -// import awais.instagrabber.interfaces.FetchListener; -// import awais.instagrabber.interfaces.ItemGetter; -// import awais.instagrabber.models.DiscoverItemModel; -// import awais.instagrabber.models.FeedModel; -// import awais.instagrabber.models.HashtagModel; -// import awais.instagrabber.models.HighlightModel; -// import awais.instagrabber.models.LocationModel; -// import awais.instagrabber.models.PostModel; -// import awais.instagrabber.models.ProfileModel; -// import awais.instagrabber.models.StoryModel; -// import awais.instagrabber.models.SuggestionModel; -// import awais.instagrabber.models.enums.DownloadMethod; -// import awais.instagrabber.models.enums.PostItemType; -// import awais.instagrabber.models.enums.SuggestionType; -// import awais.instagrabber.utils.Constants; -// import awais.instagrabber.utils.DataBox; -// import awais.instagrabber.utils.FlavorTown; -// import awais.instagrabber.utils.Utils; -// -// import static awais.instagrabber.utils.Utils.CHANNEL_ID; -// import static awais.instagrabber.utils.Utils.notificationManager; -// import static awais.instagrabber.utils.Utils.settingsHelper; -// -// @Deprecated -// public final class MainActivityBackup extends BaseLanguageActivity { -// private static final int INITIAL_DELAY_MILLIS = 200; -// private static final int DELAY_MILLIS = 60000; -// public static FetchListener scanHack; -// public static ItemGetter itemGetter; -// -// public final ArrayList allItems = new ArrayList<>(); -// public final ArrayList feedItems = new ArrayList<>(); -// public final ArrayList discoverItems = new ArrayList<>(); -// public final ArrayList selectedItems = new ArrayList<>(); -// public final ArrayList selectedDiscoverItems = new ArrayList<>(); -// -// public final HighlightsAdapter highlightsAdapter = new HighlightsAdapter(null, new View.OnClickListener() { -// @Override -// public void onClick(final View v) { -// final Object tag = v.getTag(); -// if (tag instanceof HighlightModel) { -// final HighlightModel highlightModel = (HighlightModel) tag; -// new iStoryStatusFetcher(highlightModel.getId(), null, false, false, -// (!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), true, result -> { -// if (result != null && result.length > 0) { -// // startActivity(new Intent(MainActivityBackup.this, StoryViewer.class) -// // .putExtra(Constants.EXTRAS_USERNAME, userQuery.replace("@", "")) -// // .putExtra(Constants.EXTRAS_HIGHLIGHT, highlightModel.getTitle()) -// // .putExtra(Constants.EXTRAS_STORIES, result) -// // ); -// } else -// Toast.makeText(MainActivityBackup.this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } -// }); -// -// private SuggestionsAdapter suggestionAdapter; -// private MenuItem searchAction; -// public @NonNull -// ActivityMainbackupBinding mainBinding; -// public SearchView searchView; -// public MenuItem downloadAction, settingsAction, dmsAction, notifAction; -// public StoryModel[] storyModels; -// public String userQuery = null, cookie, uid = null; -// public MainHelper mainHelper; -// public ProfileModel profileModel; -// public HashtagModel hashtagModel; -// public LocationModel locationModel; -// private AutoCompleteTextView searchAutoComplete; -// private ArrayAdapter profileDialogAdapter; -// private DialogInterface.OnClickListener profileDialogListener; -// private Stack queriesStack; -// private DataBox.CookieModel cookieModel; -// private Runnable runnable; -// private Handler handler; -// private boolean isLoggedIn; -// -// @Override -// protected void onCreate(@Nullable final Bundle bundle) { -// super.onCreate(bundle); -// mainBinding = ActivityMainbackupBinding.inflate(getLayoutInflater()); -// setContentView(mainBinding.getRoot()); -// -// if (settingsHelper.getBoolean(Constants.CHECK_UPDATES)) FlavorTown.updateCheck(this); -// FlavorTown.changelogCheck(this); -// -// cookie = settingsHelper.getString(Constants.COOKIE); -// uid = Utils.getUserIdFromCookie(cookie); -// Utils.setupCookies(cookie); -// -// MainHelper.stopCurrentExecutor(); -// mainHelper = new MainHelper(this); -// if (bundle == null) { -// queriesStack = new Stack<>(); -// userQuery = null; -// } else { -// setStack(bundle); -// userQuery = bundle.getString("query"); -// } -// isLoggedIn = !Utils.isEmpty(cookie) && Utils.getUserIdFromCookie(cookie) != null; -// -// itemGetter = itemGetType -> { -// if (itemGetType == PostItemType.MAIN) return allItems; -// if (itemGetType == PostItemType.DISCOVER) return discoverItems; -// if (itemGetType == PostItemType.FEED) return feedItems; -// return null; -// }; -// -// scanHack = result -> { -// if (mainHelper != null && !Utils.isEmpty(result)) { -// closeAnyOpenDrawer(); -// addToStack(); -// userQuery = (result.contains("/") || result.startsWith("#") || result.startsWith("@")) ? result : ("@" + result); -// mainHelper.onRefresh(); -// } -// }; -// -// // searches for your userid and returns username -// if (uid != null) { -// final FetchListener fetchListener = username -> { -// if (!Utils.isEmpty(username)) { -// // if (!BuildConfig.DEBUG) { -// userQuery = username; -// if (mainHelper != null && !mainBinding.profileView.swipeRefreshLayout.isRefreshing()) -// mainHelper.onRefresh(); -// // } -// // adds cookies to database for quick access -// cookieModel = Utils.dataBox.getCookie(uid); -// if (Utils.dataBox.getCookieCount() == 0 || cookieModel == null || Utils.isEmpty(cookieModel.getUsername())) -// Utils.dataBox.addUserCookie(new DataBox.CookieModel(uid, username, cookie)); -// } -// }; -// boolean found = false; -// cookieModel = Utils.dataBox.getCookie(uid); -// if (cookieModel != null) { -// final String username = cookieModel.getUsername(); -// if (username != null) { -// found = true; -// fetchListener.onResult("@" + username); -// } -// } -// -// if (!found) // if not in database, fetch info from instagram -// new UsernameFetcher(uid, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// suggestionAdapter = new SuggestionsAdapter(this, v -> { -// final Object tag = v.getTag(); -// if (tag instanceof CharSequence) { -// addToStack(); -// userQuery = tag.toString(); -// mainHelper.onRefresh(); -// } -// if (searchView != null && !searchView.isIconified()) { -// if (searchAction != null) searchAction.collapseActionView(); -// searchView.setIconified(true); -// searchView.setIconified(true); -// } -// }); -// -// final Resources resources = getResources(); -// profileDialogAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, -// new String[]{resources.getString(R.string.view_pfp), resources.getString(R.string.show_stories)}); -// profileDialogListener = (dialog, which) -> { -// final Intent intent; -// if (which == 0 || storyModels == null || storyModels.length < 1) { -// intent = new Intent(this, ProfilePicViewer.class).putExtra( -// ((hashtagModel != null) ? Constants.EXTRAS_HASHTAG : (locationModel != null ? Constants.EXTRAS_LOCATION : Constants.EXTRAS_PROFILE)), -// ((hashtagModel != null) ? hashtagModel : (locationModel != null ? locationModel : profileModel))); -// } else { -// // intent = new Intent(this, StoryViewer.class).putExtra(Constants.EXTRAS_USERNAME, userQuery.replace("@", "")) -// // .putExtra(Constants.EXTRAS_STORIES, storyModels) -// // .putExtra(Constants.EXTRAS_HASHTAG, (hashtagModel != null)); -// } -// // startActivity(intent); -// }; -// -// final View.OnClickListener onClickListener = v -> { -// if (v == mainBinding.profileView.mainBiography) { -// Utils.copyText(this, mainBinding.profileView.mainBiography.getText().toString()); -// } else if (v == mainBinding.profileView.locationBiography) { -// Utils.copyText(this, mainBinding.profileView.locationBiography.getText().toString()); -// } else if (v == mainBinding.profileView.mainProfileImage || v == mainBinding.profileView.mainHashtagImage || v == mainBinding.profileView.mainLocationImage) { -// if (storyModels == null || storyModels.length <= 0) { -// profileDialogListener.onClick(null, 0); -// } else { -// // because sometimes configuration changes made this crash on some phones -// new AlertDialog.Builder(this).setAdapter(profileDialogAdapter, profileDialogListener) -// .setNeutralButton(R.string.cancel, null).show(); -// } -// } -// }; -// -// mainBinding.profileView.mainBiography.setOnClickListener(onClickListener); -// mainBinding.profileView.locationBiography.setOnClickListener(onClickListener); -// mainBinding.profileView.mainProfileImage.setOnClickListener(onClickListener); -// mainBinding.profileView.mainHashtagImage.setOnClickListener(onClickListener); -// mainBinding.profileView.mainLocationImage.setOnClickListener(onClickListener); -// -// mainBinding.profileView.mainBiography.setEnabled(false); -// mainBinding.profileView.mainProfileImage.setEnabled(false); -// mainBinding.profileView.mainHashtagImage.setEnabled(false); -// mainBinding.profileView.mainLocationImage.setEnabled(false); -// -// final boolean isQueryNull = userQuery == null; -// if (isQueryNull) { -// allItems.clear(); -// mainBinding.profileView.privatePage1.setImageResource(R.drawable.ic_outline_info_24); -// mainBinding.profileView.privatePage2.setTextSize(20); -// mainBinding.profileView.privatePage2.setText(isLoggedIn ? R.string.no_acc_logged_in : R.string.no_acc); -// mainBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// } -// if (!mainBinding.profileView.swipeRefreshLayout.isRefreshing() && userQuery != null) -// mainHelper.onRefresh(); -// -// mainHelper.onIntent(getIntent()); -// -// handler = new Handler(); -// runnable = () -> { -// final GetActivityAsyncTask activityAsyncTask = new GetActivityAsyncTask(uid, cookie, result -> { -// if (result == null || notificationManager == null) { -// return; -// } -// final List list = new ArrayList<>(); -// if (result.getRelationshipsCount() != 0) { -// list.add(getString(R.string.activity_count_relationship, result.getRelationshipsCount())); -// } -// if (result.getUserTagsCount() != 0) { -// list.add(getString(R.string.activity_count_usertags, result.getUserTagsCount())); -// } -// if (result.getCommentsCount() != 0) { -// list.add(getString(R.string.activity_count_comments, result.getCommentsCount())); -// } -// if (result.getCommentLikesCount() != 0) { -// list.add(getString(R.string.activity_count_commentlikes, result.getCommentLikesCount())); -// } -// if (result.getLikesCount() != 0) { -// list.add(getString(R.string.activity_count_likes, result.getLikesCount())); -// } -// if (list.isEmpty()) { -// return; -// } -// final String join = TextUtils.join(", ", list); -// final String notificationString = getString(R.string.activity_count_prefix) + " " + join + "."; -// final Intent intent = new Intent(getApplicationContext(), NotificationsViewer.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); -// final Notification notification = new NotificationCompat.Builder(MainActivityBackup.this, CHANNEL_ID) -// .setCategory(NotificationCompat.CATEGORY_STATUS) -// .setSmallIcon(R.drawable.ic_notif) -// .setAutoCancel(true) -// .setPriority(NotificationCompat.PRIORITY_MIN) -// .setContentText(notificationString) -// .setContentIntent(PendingIntent.getActivity(getApplicationContext(), 1738, intent, PendingIntent.FLAG_UPDATE_CURRENT)) -// .build(); -// notificationManager.cancel(1800000000); -// notificationManager.notify(1800000000, notification); -// }); -// activityAsyncTask.execute(); -// if (!Utils.isEmpty(cookie) && Utils.settingsHelper.getBoolean(Constants.CHECK_ACTIVITY)) -// activityAsyncTask.execute(); -// handler.postDelayed(runnable, DELAY_MILLIS); -// }; -// handler.postDelayed(runnable, INITIAL_DELAY_MILLIS); -// } -// -// private void downloadSelectedItems() { -// if (selectedItems.size() > 0) { -// Utils.batchDownload(this, userQuery, DownloadMethod.DOWNLOAD_MAIN, selectedItems); -// } else if (selectedDiscoverItems.size() > 0) { -// Utils.batchDownload(this, null, DownloadMethod.DOWNLOAD_DISCOVER, selectedDiscoverItems); -// } -// } -// -// @Override -// protected void onNewIntent(final Intent intent) { -// super.onNewIntent(intent); -// mainHelper.onIntent(intent); -// } -// -// @Override -// public void onSaveInstanceState(@NonNull final Bundle outState, @NonNull final PersistableBundle outPersistentState) { -// outState.putString("query", userQuery); -// outState.putSerializable("stack", queriesStack); -// super.onSaveInstanceState(outState, outPersistentState); -// } -// -// @Override -// public void onRestoreInstanceState(@Nullable final Bundle savedInstanceState, @Nullable final PersistableBundle persistentState) { -// super.onRestoreInstanceState(savedInstanceState, persistentState); -// if (savedInstanceState != null) { -// userQuery = savedInstanceState.getString("query"); -// setStack(savedInstanceState); -// } -// } -// -// @Override -// protected void onSaveInstanceState(@NonNull final Bundle outState) { -// outState.putString("query", userQuery); -// outState.putSerializable("stack", queriesStack); -// super.onSaveInstanceState(outState); -// } -// -// @Override -// protected void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) { -// super.onRestoreInstanceState(savedInstanceState); -// userQuery = savedInstanceState.getString("query"); -// setStack(savedInstanceState); -// } -// -// @Override -// public boolean onCreateOptionsMenu(final Menu menu) { -// getMenuInflater().inflate(R.menu.menu, menu); -// -// final FragmentManager fragmentManager = getSupportFragmentManager(); -// final MenuItem quickAccessAction = menu.findItem(R.id.action_quickaccess).setVisible(true); -// -// final MenuItem.OnMenuItemClickListener clickListener = item -> { -// if (item == downloadAction) -// downloadSelectedItems(); -// else if (item == dmsAction) -// startActivity(new Intent(this, DirectMessagesActivity.class)); -// else if (item == notifAction) -// startActivity(new Intent(this, NotificationsViewer.class)); -// else if (item == settingsAction) -// new SettingsDialog().show(fragmentManager, "settings"); -// else if (item == quickAccessAction) -// new QuickAccessDialog() -// .setQuery(userQuery, locationModel != null ? locationModel.getName() : userQuery) -// .show(fragmentManager, "quickAccess"); -// else -// new AboutDialog().show(fragmentManager, "about"); -// return true; -// }; -// -// quickAccessAction.setOnMenuItemClickListener(clickListener); -// menu.findItem(R.id.action_about).setVisible(true).setOnMenuItemClickListener(clickListener); -// dmsAction = menu.findItem(R.id.action_dms).setOnMenuItemClickListener(clickListener); -// notifAction = menu.findItem(R.id.action_notif).setOnMenuItemClickListener(clickListener); -// settingsAction = menu.findItem(R.id.action_settings).setVisible(true).setOnMenuItemClickListener(clickListener); -// downloadAction = menu.findItem(R.id.action_download).setOnMenuItemClickListener(clickListener); -// -// if (!Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE))) { -// notifAction.setVisible(true); -// dmsAction.setVisible(true).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); -// } -// -// searchAction = menu.findItem(R.id.action_search); -// searchView = (SearchView) searchAction.getActionView(); -// final View searchText = searchView.findViewById(R.id.search_src_text); -// if (searchText instanceof AutoCompleteTextView) -// searchAutoComplete = (AutoCompleteTextView) searchText; -// -// searchView.setQueryHint(getResources().getString(R.string.action_search)); -// searchView.setSuggestionsAdapter(suggestionAdapter); -// searchView.setOnSearchClickListener(v -> { -// searchView.setQuery((cookieModel != null && userQuery != null && userQuery.equals("@" + cookieModel.getUsername())) ? "" : userQuery, false); -// menu.findItem(R.id.action_about).setVisible(false); -// menu.findItem(R.id.action_settings).setVisible(false); -// menu.findItem(R.id.action_dms).setVisible(false); -// menu.findItem(R.id.action_quickaccess).setVisible(false); -// menu.findItem(R.id.action_notif).setVisible(false); -// }); -// searchAction.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { -// @Override -// public boolean onMenuItemActionExpand(MenuItem item) { -// return true; -// } -// -// @Override -// public boolean onMenuItemActionCollapse(MenuItem item) { -// menu.findItem(R.id.action_about).setVisible(true); -// menu.findItem(R.id.action_settings).setVisible(true); -// menu.findItem(R.id.action_dms).setVisible(!Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE))); -// menu.findItem(R.id.action_quickaccess).setVisible(true); -// menu.findItem(R.id.action_notif).setVisible(true); -// return true; -// } -// }); -// searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { -// private boolean searchUser, searchHash; -// private AsyncTask prevSuggestionAsync; -// private final String[] COLUMNS = {BaseColumns._ID, Constants.EXTRAS_USERNAME, Constants.EXTRAS_NAME, -// Constants.EXTRAS_TYPE, "pfp", "verified"}; -// private final FetchListener fetchListener = new FetchListener() { -// @Override -// public void doBefore() { -// suggestionAdapter.changeCursor(null); -// } -// -// @Override -// public void onResult(final SuggestionModel[] result) { -// final MatrixCursor cursor; -// if (result == null) cursor = null; -// else { -// cursor = new MatrixCursor(COLUMNS, 0); -// for (int i = 0; i < result.length; i++) { -// final SuggestionModel suggestionModel = result[i]; -// if (suggestionModel != null) { -// final SuggestionType suggestionType = suggestionModel.getSuggestionType(); -// final Object[] objects = {i, -// (suggestionType == SuggestionType.TYPE_LOCATION) ? suggestionModel.getName() : suggestionModel.getUsername(), -// (suggestionType == SuggestionType.TYPE_LOCATION) ? suggestionModel.getUsername() : suggestionModel.getName(), -// suggestionType, suggestionModel.getProfilePic(), suggestionModel.isVerified()}; -// -// if (!searchHash && !searchUser) cursor.addRow(objects); -// else { -// final boolean isCurrHash = suggestionType == SuggestionType.TYPE_HASHTAG; -// if (searchHash && isCurrHash || !searchHash && !isCurrHash) -// cursor.addRow(objects); -// } -// } -// } -// } -// suggestionAdapter.changeCursor(cursor); -// } -// }; -// -// private void cancelSuggestionsAsync() { -// if (prevSuggestionAsync != null) -// try { -// prevSuggestionAsync.cancel(true); -// } catch (final Exception ignored) { -// } -// } -// -// @Override -// public boolean onQueryTextSubmit(final String query) { -// cancelSuggestionsAsync(); -// menu.findItem(R.id.action_about).setVisible(true); -// menu.findItem(R.id.action_settings).setVisible(true); -// -// closeAnyOpenDrawer(); -// addToStack(); -// userQuery = (query.contains("@") || query.contains("#")) ? query : ("@" + query); -// searchAction.collapseActionView(); -// searchView.setIconified(true); -// searchView.setIconified(true); -// mainHelper.onRefresh(); -// return false; -// } -// -// @Override -// public boolean onQueryTextChange(final String newText) { -// cancelSuggestionsAsync(); -// -// if (!Utils.isEmpty(newText)) { -// searchUser = newText.charAt(0) == '@'; -// searchHash = newText.charAt(0) == '#'; -// -// if (newText.length() == 1 && (searchHash || searchUser)) { -// if (searchAutoComplete != null) searchAutoComplete.setThreshold(2); -// } else { -// if (searchAutoComplete != null) searchAutoComplete.setThreshold(1); -// prevSuggestionAsync = new SuggestionsFetcher(fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, -// searchUser || searchHash ? newText.substring(1) : newText); -// } -// } -// return true; -// } -// }); -// -// return true; -// } -// -// @Override -// public void onBackPressed() { -// if (closeAnyOpenDrawer()) return; -// -// if (searchView != null && !searchView.isIconified()) { -// if (searchAction != null) searchAction.collapseActionView(); -// searchView.setIconified(true); -// searchView.setIconified(true); -// return; -// } -// -// if (!mainHelper.isSelectionCleared()) return; -// -// final GridLayoutManager layoutManager = (GridLayoutManager) mainBinding.profileView.mainPosts.getLayoutManager(); -// if (layoutManager != null && layoutManager.findFirstCompletelyVisibleItemPosition() >= layoutManager.getSpanCount()) { -// mainBinding.profileView.mainPosts.smoothScrollToPosition(0); -// mainBinding.profileView.appBarLayout.setExpanded(true, true); -// return; -// } -// -// if (queriesStack != null && queriesStack.size() > 0) { -// userQuery = queriesStack.pop(); -// if (userQuery != null) { -// mainHelper.onRefresh(); -// return; -// } -// } else { -// finish(); -// } -// } -// -// @Override -// public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { -// super.onRequestPermissionsResult(requestCode, permissions, grantResults); -// if (requestCode == 8020 && grantResults[0] == PackageManager.PERMISSION_GRANTED) -// downloadSelectedItems(); -// } -// -// @Override -// protected void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) { -// super.onActivityResult(requestCode, resultCode, data); -// if (requestCode == 9629 && (resultCode == 1692 || resultCode == RESULT_CANCELED)) -// finish(); -// else if (requestCode == 6007) -// Utils.showImportExportDialog(this); -// // else if (requestCode == 6969 && mainHelper.currentFeedPlayer != null) -// // mainHelper.currentFeedPlayer.setPlayWhenReady(true); -// } -// -// @Override -// protected void onPause() { -// if (mainHelper != null) mainHelper.onPause(); -// if (handler != null && runnable != null) { -// handler.removeCallbacks(runnable); -// } -// super.onPause(); -// } -// -// @Override -// protected void onResume() { -// if (mainHelper != null) mainHelper.onResume(); -// if (handler != null && runnable != null) { -// handler.postDelayed(runnable, INITIAL_DELAY_MILLIS); -// } -// super.onResume(); -// } -// -// private void setStack(final Bundle bundle) { -// final Object stack = bundle != null ? bundle.get("stack") : null; -// if (stack instanceof Stack) //noinspection unchecked -// queriesStack = (Stack) stack; -// } -// -// public void addToStack() { -// if (userQuery != null) { -// if (queriesStack == null) queriesStack = new Stack<>(); -// queriesStack.add(userQuery); -// } -// } -// -// private boolean closeAnyOpenDrawer() { -// final int childCount = mainBinding.drawerLayout.getChildCount(); -// for (int i = 0; i < childCount; i++) { -// final View child = mainBinding.drawerLayout.getChildAt(i); -// final MouseDrawer.LayoutParams childLp = (MouseDrawer.LayoutParams) child.getLayoutParams(); -// -// if ((childLp.openState & MouseDrawer.LayoutParams.FLAG_IS_OPENED) == 1 || -// (childLp.openState & MouseDrawer.LayoutParams.FLAG_IS_OPENING) == 2 || -// childLp.onScreen >= 0.6 || childLp.isPeeking) { -// mainBinding.drawerLayout.closeDrawer(child); -// return true; -// } -// } -// return false; -// } -// } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/activities/PostViewer.java b/app/src/main/java/awais/instagrabber/activities/PostViewer.java deleted file mode 100755 index 95c14b7f..00000000 --- a/app/src/main/java/awais/instagrabber/activities/PostViewer.java +++ /dev/null @@ -1,786 +0,0 @@ -// package awais.instagrabber.activities; -// -// import android.annotation.SuppressLint; -// import android.content.DialogInterface; -// import android.content.Intent; -// import android.content.pm.PackageManager; -// import android.content.res.ColorStateList; -// import android.content.res.Resources; -// import android.graphics.drawable.Animatable; -// import android.net.Uri; -// import android.os.AsyncTask; -// import android.os.Build; -// import android.os.Bundle; -// import android.os.Handler; -// import android.text.SpannableString; -// import android.text.method.LinkMovementMethod; -// import android.util.Log; -// import android.view.MotionEvent; -// import android.view.View; -// import android.widget.ArrayAdapter; -// import android.widget.LinearLayout; -// import android.widget.RelativeLayout; -// import android.widget.TextView; -// import android.widget.Toast; -// -// import androidx.annotation.NonNull; -// import androidx.annotation.Nullable; -// import androidx.appcompat.app.AlertDialog; -// import androidx.core.app.ActivityCompat; -// import androidx.core.content.ContextCompat; -// import androidx.core.view.GestureDetectorCompat; -// import androidx.recyclerview.widget.LinearLayoutManager; -// import androidx.recyclerview.widget.RecyclerView; -// -// import com.facebook.drawee.backends.pipeline.Fresco; -// import com.facebook.drawee.controller.BaseControllerListener; -// import com.facebook.imagepipeline.image.ImageInfo; -// import com.facebook.imagepipeline.request.ImageRequest; -// import com.facebook.imagepipeline.request.ImageRequestBuilder; -// import com.google.android.exoplayer2.SimpleExoPlayer; -// import com.google.android.exoplayer2.source.MediaSource; -// import com.google.android.exoplayer2.source.MediaSourceEventListener; -// import com.google.android.exoplayer2.source.ProgressiveMediaSource; -// import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; -// -// import java.io.IOException; -// import java.net.HttpURLConnection; -// import java.net.URL; -// import java.util.ArrayList; -// import java.util.Collections; -// import java.util.List; -// -// import awais.instagrabber.R; -// import awais.instagrabber.adapters.PostsMediaAdapter; -// import awais.instagrabber.asyncs.PostFetcher; -// import awais.instagrabber.asyncs.ProfileFetcher; -// import awais.instagrabber.asyncs.i.iPostFetcher; -// import awais.instagrabber.customviews.CommentMentionClickSpan; -// import awais.instagrabber.customviews.helpers.SwipeGestureListener; -// import awais.instagrabber.databinding.ItemFullPostViewBkBinding; -// import awais.instagrabber.interfaces.FetchListener; -// import awais.instagrabber.interfaces.SwipeEvent; -// import awais.instagrabber.models.BasePostModel; -// import awais.instagrabber.models.PostModel; -// import awais.instagrabber.models.ProfileModel; -// import awais.instagrabber.models.ViewerPostModel; -// import awais.instagrabber.models.enums.DownloadMethod; -// import awais.instagrabber.models.enums.MediaItemType; -// import awais.instagrabber.models.enums.PostItemType; -// import awais.instagrabber.utils.Constants; -// import awais.instagrabber.utils.Utils; -// -// import static awais.instagrabber.utils.Utils.settingsHelper; -// -// @Deprecated -// public final class PostViewer extends BaseLanguageActivity { -// private ItemFullPostViewBkBinding viewerBinding; -// private String url, prevUsername; -// private ProfileModel profileModel; -// private BasePostModel postModel; -// private ViewerPostModel viewerPostModel; -// private SimpleExoPlayer player; -// private ArrayAdapter profileDialogAdapter; -// private View viewsContainer, viewerCaptionParent; -// private GestureDetectorCompat gestureDetector; -// private SwipeEvent swipeEvent; -// private CharSequence postCaption = null, postUserId; -// private Resources resources; -// private boolean session = false, isFromShare, liked, saved, ok = false; -// private int slidePos = 0, lastSlidePos = 0; -// private PostItemType postItemType; -// @SuppressLint("ClickableViewAccessibility") -// final View.OnTouchListener gestureTouchListener = new View.OnTouchListener() { -// private float startX; -// private float startY; -// -// @Override -// public boolean onTouch(final View v, final MotionEvent event) { -// if (v == viewerCaptionParent) { -// switch (event.getAction()) { -// case MotionEvent.ACTION_DOWN: -// startX = event.getX(); -// startY = event.getY(); -// break; -// -// case MotionEvent.ACTION_UP: -// if (!(Utils.isEmpty(postCaption) || -// Math.abs(startX - event.getX()) > 50 || Math.abs(startY - event.getY()) > 50)) { -// Utils.copyText(PostViewer.this, postCaption); -// return false; -// } -// } -// } -// return gestureDetector.onTouchEvent(event); -// } -// }; -// private final DialogInterface.OnClickListener profileDialogListener = (dialog, which) -> { -// final String username = viewerPostModel.getProfileModel().getUsername(); -// -// if (which == 0) { -// searchUsername(username); -// } else if (profileModel != null && which == 1) { -// startActivity(new Intent(this, ProfilePicViewer.class) -// .putExtra(Constants.EXTRAS_PROFILE, profileModel)); -// } -// }; -// private final View.OnClickListener onClickListener = new View.OnClickListener() { -// @Override -// public void onClick(final View v) { -// if (v == viewerBinding.topPanel.ivProfilePic) { -// new AlertDialog.Builder(PostViewer.this).setAdapter(profileDialogAdapter, profileDialogListener) -// .setNeutralButton(R.string.cancel, null) -// .setTitle(viewerPostModel.getProfileModel().getUsername()).show(); -// -// } else if (v == viewerBinding.ivToggleFullScreen) { -// toggleFullscreen(); -// -// final LinearLayout topPanelRoot = viewerBinding.topPanel.getRoot(); -// final int iconRes; -// -// if (containerLayoutParams.weight != 3.3f) { -// containerLayoutParams.weight = 3.3f; -// iconRes = R.drawable.ic_fullscreen_exit; -// topPanelRoot.setVisibility(View.GONE); -// viewerBinding.btnDownload.setVisibility(View.VISIBLE); -// viewerBinding.bottomPanel.tvPostDate.setVisibility(View.GONE); -// } else { -// containerLayoutParams.weight = (viewerBinding.mediaList.getVisibility() == View.VISIBLE) ? 1.35f : 1.9f; -// containerLayoutParams.weight += (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) ? 0.3f : 0; -// iconRes = R.drawable.ic_fullscreen; -// topPanelRoot.setVisibility(View.VISIBLE); -// viewerBinding.btnDownload.setVisibility(View.GONE); -// viewerBinding.bottomPanel.tvPostDate.setVisibility(View.VISIBLE); -// } -// -// viewerBinding.ivToggleFullScreen.setImageResource(iconRes); -// viewerBinding.container.setLayoutParams(containerLayoutParams); -// -// } else if (v == viewerBinding.bottomPanel.btnMute) { -// if (player != null) { -// final float intVol = player.getVolume() == 0f ? 1f : 0f; -// player.setVolume(intVol); -// viewerBinding.bottomPanel.btnMute.setImageResource(intVol == 0f ? R.drawable.ic_volume_off_24 : R.drawable.ic_volume_up_24); -// Utils.sessionVolumeFull = intVol == 1f; -// } -// } else if (v == viewerBinding.btnLike) { -// new PostAction().execute("likes"); -// } else if (v == viewerBinding.btnBookmark) { -// new PostAction().execute("save"); -// } else { -// final Object tag = v.getTag(); -// if (tag instanceof ViewerPostModel) { -// viewerPostModel = (ViewerPostModel) tag; -// slidePos = Math.max(0, viewerPostModel.getPosition()); -// refreshPost(); -// } -// } -// } -// }; -// private final View.OnClickListener downloadClickListener = v -> { -// if (ContextCompat.checkSelfPermission(this, Utils.PERMS[0]) == PackageManager.PERMISSION_GRANTED) -// showDownloadDialog(); -// else -// ActivityCompat.requestPermissions(this, Utils.PERMS, 8020); -// }; -// private final PostsMediaAdapter mediaAdapter = new PostsMediaAdapter(null, onClickListener); -// private LinearLayout.LayoutParams containerLayoutParams; -// private final FetchListener pfl = result -> { -// if (result == null || result.length < 1) { -// Toast.makeText(this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); -// return; -// } -// -// viewerPostModel = result[0]; -// -// mediaAdapter.setData(result); -// if (result.length > 1) { -// viewerBinding.mediaList.setLayoutParams(new LinearLayout.LayoutParams( -// LinearLayout.LayoutParams.MATCH_PARENT, 0, 0.55f -// )); -// containerLayoutParams.weight = 1.35f; -// containerLayoutParams.weight += (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) ? 0.3f : 0; -// viewerBinding.container.setLayoutParams(containerLayoutParams); -// viewerBinding.mediaList.setVisibility(View.VISIBLE); -// } -// -// viewerCaptionParent.setOnTouchListener(gestureTouchListener); -// viewerBinding.playerView.setOnTouchListener(gestureTouchListener); -// // viewerBinding.imageViewer.setOnSingleFlingListener((e1, e2, velocityX, velocityY) -> { -// // final float diffX = e2.getX() - e1.getX(); -// // if (Math.abs(diffX) > Math.abs(e2.getY() - e1.getY()) && Math.abs(diffX) > SwipeGestureListener.SWIPE_THRESHOLD -// // && Math.abs(velocityX) > SwipeGestureListener.SWIPE_VELOCITY_THRESHOLD) { -// // swipeEvent.onSwipe(diffX > 0); -// // return true; -// // } -// // return false; -// // }); -// -// final long commentsCount = viewerPostModel.getCommentsCount(); -// viewerBinding.bottomPanel.commentsCount.setText(String.valueOf(commentsCount)); -// viewerBinding.bottomPanel.btnComments.setVisibility(View.VISIBLE); -// -// viewerBinding.bottomPanel.btnComments.setOnClickListener(v -> startActivityForResult( -// new Intent(this, CommentsViewerFragment.class) -// .putExtra(Constants.EXTRAS_SHORTCODE, postModel.getShortCode()) -// .putExtra(Constants.EXTRAS_POST, viewerPostModel.getPostId()) -// .putExtra(Constants.EXTRAS_USER, postUserId), -// 6969)); -// viewerBinding.bottomPanel.btnComments.setClickable(true); -// viewerBinding.bottomPanel.btnComments.setEnabled(true); -// -// if (postModel instanceof PostModel) { -// final PostModel postModel = (PostModel) this.postModel; -// postModel.setPostId(viewerPostModel.getPostId()); -// postModel.setTimestamp(viewerPostModel.getTimestamp()); -// postModel.setPostCaption(viewerPostModel.getPostCaption()); -// if (!ok) { -// liked = viewerPostModel.getLike(); -// saved = viewerPostModel.getBookmark(); -// } -// } -// -// setupPostInfoBar("@" + viewerPostModel.getProfileModel().getUsername(), viewerPostModel.getItemType(), -// viewerPostModel.getLocationName(), viewerPostModel.getLocation()); -// -// postCaption = postModel.getPostCaption(); -// viewerCaptionParent.setVisibility(View.VISIBLE); -// -// viewerBinding.bottomPanel.btnDownload.setOnClickListener(downloadClickListener); -// -// refreshPost(); -// }; -// -// @Override -// protected void onCreate(@Nullable final Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// viewerBinding = ItemFullPostViewBkBinding.inflate(getLayoutInflater()); -// setContentView(viewerBinding.getRoot()); -// -// final Intent intent = getIntent(); -// if (intent == null || !intent.hasExtra(Constants.EXTRAS_POST) -// || (postModel = (PostModel) intent.getSerializableExtra(Constants.EXTRAS_POST)) == null) { -// Utils.errorFinish(this); -// return; -// } -// -// containerLayoutParams = (LinearLayout.LayoutParams) viewerBinding.container.getLayoutParams(); -// -// if (intent.hasExtra(Constants.EXTRAS_TYPE)) -// postItemType = (PostItemType) intent.getSerializableExtra(Constants.EXTRAS_TYPE); -// -// resources = getResources(); -// -// viewerBinding.topPanel.title.setMovementMethod(new LinkMovementMethod()); -// viewerBinding.topPanel.title.setMentionClickListener((view, text, isHashtag, isLocation) -> searchUsername(text)); -// viewerBinding.topPanel.ivProfilePic.setOnClickListener(onClickListener); -// -// viewerBinding.ivToggleFullScreen.setOnClickListener(onClickListener); -// if (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) { -// viewerBinding.btnLike.setVisibility(View.GONE); -// viewerBinding.btnBookmark.setVisibility(View.GONE); -// viewerBinding.postActions.setVisibility(View.GONE); -// viewerBinding.postActions.setLayoutParams(new LinearLayout.LayoutParams( -// LinearLayout.LayoutParams.MATCH_PARENT, 0, 0 -// )); -// containerLayoutParams.weight = (containerLayoutParams.weight == 3.3f) ? 3.3f : 2.2f; -// viewerBinding.container.setLayoutParams(containerLayoutParams); -// } else { -// viewerBinding.btnLike.setOnClickListener(onClickListener); -// viewerBinding.btnBookmark.setOnClickListener(onClickListener); -// } -// viewerBinding.btnDownload.setOnClickListener(downloadClickListener); -// -// profileDialogAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, -// new String[]{resources.getString(R.string.open_profile), resources.getString(R.string.view_pfp)}); -// -// postModel.setPosition(intent.getIntExtra(Constants.EXTRAS_INDEX, -1)); -// -// final boolean postIdNull = postModel.getPostId() == null; -// if (!postIdNull) -// setupPostInfoBar(intent.getStringExtra(Constants.EXTRAS_USER), postModel.getItemType(), null, null); -// -// isFromShare = postModel.getPosition() == -1 || postIdNull; -// -// viewerCaptionParent = (View) viewerBinding.bottomPanel.viewerCaption.getParent(); -// viewsContainer = (View) viewerBinding.bottomPanel.videoViewsContainer; -// -// viewerBinding.mediaList.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)); -// viewerBinding.mediaList.setAdapter(mediaAdapter); -// viewerBinding.mediaList.setVisibility(View.GONE); -// -// swipeEvent = isRight -> { -// final List itemGetterItems; -// final boolean isSwipeable; -// -// // if (postItemType == PostItemType.SAVED && SavedViewerFragment.itemGetter != null) { -// // itemGetterItems = SavedViewerFragment.itemGetter.get(postItemType); -// // isSwipeable = !(itemGetterItems.size() < 1 || postItemType == PostItemType.SAVED && isFromShare); -// // } else -// if (postItemType != null && MainActivityBackup.itemGetter != null) { -// itemGetterItems = MainActivityBackup.itemGetter.get(postItemType); -// isSwipeable = !(itemGetterItems.size() < 1 || postItemType == PostItemType.MAIN && isFromShare); -// } else { -// itemGetterItems = null; -// isSwipeable = false; -// } -// -// final BasePostModel[] basePostModels = mediaAdapter.getPostModels(); -// final int slides = basePostModels.length; -// -// int position = postModel.getPosition(); -// -// if (isRight) { -// --slidePos; -// if (!isSwipeable && slidePos < 0) slidePos = 0; -// if (slides > 0 && slidePos >= 0) { -// if (basePostModels[slidePos] instanceof ViewerPostModel) { -// viewerPostModel = (ViewerPostModel) basePostModels[slidePos]; -// } -// refreshPost(); -// return; -// } -// if (isSwipeable && --position < 0) position = itemGetterItems.size() - 1; -// } else { -// ++slidePos; -// if (!isSwipeable && slidePos >= slides) slidePos = slides - 1; -// if (slides > 0 && slidePos < slides) { -// if (basePostModels[slidePos] instanceof ViewerPostModel) { -// viewerPostModel = (ViewerPostModel) basePostModels[slidePos]; -// } -// refreshPost(); -// return; -// } -// if (isSwipeable && ++position >= itemGetterItems.size()) position = 0; -// } -// -// if (isSwipeable) { -// slidePos = 0; -// ok = false; -// Log.d("AWAISKING_APP", "swipe left <<< post[" + position + "]: " + postModel + " -- " + slides); -// postModel = itemGetterItems.get(position); -// postModel.setPosition(position); -// viewPost(); -// } -// }; -// gestureDetector = new GestureDetectorCompat(this, new SwipeGestureListener(swipeEvent)); -// -// viewPost(); -// } -// -// private void viewPost() { -// lastSlidePos = 0; -// mediaAdapter.setData(null); -// viewsContainer.setVisibility(View.GONE); -// viewerCaptionParent.setVisibility(View.GONE); -// viewerBinding.mediaList.setVisibility(View.GONE); -// viewerBinding.btnDownload.setVisibility(View.GONE); -// viewerBinding.bottomPanel.btnMute.setVisibility(View.GONE); -// viewerBinding.bottomPanel.tvPostDate.setVisibility(View.GONE); -// viewerBinding.bottomPanel.btnComments.setVisibility(View.GONE); -// viewerBinding.bottomPanel.btnDownload.setVisibility(View.INVISIBLE); -// viewerBinding.bottomPanel.viewerCaption.setText(null); -// viewerBinding.bottomPanel.viewerCaption.setMentionClickListener(null); -// -// viewerBinding.playerView.setVisibility(View.GONE); -// viewerBinding.playerView.setPlayer(null); -// viewerBinding.imageViewer.setController(null); -// -// if (postModel.getShortCode() != null) -// new PostFetcher(postModel.getShortCode(), pfl).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// else if (postModel.getPostId() != null) -// new iPostFetcher(postModel.getPostId(), pfl).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// private void searchUsername(final String text) { -// // startActivity( -// // new Intent(getApplicationContext(), ProfileViewer.class) -// // .putExtra(Constants.EXTRAS_USERNAME, text) -// // ); -// } -// -// private void setupVideo() { -// viewerBinding.playerView.setVisibility(View.VISIBLE); -// viewerBinding.bottomPanel.btnDownload.setVisibility(View.VISIBLE); -// viewerBinding.bottomPanel.btnMute.setVisibility(View.VISIBLE); -// viewerBinding.progressView.setVisibility(View.GONE); -// viewerBinding.imageViewer.setVisibility(View.GONE); -// viewerBinding.imageViewer.setController(null); -// -// if (viewerPostModel.getVideoViews() > -1) { -// viewsContainer.setVisibility(View.VISIBLE); -// viewerBinding.bottomPanel.tvVideoViews.setText(String.valueOf(viewerPostModel.getVideoViews())); -// } -// -// player = new SimpleExoPlayer.Builder(this).build(); -// viewerBinding.playerView.setPlayer(player); -// float vol = Utils.settingsHelper.getBoolean(Constants.MUTED_VIDEOS) ? 0f : 1f; -// if (vol == 0f && Utils.sessionVolumeFull) vol = 1f; -// -// player.setVolume(vol); -// player.setPlayWhenReady(Utils.settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS)); -// final ProgressiveMediaSource mediaSource = new ProgressiveMediaSource.Factory(new DefaultDataSourceFactory(this, "instagram")) -// .createMediaSource(Uri.parse(url)); -// mediaSource.addEventListener(new Handler(), new MediaSourceEventListener() { -// @Override -// public void onLoadCompleted(final int windowIndex, -// @Nullable final MediaSource.MediaPeriodId mediaPeriodId, -// final LoadEventInfo loadEventInfo, -// final MediaLoadData mediaLoadData) { -// viewerBinding.progressView.setVisibility(View.GONE); -// } -// -// @Override -// public void onLoadStarted(final int windowIndex, -// @Nullable final MediaSource.MediaPeriodId mediaPeriodId, -// final LoadEventInfo loadEventInfo, -// final MediaLoadData mediaLoadData) { -// viewerBinding.progressView.setVisibility(View.VISIBLE); -// } -// -// @Override -// public void onLoadCanceled(final int windowIndex, -// @Nullable final MediaSource.MediaPeriodId mediaPeriodId, -// final LoadEventInfo loadEventInfo, -// final MediaLoadData mediaLoadData) { -// viewerBinding.progressView.setVisibility(View.GONE); -// } -// -// @Override -// public void onLoadError(final int windowIndex, -// @Nullable final MediaSource.MediaPeriodId mediaPeriodId, -// final LoadEventInfo loadEventInfo, -// final MediaLoadData mediaLoadData, -// final IOException error, -// final boolean wasCanceled) { -// viewerBinding.progressView.setVisibility(View.GONE); -// } -// }); -// player.prepare(mediaSource); -// -// player.setVolume(vol); -// viewerBinding.bottomPanel.btnMute.setImageResource(vol == 0f ? R.drawable.ic_volume_up_24 : R.drawable.ic_volume_off_24); -// -// viewerBinding.bottomPanel.btnMute.setOnClickListener(onClickListener); -// } -// -// private void setupImage() { -// viewsContainer.setVisibility(View.GONE); -// viewerBinding.playerView.setVisibility(View.GONE); -// viewerBinding.progressView.setVisibility(View.VISIBLE); -// viewerBinding.bottomPanel.btnMute.setVisibility(View.GONE); -// viewerBinding.bottomPanel.btnDownload.setVisibility(View.VISIBLE); -// viewerBinding.imageViewer.setVisibility(View.VISIBLE); -// -// final ImageRequest requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)) -// .setLocalThumbnailPreviewsEnabled(true) -// .setProgressiveRenderingEnabled(true) -// .build(); -// viewerBinding.imageViewer.setController( -// Fresco.newDraweeControllerBuilder() -// .setImageRequest(requestBuilder) -// .setOldController(viewerBinding.imageViewer.getController()) -// .setLowResImageRequest(ImageRequest.fromUri(url)) -// .setControllerListener(new BaseControllerListener() { -// -// @Override -// public void onFailure(final String id, final Throwable throwable) { -// viewerBinding.progressView.setVisibility(View.GONE); -// } -// -// @Override -// public void onFinalImageSet(final String id, final ImageInfo imageInfo, final Animatable animatable) { -// viewerBinding.progressView.setVisibility(View.GONE); -// } -// }) -// .build() -// ); -// } -// -// private void showDownloadDialog() { -// final ArrayList postModels = new ArrayList<>(); -// -// if (!session && viewerBinding.mediaList.getVisibility() == View.VISIBLE) { -// final DialogInterface.OnClickListener clickListener = (dialog, which) -> { -// postModels.clear(); -// -// if (which == DialogInterface.BUTTON_NEGATIVE) { -// final BasePostModel[] adapterPostModels = mediaAdapter.getPostModels(); -// for (int i = 0, size = mediaAdapter.getItemCount(); i < size; ++i) { -// if (adapterPostModels[i] instanceof ViewerPostModel) -// postModels.add(adapterPostModels[i]); -// } -// } else if (which == DialogInterface.BUTTON_POSITIVE) { -// postModels.add(viewerPostModel); -// } else { -// session = true; -// postModels.add(viewerPostModel); -// } -// -// if (postModels.size() > 0) -// Utils.batchDownload(this, viewerPostModel.getProfileModel().getUsername(), DownloadMethod.DOWNLOAD_POST_VIEWER, postModels); -// }; -// -// new AlertDialog.Builder(this).setTitle(R.string.post_viewer_download_dialog_title) -// .setMessage(R.string.post_viewer_download_message) -// .setNeutralButton(R.string.post_viewer_download_session, clickListener) -// .setPositiveButton(R.string.post_viewer_download_current, clickListener) -// .setNegativeButton(R.string.post_viewer_download_album, clickListener).show(); -// } else { -// Utils.batchDownload(this, viewerPostModel.getProfileModel().getUsername(), DownloadMethod.DOWNLOAD_POST_VIEWER, -// Collections.singletonList(viewerPostModel)); -// } -// } -// -// @Override -// public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { -// super.onRequestPermissionsResult(requestCode, permissions, grantResults); -// if (requestCode == 8020 && grantResults[0] == PackageManager.PERMISSION_GRANTED) -// showDownloadDialog(); -// } -// -// @Override -// protected void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) { -// super.onActivityResult(requestCode, resultCode, data); -// if (resultCode == 6969) { -// setResult(RESULT_OK); -// finish(); -// } -// } -// -// @Override -// public void onPause() { -// super.onPause(); -// if (Build.VERSION.SDK_INT < 24) releasePlayer(); -// } -// -// @Override -// public void onStop() { -// super.onStop(); -// if (Build.VERSION.SDK_INT >= 24) releasePlayer(); -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// if (player == null && viewerPostModel != null && viewerPostModel.getItemType() == MediaItemType.MEDIA_TYPE_VIDEO) -// setupVideo(); -// else if (player != null) { -// player.setPlayWhenReady(true); -// player.getPlaybackState(); -// } -// } -// -// private void refreshPost() { -// if (containerLayoutParams.weight != 3.3f) { -// containerLayoutParams.weight = (viewerBinding.mediaList.getVisibility() == View.VISIBLE) ? 1.35f : 1.9f; -// viewerBinding.container.setLayoutParams(containerLayoutParams); -// } -// if (viewerBinding.mediaList.getVisibility() == View.VISIBLE) { -// ViewerPostModel item = mediaAdapter.getItemAt(lastSlidePos); -// if (item != null) { -// item.setCurrentSlide(false); -// mediaAdapter.notifyItemChanged(lastSlidePos, item); -// } -// -// item = mediaAdapter.getItemAt(slidePos); -// if (item != null) { -// item.setCurrentSlide(true); -// mediaAdapter.notifyItemChanged(slidePos, item); -// } -// } -// lastSlidePos = slidePos; -// -// postCaption = viewerPostModel.getPostCaption(); -// -// if (Utils.hasMentions(postCaption)) { -// viewerBinding.bottomPanel.viewerCaption.setText(Utils.getMentionText(postCaption), TextView.BufferType.SPANNABLE); -// viewerBinding.bottomPanel.viewerCaption.setMentionClickListener((view, text, isHashtag, isLocation) -> searchUsername(text)); -// } else { -// viewerBinding.bottomPanel.viewerCaption.setMentionClickListener(null); -// viewerBinding.bottomPanel.viewerCaption.setText(postCaption); -// } -// -// setupPostInfoBar("@" + viewerPostModel.getProfileModel().getUsername(), viewerPostModel.getItemType(), -// viewerPostModel.getLocationName(), viewerPostModel.getLocation()); -// -// if (postModel instanceof PostModel) { -// final PostModel postModel = (PostModel) this.postModel; -// postModel.setPostId(viewerPostModel.getPostId()); -// postModel.setTimestamp(viewerPostModel.getTimestamp()); -// postModel.setPostCaption(viewerPostModel.getPostCaption()); -// if (liked == true) { -// viewerBinding.btnLike.setText(resources.getString(R.string.unlike, viewerPostModel.getLikes() -// + ((ok && viewerPostModel.getLike() != liked) ? (liked ? 1L : -1L) : 0L))); -// viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// getApplicationContext(), R.color.btn_pink_background))); -// } else { -// viewerBinding.btnLike.setText(resources.getString(R.string.like, viewerPostModel.getLikes() -// + ((ok && viewerPostModel.getLike() != liked) ? (liked ? 1L : -1L) : 0L))); -// viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// getApplicationContext(), R.color.btn_lightpink_background))); -// } -// if (saved == true) { -// viewerBinding.btnBookmark.setText(R.string.unbookmark); -// viewerBinding.btnBookmark.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// getApplicationContext(), R.color.btn_orange_background))); -// } else { -// viewerBinding.btnBookmark.setText(R.string.bookmark); -// viewerBinding.btnBookmark.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// getApplicationContext(), R.color.btn_lightorange_background))); -// } -// } -// -// viewerBinding.bottomPanel.tvPostDate.setText(viewerPostModel.getPostDate()); -// viewerBinding.bottomPanel.tvPostDate.setVisibility(containerLayoutParams.weight != 3.3f ? View.VISIBLE : View.GONE); -// viewerBinding.bottomPanel.tvPostDate.setSelected(true); -// -// url = viewerPostModel.getDisplayUrl(); -// releasePlayer(); -// -// viewerBinding.btnDownload.setVisibility(containerLayoutParams.weight == 3.3f ? View.VISIBLE : View.GONE); -// if (viewerPostModel.getItemType() == MediaItemType.MEDIA_TYPE_VIDEO) setupVideo(); -// else setupImage(); -// } -// -// private void releasePlayer() { -// if (player != null) { -// player.release(); -// player = null; -// } -// } -// -// private void setupPostInfoBar(final String from, final MediaItemType mediaItemType, final String locationName, final String location) { -// if (prevUsername == null || !prevUsername.equals(from)) { -// // viewerBinding.topPanel.ivProfilePic.setImageBitmap(null); -// // viewerBinding.topPanel.ivProfilePic.setImageDrawable(null); -// // viewerBinding.topPanel.ivProfilePic.setImageResource(0); -// viewerBinding.topPanel.ivProfilePic.setImageRequest(null); -// -// if (!Utils.isEmpty(from) && from.charAt(0) == '@') -// new ProfileFetcher(from.substring(1), result -> { -// profileModel = result; -// -// if (result != null) { -// // final String hdProfilePic = result.getHdProfilePic(); -// // final String sdProfilePic = result.getSdProfilePic(); -// postUserId = result.getId(); -// -// // final boolean hdPicEmpty = Utils.isEmpty(hdProfilePic); -// // glideRequestManager.load(hdPicEmpty ? sdProfilePic : hdProfilePic).listener(new RequestListener() { -// // private boolean loaded = true; -// // -// // @Override -// // public boolean onLoadFailed(@Nullable final GlideException e, final Object model, final Target target, final boolean isFirstResource) { -// // viewerBinding.topPanel.ivProfilePic.setEnabled(false); -// // viewerBinding.topPanel.ivProfilePic.setOnClickListener(null); -// // if (loaded) { -// // loaded = false; -// // if (!Utils.isEmpty(sdProfilePic)) glideRequestManager.load(sdProfilePic).listener(this) -// // .into(viewerBinding.topPanel.ivProfilePic); -// // } -// // return false; -// // } -// // -// // @Override -// // public boolean onResourceReady(final Drawable resource, final Object model, final Target target, final DataSource dataSource, final boolean isFirstResource) { -// // viewerBinding.topPanel.ivProfilePic.setEnabled(true); -// // viewerBinding.topPanel.ivProfilePic.setOnClickListener(onClickListener); -// // return false; -// // } -// // }).into(viewerBinding.topPanel.ivProfilePic); -// viewerBinding.topPanel.ivProfilePic.setImageURI(profileModel.getSdProfilePic()); -// -// final View viewStoryPost = findViewById(R.id.viewStoryPost); -// if (viewStoryPost != null) { -// viewStoryPost.setOnClickListener(v -> { -// if (result.isPrivate()) -// Toast.makeText(getApplicationContext(), R.string.share_private_post, Toast.LENGTH_LONG).show(); -// Intent sharingIntent = new Intent(Intent.ACTION_SEND); -// sharingIntent.setType("text/plain"); -// sharingIntent.putExtra(Intent.EXTRA_TEXT, "https://instagram.com/p/" + postModel.getShortCode()); -// startActivity(Intent.createChooser(sharingIntent, -// (result.isPrivate()) -// ? getString(R.string.share_private_post) -// : getString(R.string.share_public_post))); -// }); -// } -// } -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// prevUsername = from; -// } -// -// final String titlePrefix = resources.getString(mediaItemType == MediaItemType.MEDIA_TYPE_VIDEO ? -// R.string.post_viewer_video_post : R.string.post_viewer_image_post); -// if (Utils.isEmpty(from)) viewerBinding.topPanel.title.setText(titlePrefix); -// else { -// final int titleLen = from.length(); -// final SpannableString spannableString = new SpannableString(from); -// spannableString.setSpan(new CommentMentionClickSpan(), 0, titleLen, 0); -// viewerBinding.topPanel.title.setText(spannableString); -// } -// -// if (location == null) { -// viewerBinding.topPanel.location.setVisibility(View.GONE); -// viewerBinding.topPanel.title.setLayoutParams(new RelativeLayout.LayoutParams( -// RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT -// )); -// } else { -// viewerBinding.topPanel.location.setVisibility(View.VISIBLE); -// viewerBinding.topPanel.location.setText(locationName); -// viewerBinding.topPanel.location.setOnClickListener(v -> searchUsername(location)); -// viewerBinding.topPanel.title.setLayoutParams(new RelativeLayout.LayoutParams( -// RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT -// )); -// } -// } -// -// private void toggleFullscreen() { -// final View decorView = getWindow().getDecorView(); -// int newUiOptions = decorView.getSystemUiVisibility(); -// newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; -// newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN; -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) -// newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; -// decorView.setSystemUiVisibility(newUiOptions); -// } -// -// class PostAction extends AsyncTask { -// String action; -// -// protected Void doInBackground(String... rawAction) { -// action = rawAction[0]; -// final String url = "https://www.instagram.com/web/" + action + "/" + postModel.getPostId() + "/" + (action == "save" ? -// (saved ? "unsave/" : "save/") : -// (liked ? "unlike/" : "like/")); -// try { -// final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); -// urlConnection.setRequestMethod("POST"); -// urlConnection.setUseCaches(false); -// urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT); -// urlConnection.setRequestProperty("x-csrftoken", -// settingsHelper.getString(Constants.COOKIE).split("csrftoken=")[1].split(";")[0]); -// urlConnection.connect(); -// if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { -// ok = true; -// } -// urlConnection.disconnect(); -// } catch (Throwable ex) { -// Log.e("austin_debug", action + ": " + ex); -// } -// return null; -// } -// -// @Override -// protected void onPostExecute(Void result) { -// if (ok == true && action == "likes") { -// liked = !liked; -// refreshPost(); -// } else if (ok == true && action == "save") { -// saved = !saved; -// refreshPost(); -// } else -// Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); -// } -// } -// } diff --git a/app/src/main/java/awais/instagrabber/activities/ProfilePicViewer.java b/app/src/main/java/awais/instagrabber/activities/ProfilePicViewer.java deleted file mode 100755 index 414226b3..00000000 --- a/app/src/main/java/awais/instagrabber/activities/ProfilePicViewer.java +++ /dev/null @@ -1,223 +0,0 @@ -// package awais.instagrabber.activities; -// -// import android.content.Intent; -// import android.graphics.Bitmap; -// import android.graphics.drawable.BitmapDrawable; -// import android.graphics.drawable.Drawable; -// import android.os.AsyncTask; -// import android.os.Bundle; -// import android.os.Environment; -// import android.view.Menu; -// import android.view.MenuItem; -// import android.view.View; -// import android.widget.Toast; -// -// import androidx.annotation.Nullable; -// import androidx.fragment.app.FragmentManager; -// -// import com.bumptech.glide.Glide; -// import com.bumptech.glide.RequestManager; -// import com.bumptech.glide.load.DataSource; -// import com.bumptech.glide.load.engine.GlideException; -// import com.bumptech.glide.request.RequestListener; -// import com.bumptech.glide.request.target.Target; -// -// import java.io.File; -// -// import awais.instagrabber.R; -// import awais.instagrabber.asyncs.DownloadAsync; -// import awais.instagrabber.asyncs.ProfilePictureFetcher; -// import awais.instagrabber.databinding.ActivityProfilepicBinding; -// import awais.instagrabber.interfaces.FetchListener; -// import awais.instagrabber.models.HashtagModel; -// import awais.instagrabber.models.LocationModel; -// import awais.instagrabber.models.ProfileModel; -// import awais.instagrabber.utils.Constants; -// import awais.instagrabber.utils.Utils; -// -// public final class ProfilePicViewer extends BaseLanguageActivity { -// private ActivityProfilepicBinding profileBinding; -// private ProfileModel profileModel; -// private HashtagModel hashtagModel; -// private LocationModel locationModel; -// private MenuItem menuItemDownload; -// private String profilePicUrl; -// private FragmentManager fragmentManager; -// private FetchListener fetchListener; -// private boolean errorHandled = false; -// private boolean fallbackToProfile = false; -// private boolean destroyed = false; -// -// @Override -// protected void onCreate(@Nullable final Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// profileBinding = ActivityProfilepicBinding.inflate(getLayoutInflater()); -// setContentView(profileBinding.getRoot()); -// -// final Intent intent = getIntent(); -// if (intent == null || (!intent.hasExtra(Constants.EXTRAS_PROFILE) && !intent.hasExtra(Constants.EXTRAS_HASHTAG) && !intent -// .hasExtra(Constants.EXTRAS_LOCATION)) -// || ((profileModel = (ProfileModel) intent.getSerializableExtra(Constants.EXTRAS_PROFILE)) == null -// && (hashtagModel = (HashtagModel) intent.getSerializableExtra(Constants.EXTRAS_HASHTAG)) == null -// && (locationModel = (LocationModel) intent.getSerializableExtra(Constants.EXTRAS_LOCATION)) == null)) { -// Utils.errorFinish(this); -// return; -// } -// -// fragmentManager = getSupportFragmentManager(); -// -// final String id = hashtagModel != null ? hashtagModel.getId() : (locationModel != null ? locationModel.getId() : profileModel.getId()); -// final String username = hashtagModel != null -// ? hashtagModel.getName() -// : (locationModel != null ? locationModel.getName() : profileModel.getUsername()); -// -// // profileBinding.toolbar.toolbar.setTitle(username); -// -// profileBinding.progressView.setVisibility(View.VISIBLE); -// profileBinding.imageViewer.setVisibility(View.VISIBLE); -// -// // profileBinding.imageViewer.setZoomable(true); -// // profileBinding.imageViewer.setZoomTransitionDuration(420); -// // profileBinding.imageViewer.setMaximumScale(7.2f); -// -// fetchListener = profileUrl -> { -// profilePicUrl = profileUrl; -// -// if (!fallbackToProfile && Utils.isEmpty(profilePicUrl)) { -// fallbackToProfile = true; -// new ProfilePictureFetcher(username, id, fetchListener, profilePicUrl, (hashtagModel != null || locationModel != null)) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// return; -// } -// -// if (errorHandled && fallbackToProfile || Utils.isEmpty(profilePicUrl)) -// profilePicUrl = hashtagModel != null -// ? hashtagModel.getSdProfilePic() -// : (locationModel != null ? locationModel.getSdProfilePic() : profileModel.getHdProfilePic()); -// -// if (destroyed == true) return; -// -// final RequestManager glideRequestManager = Glide.with(this); -// -// glideRequestManager.load(profilePicUrl).addListener(new RequestListener() { -// @Override -// public boolean onLoadFailed(@Nullable final GlideException e, -// final Object model, -// final Target target, -// final boolean isFirstResource) { -// fallbackToProfile = true; -// if (!errorHandled) { -// errorHandled = true; -// new ProfilePictureFetcher(username, id, fetchListener, profilePicUrl, (hashtagModel != null || locationModel != null)) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// profileBinding.progressView.setVisibility(View.GONE); -// return false; -// } -// -// @Override -// public boolean onResourceReady(final Drawable resource, -// final Object model, -// final Target target, -// final DataSource dataSource, -// final boolean isFirstResource) { -// if (menuItemDownload != null) menuItemDownload.setEnabled(true); -// showImageInfo(); -// profileBinding.progressView.setVisibility(View.GONE); -// return false; -// } -// -// private void showImageInfo() { -// final Drawable drawable = profileBinding.imageViewer.getDrawable(); -// if (drawable != null) { -// final StringBuilder info = new StringBuilder( -// getString(R.string.profile_viewer_imageinfo, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight())); -// if (drawable instanceof BitmapDrawable) { -// final Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); -// if (bitmap != null) { -// final String colorDepthPrefix = getString(R.string.profile_viewer_colordepth_prefix); -// switch (bitmap.getConfig()) { -// case ALPHA_8: -// info.append(colorDepthPrefix).append(" 8-bits(A)"); -// break; -// case RGB_565: -// info.append(colorDepthPrefix).append(" 16-bits-A"); -// break; -// case ARGB_4444: -// info.append(colorDepthPrefix).append(" 16-bits+A"); -// break; -// case ARGB_8888: -// info.append(colorDepthPrefix).append(" 32-bits+A"); -// break; -// case RGBA_F16: -// info.append(colorDepthPrefix).append(" 64-bits+A"); -// break; -// case HARDWARE: -// info.append(colorDepthPrefix).append(" auto"); -// break; -// } -// } -// } -// // profileBinding.imageInfo.setText(info); -// // profileBinding.imageInfo.setVisibility(View.VISIBLE); -// } -// } -// }).error(glideRequestManager.load(profilePicUrl)).into(profileBinding.imageViewer); -// }; -// -// new ProfilePictureFetcher(username, id, fetchListener, profilePicUrl, (hashtagModel != null || locationModel != null)) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// private void downloadProfilePicture() { -// int error = 0; -// -// if (profileModel != null) { -// final File dir = new File(Environment.getExternalStorageDirectory(), "Download"); -// if (dir.exists() || dir.mkdirs()) { -// -// final File saveFile = new File(dir, profileModel.getUsername() + '_' + System.currentTimeMillis() -// + Utils.getExtensionFromModel(profilePicUrl, profileModel)); -// -// new DownloadAsync(this, -// profilePicUrl, -// saveFile, -// result -> { -// final int toastRes = result != null && result.exists() ? -// R.string.downloader_downloaded_in_folder : R.string.downloader_error_download_file; -// Toast.makeText(this, toastRes, Toast.LENGTH_SHORT).show(); -// }).setItems(null, profileModel.getUsername()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } else error = 1; -// } else error = 2; -// -// if (error == 1) Toast.makeText(this, R.string.downloader_error_creating_folder, Toast.LENGTH_SHORT).show(); -// else if (error == 2) Toast.makeText(this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); -// } -// -// @Override -// protected void onDestroy() { -// super.onDestroy(); -// getDelegate().onDestroy(); -// destroyed = true; -// } -// -// @Override -// public boolean onCreateOptionsMenu(final Menu menu) { -// getMenuInflater().inflate(R.menu.menu, menu); -// -// final MenuItem.OnMenuItemClickListener menuItemClickListener = item -> { -// if (item == menuItemDownload) { -// downloadProfilePicture(); -// } -// return true; -// }; -// -// menu.findItem(R.id.action_search).setVisible(false); -// menuItemDownload = menu.findItem(R.id.action_download); -// menuItemDownload.setVisible(true); -// menuItemDownload.setEnabled(false); -// menuItemDownload.setOnMenuItemClickListener(menuItemClickListener); -// -// return true; -// } -// } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/activities/ProfileViewer.java b/app/src/main/java/awais/instagrabber/activities/ProfileViewer.java deleted file mode 100755 index 16744a4d..00000000 --- a/app/src/main/java/awais/instagrabber/activities/ProfileViewer.java +++ /dev/null @@ -1,950 +0,0 @@ -// package awais.instagrabber.activities; -// -// import android.content.DialogInterface; -// import android.content.Intent; -// import android.content.pm.PackageManager; -// import android.content.res.ColorStateList; -// import android.content.res.Resources; -// import android.graphics.Bitmap; -// import android.graphics.BitmapFactory; -// import android.graphics.Typeface; -// import android.net.Uri; -// import android.os.AsyncTask; -// import android.os.Bundle; -// import android.text.SpannableStringBuilder; -// import android.text.method.LinkMovementMethod; -// import android.text.style.RelativeSizeSpan; -// import android.text.style.StyleSpan; -// import android.util.Log; -// import android.view.Menu; -// import android.view.MenuItem; -// import android.view.View; -// import android.widget.ArrayAdapter; -// import android.widget.TextView; -// import android.widget.Toast; -// -// import androidx.annotation.NonNull; -// import androidx.annotation.Nullable; -// import androidx.appcompat.app.AlertDialog; -// import androidx.core.content.ContextCompat; -// import androidx.recyclerview.widget.LinearLayoutManager; -// import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -// -// import java.io.DataOutputStream; -// import java.io.InputStream; -// import java.net.HttpURLConnection; -// import java.net.URL; -// import java.util.ArrayList; -// import java.util.Arrays; -// -// import awais.instagrabber.BuildConfig; -// import awais.instagrabber.R; -// import awais.instagrabber.adapters.HighlightsAdapter; -// import awais.instagrabber.adapters.PostsAdapter; -// import awais.instagrabber.asyncs.HashtagFetcher; -// import awais.instagrabber.asyncs.HighlightsFetcher; -// import awais.instagrabber.asyncs.LocationFetcher; -// import awais.instagrabber.asyncs.PostsFetcher; -// import awais.instagrabber.asyncs.ProfileFetcher; -// import awais.instagrabber.asyncs.i.iStoryStatusFetcher; -// import awais.instagrabber.customviews.RamboTextView; -// import awais.instagrabber.customviews.helpers.GridAutofitLayoutManager; -// import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration; -// import awais.instagrabber.customviews.helpers.RecyclerLazyLoader; -// import awais.instagrabber.databinding.ActivityProfileBinding; -// import awais.instagrabber.fragments.SavedViewerFragment; -// import awais.instagrabber.interfaces.FetchListener; -// import awais.instagrabber.interfaces.MentionClickListener; -// import awais.instagrabber.models.BasePostModel; -// import awais.instagrabber.models.HashtagModel; -// import awais.instagrabber.models.HighlightModel; -// import awais.instagrabber.models.LocationModel; -// import awais.instagrabber.models.PostModel; -// import awais.instagrabber.models.ProfileModel; -// import awais.instagrabber.models.StoryModel; -// import awais.instagrabber.models.enums.DownloadMethod; -// import awais.instagrabber.models.enums.PostItemType; -// import awais.instagrabber.utils.Constants; -// import awais.instagrabber.utils.DataBox; -// import awais.instagrabber.utils.Utils; -// import awaisomereport.LogCollector; -// -// import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS; -// import static awais.instagrabber.utils.Utils.logCollector; -// -// @Deprecated -// public final class ProfileViewer extends BaseLanguageActivity implements SwipeRefreshLayout.OnRefreshListener { -// private final ArrayList allItems = new ArrayList<>(), selectedItems = new ArrayList<>(); -// private static AsyncTask currentlyExecuting; -// private final boolean autoloadPosts = Utils.settingsHelper.getBoolean(AUTOLOAD_POSTS); -// private boolean hasNextPage = false; -// private View collapsingToolbar; -// private String endCursor = null; -// private ProfileModel profileModel; -// private HashtagModel hashtagModel; -// private LocationModel locationModel; -// private StoryModel[] storyModels; -// private MenuItem downloadAction, favouriteAction; -// private final FetchListener postsFetchListener = new FetchListener() { -// @Override -// public void onResult(final PostModel[] result) { -// if (result != null) { -// final int oldSize = allItems.size(); -// allItems.addAll(Arrays.asList(result)); -// -// postsAdapter.notifyItemRangeInserted(oldSize, result.length); -// -// profileBinding.profileView.mainPosts.post(() -> { -// profileBinding.profileView.mainPosts.setNestedScrollingEnabled(true); -// profileBinding.profileView.mainPosts.setVisibility(View.VISIBLE); -// }); -// -// if (isHashtag) -// profileBinding.toolbar.toolbar.setTitle(userQuery); -// else if (isLocation) -// profileBinding.toolbar.toolbar.setTitle(locationModel.getName()); -// else profileBinding.toolbar.toolbar.setTitle("@" + profileModel.getUsername()); -// -// final PostModel model = result[result.length - 1]; -// if (model != null) { -// endCursor = model.getEndCursor(); -// hasNextPage = model.hasNextPage(); -// if (autoloadPosts && hasNextPage) -// currentlyExecuting = new PostsFetcher( -// profileModel != null ? profileModel.getId() -// : (hashtagModel != null ? (hashtagModel.getName()) : locationModel.getId()), -// profileModel != null ? PostItemType.MAIN : (hashtagModel != null ? PostItemType.HASHTAG : PostItemType.LOCATION), -// endCursor, -// this) -// .setUsername((isLocation || isHashtag) ? null : profileModel.getUsername()) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// else { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// } -// model.setPageCursor(false, null); -// } -// } else { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// profileBinding.profileView.privatePage1.setImageResource(R.drawable.ic_cancel); -// profileBinding.profileView.privatePage2.setText(R.string.empty_acc); -// profileBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// } -// } -// }; -// private final MentionClickListener mentionClickListener = new MentionClickListener() { -// @Override -// 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)); -// } -// }; -// public final HighlightsAdapter highlightsAdapter = new HighlightsAdapter(null, new View.OnClickListener() { -// @Override -// public void onClick(final View v) { -// final Object tag = v.getTag(); -// if (tag instanceof HighlightModel) { -// final HighlightModel highlightModel = (HighlightModel) tag; -// new iStoryStatusFetcher(highlightModel.getId(), null, false, false, -// (!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), true, result -> { -// if (result != null && result.length > 0) { -// // startActivity(new Intent(ProfileViewer.this, StoryViewer.class) -// // .putExtra(Constants.EXTRAS_USERNAME, userQuery.replace("@", "")) -// // .putExtra(Constants.EXTRAS_HIGHLIGHT, highlightModel.getTitle()) -// // .putExtra(Constants.EXTRAS_STORIES, result) -// // ); -// } else -// Toast.makeText(ProfileViewer.this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } -// }); -// private Resources resources; -// private RecyclerLazyLoader lazyLoader; -// private boolean isHashtag, isUser, isLocation; -// private PostsAdapter postsAdapter; -// private String cookie = Utils.settingsHelper.getString(Constants.COOKIE), userQuery; -// public boolean isLoggedIn = !Utils.isEmpty(cookie); -// private ActivityProfileBinding profileBinding; -// private ArrayAdapter profileDialogAdapter; -// private DialogInterface.OnClickListener profileDialogListener; -// -// protected void onCreate(@Nullable final Bundle savedInstanceState) { -// stopCurrentExecutor(); -// super.onCreate(savedInstanceState); -// -// final Intent intent = getIntent(); -// if (intent == null || !intent.hasExtra(Constants.EXTRAS_USERNAME) -// || Utils.isEmpty((userQuery = intent.getStringExtra(Constants.EXTRAS_USERNAME)))) { -// Utils.errorFinish(this); -// return; -// } -// -// userQuery = (userQuery.contains("/") || userQuery.startsWith("#") || userQuery.startsWith("@")) ? userQuery : ("@" + userQuery); -// -// profileBinding = ActivityProfileBinding.inflate(getLayoutInflater()); -// setContentView(profileBinding.getRoot()); -// -// resources = getResources(); -// -// profileDialogAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, -// new String[]{resources.getString(R.string.view_pfp), resources.getString(R.string.show_stories)}); -// profileDialogListener = (dialog, which) -> { -// final Intent newintent; -// if (which == 0 || storyModels == null || storyModels.length < 1) { -// newintent = new Intent(this, ProfilePicViewer.class).putExtra( -// ((hashtagModel != null) -// ? Constants.EXTRAS_HASHTAG -// : (locationModel != null ? Constants.EXTRAS_LOCATION : Constants.EXTRAS_PROFILE)), -// ((hashtagModel != null) ? hashtagModel : (locationModel != null ? locationModel : profileModel))); -// } -// // else -// // newintent = new Intent(this, StoryViewer.class).putExtra(Constants.EXTRAS_USERNAME, userQuery.replace("@", "")) -// // .putExtra(Constants.EXTRAS_STORIES, storyModels) -// // .putExtra(Constants.EXTRAS_HASHTAG, (hashtagModel != null)); -// // startActivity(newintent); -// }; -// -// profileBinding.profileView.swipeRefreshLayout.setOnRefreshListener(this); -// profileBinding.profileView.mainUrl.setMovementMethod(new LinkMovementMethod()); -// -// isLoggedIn = !Utils.isEmpty(cookie); -// -// collapsingToolbar = profileBinding.profileView.appBarLayout.getChildAt(0); -// -// profileBinding.profileView.mainPosts.setNestedScrollingEnabled(false); -// profileBinding.profileView.highlightsList.setLayoutManager( -// new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false)); -// profileBinding.profileView.highlightsList.setAdapter(highlightsAdapter); -// -// setSupportActionBar(profileBinding.toolbar.toolbar); -// -// // change the next number to adjust grid -// final GridAutofitLayoutManager layoutManager = new GridAutofitLayoutManager(ProfileViewer.this, Utils.convertDpToPx(110)); -// profileBinding.profileView.mainPosts.setLayoutManager(layoutManager); -// profileBinding.profileView.mainPosts.addItemDecoration(new GridSpacingItemDecoration(Utils.convertDpToPx(4))); -// // profileBinding.profileView.mainPosts.setAdapter(postsAdapter = new PostsAdapter(allItems, v -> { -// // final Object tag = v.getTag(); -// // if (tag instanceof PostModel) { -// // final PostModel postModel = (PostModel) tag; -// // -// // if (postsAdapter.isSelecting) toggleSelection(postModel); -// // else startActivity(new Intent(ProfileViewer.this, PostViewer.class) -// // .putExtra(Constants.EXTRAS_INDEX, postModel.getPosition()) -// // .putExtra(Constants.EXTRAS_POST, postModel) -// // .putExtra(Constants.EXTRAS_USER, userQuery) -// // .putExtra(Constants.EXTRAS_TYPE, ItemGetType.MAIN_ITEMS)); -// // } -// // }, v -> { // long click listener -// // final Object tag = v.getTag(); -// // if (tag instanceof PostModel) { -// // postsAdapter.isSelecting = true; -// // toggleSelection((PostModel) tag); -// // } -// // return true; -// // })); -// -// this.lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> { -// if ((!autoloadPosts || isHashtag) && hasNextPage) { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(true); -// stopCurrentExecutor(); -// currentlyExecuting = new PostsFetcher(profileModel != null ? profileModel.getId() -// : (hashtagModel != null -// ? ("#" + hashtagModel.getName()) -// : locationModel.getId()), -// profileModel != null -// ? PostItemType.MAIN -// : (hashtagModel != null ? PostItemType.HASHTAG : PostItemType.LOCATION), -// endCursor, postsFetchListener) -// .setUsername((isHashtag || isLocation) ? null : profileModel.getUsername()) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// endCursor = null; -// } -// }); -// profileBinding.profileView.mainPosts.addOnScrollListener(lazyLoader); -// -// final View.OnClickListener onClickListener = v -> { -// if (v == profileBinding.profileView.mainBiography) { -// Utils.copyText(this, profileBinding.profileView.mainBiography.getText().toString()); -// } else if (v == profileBinding.profileView.locationBiography) { -// Utils.copyText(this, profileBinding.profileView.locationBiography.getText().toString()); -// } else if (v == profileBinding.profileView.mainProfileImage || v == profileBinding.profileView.mainHashtagImage || v == profileBinding.profileView.mainLocationImage) { -// if (storyModels == null || storyModels.length <= 0) { -// profileDialogListener.onClick(null, 0); -// } else { -// // because sometimes configuration changes made this crash on some phones -// new AlertDialog.Builder(this).setAdapter(profileDialogAdapter, profileDialogListener) -// .setNeutralButton(R.string.cancel, null).show(); -// } -// } -// }; -// -// profileBinding.profileView.mainBiography.setOnClickListener(onClickListener); -// profileBinding.profileView.locationBiography.setOnClickListener(onClickListener); -// profileBinding.profileView.mainProfileImage.setOnClickListener(onClickListener); -// profileBinding.profileView.mainHashtagImage.setOnClickListener(onClickListener); -// profileBinding.profileView.mainLocationImage.setOnClickListener(onClickListener); -// -// this.onRefresh(); -// } -// -// @Override -// public void onRefresh() { -// if (lazyLoader != null) lazyLoader.resetState(); -// stopCurrentExecutor(); -// allItems.clear(); -// selectedItems.clear(); -// if (postsAdapter != null) { -// // postsAdapter.isSelecting = false; -// postsAdapter.notifyDataSetChanged(); -// } -// profileBinding.profileView.appBarLayout.setExpanded(true, true); -// profileBinding.profileView.privatePage.setVisibility(View.GONE); -// profileBinding.profileView.privatePage2.setTextSize(28); -// // profileBinding.profileView.mainProfileImage.setImageBitmap(null); -// // profileBinding.profileView.mainHashtagImage.setImageBitmap(null); -// // profileBinding.profileView.mainLocationImage.setImageBitmap(null); -// profileBinding.profileView.mainUrl.setText(null); -// profileBinding.profileView.locationUrl.setText(null); -// profileBinding.profileView.mainFullName.setText(null); -// profileBinding.profileView.locationFullName.setText(null); -// profileBinding.profileView.mainPostCount.setText(null); -// profileBinding.profileView.mainLocPostCount.setText(null); -// profileBinding.profileView.mainTagPostCount.setText(null); -// profileBinding.profileView.mainFollowers.setText(null); -// profileBinding.profileView.mainFollowing.setText(null); -// profileBinding.profileView.mainBiography.setText(null); -// profileBinding.profileView.locationBiography.setText(null); -// profileBinding.profileView.mainBiography.setEnabled(false); -// profileBinding.profileView.locationBiography.setEnabled(false); -// profileBinding.profileView.mainProfileImage.setEnabled(false); -// profileBinding.profileView.mainLocationImage.setEnabled(false); -// profileBinding.profileView.mainHashtagImage.setEnabled(false); -// profileBinding.profileView.mainBiography.setMentionClickListener(null); -// profileBinding.profileView.locationBiography.setMentionClickListener(null); -// profileBinding.profileView.mainUrl.setVisibility(View.GONE); -// profileBinding.profileView.locationUrl.setVisibility(View.GONE); -// profileBinding.profileView.isVerified.setVisibility(View.GONE); -// profileBinding.profileView.btnFollow.setVisibility(View.GONE); -// profileBinding.profileView.btnRestrict.setVisibility(View.GONE); -// profileBinding.profileView.btnBlock.setVisibility(View.GONE); -// profileBinding.profileView.btnSaved.setVisibility(View.GONE); -// profileBinding.profileView.btnLiked.setVisibility(View.GONE); -// profileBinding.profileView.btnTagged.setVisibility(View.GONE); -// profileBinding.profileView.btnMap.setVisibility(View.GONE); -// -// profileBinding.profileView.btnFollow.setOnClickListener(profileActionListener); -// profileBinding.profileView.btnRestrict.setOnClickListener(profileActionListener); -// profileBinding.profileView.btnBlock.setOnClickListener(profileActionListener); -// profileBinding.profileView.btnSaved.setOnClickListener(profileActionListener); -// profileBinding.profileView.btnLiked.setOnClickListener(profileActionListener); -// profileBinding.profileView.btnTagged.setOnClickListener(profileActionListener); -// profileBinding.profileView.btnFollowTag.setOnClickListener(profileActionListener); -// -// profileBinding.profileView.infoContainer.setVisibility(View.GONE); -// profileBinding.profileView.tagInfoContainer.setVisibility(View.GONE); -// profileBinding.profileView.locInfoContainer.setVisibility(View.GONE); -// -// profileBinding.profileView.mainPosts.setNestedScrollingEnabled(false); -// profileBinding.profileView.highlightsList.setVisibility(View.GONE); -// collapsingToolbar.setVisibility(View.GONE); -// highlightsAdapter.setData(null); -// -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(userQuery != null); -// if (userQuery == null) { -// profileBinding.toolbar.toolbar.setTitle(R.string.app_name); -// return; -// } -// -// isHashtag = userQuery.charAt(0) == '#'; -// isUser = userQuery.charAt(0) == '@'; -// isLocation = userQuery.contains("/"); -// collapsingToolbar.setVisibility(isUser ? View.VISIBLE : View.GONE); -// -// if (isHashtag) { -// profileModel = null; -// locationModel = null; -// profileBinding.toolbar.toolbar.setTitle(userQuery); -// profileBinding.profileView.tagInfoContainer.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnFollowTag.setVisibility(View.GONE); -// -// currentlyExecuting = new HashtagFetcher(userQuery.substring(1), result -> { -// hashtagModel = result; -// -// if (hashtagModel == null) { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// Toast.makeText(ProfileViewer.this, R.string.error_loading_profile, Toast.LENGTH_SHORT).show(); -// profileBinding.toolbar.toolbar.setTitle(R.string.app_name); -// return; -// } -// -// currentlyExecuting = new PostsFetcher(userQuery, PostItemType.HASHTAG, null, postsFetchListener) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// -// profileBinding.profileView.btnFollowTag.setVisibility(View.VISIBLE); -// -// if (isLoggedIn) { -// new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, false, false, stories -> { -// storyModels = stories; -// if (stories != null && stories.length > 0) -// profileBinding.profileView.mainHashtagImage.setStoriesBorder(); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// -// if (hashtagModel.getFollowing()) { -// profileBinding.profileView.btnFollowTag.setText(R.string.unfollow); -// profileBinding.profileView.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_purple_background))); -// } else { -// profileBinding.profileView.btnFollowTag.setText(R.string.follow); -// profileBinding.profileView.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_pink_background))); -// } -// } else { -// if (Utils.dataBox.getFavorite(userQuery) != null) { -// profileBinding.profileView.btnFollowTag.setText(R.string.unfavorite_short); -// profileBinding.profileView.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_purple_background))); -// } else { -// profileBinding.profileView.btnFollowTag.setText(R.string.favorite_short); -// profileBinding.profileView.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_pink_background))); -// } -// } -// -// // profileBinding.profileView.mainHashtagImage.setEnabled(false); -// profileBinding.profileView.mainHashtagImage.setImageURI(hashtagModel.getSdProfilePic()); -// profileBinding.profileView.mainHashtagImage.setEnabled(true); -// -// final String postCount = String.valueOf(hashtagModel.getPostCount()); -// -// SpannableStringBuilder span = new SpannableStringBuilder(resources.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); -// profileBinding.profileView.mainTagPostCount.setText(span); -// profileBinding.profileView.mainTagPostCount.setVisibility(View.VISIBLE); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } else if (isUser) { -// hashtagModel = null; -// locationModel = null; -// profileBinding.toolbar.toolbar.setTitle(userQuery); -// profileBinding.profileView.infoContainer.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnFollowTag.setVisibility(View.GONE); -// -// currentlyExecuting = new ProfileFetcher(userQuery.substring(1), result -> { -// profileModel = result; -// -// if (profileModel == null) { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// Toast.makeText(ProfileViewer.this, R.string.error_loading_profile, Toast.LENGTH_SHORT).show(); -// profileBinding.toolbar.toolbar.setTitle(R.string.app_name); -// return; -// } -// -// profileBinding.profileView.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE); -// final String profileId = profileModel.getId(); -// -// if (isLoggedIn || Utils.settingsHelper.getBoolean(Constants.STORIESIG)) { -// new iStoryStatusFetcher(profileId, profileModel.getUsername(), false, false, -// (!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), false, -// stories -> { -// storyModels = stories; -// if (stories != null && stories.length > 0) -// profileBinding.profileView.mainProfileImage.setStoriesBorder(); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// -// new HighlightsFetcher(profileId, (!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), hls -> { -// if (hls != null && hls.length > 0) { -// profileBinding.profileView.highlightsList.setVisibility(View.VISIBLE); -// highlightsAdapter.setData(hls); -// } else profileBinding.profileView.highlightsList.setVisibility(View.GONE); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// if (isLoggedIn) { -// final String myId = Utils.getUserIdFromCookie(cookie); -// if (!profileId.equals(myId)) { -// profileBinding.profileView.btnTagged.setVisibility(View.GONE); -// profileBinding.profileView.btnSaved.setVisibility(View.GONE); -// profileBinding.profileView.btnLiked.setVisibility(View.GONE); -// profileBinding.profileView.btnFollow.setVisibility(View.VISIBLE); -// if (profileModel.getFollowing() == true) { -// profileBinding.profileView.btnFollow.setText(R.string.unfollow); -// profileBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_purple_background))); -// } else if (profileModel.getRequested() == true) { -// profileBinding.profileView.btnFollow.setText(R.string.cancel); -// profileBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_purple_background))); -// } else { -// profileBinding.profileView.btnFollow.setText(R.string.follow); -// profileBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_pink_background))); -// } -// profileBinding.profileView.btnRestrict.setVisibility(View.VISIBLE); -// if (profileModel.getRestricted() == true) { -// profileBinding.profileView.btnRestrict.setText(R.string.unrestrict); -// profileBinding.profileView.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_green_background))); -// } else { -// profileBinding.profileView.btnRestrict.setText(R.string.restrict); -// profileBinding.profileView.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_orange_background))); -// } -// if (profileModel.isReallyPrivate()) { -// profileBinding.profileView.btnBlock.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnTagged.setVisibility(View.GONE); -// if (profileModel.getBlocked() == true) { -// profileBinding.profileView.btnBlock.setText(R.string.unblock); -// profileBinding.profileView.btnBlock.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_green_background))); -// } else { -// profileBinding.profileView.btnBlock.setText(R.string.block); -// profileBinding.profileView.btnBlock.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_red_background))); -// } -// } else { -// profileBinding.profileView.btnBlock.setVisibility(View.GONE); -// profileBinding.profileView.btnSaved.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnTagged.setVisibility(View.VISIBLE); -// if (profileModel.getBlocked() == true) { -// profileBinding.profileView.btnSaved.setText(R.string.unblock); -// profileBinding.profileView.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_green_background))); -// } else { -// profileBinding.profileView.btnSaved.setText(R.string.block); -// profileBinding.profileView.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_red_background))); -// } -// } -// } else { -// profileBinding.profileView.btnTagged.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnSaved.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnLiked.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnSaved.setText(R.string.saved); -// profileBinding.profileView.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_orange_background))); -// } -// } else { -// if (Utils.dataBox.getFavorite(userQuery) != null) { -// profileBinding.profileView.btnFollow.setText(R.string.unfavorite_short); -// profileBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_purple_background))); -// } else { -// profileBinding.profileView.btnFollow.setText(R.string.favorite_short); -// profileBinding.profileView.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_pink_background))); -// } -// profileBinding.profileView.btnFollow.setVisibility(View.VISIBLE); -// if (!profileModel.isReallyPrivate()) { -// profileBinding.profileView.btnRestrict.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnRestrict.setText(R.string.tagged); -// profileBinding.profileView.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( -// ProfileViewer.this, R.color.btn_blue_background))); -// } -// } -// -// // profileBinding.profileView.mainProfileImage.setEnabled(false); -// profileBinding.profileView.mainProfileImage.setImageURI(profileModel.getSdProfilePic(), null); -// // profileBinding.profileView.mainProfileImage.setEnabled(true); -// -// final long followersCount = profileModel.getFollowersCount(); -// final long followingCount = profileModel.getFollowingCount(); -// -// final String postCount = String.valueOf(profileModel.getPostCount()); -// -// SpannableStringBuilder span = new SpannableStringBuilder(resources.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); -// profileBinding.profileView.mainPostCount.setText(span); -// -// final String followersCountStr = String.valueOf(followersCount); -// final int followersCountStrLen = followersCountStr.length(); -// span = new SpannableStringBuilder(resources.getString(R.string.main_posts_followers, followersCountStr)); -// span.setSpan(new RelativeSizeSpan(1.2f), 0, followersCountStrLen, 0); -// span.setSpan(new StyleSpan(Typeface.BOLD), 0, followersCountStrLen, 0); -// profileBinding.profileView.mainFollowers.setText(span); -// -// final String followingCountStr = String.valueOf(followingCount); -// final int followingCountStrLen = followingCountStr.length(); -// span = new SpannableStringBuilder(resources.getString(R.string.main_posts_following, followingCountStr)); -// span.setSpan(new RelativeSizeSpan(1.2f), 0, followingCountStrLen, 0); -// span.setSpan(new StyleSpan(Typeface.BOLD), 0, followingCountStrLen, 0); -// profileBinding.profileView.mainFollowing.setText(span); -// -// profileBinding.profileView.mainFullName -// .setText(Utils.isEmpty(profileModel.getName()) ? profileModel.getUsername() : profileModel.getName()); -// -// CharSequence biography = profileModel.getBiography(); -// profileBinding.profileView.mainBiography.setCaptionIsExpandable(true); -// profileBinding.profileView.mainBiography.setCaptionIsExpanded(true); -// if (Utils.hasMentions(biography)) { -// biography = Utils.getMentionText(biography); -// profileBinding.profileView.mainBiography.setText(biography, TextView.BufferType.SPANNABLE); -// profileBinding.profileView.mainBiography.setMentionClickListener(mentionClickListener); -// } else { -// profileBinding.profileView.mainBiography.setText(biography); -// profileBinding.profileView.mainBiography.setMentionClickListener(null); -// } -// -// final String url = profileModel.getUrl(); -// if (Utils.isEmpty(url)) { -// profileBinding.profileView.mainUrl.setVisibility(View.GONE); -// } else { -// profileBinding.profileView.mainUrl.setVisibility(View.VISIBLE); -// profileBinding.profileView.mainUrl.setText(Utils.getSpannableUrl(url)); -// } -// -// profileBinding.profileView.mainFullName.setSelected(true); -// profileBinding.profileView.mainBiography.setEnabled(true); -// -// if (!profileModel.isReallyPrivate()) { -// profileBinding.profileView.mainFollowing.setClickable(true); -// profileBinding.profileView.mainFollowers.setClickable(true); -// -// if (isLoggedIn) { -// // final View.OnClickListener followClickListener = v -> startActivity( -// // new Intent(ProfileViewer.this, FollowViewerFragment.class) -// // .putExtra(Constants.EXTRAS_FOLLOWERS, v == profileBinding.profileView.mainFollowers) -// // .putExtra(Constants.EXTRAS_NAME, profileModel.getUsername()) -// // .putExtra(Constants.EXTRAS_ID, profileId)); -// // -// // profileBinding.profileView.mainFollowers.setOnClickListener(followersCount > 0 ? followClickListener : null); -// // profileBinding.profileView.mainFollowing.setOnClickListener(followingCount > 0 ? followClickListener : null); -// } -// -// if (profileModel.getPostCount() == 0) { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// profileBinding.profileView.privatePage1.setImageResource(R.drawable.ic_cancel); -// profileBinding.profileView.privatePage2.setText(R.string.empty_acc); -// profileBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// } else { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(true); -// profileBinding.profileView.mainPosts.setVisibility(View.VISIBLE); -// currentlyExecuting = new PostsFetcher(profileId, PostItemType.MAIN, null, postsFetchListener) -// .setUsername(profileModel.getUsername()) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } else { -// profileBinding.profileView.mainFollowers.setClickable(false); -// profileBinding.profileView.mainFollowing.setClickable(false); -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// // error -// profileBinding.profileView.privatePage1.setImageResource(R.drawable.lock); -// profileBinding.profileView.privatePage2.setText(R.string.priv_acc); -// profileBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// profileBinding.profileView.mainPosts.setVisibility(View.GONE); -// } -// } -// ).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } else if (isLocation) { -// profileModel = null; -// hashtagModel = null; -// profileBinding.toolbar.toolbar.setTitle(userQuery); -// profileBinding.profileView.locInfoContainer.setVisibility(View.VISIBLE); -// -// currentlyExecuting = new LocationFetcher(userQuery.split("/")[0], result -> { -// locationModel = result; -// -// if (locationModel == null) { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// Toast.makeText(ProfileViewer.this, R.string.error_loading_profile, Toast.LENGTH_SHORT).show(); -// profileBinding.toolbar.toolbar.setTitle(R.string.app_name); -// return; -// } -// profileBinding.toolbar.toolbar.setTitle(locationModel.getName()); -// -// final String profileId = locationModel.getId(); -// -// if (isLoggedIn) { -// new iStoryStatusFetcher(profileId.split("/")[0], null, true, false, false, false, stories -> { -// storyModels = stories; -// if (stories != null && stories.length > 0) -// profileBinding.profileView.mainLocationImage.setStoriesBorder(); -// }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// -// // profileBinding.profileView.mainLocationImage.setEnabled(false); -// profileBinding.profileView.mainLocationImage.setImageURI(locationModel.getSdProfilePic()); -// profileBinding.profileView.mainLocationImage.setEnabled(true); -// -// final String postCount = String.valueOf(locationModel.getPostCount()); -// -// SpannableStringBuilder span = new SpannableStringBuilder(resources.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); -// profileBinding.profileView.mainLocPostCount.setText(span); -// -// profileBinding.profileView.locationFullName.setText(locationModel.getName()); -// -// CharSequence biography = locationModel.getBio(); -// profileBinding.profileView.locationBiography.setCaptionIsExpandable(true); -// profileBinding.profileView.locationBiography.setCaptionIsExpanded(true); -// -// if (Utils.isEmpty(biography)) { -// profileBinding.profileView.locationBiography.setVisibility(View.GONE); -// } else if (Utils.hasMentions(biography)) { -// profileBinding.profileView.locationBiography.setVisibility(View.VISIBLE); -// biography = Utils.getMentionText(biography); -// profileBinding.profileView.locationBiography.setText(biography, TextView.BufferType.SPANNABLE); -// profileBinding.profileView.locationBiography.setMentionClickListener(mentionClickListener); -// } else { -// profileBinding.profileView.locationBiography.setVisibility(View.VISIBLE); -// profileBinding.profileView.locationBiography.setText(biography); -// profileBinding.profileView.locationBiography.setMentionClickListener(null); -// } -// -// if (!locationModel.getGeo().startsWith("geo:0.0,0.0?z=17")) { -// profileBinding.profileView.btnMap.setVisibility(View.VISIBLE); -// profileBinding.profileView.btnMap.setOnClickListener(v -> { -// final Intent intent = new Intent(Intent.ACTION_VIEW); -// intent.setData(Uri.parse(locationModel.getGeo())); -// startActivity(intent); -// }); -// } else { -// profileBinding.profileView.btnMap.setVisibility(View.GONE); -// profileBinding.profileView.btnMap.setOnClickListener(null); -// } -// -// final String url = locationModel.getUrl(); -// if (Utils.isEmpty(url)) { -// profileBinding.profileView.locationUrl.setVisibility(View.GONE); -// } else if (!url.startsWith("http")) { -// profileBinding.profileView.locationUrl.setVisibility(View.VISIBLE); -// profileBinding.profileView.locationUrl.setText(Utils.getSpannableUrl("http://" + url)); -// } else { -// profileBinding.profileView.locationUrl.setVisibility(View.VISIBLE); -// profileBinding.profileView.locationUrl.setText(Utils.getSpannableUrl(url)); -// } -// -// profileBinding.profileView.locationFullName.setSelected(true); -// profileBinding.profileView.locationBiography.setEnabled(true); -// -// if (locationModel.getPostCount() == 0) { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(false); -// profileBinding.profileView.privatePage1.setImageResource(R.drawable.ic_cancel); -// profileBinding.profileView.privatePage2.setText(R.string.empty_acc); -// profileBinding.profileView.privatePage.setVisibility(View.VISIBLE); -// } else { -// profileBinding.profileView.swipeRefreshLayout.setRefreshing(true); -// profileBinding.profileView.mainPosts.setVisibility(View.VISIBLE); -// currentlyExecuting = new PostsFetcher(profileId, PostItemType.LOCATION, null, postsFetchListener) -// .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } -// ).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); -// } -// } -// -// public static void stopCurrentExecutor() { -// if (currentlyExecuting != null) { -// try { -// currentlyExecuting.cancel(true); -// } catch (final Exception e) { -// if (logCollector != null) -// logCollector.appendException(e, LogCollector.LogFile.MAIN_HELPER, "stopCurrentExecutor"); -// if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); -// } -// } -// } -// -// @Override -// public boolean onCreateOptionsMenu(final Menu menu) { -// getMenuInflater().inflate(R.menu.saved, menu); -// -// downloadAction = menu.findItem(R.id.downloadAction); -// downloadAction.setVisible(false); -// -// favouriteAction = menu.findItem(R.id.favouriteAction); -// favouriteAction.setVisible(!Utils.isEmpty(cookie)); -// favouriteAction.setIcon(Utils.dataBox.getFavorite(userQuery) == null ? R.drawable.ic_not_liked : R.drawable.ic_like); -// -// downloadAction.setOnMenuItemClickListener(item -> { -// if (selectedItems.size() > 0) { -// Utils.batchDownload(this, userQuery, DownloadMethod.DOWNLOAD_MAIN, selectedItems); -// } -// return true; -// }); -// -// favouriteAction.setOnMenuItemClickListener(item -> { -// if (Utils.dataBox.getFavorite(userQuery) == null) { -// Utils.dataBox.addFavorite(new DataBox.FavoriteModel(userQuery, System.currentTimeMillis(), -// locationModel != null -// ? locationModel.getName() -// : userQuery.replaceAll("^@", ""))); -// favouriteAction.setIcon(R.drawable.ic_like); -// } else { -// Utils.dataBox.delFavorite(new DataBox.FavoriteModel(userQuery, -// Long.parseLong(Utils.dataBox.getFavorite(userQuery).split("/")[1]), -// locationModel != null -// ? locationModel.getName() -// : userQuery.replaceAll("^@", ""))); -// favouriteAction.setIcon(R.drawable.ic_not_liked); -// } -// return true; -// }); -// -// return true; -// } -// -// private void toggleSelection(final PostModel postModel) { -// if (postModel != null && postsAdapter != null) { -// if (postModel.isSelected()) selectedItems.remove(postModel); -// else if (selectedItems.size() >= 100) { -// Toast.makeText(ProfileViewer.this, R.string.downloader_too_many, Toast.LENGTH_SHORT); -// return; -// } else selectedItems.add(postModel); -// postModel.setSelected(!postModel.isSelected()); -// notifyAdapter(postModel); -// } -// } -// -// private void notifyAdapter(final PostModel postModel) { -// // if (selectedItems.size() < 1) postsAdapter.isSelecting = false; -// // if (postModel.getPosition() < 0) postsAdapter.notifyDataSetChanged(); -// // else postsAdapter.notifyItemChanged(postModel.getPosition(), postModel); -// // -// // if (downloadAction != null) downloadAction.setVisible(postsAdapter.isSelecting); -// } -// -// @Override -// public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { -// super.onRequestPermissionsResult(requestCode, permissions, grantResults); -// if (requestCode == 8020 && grantResults[0] == PackageManager.PERMISSION_GRANTED && selectedItems.size() > 0) -// Utils.batchDownload(this, userQuery, DownloadMethod.DOWNLOAD_MAIN, selectedItems); -// } -// -// public void deselectSelection(final BasePostModel postModel) { -// if (postModel instanceof PostModel) { -// selectedItems.remove(postModel); -// postModel.setSelected(false); -// if (postsAdapter != null) notifyAdapter((PostModel) postModel); -// } -// } -// -// class MyTask extends AsyncTask { -// private Bitmap mIcon_val; -// -// protected Void doInBackground(Void... voids) { -// try { -// String url; -// if (hashtagModel != null) { -// url = hashtagModel.getSdProfilePic(); -// } else if (locationModel != null) { -// url = locationModel.getSdProfilePic(); -// } else { -// url = profileModel.getSdProfilePic(); -// } -// mIcon_val = BitmapFactory.decodeStream((InputStream) new URL(url).getContent()); -// } catch (Throwable ex) { -// Log.e("austin_debug", "bitmap: " + ex); -// } -// return null; -// } -// -// @Override -// protected void onPostExecute(Void result) { -// if (hashtagModel != null) -// profileBinding.profileView.mainHashtagImage.setImageBitmap(mIcon_val); -// else if (locationModel != null) -// profileBinding.profileView.mainLocationImage.setImageBitmap(mIcon_val); -// else profileBinding.profileView.mainProfileImage.setImageBitmap(mIcon_val); -// } -// } -// -// private final View.OnClickListener profileActionListener = new View.OnClickListener() { -// @Override -// public void onClick(final View v) { -// final boolean iamme = (isLoggedIn && profileModel != null) && Utils.getUserIdFromCookie(cookie).equals(profileModel.getId()); -// if (!isLoggedIn && Utils.dataBox.getFavorite(userQuery) != null && v == profileBinding.profileView.btnFollow) { -// Utils.dataBox.delFavorite(new DataBox.FavoriteModel(userQuery, -// Long.parseLong(Utils.dataBox.getFavorite(userQuery).split("/")[1]), -// locationModel != null -// ? locationModel.getName() -// : userQuery.replaceAll("^@", ""))); -// onRefresh(); -// } else if (!isLoggedIn && (v == profileBinding.profileView.btnFollow || v == profileBinding.profileView.btnFollowTag)) { -// Utils.dataBox.addFavorite(new DataBox.FavoriteModel(userQuery, System.currentTimeMillis(), -// locationModel != null -// ? locationModel.getName() -// : userQuery.replaceAll("^@", ""))); -// onRefresh(); -// } else if (v == profileBinding.profileView.btnFollow) { -// new ProfileAction().execute("follow"); -// } else if (v == profileBinding.profileView.btnRestrict && isLoggedIn) { -// new ProfileAction().execute("restrict"); -// } else if (v == profileBinding.profileView.btnSaved && !iamme) { -// new ProfileAction().execute("block"); -// } else if (v == profileBinding.profileView.btnFollowTag) { -// new ProfileAction().execute("followtag"); -// } else if (v == profileBinding.profileView.btnTagged || (v == profileBinding.profileView.btnRestrict && !isLoggedIn)) { -// startActivity(new Intent(ProfileViewer.this, SavedViewerFragment.class) -// .putExtra(Constants.EXTRAS_INDEX, "%" + profileModel.getId()) -// .putExtra(Constants.EXTRAS_USER, "@" + profileModel.getUsername()) -// ); -// } else if (v == profileBinding.profileView.btnSaved) { -// startActivity(new Intent(ProfileViewer.this, SavedViewerFragment.class) -// .putExtra(Constants.EXTRAS_INDEX, "$" + profileModel.getId()) -// .putExtra(Constants.EXTRAS_USER, "@" + profileModel.getUsername()) -// ); -// } else if (v == profileBinding.profileView.btnLiked) { -// startActivity(new Intent(ProfileViewer.this, SavedViewerFragment.class) -// .putExtra(Constants.EXTRAS_INDEX, "^" + profileModel.getId()) -// .putExtra(Constants.EXTRAS_USER, "@" + profileModel.getUsername()) -// ); -// } -// } -// }; -// -// class ProfileAction extends AsyncTask { -// boolean ok = false; -// String action; -// -// protected Void doInBackground(String... rawAction) { -// action = rawAction[0]; -// final String url = "https://www.instagram.com/web/" + -// ((action.equals("followtag") && hashtagModel != null) ? ("tags/" + -// (hashtagModel.getFollowing() ? "unfollow/" : "follow/") + hashtagModel.getName() + "/") : ( -// ((action.equals("restrict") && profileModel != null) -// ? "restrict_action" -// : ("friendships/" + profileModel.getId())) + "/" + -// ((action.equals("follow") && profileModel != null) ? -// ((profileModel.getFollowing() || -// (!profileModel.getFollowing() && profileModel.getRequested())) -// ? "unfollow/" : "follow/") : -// ((action.equals("restrict") && profileModel != null) ? -// (profileModel.getRestricted() ? "unrestrict/" : "restrict/") : -// (profileModel.getBlocked() ? "unblock/" : "block/"))))); -// try { -// final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); -// urlConnection.setRequestMethod("POST"); -// urlConnection.setUseCaches(false); -// urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT); -// urlConnection.setRequestProperty("x-csrftoken", cookie.split("csrftoken=")[1].split(";")[0]); -// if (action == "restrict") { -// final String urlParameters = "target_user_id=" + profileModel.getId(); -// urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); -// urlConnection.setRequestProperty("Content-Length", "" + -// urlParameters.getBytes().length); -// urlConnection.setDoOutput(true); -// DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream()); -// wr.writeBytes(urlParameters); -// wr.flush(); -// wr.close(); -// } else urlConnection.connect(); -// if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { -// ok = true; -// } else -// Toast.makeText(ProfileViewer.this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); -// urlConnection.disconnect(); -// } catch (Throwable ex) { -// Log.e("austin_debug", action + ": " + ex); -// } -// return null; -// } -// -// @Override -// protected void onPostExecute(Void result) { -// if (ok) { -// onRefresh(); -// } -// } -// } -// } \ No newline at end of file