From de51ba1acacc123b98629331abdc2bed05c41444 Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Mon, 21 May 2018 11:08:24 +0200 Subject: [PATCH] remove legacy code after refactoring to a helper class --- .../ui/fragment/ShareFileFragment.java | 35 ++++--------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java b/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java index c094a2d642..cc04ace26a 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java @@ -4,17 +4,19 @@ * @author masensio * @author David A. Velasco * @author Juan Carlos González Cabrero + * @author Andy Scherzinger * Copyright (C) 2015 ownCloud Inc. - *

+ * Copyright (C) 2018 Andy Scherzinger + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - *

+ * * This program 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 this program. If not, see . */ @@ -40,7 +42,6 @@ import android.widget.Button; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ListAdapter; import android.widget.ListView; import android.widget.ScrollView; import android.widget.TextView; @@ -57,6 +58,7 @@ import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.adapter.ShareUserListAdapter; import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment; import com.owncloud.android.ui.dialog.SharePasswordDialogFragment; +import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.MimeTypeUtil; import com.owncloud.android.utils.ThemeUtils; @@ -651,7 +653,7 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter. noShares.setVisibility(View.GONE); usersList.setVisibility(View.VISIBLE); usersList.setAdapter(mUserGroupsAdapter); - setListViewHeightBasedOnChildren(usersList); + FileDetailSharingFragmentHelper.setListViewHeightBasedOnChildren(usersList); } else { noShares.setVisibility(View.VISIBLE); usersList.setVisibility(View.GONE); @@ -908,29 +910,6 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter. getHideFileListingPermissionSection().setVisibility(View.GONE); } - public static void setListViewHeightBasedOnChildren(ListView listView) { - ListAdapter listAdapter = listView.getAdapter(); - if (listAdapter == null) { - return; - } - int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.AT_MOST); - int totalHeight = 0; - View view = null; - for (int i = 0; i < listAdapter.getCount(); i++) { - view = listAdapter.getView(i, view, listView); - if (i == 0) { - view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT)); - } - view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED); - totalHeight += view.getMeasuredHeight(); - } - ViewGroup.LayoutParams params = listView.getLayoutParams(); - params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); - listView.setLayoutParams(params); - listView.requestLayout(); - } - - /** * Starts a dialog that requests a password to the user to protect a share link. *