dropdown revised
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package de.joel.zoomhelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AutoSuggestAdapter extends ArrayAdapter<String> implements Filterable {
|
||||
private List<String> mlistData;
|
||||
|
||||
public AutoSuggestAdapter(@NonNull Context context, int resource) {
|
||||
super(context, resource);
|
||||
mlistData = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setData(List<String> list) {
|
||||
mlistData.clear();
|
||||
mlistData.addAll(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mlistData.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getItem(int position) {
|
||||
return mlistData.get(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to Return the full object directly from adapter.
|
||||
*
|
||||
* @param position
|
||||
* @return
|
||||
*/
|
||||
public String getObject(int position) {
|
||||
return mlistData.get(position);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
Filter dataFilter = new Filter() {
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
FilterResults filterResults = new FilterResults();
|
||||
if (constraint != null) {
|
||||
filterResults.values = mlistData;
|
||||
filterResults.count = mlistData.size();
|
||||
}
|
||||
return filterResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
if (results != null && (results.count > 0)) {
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
notifyDataSetInvalidated();
|
||||
}
|
||||
}
|
||||
};
|
||||
return dataFilter;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -44,7 +45,7 @@ class InstantAutoComplete extends com.google.android.material.textfield.Material
|
||||
}
|
||||
@Override
|
||||
public boolean enoughToFilter() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -146,9 +147,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
builder.setNegativeButton(R.string.no, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
builder.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss());
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
@@ -205,24 +204,22 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
AutoCompleteTextView textMeetingName = findViewById(R.id.TextMeetingName);
|
||||
ImageView dropdown = findViewById(R.id.iconDropdownMeetingName);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, meetingNames);
|
||||
//ImageView dropdown = findViewById(R.id.iconDropdownMeetingName);
|
||||
AutoSuggestAdapter adapter = new AutoSuggestAdapter(this, android.R.layout.simple_dropdown_item_1line);
|
||||
adapter.setData(Arrays.asList(meetingNames));
|
||||
textMeetingName.setAdapter(adapter);
|
||||
|
||||
textMeetingName.setOnTouchListener((View.OnTouchListener) (paramView, paramMotionEvent) -> {
|
||||
adapter.getFilter().filter(null);
|
||||
textMeetingName.showDropDown();
|
||||
return false;
|
||||
});
|
||||
textMeetingName.setOnTouchListener((View.OnTouchListener) (paramView, paramMotionEvent) -> false);
|
||||
|
||||
textMeetingName.setOnItemClickListener((arg0, view, arg2, arg3) -> fillWithSelectedMeeting());
|
||||
|
||||
dropdown.setOnClickListener(v -> {
|
||||
/*dropdown.setOnClickListener(v -> {
|
||||
textMeetingName.showDropDown();
|
||||
adapter.getFilter().filter(null);
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
public void fillDropdownAttendeeName(int meetingIndex) {
|
||||
Meeting meeting = getMeetings().get(meetingIndex);
|
||||
ArrayList<Attendee> attendees = meeting.attendees;
|
||||
@@ -233,16 +230,19 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
AutoCompleteTextView textName = findViewById(R.id.textBoxName);
|
||||
ImageView dropdown = findViewById(R.id.iconDropdownAttName);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, attNames);
|
||||
//ImageView dropdown = findViewById(R.id.iconDropdownAttName);
|
||||
AutoSuggestAdapter adapter = new AutoSuggestAdapter(this, android.R.layout.simple_dropdown_item_1line);
|
||||
adapter.setData(Arrays.asList(attNames));
|
||||
textName.setAdapter(adapter);
|
||||
|
||||
textName.setOnTouchListener((View.OnTouchListener) (paramView, paramMotionEvent) -> false);
|
||||
|
||||
textName.setOnItemClickListener((arg0, view, arg2, arg3) -> fillWithSelectedAtt());
|
||||
|
||||
dropdown.setOnClickListener(v -> {
|
||||
/*dropdown.setOnClickListener(v -> {
|
||||
textName.showDropDown();
|
||||
adapter.getFilter().filter(null);
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
private void fillWithSelectedAtt() {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="vertical"
|
||||
@@ -20,6 +20,7 @@
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_weight="1"
|
||||
android:fillViewport="true">
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
app:boxBackgroundColor="@android:color/transparent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/layoutName"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintWidth_percent="0.9">
|
||||
app:layout_constraintWidth_percent="0.9"
|
||||
app:endIconMode="dropdown_menu">
|
||||
|
||||
<de.joel.zoomhelper.InstantAutoComplete
|
||||
android:id="@+id/TextMeetingName"
|
||||
@@ -31,7 +32,7 @@
|
||||
android:nextFocusForward="@+id/textBoxName" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<ImageView
|
||||
<!--<ImageView
|
||||
android:id="@+id/iconDropdownMeetingName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -43,7 +44,7 @@
|
||||
android:src="@mipmap/baseline_arrow_drop_down_black_24"
|
||||
app:layout_constraintStart_toEndOf="@+id/layoutMeetingName"
|
||||
app:layout_constraintTop_toTopOf="@+id/layoutMeetingName"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/layoutMeetingName"/>
|
||||
app:layout_constraintBottom_toBottomOf="@+id/layoutMeetingName"/>-->
|
||||
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
@@ -105,7 +106,8 @@
|
||||
app:boxBackgroundColor="@android:color/transparent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/layoutAtt"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintWidth_percent="0.9">
|
||||
app:layout_constraintWidth_percent="0.9"
|
||||
app:endIconMode="dropdown_menu">
|
||||
|
||||
<de.joel.zoomhelper.InstantAutoComplete
|
||||
android:id="@+id/textBoxName"
|
||||
@@ -116,13 +118,10 @@
|
||||
android:focusableInTouchMode="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:inputType="text"
|
||||
android:nextFocusForward="@+id/editAtt"
|
||||
app:layout_constraintBottom_toTopOf="@+id/editAtt"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintWidth_percent="0.9" />
|
||||
android:nextFocusForward="@+id/editAtt" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<ImageView
|
||||
<!--<ImageView
|
||||
android:id="@+id/iconDropdownAttName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -134,7 +133,7 @@
|
||||
android:src="@mipmap/baseline_arrow_drop_down_black_24"
|
||||
app:layout_constraintStart_toEndOf="@+id/layoutName"
|
||||
app:layout_constraintTop_toTopOf="@+id/layoutName"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/layoutName"/>
|
||||
app:layout_constraintBottom_toBottomOf="@+id/layoutName"/>-->
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/layoutAtt"
|
||||
|
||||
Reference in New Issue
Block a user