Commit 496e49a8 authored by Adrien Béraud's avatar Adrien Béraud

plugin: cleanup

Change-Id: Ic995b504e71fb95ec0ccd96e1d0837e8620c5c51
parent 93e887fc
......@@ -327,8 +327,7 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements
((JamiApplication) requireActivity().getApplication()).getInjectionComponent().inject(this);
binding = DataBindingUtil.inflate(inflater, R.layout.frag_call, container, false);
binding.setPresenter(this);
rp = new RecyclerPicker(requireActivity(),
binding.recyclerPicker,
rp = new RecyclerPicker(binding.recyclerPicker,
R.layout.item_picker,
LinearLayout.HORIZONTAL, this);
rp.setFirstLastElementsWidths(112, 112);
......@@ -1274,13 +1273,7 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements
}
private void stopShareScreen() {
if(choosePluginMode)
{
binding.previewSurface.setVisibility(View.VISIBLE);
}
else {
binding.previewSurface.setVisibility(View.VISIBLE);
}
binding.previewSurface.setVisibility(View.VISIBLE);
presenter.stopScreenShare();
}
......@@ -1357,7 +1350,6 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements
// Reset the padding of the RecyclerPicker on each
rp.setFirstLastElementsWidths(112, 112);
binding.recyclerPicker.setVisibility(View.GONE);
Log.i("ZZZ", "Height: " + binding.recyclerPicker.getHeight());
if (choosePluginMode) {
displayHangupButton(false);
binding.recyclerPicker.setVisibility(View.VISIBLE);
......
package cx.ring.plugins.RecyclerPicker;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
......@@ -11,7 +10,6 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
public class RecyclerPicker implements RecyclerPickerAdapter.ItemClickListener{
private Context mContext;
private RecyclerView mRecyclerView;
private int mItemLayoutResource;
private RecyclerPickerAdapter mAdapter;
......@@ -21,14 +19,13 @@ public class RecyclerPicker implements RecyclerPickerAdapter.ItemClickListener{
private int paddingLeft;
private int paddingRight;
public RecyclerPicker(Context context, RecyclerView recyclerView,
public RecyclerPicker(RecyclerView recyclerView,
@LayoutRes int recyclerItemLayout, int orientation,
RecyclerPickerLayoutManager.ItemSelectedListener listener) {
this.mContext = context;
this.mRecyclerView = recyclerView;
this.mItemLayoutResource = recyclerItemLayout;
this.mOrientation = orientation;
this.mItemSelectedListener = listener;
mRecyclerView = recyclerView;
mItemLayoutResource = recyclerItemLayout;
mOrientation = orientation;
mItemSelectedListener = listener;
init();
}
......@@ -37,12 +34,12 @@ public class RecyclerPicker implements RecyclerPickerAdapter.ItemClickListener{
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);
// use a linear layout manager
mLayoutManager = new RecyclerPickerLayoutManager(mContext, mOrientation,false,
mLayoutManager = new RecyclerPickerLayoutManager(mRecyclerView.getContext(), mOrientation,false,
mItemSelectedListener);
mRecyclerView.setLayoutManager(mLayoutManager);
// specify an adapter (see also next example)
mAdapter = new RecyclerPickerAdapter(mItemLayoutResource, this);
mAdapter = new RecyclerPickerAdapter(mRecyclerView.getContext(), mItemLayoutResource, this);
mRecyclerView.setAdapter(mAdapter);
setRecyclerViewPadding();
}
......@@ -55,26 +52,23 @@ public class RecyclerPicker implements RecyclerPickerAdapter.ItemClickListener{
public void onItemClicked(View view) {
int position = mRecyclerView.getChildLayoutPosition(view);
int currentPos = mLayoutManager.findFirstVisibleItemPosition();
if(position != currentPos) {
if (position != currentPos) {
mRecyclerView.smoothScrollToPosition(position);
mItemSelectedListener.onItemSelected(position);
} else {
mItemSelectedListener.onItemClicked(position);
}
}
public void setFirstLastElementsWidths(int first, int last){
paddingLeft = RecyclerPickerUtils.getScreenWidth(mContext)/2 - RecyclerPickerUtils.
dpToPx(mContext, first/2);
paddingRight = RecyclerPickerUtils.getScreenWidth(mContext)/2 - RecyclerPickerUtils.
dpToPx(mContext, last/2);
paddingLeft = RecyclerPickerUtils.getScreenWidth(mRecyclerView.getContext())/2 - RecyclerPickerUtils.dpToPx(mRecyclerView.getContext(), first/2);
paddingRight = RecyclerPickerUtils.getScreenWidth(mRecyclerView.getContext())/2 - RecyclerPickerUtils.dpToPx(mRecyclerView.getContext(), last/2);
updateRecyclerViewPadding();
}
private void setRecyclerViewPadding() {
paddingLeft = RecyclerPickerUtils.getScreenWidth(mContext)/2;
paddingRight = RecyclerPickerUtils.getScreenWidth(mContext)/2;
paddingLeft = RecyclerPickerUtils.getScreenWidth(mRecyclerView.getContext())/2;
paddingRight = RecyclerPickerUtils.getScreenWidth(mRecyclerView.getContext())/2;
updateRecyclerViewPadding();
}
......
package cx.ring.plugins.RecyclerPicker;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
......@@ -18,23 +19,19 @@ public class RecyclerPickerAdapter extends RecyclerView.Adapter<RecyclerPickerAd
private List<Drawable> mList;
private ItemClickListener mItemClickListener;
private int mItemLayoutResource;
private final LayoutInflater mInflater;
public RecyclerPickerAdapter(@LayoutRes int recyclerItemLayout, ItemClickListener itemClickListener) {
public RecyclerPickerAdapter(Context ctx, @LayoutRes int recyclerItemLayout, ItemClickListener itemClickListener) {
this.mItemLayoutResource = recyclerItemLayout;
this.mItemClickListener = itemClickListener;
mInflater = LayoutInflater.from(ctx);
}
@NonNull
@Override
public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(mItemLayoutResource, parent, false);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mItemClickListener.onItemClicked(v);
}
});
View view = mInflater.inflate(mItemLayoutResource, parent, false);
view.setOnClickListener(v -> mItemClickListener.onItemClicked(v));
return new ItemViewHolder(view);
}
......
......@@ -370,20 +370,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
app:useCompatPadding="true" />
</RelativeLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:clipToPadding="false"
tools:listitem="@layout/item_picker"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginBottom="16dp"
android:layout_gravity="bottom"
android:clipToPadding="false"
tools:listitem="@layout/item_picker"
android:orientation="horizontal"
app:layoutManager="LinearLayoutManager"/>
</FrameLayout>
</layout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment