lbry-android/app/src/main/java/io/lbry/browser/adapter/InlineChannelSpinnerAdapter.java

101 lines
3.1 KiB
Java
Raw Normal View History

Native rewrite (#878) * initial native rewrite commit * update gitlab CI script * add printVersionName gradle task * fix Gitlab CI script * Fix first time wallet sync. add Discover dialog to Following page. * Finish Following and All Content views. Add customize your tags view. * Wallet sync get and set preferences, update interval. * Editor's Choice. Reposts. Some ontent page tweaks. * display no related content view when none loaded * Search cache. File view updates. Floating wallet balance. * Send tip dialog. Channel page share and follow/unfollow. * Handle lbry:// url scheme. Properly set URL bar values. SDK 0.71.0. * Channel follow/unfollow fixes. Display stream cost. * Channel management and channel creation / editing * phone number verification and rewards page * add Invites page * tweak player loading and playback when loading new claims * tweak about page layout * display text and markdown content * purchase_uri for free content * don't display invites history if none exist * fix channel list adapters * change launch mode from singleInstance to singleTask * url history and player fixes * Library page. URL and view history. * bumpversion 0.15.0 --> 0.15.1 * Make file view a fragment to prevent headaches with multiple Android task recents * Better handling of file view URLs. Some issue list fixes. * Abandon channels and bulk delete files tasks. Some visual tweaks. * bumpversion 0.15.1 --> 0.15.2 * fix some events * Some visual tweaks. Wunderbar clear focus hotfix for some devices. * sdk 0.74.0. Publish and Publishes pages. * Fix displayed amounts. Send Firebase token with install_new. * Some dark theme and crash fixes. Implement publish form. * Fix minor typo for string in 'generate_address_hint'. * Publish form and publish creation flow. UI tweaks and fixes. * Basic native mobile publishing * remove closeDatabase calls causing crashes * Implement file and channel page delete actions. UI action cleanup. * publish drivers for unresolved file page and featured search result item * show URL suggestions and data network (DHT) settings * Filter own claims from downloads. Fix address input. * fix edit channel crash * fix for possible blank / invalid video thumbnails * adjust minimum deposit. fix channel edit mode. * quick skip and playback speed media controls * change play and pause icons * Fix file size display. Tweak playback speed control. * Add exoplayer mediasession extension. Set player auto attributes. * Inline publish address validation error. Increase image upload request timeout. * fix no related content display * Claim new_android reward. Use canonical_url for share links. * force US locale for amount / bid values sent with sdk requests * Afrikaans and Spanish strings * Add media player error handling policy. Use : in share links. * don't proceed with publish if optimization is in progress.
2020-05-23 07:49:00 +01:00
package io.lbry.browser.adapter;
import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Collection;
Native rewrite (#878) * initial native rewrite commit * update gitlab CI script * add printVersionName gradle task * fix Gitlab CI script * Fix first time wallet sync. add Discover dialog to Following page. * Finish Following and All Content views. Add customize your tags view. * Wallet sync get and set preferences, update interval. * Editor's Choice. Reposts. Some ontent page tweaks. * display no related content view when none loaded * Search cache. File view updates. Floating wallet balance. * Send tip dialog. Channel page share and follow/unfollow. * Handle lbry:// url scheme. Properly set URL bar values. SDK 0.71.0. * Channel follow/unfollow fixes. Display stream cost. * Channel management and channel creation / editing * phone number verification and rewards page * add Invites page * tweak player loading and playback when loading new claims * tweak about page layout * display text and markdown content * purchase_uri for free content * don't display invites history if none exist * fix channel list adapters * change launch mode from singleInstance to singleTask * url history and player fixes * Library page. URL and view history. * bumpversion 0.15.0 --> 0.15.1 * Make file view a fragment to prevent headaches with multiple Android task recents * Better handling of file view URLs. Some issue list fixes. * Abandon channels and bulk delete files tasks. Some visual tweaks. * bumpversion 0.15.1 --> 0.15.2 * fix some events * Some visual tweaks. Wunderbar clear focus hotfix for some devices. * sdk 0.74.0. Publish and Publishes pages. * Fix displayed amounts. Send Firebase token with install_new. * Some dark theme and crash fixes. Implement publish form. * Fix minor typo for string in 'generate_address_hint'. * Publish form and publish creation flow. UI tweaks and fixes. * Basic native mobile publishing * remove closeDatabase calls causing crashes * Implement file and channel page delete actions. UI action cleanup. * publish drivers for unresolved file page and featured search result item * show URL suggestions and data network (DHT) settings * Filter own claims from downloads. Fix address input. * fix edit channel crash * fix for possible blank / invalid video thumbnails * adjust minimum deposit. fix channel edit mode. * quick skip and playback speed media controls * change play and pause icons * Fix file size display. Tweak playback speed control. * Add exoplayer mediasession extension. Set player auto attributes. * Inline publish address validation error. Increase image upload request timeout. * fix no related content display * Claim new_android reward. Use canonical_url for share links. * force US locale for amount / bid values sent with sdk requests * Afrikaans and Spanish strings * Add media player error handling policy. Use : in share links. * don't proceed with publish if optimization is in progress.
2020-05-23 07:49:00 +01:00
import java.util.List;
import io.lbry.browser.R;
import io.lbry.browser.model.Claim;
public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> {
private List<Claim> channels;
private int layoutResourceId;
private LayoutInflater inflater;
public InlineChannelSpinnerAdapter(Context context, int resource, List<Claim> channels) {
super(context, resource, 0, channels);
inflater = LayoutInflater.from(context);
layoutResourceId = resource;
this.channels = new ArrayList<>(channels);
}
public void addPlaceholder(boolean includeAnonymous) {
Claim placeholder = new Claim();
placeholder.setPlaceholder(true);
insert(placeholder, 0);
channels.add(0, placeholder);
if (includeAnonymous) {
Claim anonymous = new Claim();
anonymous.setPlaceholderAnonymous(true);
insert(anonymous, 1);
channels.add(1, anonymous);
}
}
public void addAnonymousPlaceholder() {
Claim anonymous = new Claim();
anonymous.setPlaceholderAnonymous(true);
insert(anonymous, 0);
channels.add(0, anonymous);
}
Native rewrite (#878) * initial native rewrite commit * update gitlab CI script * add printVersionName gradle task * fix Gitlab CI script * Fix first time wallet sync. add Discover dialog to Following page. * Finish Following and All Content views. Add customize your tags view. * Wallet sync get and set preferences, update interval. * Editor's Choice. Reposts. Some ontent page tweaks. * display no related content view when none loaded * Search cache. File view updates. Floating wallet balance. * Send tip dialog. Channel page share and follow/unfollow. * Handle lbry:// url scheme. Properly set URL bar values. SDK 0.71.0. * Channel follow/unfollow fixes. Display stream cost. * Channel management and channel creation / editing * phone number verification and rewards page * add Invites page * tweak player loading and playback when loading new claims * tweak about page layout * display text and markdown content * purchase_uri for free content * don't display invites history if none exist * fix channel list adapters * change launch mode from singleInstance to singleTask * url history and player fixes * Library page. URL and view history. * bumpversion 0.15.0 --> 0.15.1 * Make file view a fragment to prevent headaches with multiple Android task recents * Better handling of file view URLs. Some issue list fixes. * Abandon channels and bulk delete files tasks. Some visual tweaks. * bumpversion 0.15.1 --> 0.15.2 * fix some events * Some visual tweaks. Wunderbar clear focus hotfix for some devices. * sdk 0.74.0. Publish and Publishes pages. * Fix displayed amounts. Send Firebase token with install_new. * Some dark theme and crash fixes. Implement publish form. * Fix minor typo for string in 'generate_address_hint'. * Publish form and publish creation flow. UI tweaks and fixes. * Basic native mobile publishing * remove closeDatabase calls causing crashes * Implement file and channel page delete actions. UI action cleanup. * publish drivers for unresolved file page and featured search result item * show URL suggestions and data network (DHT) settings * Filter own claims from downloads. Fix address input. * fix edit channel crash * fix for possible blank / invalid video thumbnails * adjust minimum deposit. fix channel edit mode. * quick skip and playback speed media controls * change play and pause icons * Fix file size display. Tweak playback speed control. * Add exoplayer mediasession extension. Set player auto attributes. * Inline publish address validation error. Increase image upload request timeout. * fix no related content display * Claim new_android reward. Use canonical_url for share links. * force US locale for amount / bid values sent with sdk requests * Afrikaans and Spanish strings * Add media player error handling policy. Use : in share links. * don't proceed with publish if optimization is in progress.
2020-05-23 07:49:00 +01:00
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();
}
Native rewrite (#878) * initial native rewrite commit * update gitlab CI script * add printVersionName gradle task * fix Gitlab CI script * Fix first time wallet sync. add Discover dialog to Following page. * Finish Following and All Content views. Add customize your tags view. * Wallet sync get and set preferences, update interval. * Editor's Choice. Reposts. Some ontent page tweaks. * display no related content view when none loaded * Search cache. File view updates. Floating wallet balance. * Send tip dialog. Channel page share and follow/unfollow. * Handle lbry:// url scheme. Properly set URL bar values. SDK 0.71.0. * Channel follow/unfollow fixes. Display stream cost. * Channel management and channel creation / editing * phone number verification and rewards page * add Invites page * tweak player loading and playback when loading new claims * tweak about page layout * display text and markdown content * purchase_uri for free content * don't display invites history if none exist * fix channel list adapters * change launch mode from singleInstance to singleTask * url history and player fixes * Library page. URL and view history. * bumpversion 0.15.0 --> 0.15.1 * Make file view a fragment to prevent headaches with multiple Android task recents * Better handling of file view URLs. Some issue list fixes. * Abandon channels and bulk delete files tasks. Some visual tweaks. * bumpversion 0.15.1 --> 0.15.2 * fix some events * Some visual tweaks. Wunderbar clear focus hotfix for some devices. * sdk 0.74.0. Publish and Publishes pages. * Fix displayed amounts. Send Firebase token with install_new. * Some dark theme and crash fixes. Implement publish form. * Fix minor typo for string in 'generate_address_hint'. * Publish form and publish creation flow. UI tweaks and fixes. * Basic native mobile publishing * remove closeDatabase calls causing crashes * Implement file and channel page delete actions. UI action cleanup. * publish drivers for unresolved file page and featured search result item * show URL suggestions and data network (DHT) settings * Filter own claims from downloads. Fix address input. * fix edit channel crash * fix for possible blank / invalid video thumbnails * adjust minimum deposit. fix channel edit mode. * quick skip and playback speed media controls * change play and pause icons * Fix file size display. Tweak playback speed control. * Add exoplayer mediasession extension. Set player auto attributes. * Inline publish address validation error. Increase image upload request timeout. * fix no related content display * Claim new_android reward. Use canonical_url for share links. * force US locale for amount / bid values sent with sdk requests * Afrikaans and Spanish strings * Add media player error handling policy. Use : in share links. * don't proceed with publish if optimization is in progress.
2020-05-23 07:49:00 +01:00
public int getItemPosition(Claim item) {
for (int i = 0; i < channels.size(); i++) {
Claim channel = channels.get(i);
if (item.getClaimId() != null && item.getClaimId().equalsIgnoreCase(channel.getClaimId())) {
Native rewrite (#878) * initial native rewrite commit * update gitlab CI script * add printVersionName gradle task * fix Gitlab CI script * Fix first time wallet sync. add Discover dialog to Following page. * Finish Following and All Content views. Add customize your tags view. * Wallet sync get and set preferences, update interval. * Editor's Choice. Reposts. Some ontent page tweaks. * display no related content view when none loaded * Search cache. File view updates. Floating wallet balance. * Send tip dialog. Channel page share and follow/unfollow. * Handle lbry:// url scheme. Properly set URL bar values. SDK 0.71.0. * Channel follow/unfollow fixes. Display stream cost. * Channel management and channel creation / editing * phone number verification and rewards page * add Invites page * tweak player loading and playback when loading new claims * tweak about page layout * display text and markdown content * purchase_uri for free content * don't display invites history if none exist * fix channel list adapters * change launch mode from singleInstance to singleTask * url history and player fixes * Library page. URL and view history. * bumpversion 0.15.0 --> 0.15.1 * Make file view a fragment to prevent headaches with multiple Android task recents * Better handling of file view URLs. Some issue list fixes. * Abandon channels and bulk delete files tasks. Some visual tweaks. * bumpversion 0.15.1 --> 0.15.2 * fix some events * Some visual tweaks. Wunderbar clear focus hotfix for some devices. * sdk 0.74.0. Publish and Publishes pages. * Fix displayed amounts. Send Firebase token with install_new. * Some dark theme and crash fixes. Implement publish form. * Fix minor typo for string in 'generate_address_hint'. * Publish form and publish creation flow. UI tweaks and fixes. * Basic native mobile publishing * remove closeDatabase calls causing crashes * Implement file and channel page delete actions. UI action cleanup. * publish drivers for unresolved file page and featured search result item * show URL suggestions and data network (DHT) settings * Filter own claims from downloads. Fix address input. * fix edit channel crash * fix for possible blank / invalid video thumbnails * adjust minimum deposit. fix channel edit mode. * quick skip and playback speed media controls * change play and pause icons * Fix file size display. Tweak playback speed control. * Add exoplayer mediasession extension. Set player auto attributes. * Inline publish address validation error. Increase image upload request timeout. * fix no related content display * Claim new_android reward. Use canonical_url for share links. * force US locale for amount / bid values sent with sdk requests * Afrikaans and Spanish strings * Add media player error handling policy. Use : in share links. * don't proceed with publish if optimization is in progress.
2020-05-23 07:49:00 +01:00
return i;
}
}
return -1;
}
@Override
public View getDropDownView(int position, View view, ViewGroup parent) {
return createView(position, view, parent);
}
@Override
public View getView(int position, View view, ViewGroup parent) {
return createView(position, view, parent);
}
private View createView(int position, View convertView, ViewGroup parent){
View view = inflater.inflate(layoutResourceId, parent, false);
Context context = getContext();
Claim channel = getItem(position);
String name = channel.getName();
if (channel.isPlaceholder()) {
name = context.getString(R.string.create_a_channel);
} else if (channel.isPlaceholderAnonymous()) {
name = context.getString(R.string.anonymous);
}
TextView label = view.findViewById(R.id.channel_item_name);
label.setText(name);
return view;
}
}