X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fadapters%2FWebViewPagerAdapter.java;h=52e7234536a22a244cc232b9788112d79c9f7d29;hb=HEAD;hp=d7ea9cf072984bc83b71e041d63d3f762b5ea98c;hpb=9d5e4c56326502b6b74e8f3e463275f5c1e176cc;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/adapters/WebViewPagerAdapter.java b/app/src/main/java/com/stoutner/privacybrowser/adapters/WebViewPagerAdapter.java deleted file mode 100644 index d7ea9cf0..00000000 --- a/app/src/main/java/com/stoutner/privacybrowser/adapters/WebViewPagerAdapter.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright © 2019 Soren Stoutner . - * - * This file is part of Privacy Browser . - * - * Privacy Browser is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Privacy Browser is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser. If not, see . - */ - -package com.stoutner.privacybrowser.adapters; - -import com.stoutner.privacybrowser.fragments.WebViewTabFragment; - -import java.util.LinkedList; - -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentPagerAdapter; - -public class WebViewPagerAdapter extends FragmentPagerAdapter { - // The WebView fragments list contains all the WebViews. - private LinkedList webViewFragmentsList = new LinkedList<>(); - - // Define the constructor. - public WebViewPagerAdapter(FragmentManager fragmentManager){ - // Run the default commands. - super(fragmentManager); - } - - @Override - public int getCount() { - // Return the number of pages. - return webViewFragmentsList.size(); - } - - @Override - public int getItemPosition(@NonNull Object object) { - //noinspection SuspiciousMethodCalls - if (webViewFragmentsList.contains(object)) { - // Return the current page position. - //noinspection SuspiciousMethodCalls - return webViewFragmentsList.indexOf(object); - } else { - // The tab has been deleted. - return POSITION_NONE; - } - } - - @Override - public Fragment getItem(int pageNumber) { - // Get the fragment for a particular page. Page numbers are 0 indexed. - return webViewFragmentsList.get(pageNumber); - } - - @Override - public long getItemId(int position) { - // Return the unique ID for this page. - return webViewFragmentsList.get(position).fragmentId; - } - - public int getPositionForId(long fragmentId) { - // Initialize the position variable. - int position = -1; - - // Initialize the while counter. - int i = 0; - - // Find the current position of the WebView fragment with the given ID. - while (position < 0 && i < webViewFragmentsList.size()) { - // Check to see if the tab ID of this WebView matches the page ID. - if (webViewFragmentsList.get(i).fragmentId == fragmentId) { - // Store the position if they are a match. - position = i; - } - - // Increment the counter. - i++; - } - - // Return the position. - return position; - } - - public void addPage(int pageNumber) { - // Add a new page. - webViewFragmentsList.add(WebViewTabFragment.createPage(pageNumber)); - - // Update the view pager. - notifyDataSetChanged(); - } - - public void deletePage(int pageNumber) { - // Delete the page. - webViewFragmentsList.remove(pageNumber); - - // Update the view pager. - notifyDataSetChanged(); - } - - public WebViewTabFragment getPageFragment(int pageNumber) { - return webViewFragmentsList.get(pageNumber); - } -} \ No newline at end of file