Search in sources :

Example 6 with InlineChannelSpinnerAdapter

use of com.odysee.app.adapter.InlineChannelSpinnerAdapter in project odysee-android by OdyseeTeam.

the class CreateSupportDialogFragment method updateChannelList.

private void updateChannelList(List<Claim> channels) {
    if (channelSpinnerAdapter == null) {
        Context context = getContext();
        if (context != null) {
            channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, new ArrayList<>(channels));
            channelSpinnerAdapter.addAnonymousPlaceholder();
            channelSpinnerAdapter.notifyDataSetChanged();
        }
    } else {
        channelSpinnerAdapter.clear();
        channelSpinnerAdapter.addAll(channels);
        channelSpinnerAdapter.addAnonymousPlaceholder();
        channelSpinnerAdapter.notifyDataSetChanged();
    }
    if (channelSpinner != null) {
        channelSpinner.setAdapter(channelSpinnerAdapter);
    }
    if (channelSpinnerAdapter != null && channelSpinner != null) {
        if (channelSpinnerAdapter.getCount() > 1) {
            channelSpinner.setSelection(1);
        }
    }
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) InlineChannelSpinnerAdapter(com.odysee.app.adapter.InlineChannelSpinnerAdapter)

Example 7 with InlineChannelSpinnerAdapter

use of com.odysee.app.adapter.InlineChannelSpinnerAdapter in project odysee-android by OdyseeTeam.

the class RepostClaimDialogFragment method loadChannels.

private void loadChannels(List<Claim> channels) {
    if (channelSpinnerAdapter == null) {
        Context context = getContext();
        if (context != null) {
            channelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, channels);
            channelSpinnerAdapter.notifyDataSetChanged();
        }
    } else {
        channelSpinnerAdapter.clear();
        channelSpinnerAdapter.addAll(channels);
        channelSpinnerAdapter.notifyDataSetChanged();
    }
    if (channelSpinner != null && channelSpinnerAdapter != null) {
        channelSpinner.setAdapter(channelSpinnerAdapter);
    }
}
Also used : Context(android.content.Context) InlineChannelSpinnerAdapter(com.odysee.app.adapter.InlineChannelSpinnerAdapter)

Example 8 with InlineChannelSpinnerAdapter

use of com.odysee.app.adapter.InlineChannelSpinnerAdapter in project odysee-android by OdyseeTeam.

the class ChannelCommentsFragment method updateChannelList.

private void updateChannelList(List<Claim> channels) {
    if (commentChannelSpinnerAdapter == null) {
        Context context = getContext();
        if (context != null) {
            commentChannelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, new ArrayList<>(channels));
            commentChannelSpinnerAdapter.addPlaceholder(false);
            commentChannelSpinnerAdapter.notifyDataSetChanged();
        }
    } else {
        commentChannelSpinnerAdapter.clear();
        commentChannelSpinnerAdapter.addAll(channels);
        commentChannelSpinnerAdapter.addPlaceholder(false);
        commentChannelSpinnerAdapter.notifyDataSetChanged();
    }
    if (commentChannelSpinner != null) {
        commentChannelSpinner.setAdapter(commentChannelSpinnerAdapter);
    }
    if (commentChannelSpinnerAdapter != null && commentChannelSpinner != null) {
        if (commentChannelSpinnerAdapter.getCount() > 1) {
            commentChannelSpinner.setSelection(1);
        }
    }
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) InlineChannelSpinnerAdapter(com.odysee.app.adapter.InlineChannelSpinnerAdapter)

Example 9 with InlineChannelSpinnerAdapter

use of com.odysee.app.adapter.InlineChannelSpinnerAdapter in project odysee-android by OdyseeTeam.

the class InvitesFragment method initUi.

private void initUi() {
    layoutAccountDriver.setVisibility(Lbryio.isSignedIn() ? View.GONE : View.VISIBLE);
    Helper.applyHtmlForTextView(textLearnMoreLink);
    rewardDriverCard.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Context context = getContext();
            if (context instanceof MainActivity) {
                ((MainActivity) context).openRewards();
            }
        }
    });
    inputEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            layoutInputEmail.setHint(hasFocus ? getString(R.string.email) : Helper.getValue(inputEmail.getText()).length() > 0 ? getString(R.string.email) : getString(R.string.invite_email_placeholder));
        }
    });
    inputEmail.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            Helper.setViewEnabled(buttonInviteByEmail, charSequence.length() > 0);
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });
    buttonInviteByEmail.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String email = Helper.getValue(inputEmail.getText());
            if (!email.contains("@")) {
                showError(getString(R.string.provide_valid_email));
                return;
            }
            InviteByEmailTask task = new InviteByEmailTask(email, progressLoadingInviteByEmail, new GenericTaskHandler() {

                @Override
                public void beforeStart() {
                    Helper.setViewEnabled(buttonInviteByEmail, false);
                }

                @Override
                public void onSuccess() {
                    Snackbar.make(getView(), getString(R.string.invite_sent_to, email), Snackbar.LENGTH_LONG).show();
                    Helper.setViewText(inputEmail, null);
                    Helper.setViewEnabled(buttonInviteByEmail, true);
                    fetchInviteStatus();
                }

                @Override
                public void onError(Exception error) {
                    showError(error.getMessage());
                    Helper.setViewEnabled(buttonInviteByEmail, true);
                }
            });
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    });
    buttonGetStarted.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Context context = getContext();
            if (context instanceof MainActivity) {
                ((MainActivity) context).simpleSignIn(R.id.action_home_menu);
            }
        }
    });
    channelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            Object item = adapterView.getItemAtPosition(position);
            if (item instanceof Claim) {
                Claim claim = (Claim) item;
                if (claim.isPlaceholder()) {
                    if (!fetchingChannels) {
                        showChannelCreator();
                    }
                } else {
                    // build invite link
                    updateInviteLink(claim);
                }
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    textInviteLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            copyInviteLink();
        }
    });
    buttonCopyInviteLink.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            copyInviteLink();
        }
    });
    channelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>());
    channelSpinnerAdapter.addPlaceholder(false);
}
Also used : Context(android.content.Context) GenericTaskHandler(com.odysee.app.tasks.GenericTaskHandler) ArrayList(java.util.ArrayList) MainActivity(com.odysee.app.MainActivity) InlineChannelSpinnerAdapter(com.odysee.app.adapter.InlineChannelSpinnerAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) InviteByEmailTask(com.odysee.app.tasks.lbryinc.InviteByEmailTask) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) AdapterView(android.widget.AdapterView) Claim(com.odysee.app.model.Claim)

Aggregations

Context (android.content.Context)9 InlineChannelSpinnerAdapter (com.odysee.app.adapter.InlineChannelSpinnerAdapter)9 ArrayList (java.util.ArrayList)6 Editable (android.text.Editable)3 TextWatcher (android.text.TextWatcher)3 View (android.view.View)3 AdapterView (android.widget.AdapterView)3 TextView (android.widget.TextView)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 MainActivity (com.odysee.app.MainActivity)3 Claim (com.odysee.app.model.Claim)3 ImageView (android.widget.ImageView)2 NestedScrollView (androidx.core.widget.NestedScrollView)2 AttributeProviderContext (org.commonmark.renderer.html.AttributeProviderContext)2 JSONObject (org.json.JSONObject)2 Manifest (android.Manifest)1 Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1