auto select corresponding channel when editing a publish
This commit is contained in:
parent
26ccbf2709
commit
a04448ebe8
2 changed files with 22 additions and 6 deletions
|
@ -10,6 +10,7 @@ import android.widget.SpinnerAdapter;
|
|||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
|
@ -41,6 +42,19 @@ public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> {
|
|||
}
|
||||
}
|
||||
|
||||
public void addAll(Collection<? extends Claim> collection) {
|
||||
for (Claim claim : collection) {
|
||||
if (!channels.contains(claim)) {
|
||||
channels.add(claim);
|
||||
}
|
||||
}
|
||||
super.addAll(collection);
|
||||
}
|
||||
public void clear() {
|
||||
channels.clear();
|
||||
super.clear();
|
||||
}
|
||||
|
||||
public int getItemPosition(Claim item) {
|
||||
for (int i = 0; i < channels.size(); i++) {
|
||||
Claim channel = channels.get(i);
|
||||
|
|
|
@ -983,8 +983,8 @@ public class PublishFormFragment extends BaseFragment implements
|
|||
}
|
||||
} else {
|
||||
channelSpinnerAdapter.clear();
|
||||
channelSpinnerAdapter.addAll(channels);
|
||||
channelSpinnerAdapter.addPlaceholder(true);
|
||||
channelSpinnerAdapter.addAll(channels);
|
||||
channelSpinnerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
@ -993,12 +993,14 @@ public class PublishFormFragment extends BaseFragment implements
|
|||
}
|
||||
|
||||
if (channelSpinnerAdapter != null && channelSpinner != null) {
|
||||
if (editMode && currentClaim.getSigningChannel() != null && !editChannelSpinnerLoaded) {
|
||||
if (editMode) {
|
||||
if (currentClaim.getSigningChannel() != null && !editChannelSpinnerLoaded) {
|
||||
int position = channelSpinnerAdapter.getItemPosition(currentClaim.getSigningChannel());
|
||||
if (position > -1) {
|
||||
channelSpinner.setSelection(position);
|
||||
}
|
||||
editChannelSpinnerLoaded = true;
|
||||
}
|
||||
} else {
|
||||
if (channelSpinnerAdapter.getCount() > 2) {
|
||||
// if anonymous displayed, select first channel if available
|
||||
|
|
Loading…
Reference in a new issue