Some fixes
This commit is contained in:
parent
e0907f1dc8
commit
e15252a0f8
|
@ -21,12 +21,8 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
|
@ -42,9 +38,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import app.fedilab.fedilabtube.client.entities.SepiaSearch;
|
||||
import app.fedilab.fedilabtube.databinding.ActivitySepiaSearchBinding;
|
||||
import app.fedilab.fedilabtube.fragment.DisplaySepiaSearchFragment;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
import mabbas007.tagsedittext.TagsEditText;
|
||||
|
||||
import static app.fedilab.fedilabtube.PeertubeActivity.hideKeyboard;
|
||||
import static app.fedilab.fedilabtube.helper.Helper.peertubeInformation;
|
||||
|
@ -54,15 +50,17 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
|
||||
|
||||
private SepiaSearch sepiaSearchVideo, sepiaSearchChannel;
|
||||
private TagsEditText sepia_element_all_of_tags, sepia_element_one_of_tags;
|
||||
private MaterialSearchBar searchBar;
|
||||
private ConstraintLayout filter_elements;
|
||||
|
||||
private ActivitySepiaSearchBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_sepia_search);
|
||||
binding = ActivitySepiaSearchBinding.inflate(getLayoutInflater());
|
||||
View rootView = binding.getRoot();
|
||||
setContentView(rootView);
|
||||
|
||||
|
||||
sepiaSearchVideo = new SepiaSearch();
|
||||
sepiaSearchChannel = new SepiaSearch();
|
||||
|
@ -76,21 +74,18 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
|
||||
Button filter = findViewById(R.id.filter);
|
||||
filter_elements = findViewById(R.id.filter_elements);
|
||||
filter.setOnClickListener(view -> {
|
||||
if (filter_elements.getVisibility() == View.VISIBLE) {
|
||||
filter_elements.setVisibility(View.GONE);
|
||||
binding.filter.setOnClickListener(view -> {
|
||||
if (binding.filterElements.getVisibility() == View.VISIBLE) {
|
||||
binding.filterElements.setVisibility(View.GONE);
|
||||
} else {
|
||||
filter_elements.setVisibility(View.VISIBLE);
|
||||
binding.filterElements.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
RadioGroup sepia_element_nsfw = findViewById(R.id.sepia_element_nsfw);
|
||||
sepia_element_nsfw.setOnCheckedChangeListener((group, checkedId) -> sepiaSearchVideo.setNsfw(checkedId != R.id.sepia_element_nsfw_no));
|
||||
|
||||
RadioGroup radio_date = findViewById(R.id.radio_date);
|
||||
radio_date.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
binding.sepiaElementNsfw.setOnCheckedChangeListener((group, checkedId) -> sepiaSearchVideo.setNsfw(checkedId != R.id.sepia_element_nsfw_no));
|
||||
|
||||
binding.radioDate.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
if (checkedId == R.id.sepia_element_published_date_today) {
|
||||
Calendar cal = GregorianCalendar.getInstance();
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
|
@ -122,8 +117,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
|
||||
RadioGroup duration = findViewById(R.id.duration);
|
||||
duration.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
binding.duration.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
if (checkedId == R.id.sepia_element_duration_short) {
|
||||
sepiaSearchVideo.setDurationMin(0);
|
||||
sepiaSearchVideo.setDurationMax(240);
|
||||
|
@ -140,11 +134,10 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
|
||||
Spinner sort_by = findViewById(R.id.sort_by);
|
||||
ArrayAdapter<String> adapterSortBy = new ArrayAdapter<>(SepiaSearchActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, getResources().getStringArray(R.array.sort_by_array));
|
||||
sort_by.setAdapter(adapterSortBy);
|
||||
sort_by.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.sortBy.setAdapter(adapterSortBy);
|
||||
binding.sortBy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
String orderby, channelOrderBy;
|
||||
|
@ -171,12 +164,6 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
Spinner sepia_element_category = findViewById(R.id.sepia_element_category);
|
||||
Spinner sepia_element_license = findViewById(R.id.sepia_element_license);
|
||||
Spinner sepia_element_language = findViewById(R.id.sepia_element_language);
|
||||
|
||||
sepia_element_all_of_tags = findViewById(R.id.sepia_element_all_of_tags);
|
||||
sepia_element_one_of_tags = findViewById(R.id.sepia_element_one_of_tags);
|
||||
|
||||
LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
|
||||
LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
|
||||
|
@ -203,7 +190,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
}
|
||||
ArrayAdapter<String> adapterCatgories = new ArrayAdapter<>(SepiaSearchActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, categoriesA);
|
||||
sepia_element_category.setAdapter(adapterCatgories);
|
||||
binding.sepiaElementCategory.setAdapter(adapterCatgories);
|
||||
|
||||
|
||||
//Populate licenses
|
||||
|
@ -222,7 +209,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
}
|
||||
ArrayAdapter<String> adapterLicenses = new ArrayAdapter<>(SepiaSearchActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, licensesA);
|
||||
sepia_element_license.setAdapter(adapterLicenses);
|
||||
binding.sepiaElementLicense.setAdapter(adapterLicenses);
|
||||
|
||||
//Populate languages
|
||||
String[] languagesA = new String[languages.size() + 1];
|
||||
|
@ -240,10 +227,10 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
}
|
||||
ArrayAdapter<String> adapterLanguages = new ArrayAdapter<>(SepiaSearchActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, languagesA);
|
||||
sepia_element_language.setAdapter(adapterLanguages);
|
||||
binding.sepiaElementLanguage.setAdapter(adapterLanguages);
|
||||
|
||||
|
||||
sepia_element_license.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.sepiaElementLicense.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
updateLicensePosition(position);
|
||||
|
@ -255,7 +242,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
//Manage categories
|
||||
sepia_element_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.sepiaElementCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
updateCategoryPosition(position);
|
||||
|
@ -268,7 +255,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
//Manage languages
|
||||
sepia_element_language.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.sepiaElementLanguage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
updateLanguagesPosition(position);
|
||||
|
@ -281,9 +268,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
|
||||
searchBar = findViewById(R.id.searchBar);
|
||||
|
||||
searchBar.setOnSearchActionListener(new MaterialSearchBar.OnSearchActionListener() {
|
||||
binding.searchBar.setOnSearchActionListener(new MaterialSearchBar.OnSearchActionListener() {
|
||||
@Override
|
||||
public void onSearchStateChanged(boolean enabled) {
|
||||
|
||||
|
@ -299,22 +284,21 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
makeSearch();
|
||||
}
|
||||
});
|
||||
Button apply_filter = findViewById(R.id.apply_filter);
|
||||
apply_filter.setOnClickListener(v -> makeSearch());
|
||||
binding.applyFilter.setOnClickListener(v -> makeSearch());
|
||||
|
||||
searchBar.openSearch();
|
||||
binding.searchBar.openSearch();
|
||||
}
|
||||
|
||||
private void makeSearch() {
|
||||
hideKeyboard(SepiaSearchActivity.this);
|
||||
sepiaSearchVideo.setStart("0");
|
||||
if (sepia_element_one_of_tags.getTags().size() > 0) {
|
||||
sepiaSearchVideo.setTagsOneOf(sepia_element_one_of_tags.getTags());
|
||||
if (binding.sepiaElementOneOfTags.getTags().size() > 0) {
|
||||
sepiaSearchVideo.setTagsOneOf(binding.sepiaElementOneOfTags.getTags());
|
||||
} else {
|
||||
sepiaSearchVideo.setTagsOneOf(null);
|
||||
}
|
||||
if (sepia_element_all_of_tags.getTags().size() > 0) {
|
||||
sepiaSearchVideo.setTagsAllOf(sepia_element_all_of_tags.getTags());
|
||||
if (binding.sepiaElementAllOfTags.getTags().size() > 0) {
|
||||
sepiaSearchVideo.setTagsAllOf(binding.sepiaElementAllOfTags.getTags());
|
||||
} else {
|
||||
sepiaSearchVideo.setTagsAllOf(null);
|
||||
}
|
||||
|
@ -322,8 +306,8 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||
Fragment fragment = getSupportFragmentManager().findFragmentByTag("SEPIA_SEARCH");
|
||||
if (fragment != null)
|
||||
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
|
||||
filter_elements.setVisibility(View.GONE);
|
||||
sepiaSearchVideo.setSearch(searchBar.getText());
|
||||
binding.filterElements.setVisibility(View.GONE);
|
||||
sepiaSearchVideo.setSearch(binding.searchBar.getText());
|
||||
DisplaySepiaSearchFragment displaySepiaSearchFragment = new DisplaySepiaSearchFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("sepiaSearchVideo", sepiaSearchVideo);
|
||||
|
|
Loading…
Reference in New Issue