// Path: example/src/main/java/im/getsocial/demo/dialog/SortOrderDelegate.java
// public interface SortOrderDelegate {
//     void onSortKeySelected(Pair<String, String> pair);
// }
// 
// Path: example/src/main/java/im/getsocial/demo/dialog/SortOrderDialog.java
// public final class SortOrderDialog extends DialogFragment {
// 
// 	@BindView(R.id.sort_by)
// 	LinearLayout _status;
// 
// 	private final List<Pair<String, String>> _sortKeys;
// 	private final SortOrderDelegate _delegate;
// 
// 	private Dialog _dialog;
// 
// 	public SortOrderDialog(List<Pair<String, String>> sortKeys, SortOrderDelegate delegate) {
// 		this._sortKeys = sortKeys;
// 		this._delegate = delegate;
// 	}
// 
// 	public static void show(FragmentManager manager, List<Pair<String, String>> sortKeys, SortOrderDelegate delegate) {
// 		new SortOrderDialog(sortKeys, delegate).show(manager, "dialog_sort_order");
// 	}
// 
// 	@NonNull
// 	@Override
// 	public Dialog onCreateDialog(Bundle savedInstanceState) {
// 		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
// 				.setTitle("Sort By")
// 				.setNegativeButton("Cancel",
// 						new DialogInterface.OnClickListener() {
// 							public void onClick(DialogInterface dialog, int whichButton) {
// 								dialog.dismiss();
// 							}
// 						}
// 				);
// 
// 		View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_sort_order, null);
// 		builder.setView(view);
// 
// 		setUpView(view);
// 
// 		_dialog = builder.create();
// 		return _dialog;
// 	}
// 
// 	private void drawSortKeys() {
// 		for (final Pair<String, String> pair : _sortKeys) {
// 			Button button = new Button(getContext());
// 			button.setText(pair.second + pair.first);
// 			button.setOnClickListener((view) -> {
// 				this._delegate.onSortKeySelected(pair);
// 				_dialog.dismiss();
// 			});
// 			_status.addView(button);
// 		}
// 	}
// 
// 	private void setUpView(View view) {
// 		ButterKnife.bind(this, view);
// 
// 		drawSortKeys();
// 	}
// }


import android.os.Bundle;
import android.util.Pair;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import im.getsocial.demo.dialog.SortOrderDelegate;
import im.getsocial.demo.dialog.SortOrderDialog;
import im.getsocial.sdk.communities.GroupsQuery;

	@Override
	public String getTitle() {
		return "Groups";
	}

	@Override
	public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		super.showAdvancedSearch();
	}

	@Override
	public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
		menu.add(Menu.NONE, 0x42, Menu.NONE, _isTrending ? "All" : "Trending");
		super.onCreateOptionsMenu(menu, inflater);
	}

	@Override
	public boolean onOptionsItemSelected(final android.view.MenuItem item) {
		if (item.getItemId() == 0x42) {
			_isTrending = !_isTrending;
			_sortDirection = null;
			_sortKey = null;
			loadItems();
			getActivity().invalidateOptionsMenu();
			return true;
		}
		if (item.getItemId() == 0x43) {
			showSortDialog();
// Path: example/src/main/java/im/getsocial/demo/dialog/SortOrderDelegate.java
// public interface SortOrderDelegate {
//     void onSortKeySelected(Pair<String, String> pair);
// }
// 
// Path: example/src/main/java/im/getsocial/demo/dialog/SortOrderDialog.java
// public final class SortOrderDialog extends DialogFragment {
// 
// 	@BindView(R.id.sort_by)
// 	LinearLayout _status;
// 
// 	private final List<Pair<String, String>> _sortKeys;
// 	private final SortOrderDelegate _delegate;
// 
// 	private Dialog _dialog;
// 
// 	public SortOrderDialog(List<Pair<String, String>> sortKeys, SortOrderDelegate delegate) {
// 		this._sortKeys = sortKeys;
// 		this._delegate = delegate;
// 	}
// 
// 	public static void show(FragmentManager manager, List<Pair<String, String>> sortKeys, SortOrderDelegate delegate) {
// 		new SortOrderDialog(sortKeys, delegate).show(manager, "dialog_sort_order");
// 	}
// 
// 	@NonNull
// 	@Override
// 	public Dialog onCreateDialog(Bundle savedInstanceState) {
// 		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
// 				.setTitle("Sort By")
// 				.setNegativeButton("Cancel",
// 						new DialogInterface.OnClickListener() {
// 							public void onClick(DialogInterface dialog, int whichButton) {
// 								dialog.dismiss();
// 							}
// 						}
// 				);
// 
// 		View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_sort_order, null);
// 		builder.setView(view);
// 
// 		setUpView(view);
// 
// 		_dialog = builder.create();
// 		return _dialog;
// 	}
// 
// 	private void drawSortKeys() {
// 		for (final Pair<String, String> pair : _sortKeys) {
// 			Button button = new Button(getContext());
// 			button.setText(pair.second + pair.first);
// 			button.setOnClickListener((view) -> {
// 				this._delegate.onSortKeySelected(pair);
// 				_dialog.dismiss();
// 			});
// 			_status.addView(button);
// 		}
// 	}
// 
// 	private void setUpView(View view) {
// 		ButterKnife.bind(this, view);
// 
// 		drawSortKeys();
// 	}
// }


// Path: example/src/main/java/im/getsocial/demo/fragment/GroupsSearchFragment.java
import android.os.Bundle;
import android.util.Pair;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import im.getsocial.demo.dialog.SortOrderDelegate;
import im.getsocial.demo.dialog.SortOrderDialog;
import im.getsocial.sdk.communities.GroupsQuery;


	@Override
	public String getTitle() {
		return "Groups";
	}

	@Override
	public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		super.showAdvancedSearch();
	}

	@Override
	public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
		menu.add(Menu.NONE, 0x42, Menu.NONE, _isTrending ? "All" : "Trending");
		super.onCreateOptionsMenu(menu, inflater);
	}

	@Override
	public boolean onOptionsItemSelected(final android.view.MenuItem item) {
		if (item.getItemId() == 0x42) {
			_isTrending = !_isTrending;
			_sortDirection = null;
			_sortKey = null;
			loadItems();
			getActivity().invalidateOptionsMenu();
			return true;
		}
		if (item.getItemId() == 0x43) {
			showSortDialog();
			getActivity().invalidateOptionsMenu();